Skip to content

Commit 7c06149

Browse files
committed
Merge branch 'master' into p2p-dump
2 parents fa338e6 + c8a800c commit 7c06149

File tree

13 files changed

+244
-11
lines changed

13 files changed

+244
-11
lines changed

Diff for: ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/state/versions/electra/PendingPartialWithdrawal.java

+15-6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@
2222

2323
public class PendingPartialWithdrawal
2424
extends Container3<PendingPartialWithdrawal, SszUInt64, SszUInt64, SszUInt64> {
25+
protected PendingPartialWithdrawal(
26+
ContainerSchema3<PendingPartialWithdrawal, SszUInt64, SszUInt64, SszUInt64> schema) {
27+
super(schema);
28+
}
29+
30+
public PendingPartialWithdrawal(
31+
final PendingPartialWithdrawalSchema pendingPartialWithdrawalSchema,
32+
final SszUInt64 index,
33+
final SszUInt64 amount,
34+
final SszUInt64 withdrawableEpoch) {
35+
super(pendingPartialWithdrawalSchema, index, amount, withdrawableEpoch);
36+
}
2537

2638
public static class PendingPartialWithdrawalSchema
2739
extends ContainerSchema3<PendingPartialWithdrawal, SszUInt64, SszUInt64, SszUInt64> {
@@ -52,16 +64,13 @@ public SszUInt64 getWithdrawableEpochSchema() {
5264

5365
@Override
5466
public PendingPartialWithdrawal createFromBackingNode(TreeNode node) {
55-
return null;
67+
return new PendingPartialWithdrawal(this, node);
5668
}
5769
}
5870

5971
private PendingPartialWithdrawal(
60-
PendingPartialWithdrawal.PendingPartialWithdrawalSchema type,
61-
final SszUInt64 index,
62-
final SszUInt64 amount,
63-
final SszUInt64 withdrawableEpoch) {
64-
super(type, index, amount, withdrawableEpoch);
72+
PendingPartialWithdrawal.PendingPartialWithdrawalSchema type, final TreeNode backingNode) {
73+
super(type, backingNode);
6574
}
6675

6776
public int getIndex() {

Diff for: ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsAltair.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public SchemaDefinitionsAltair(final SpecConfigAltair specConfig) {
7979
public static SchemaDefinitionsAltair required(final SchemaDefinitions schemaDefinitions) {
8080
Preconditions.checkArgument(
8181
schemaDefinitions instanceof SchemaDefinitionsAltair,
82-
"Expected definitions of type %s by got %s",
82+
"Expected definitions of type %s but got %s",
8383
SchemaDefinitionsAltair.class,
8484
schemaDefinitions.getClass());
8585
return (SchemaDefinitionsAltair) schemaDefinitions;

Diff for: ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsBellatrix.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public SchemaDefinitionsBellatrix(final SpecConfigBellatrix specConfig) {
8181
public static SchemaDefinitionsBellatrix required(final SchemaDefinitions schemaDefinitions) {
8282
checkArgument(
8383
schemaDefinitions instanceof SchemaDefinitionsBellatrix,
84-
"Expected definitions of type %s by got %s",
84+
"Expected definitions of type %s but got %s",
8585
SchemaDefinitionsBellatrix.class,
8686
schemaDefinitions.getClass());
8787
return (SchemaDefinitionsBellatrix) schemaDefinitions;

Diff for: ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsCapella.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public SchemaDefinitionsCapella(final SpecConfigCapella specConfig) {
109109
public static SchemaDefinitionsCapella required(final SchemaDefinitions schemaDefinitions) {
110110
checkArgument(
111111
schemaDefinitions instanceof SchemaDefinitionsCapella,
112-
"Expected definitions of type %s by got %s",
112+
"Expected definitions of type %s but got %s",
113113
SchemaDefinitionsCapella.class,
114114
schemaDefinitions.getClass());
115115
return (SchemaDefinitionsCapella) schemaDefinitions;

Diff for: ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsDeneb.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public SchemaDefinitionsDeneb(final SpecConfigDeneb specConfig) {
140140
public static SchemaDefinitionsDeneb required(final SchemaDefinitions schemaDefinitions) {
141141
checkArgument(
142142
schemaDefinitions instanceof SchemaDefinitionsDeneb,
143-
"Expected definitions of type %s by got %s",
143+
"Expected definitions of type %s but got %s",
144144
SchemaDefinitionsDeneb.class,
145145
schemaDefinitions.getClass());
146146
return (SchemaDefinitionsDeneb) schemaDefinitions;

Diff for: ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsElectra.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public SchemaDefinitionsElectra(final SpecConfigElectra specConfig) {
144144
public static SchemaDefinitionsElectra required(final SchemaDefinitions schemaDefinitions) {
145145
checkArgument(
146146
schemaDefinitions instanceof SchemaDefinitionsElectra,
147-
"Expected definitions of type %s by got %s",
147+
"Expected definitions of type %s but got %s",
148148
SchemaDefinitionsElectra.class,
149149
schemaDefinitions.getClass());
150150
return (SchemaDefinitionsElectra) schemaDefinitions;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright Consensys Software Inc., 2024
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
14+
package tech.pegasys.teku.spec.datastructures.state;
15+
16+
import static tech.pegasys.teku.spec.propertytest.util.PropertyTestHelper.assertDeserializeMutatedThrowsExpected;
17+
import static tech.pegasys.teku.spec.propertytest.util.PropertyTestHelper.assertRoundTrip;
18+
19+
import com.fasterxml.jackson.core.JsonProcessingException;
20+
import net.jqwik.api.ForAll;
21+
import net.jqwik.api.Property;
22+
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingBalanceDeposit;
23+
import tech.pegasys.teku.spec.propertytest.suppliers.state.PendingBalanceDepositSupplier;
24+
25+
public class PendingBalanceDepositPropertyTest {
26+
@Property
27+
void roundTrip(
28+
@ForAll(supplier = PendingBalanceDepositSupplier.class)
29+
final PendingBalanceDeposit pendingBalanceDeposit)
30+
throws JsonProcessingException {
31+
assertRoundTrip(pendingBalanceDeposit);
32+
}
33+
34+
@Property
35+
void deserializeMutated(
36+
@ForAll(supplier = PendingBalanceDepositSupplier.class)
37+
final PendingBalanceDeposit pendingBalanceDeposit,
38+
@ForAll final int seed) {
39+
assertDeserializeMutatedThrowsExpected(pendingBalanceDeposit, seed);
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright Consensys Software Inc., 2024
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
14+
package tech.pegasys.teku.spec.datastructures.state;
15+
16+
import static tech.pegasys.teku.spec.propertytest.util.PropertyTestHelper.assertDeserializeMutatedThrowsExpected;
17+
import static tech.pegasys.teku.spec.propertytest.util.PropertyTestHelper.assertRoundTrip;
18+
19+
import com.fasterxml.jackson.core.JsonProcessingException;
20+
import net.jqwik.api.ForAll;
21+
import net.jqwik.api.Property;
22+
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingConsolidation;
23+
import tech.pegasys.teku.spec.propertytest.suppliers.state.PendingConsolidationSupplier;
24+
25+
public class PendingConsolidationPropertyTest {
26+
@Property
27+
void roundTrip(
28+
@ForAll(supplier = PendingConsolidationSupplier.class)
29+
final PendingConsolidation pendingConsolidation)
30+
throws JsonProcessingException {
31+
assertRoundTrip(pendingConsolidation);
32+
}
33+
34+
@Property
35+
void deserializeMutated(
36+
@ForAll(supplier = PendingConsolidationSupplier.class)
37+
final PendingConsolidation pendingConsolidation,
38+
@ForAll final int seed) {
39+
assertDeserializeMutatedThrowsExpected(pendingConsolidation, seed);
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright Consensys Software Inc., 2024
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
14+
package tech.pegasys.teku.spec.datastructures.state;
15+
16+
import static tech.pegasys.teku.spec.propertytest.util.PropertyTestHelper.assertDeserializeMutatedThrowsExpected;
17+
import static tech.pegasys.teku.spec.propertytest.util.PropertyTestHelper.assertRoundTrip;
18+
19+
import com.fasterxml.jackson.core.JsonProcessingException;
20+
import net.jqwik.api.ForAll;
21+
import net.jqwik.api.Property;
22+
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingPartialWithdrawal;
23+
import tech.pegasys.teku.spec.propertytest.suppliers.state.PendingPartialWithdrawalSupplier;
24+
25+
public class PendingPartialWithdrawalPropertyTest {
26+
@Property
27+
void roundTrip(
28+
@ForAll(supplier = PendingPartialWithdrawalSupplier.class)
29+
final PendingPartialWithdrawal pendingPartialWithdrawal)
30+
throws JsonProcessingException {
31+
assertRoundTrip(pendingPartialWithdrawal);
32+
}
33+
34+
@Property
35+
void deserializeMutated(
36+
@ForAll(supplier = PendingPartialWithdrawalSupplier.class)
37+
final PendingPartialWithdrawal pendingPartialWithdrawal,
38+
@ForAll final int seed) {
39+
assertDeserializeMutatedThrowsExpected(pendingPartialWithdrawal, seed);
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright Consensys Software Inc., 2024
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
14+
package tech.pegasys.teku.spec.propertytest.suppliers.state;
15+
16+
import tech.pegasys.teku.spec.SpecMilestone;
17+
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingBalanceDeposit;
18+
import tech.pegasys.teku.spec.propertytest.suppliers.DataStructureUtilSupplier;
19+
import tech.pegasys.teku.spec.util.DataStructureUtil;
20+
21+
public class PendingBalanceDepositSupplier
22+
extends DataStructureUtilSupplier<PendingBalanceDeposit> {
23+
public PendingBalanceDepositSupplier() {
24+
super(DataStructureUtil::randomPendingBalanceDeposit, SpecMilestone.ELECTRA);
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright Consensys Software Inc., 2024
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
14+
package tech.pegasys.teku.spec.propertytest.suppliers.state;
15+
16+
import tech.pegasys.teku.spec.SpecMilestone;
17+
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingConsolidation;
18+
import tech.pegasys.teku.spec.propertytest.suppliers.DataStructureUtilSupplier;
19+
import tech.pegasys.teku.spec.util.DataStructureUtil;
20+
21+
public class PendingConsolidationSupplier extends DataStructureUtilSupplier<PendingConsolidation> {
22+
public PendingConsolidationSupplier() {
23+
super(DataStructureUtil::randomPendingConsolidation, SpecMilestone.ELECTRA);
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright Consensys Software Inc., 2024
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
14+
package tech.pegasys.teku.spec.propertytest.suppliers.state;
15+
16+
import tech.pegasys.teku.spec.SpecMilestone;
17+
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingPartialWithdrawal;
18+
import tech.pegasys.teku.spec.propertytest.suppliers.DataStructureUtilSupplier;
19+
import tech.pegasys.teku.spec.util.DataStructureUtil;
20+
21+
public class PendingPartialWithdrawalSupplier
22+
extends DataStructureUtilSupplier<PendingPartialWithdrawal> {
23+
public PendingPartialWithdrawalSupplier() {
24+
super(DataStructureUtil::randomPendingPartialWithdrawal, SpecMilestone.ELECTRA);
25+
}
26+
}

Diff for: ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/util/DataStructureUtil.java

+24
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@
175175
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.altair.BeaconStateSchemaAltair;
176176
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.BeaconStateSchemaPhase0;
177177
import tech.pegasys.teku.spec.datastructures.state.versions.capella.HistoricalSummary;
178+
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingBalanceDeposit;
179+
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingConsolidation;
180+
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingPartialWithdrawal;
178181
import tech.pegasys.teku.spec.datastructures.type.SszKZGCommitment;
179182
import tech.pegasys.teku.spec.datastructures.type.SszKZGProof;
180183
import tech.pegasys.teku.spec.datastructures.type.SszPublicKey;
@@ -2461,6 +2464,27 @@ public ExecutionLayerExit executionLayerExit(final Validator validator) {
24612464
.create(executionAddress, validator.getPublicKey());
24622465
}
24632466

2467+
public PendingBalanceDeposit randomPendingBalanceDeposit() {
2468+
return getElectraSchemaDefinitions(randomSlot())
2469+
.getPendingBalanceDepositSchema()
2470+
.create(SszUInt64.of(randomUInt64()), SszUInt64.of(randomUInt64()));
2471+
}
2472+
2473+
public PendingConsolidation randomPendingConsolidation() {
2474+
return getElectraSchemaDefinitions(randomSlot())
2475+
.getPendingConsolidationSchema()
2476+
.create(SszUInt64.of(randomUInt64()), SszUInt64.of(randomUInt64()));
2477+
}
2478+
2479+
public PendingPartialWithdrawal randomPendingPartialWithdrawal() {
2480+
return getElectraSchemaDefinitions(randomSlot())
2481+
.getPendingPartialWithdrawalSchema()
2482+
.create(
2483+
SszUInt64.of(randomUInt64()),
2484+
SszUInt64.of(randomUInt64()),
2485+
SszUInt64.of(randomUInt64()));
2486+
}
2487+
24642488
public UInt64 randomBlobSidecarIndex() {
24652489
return randomUInt64(spec.getMaxBlobsPerBlock().orElseThrow());
24662490
}

0 commit comments

Comments
 (0)