Skip to content

Commit 77b8215

Browse files
committed
Fix unit tests
1 parent d24aee8 commit 77b8215

File tree

7 files changed

+65
-28
lines changed

7 files changed

+65
-28
lines changed

data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/BeaconBlockBodyElectra.java

+16-11
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import tech.pegasys.teku.spec.SpecVersion;
3737
import tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBody;
3838
import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.electra.BeaconBlockBodySchemaElectra;
39-
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ExecutionRequestsBuilderElectra;
4039
import tech.pegasys.teku.spec.datastructures.type.SszKZGCommitment;
4140
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsElectra;
4241

@@ -109,9 +108,19 @@ public BeaconBlockBodyElectra(
109108
.map(SszKZGCommitment::getKZGCommitment)
110109
.map(KZGCommitment::new)
111110
.toList();
112-
// TODO add execution requests from BeaconBlocBodyElectra
113-
// (https://github.com/Consensys/teku/pull/8600)
114-
this.executionRequests = new ExecutionRequests(List.of(), List.of(), List.of());
111+
112+
final List<DepositRequest> depositRequests =
113+
message.getExecutionRequests().getDeposits().stream().map(DepositRequest::new).toList();
114+
final List<WithdrawalRequest> withdrawalRequests =
115+
message.getExecutionRequests().getWithdrawals().stream()
116+
.map(WithdrawalRequest::new)
117+
.toList();
118+
final List<ConsolidationRequest> consolidationRequests =
119+
message.getExecutionRequests().getConsolidations().stream()
120+
.map(ConsolidationRequest::new)
121+
.toList();
122+
this.executionRequests =
123+
new ExecutionRequests(depositRequests, withdrawalRequests, consolidationRequests);
115124
}
116125

117126
@Override
@@ -140,14 +149,10 @@ public BeaconBlockBody asInternalBeaconBlockBody(final SpecVersion spec) {
140149
.map(KZGCommitment::asInternalKZGCommitment)
141150
.map(SszKZGCommitment::new)
142151
.collect(blobKZGCommitmentsSchema.collector()));
143-
144-
// TODO update as part of Electra Beacon API changes
145-
// (https://github.com/Consensys/teku/issues/8623)
146152
builder.executionRequests(
147-
new ExecutionRequestsBuilderElectra(
148-
SchemaDefinitionsElectra.required(spec.getSchemaDefinitions())
149-
.getExecutionRequestsSchema())
150-
.build());
153+
this.executionRequests.asInternalConsolidationRequest(
154+
SchemaDefinitionsElectra.required(spec.getSchemaDefinitions())
155+
.getExecutionRequestsSchema()));
151156

152157
return SafeFuture.COMPLETE;
153158
});

ethereum/executionclient/src/integration-test/resources/builder/electra/signedBlindedBeaconBlock.json

+34-5
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,7 @@
213213
"transactions_root": "0xd3440acd6cea6c2135fc151371cb6830e25203b250ea8181ae251cc6c54f1a81",
214214
"withdrawals_root": "0x18cf2fce2e25d0ad50e8ea981c126622aabb342eb3b68a25beeaeca81f654969",
215215
"blob_gas_used": "14779654655076927372",
216-
"excess_blob_gas": "14778002167565275948",
217-
"deposit_requests_root": "0x18cf2fce2e25d0ad50e8ea981c126622aabb342eb3b68a25beeaeca81f654969",
218-
"withdrawal_requests_root": "0x18cf2fce2e25d0ad50e8ea981c126622aabb342eb3b68a25beeaeca81f654969",
219-
"consolidation_requests_root": "0x18cf2fce2e25d0ad50e8ea981c126622aabb342eb3b68a25beeaeca81f654969"
216+
"excess_blob_gas": "14778002167565275948"
220217
},
221218
"bls_to_execution_changes": [
222219
{
@@ -350,7 +347,39 @@
350347
],
351348
"blob_kzg_commitments": [
352349
"0xa94170080872584e54a1cf092d845703b13907f2e6b3b1c0ad573b910530499e3bcd48c6378846b80d2bfa58c81cf3d5"
353-
]
350+
],
351+
"execution_requests": {
352+
"deposits": [
353+
{
354+
"pubkey": "0x99c16f59ffb2e2138feb9b6f1804752cdbfe3796e20c52a3ae489f8348df4c1a9614cb6ce6860bed51544aaa1d22cc80",
355+
"withdrawal_credentials": "0x01000000000000000000000096792942ef2204941676b7f0048626f766aa1798",
356+
"amount": "4706333459101651213",
357+
"signature": "0x819666da9089ad1a3879b16a3c7dbab04454cb7da5eb5737c18fd5be53b54c3b38dda74617a27683fe5620a3b213e55e083a85f6223d89e16ce7b93ceb55c5c7e227da6e03bd60f1845e66983d339937d5981e541dedb49d47c3f0573a9b6f41",
358+
"index": "4709638425535019469"
359+
},
360+
{
361+
"pubkey": "0x9786334738ef86988505249871273257e40b3e3c47995e751a40a52bc46f915fbaab7e2b1802ca3dcbf2db0567e8c9ae",
362+
"withdrawal_credentials": "0x010000000000000000000000b8e632412d8ba6e05272a80fbcf8849c6c29ee8b",
363+
"amount": "4703028492668282957",
364+
"signature": "0xad2792e9c241d24ba5ff5f4ae1f7839009dae5f9de18e56a77510d695c4fcc4ffe40c5fa688e06476ae50dc93a7882d60630e2d4d8deb9ec43469ed6caf8067823e18f8c44de05433aaae7f39f7576c860e331e99681e7eebff012ddf1e3b0b4",
365+
"index": "4693113584778243597"
366+
}
367+
],
368+
"withdrawals": [
369+
{
370+
"source_address": "0xde2827416d22656a3cf87666640aae36792fecaf",
371+
"validator_pubkey": "0xa52467f43393c040dbac590c4fa4fdf260f050357947fa261f2285f35c8381f256c8ab0584c940f30766a40ebc447340",
372+
"amount": "4684851168694822957"
373+
}
374+
],
375+
"consolidations": [
376+
{
377+
"source_address": "0x2730ae410e57553a34f42f8060bfd5c9e9e90292",
378+
"source_pubkey": "0xb8a7fcd7c58854073db5f088cddf200b04864b6980925343c0d0b3238d5ce3880197ba175c59b61aade73eb79a74cb28",
379+
"target_pubkey": "0x88f8fa6c349ee56559e614799a5788c17fdcde24ea5922a7c7fe6bed8df5c0140aeebbb46d0cadc7a9107e98344194f1"
380+
}
381+
]
382+
}
354383
}
355384
},
356385
"signature": "0xa208fa451f0cb280d1bad7212a5b619097885383a9fdf300b91b33e73fd360329161843794ad1c2c7e84a3f0826a4f181165840b29947d2e681005811ee84f4d222510b1287eb1d4de480ce50be7cb2eeb007bdb4ed6c23358fc03b225abc8a8"

ethereum/executionclient/src/integration-test/resources/builder/electra/signedBuilderBid.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@
1919
"excess_blob_gas": "1",
2020
"block_hash": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
2121
"transactions_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
22-
"withdrawals_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
23-
"deposit_requests_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
24-
"withdrawal_requests_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
25-
"consolidation_requests_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2"
22+
"withdrawals_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2"
2623
},
2724
"blob_kzg_commitments": [
2825
"0xa94170080872584e54a1cf092d845703b13907f2e6b3b1c0ad573b910530499e3bcd48c6378846b80d2bfa58c81cf3d5"

ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/ElectraExecutionClientHandlerTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.tuweni.bytes.Bytes32;
2424
import org.apache.tuweni.units.bigints.UInt256;
2525
import org.junit.jupiter.api.BeforeEach;
26+
import org.junit.jupiter.api.Disabled;
2627
import org.junit.jupiter.api.Test;
2728
import tech.pegasys.teku.ethereum.executionclient.schema.BlobsBundleV1;
2829
import tech.pegasys.teku.ethereum.executionclient.schema.ExecutionPayloadV4;
@@ -47,6 +48,7 @@
4748
import tech.pegasys.teku.spec.logic.versions.deneb.types.VersionedHash;
4849
import tech.pegasys.teku.spec.util.DataStructureUtil;
4950

51+
@Disabled("Waiting for https://github.com/Consensys/teku/issues/8620")
5052
public class ElectraExecutionClientHandlerTest extends ExecutionHandlerClientTest {
5153

5254
@BeforeEach

ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/ExecutionPayloadFields.java

+1-7
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,7 @@ public enum ExecutionPayloadFields implements SszFieldName {
3535
TRANSACTIONS_ROOT,
3636
WITHDRAWALS_ROOT,
3737
BLOB_GAS_USED,
38-
EXCESS_BLOB_GAS,
39-
DEPOSIT_REQUESTS,
40-
DEPOSIT_REQUESTS_ROOT,
41-
WITHDRAWAL_REQUESTS,
42-
WITHDRAWAL_REQUESTS_ROOT,
43-
CONSOLIDATION_REQUESTS,
44-
CONSOLIDATION_REQUESTS_ROOT;
38+
EXCESS_BLOB_GAS;
4539

4640
private final String sszFieldName;
4741

ethereum/spec/src/test/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodyElectraTest.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.bellatrix.BlindedBeaconBlockBodyBellatrix;
2424
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload;
2525
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader;
26+
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ExecutionRequests;
2627
import tech.pegasys.teku.spec.datastructures.operations.SignedBlsToExecutionChange;
2728
import tech.pegasys.teku.spec.datastructures.type.SszKZGCommitment;
2829

@@ -33,6 +34,7 @@ class BeaconBlockBodyElectraTest extends AbstractBeaconBlockBodyTest<BeaconBlock
3334
protected ExecutionPayloadHeader executionPayloadHeader;
3435
protected SszList<SignedBlsToExecutionChange> blsToExecutionChanges;
3536
protected SszList<SszKZGCommitment> blobKzgCommitments;
37+
protected ExecutionRequests executionRequests;
3638

3739
@BeforeEach
3840
void setup() {
@@ -44,6 +46,7 @@ void setup() {
4446
executionPayloadHeader = dataStructureUtil.randomExecutionPayloadHeader();
4547
blsToExecutionChanges = dataStructureUtil.randomSignedBlsToExecutionChangesList();
4648
blobKzgCommitments = dataStructureUtil.randomBlobKzgCommitments();
49+
executionRequests = dataStructureUtil.randomExecutionRequests();
4750
});
4851
}
4952

@@ -71,7 +74,8 @@ protected Consumer<BeaconBlockBodyBuilder> createContentProvider(final boolean b
7174
builder
7275
.syncAggregate(syncAggregate)
7376
.blsToExecutionChanges(blsToExecutionChanges)
74-
.blobKzgCommitments(blobKzgCommitments);
77+
.blobKzgCommitments(blobKzgCommitments)
78+
.executionRequests(executionRequests);
7579
if (blinded) {
7680
builder.executionPayloadHeader(executionPayloadHeader);
7781
} else {

ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/generator/BlockProposalTestUtil.java

+6
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ public SafeFuture<SignedBlockAndState> createNewBlock(
128128
builder.blobKzgCommitments(
129129
kzgCommitments.orElseGet(dataStructureUtil::emptyBlobKzgCommitments));
130130
}
131+
if (builder.supportsExecutionRequests()) {
132+
builder.executionRequests(dataStructureUtil.randomExecutionRequests());
133+
}
131134
return SafeFuture.COMPLETE;
132135
},
133136
BlockProductionPerformance.NOOP)
@@ -201,6 +204,9 @@ public SafeFuture<SignedBlockAndState> createNewBlockSkippingStateTransition(
201204
builder.blobKzgCommitments(
202205
kzgCommitments.orElseGet(dataStructureUtil::emptyBlobKzgCommitments));
203206
}
207+
if (builder.supportsExecutionRequests()) {
208+
builder.executionRequests(dataStructureUtil.randomExecutionRequests());
209+
}
204210
return SafeFuture.COMPLETE;
205211
})
206212
.thenApply(

0 commit comments

Comments
 (0)