Skip to content

Commit c0c0b9c

Browse files
lucassaldanhamehdi-aouaditbenr
authored
Electra devnet 5 (#8817)
use forkChoiceUpdatedV4 with PayloadAttributesV4 Co-authored-by: Mehdi AOUADI <[email protected]> Co-authored-by: Enrico Del Fante <[email protected]>
1 parent e8289f1 commit c0c0b9c

File tree

5 files changed

+21
-17
lines changed

5 files changed

+21
-17
lines changed

ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/MilestoneBasedEngineJsonRpcMethodsResolver.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import tech.pegasys.teku.ethereum.executionclient.methods.EngineForkChoiceUpdatedV1;
3232
import tech.pegasys.teku.ethereum.executionclient.methods.EngineForkChoiceUpdatedV2;
3333
import tech.pegasys.teku.ethereum.executionclient.methods.EngineForkChoiceUpdatedV3;
34+
import tech.pegasys.teku.ethereum.executionclient.methods.EngineForkChoiceUpdatedV4;
3435
import tech.pegasys.teku.ethereum.executionclient.methods.EngineGetBlobsV1;
3536
import tech.pegasys.teku.ethereum.executionclient.methods.EngineGetPayloadV1;
3637
import tech.pegasys.teku.ethereum.executionclient.methods.EngineGetPayloadV2;
@@ -119,9 +120,7 @@ private Map<EngineApiMethod, EngineJsonRpcMethod<?>> electraSupportedMethods() {
119120

120121
methods.put(ENGINE_NEW_PAYLOAD, new EngineNewPayloadV4(executionEngineClient));
121122
methods.put(ENGINE_GET_PAYLOAD, new EngineGetPayloadV4(executionEngineClient, spec));
122-
// TODO EIP-7742 Replace with EngineForkChoiceUpdatedV4
123-
// (https://github.com/Consensys/teku/issues/8745)
124-
methods.put(ENGINE_FORK_CHOICE_UPDATED, new EngineForkChoiceUpdatedV3(executionEngineClient));
123+
methods.put(ENGINE_FORK_CHOICE_UPDATED, new EngineForkChoiceUpdatedV4(executionEngineClient));
125124
methods.put(ENGINE_GET_BLOBS, new EngineGetBlobsV1(executionEngineClient, spec));
126125

127126
return methods;

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import tech.pegasys.teku.ethereum.executionclient.schema.ForkChoiceStateV1;
3232
import tech.pegasys.teku.ethereum.executionclient.schema.ForkChoiceUpdatedResult;
3333
import tech.pegasys.teku.ethereum.executionclient.schema.GetPayloadV4Response;
34-
import tech.pegasys.teku.ethereum.executionclient.schema.PayloadAttributesV3;
34+
import tech.pegasys.teku.ethereum.executionclient.schema.PayloadAttributesV4;
3535
import tech.pegasys.teku.ethereum.executionclient.schema.PayloadStatusV1;
3636
import tech.pegasys.teku.ethereum.executionclient.schema.Response;
3737
import tech.pegasys.teku.infrastructure.async.SafeFuture;
@@ -128,7 +128,6 @@ void engineNewPayload_shouldCallNewPayloadV4() {
128128

129129
@Test
130130
void engineForkChoiceUpdated_shouldCallEngineForkChoiceUpdatedV3() {
131-
// TODO EIP-7742 should call FcUV4 (https://github.com/Consensys/teku/issues/8745)
132131
final ExecutionClientHandler handler = getHandler();
133132
final ForkChoiceState forkChoiceState = dataStructureUtil.randomForkChoiceState(false);
134133
final ForkChoiceStateV1 forkChoiceStateV1 =
@@ -142,21 +141,23 @@ void engineForkChoiceUpdated_shouldCallEngineForkChoiceUpdatedV3() {
142141
dataStructureUtil.randomEth1Address(),
143142
Optional.empty(),
144143
Optional.of(List.of()),
145-
dataStructureUtil.randomBytes32());
146-
final Optional<PayloadAttributesV3> payloadAttributes =
147-
PayloadAttributesV3.fromInternalPayloadBuildingAttributesV3(Optional.of(attributes));
144+
dataStructureUtil.randomBytes32(),
145+
spec.getMaxBlobsPerBlock().map(max -> UInt64.valueOf(max / 2)),
146+
spec.getMaxBlobsPerBlock().map(UInt64::valueOf));
147+
final Optional<PayloadAttributesV4> payloadAttributes =
148+
PayloadAttributesV4.fromInternalPayloadBuildingAttributesV4(Optional.of(attributes));
148149
final ForkChoiceUpdatedResult responseData =
149150
new ForkChoiceUpdatedResult(
150151
new PayloadStatusV1(
151152
ExecutionPayloadStatus.ACCEPTED, dataStructureUtil.randomBytes32(), ""),
152153
dataStructureUtil.randomBytes8());
153154
final SafeFuture<Response<ForkChoiceUpdatedResult>> dummyResponse =
154155
SafeFuture.completedFuture(new Response<>(responseData));
155-
when(executionEngineClient.forkChoiceUpdatedV3(forkChoiceStateV1, payloadAttributes))
156+
when(executionEngineClient.forkChoiceUpdatedV4(forkChoiceStateV1, payloadAttributes))
156157
.thenReturn(dummyResponse);
157158
final SafeFuture<tech.pegasys.teku.spec.executionlayer.ForkChoiceUpdatedResult> future =
158159
handler.engineForkChoiceUpdated(forkChoiceState, Optional.of(attributes));
159-
verify(executionEngineClient).forkChoiceUpdatedV3(forkChoiceStateV1, payloadAttributes);
160+
verify(executionEngineClient).forkChoiceUpdatedV4(forkChoiceStateV1, payloadAttributes);
160161
assertThat(future).isCompletedWithValue(responseData.asInternalExecutionPayload());
161162
}
162163

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import tech.pegasys.teku.ethereum.executionclient.methods.EngineForkChoiceUpdatedV1;
3535
import tech.pegasys.teku.ethereum.executionclient.methods.EngineForkChoiceUpdatedV2;
3636
import tech.pegasys.teku.ethereum.executionclient.methods.EngineForkChoiceUpdatedV3;
37+
import tech.pegasys.teku.ethereum.executionclient.methods.EngineForkChoiceUpdatedV4;
3738
import tech.pegasys.teku.ethereum.executionclient.methods.EngineGetBlobsV1;
3839
import tech.pegasys.teku.ethereum.executionclient.methods.EngineGetPayloadV1;
3940
import tech.pegasys.teku.ethereum.executionclient.methods.EngineGetPayloadV2;
@@ -200,7 +201,7 @@ private static Stream<Arguments> electraMethods() {
200201
return Stream.of(
201202
arguments(ENGINE_NEW_PAYLOAD, EngineNewPayloadV4.class),
202203
arguments(ENGINE_GET_PAYLOAD, EngineGetPayloadV4.class),
203-
arguments(ENGINE_FORK_CHOICE_UPDATED, EngineForkChoiceUpdatedV3.class),
204+
arguments(ENGINE_FORK_CHOICE_UPDATED, EngineForkChoiceUpdatedV4.class),
204205
arguments(ENGINE_GET_BLOBS, EngineGetBlobsV1.class));
205206
}
206207

@@ -227,7 +228,8 @@ void getsCapabilities() {
227228
"engine_getPayloadV3",
228229
"engine_forkchoiceUpdatedV3",
229230
"engine_newPayloadV4",
230-
"engine_getPayloadV4");
231+
"engine_getPayloadV4",
232+
"engine_forkchoiceUpdatedV4");
231233
}
232234

233235
@Test

ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ProposersDataManager.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,8 @@ private Optional<PayloadBuildingAttributes> calculatePayloadBuildingAttributes(
237237
.map(RegisteredValidatorInfo::getSignedValidatorRegistration);
238238

239239
final Eth1Address feeRecipient = getFeeRecipient(proposerInfo, blockSlot);
240+
final Optional<UInt64> maxBlobsPerBlock = spec.getMaxBlobsPerBlock().map(UInt64::valueOf);
240241

241-
// TODO EIP-7742 add targetBlobCount and maximumBlobCount
242-
// (https://github.com/Consensys/teku/issues/8745)
243242
return Optional.of(
244243
new PayloadBuildingAttributes(
245244
proposerIndex,
@@ -250,8 +249,8 @@ private Optional<PayloadBuildingAttributes> calculatePayloadBuildingAttributes(
250249
validatorRegistration,
251250
spec.getExpectedWithdrawals(state),
252251
currentHeadBlockRoot,
253-
Optional.empty(),
254-
Optional.empty()));
252+
maxBlobsPerBlock.map(maxBlobs -> maxBlobs.dividedBy(2)),
253+
maxBlobsPerBlock));
255254
}
256255

257256
// this function MUST return a fee recipient.

ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceNotifierTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,7 @@ private PayloadBuildingAttributes getExpectedPayloadBuildingAttributes(
10951095
overrideFeeRecipient.orElse(dataStructureUtil.randomEth1Address());
10961096
final UInt64 timestamp = spec.computeTimeAtSlot(headState, blockSlot);
10971097
final Bytes32 random = spec.getRandaoMix(headState, UInt64.ZERO);
1098+
final Optional<UInt64> maxBlobsPerBlock = spec.getMaxBlobsPerBlock().map(UInt64::valueOf);
10981099
return new PayloadBuildingAttributes(
10991100
proposerIndex,
11001101
blockSlot,
@@ -1103,7 +1104,9 @@ private PayloadBuildingAttributes getExpectedPayloadBuildingAttributes(
11031104
feeRecipient,
11041105
validatorRegistration,
11051106
dataStructureUtil.randomWithdrawalList(),
1106-
forkChoiceState.getHeadBlockRoot());
1107+
forkChoiceState.getHeadBlockRoot(),
1108+
maxBlobsPerBlock.map(maxBlobs -> maxBlobs.dividedBy(2)),
1109+
maxBlobsPerBlock);
11071110
}
11081111

11091112
private ForkChoiceState getCurrentForkChoiceState() {

0 commit comments

Comments
 (0)