From 2181e4a2dfe98ceb6469b463385f5052ce46b228 Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Fri, 7 Jul 2023 12:30:04 +0800 Subject: [PATCH 01/36] Rename deposit to depositReceipts in payload param Signed-off-by: Navie Chan --- .../api/jsonrpc/internal/parameters/EnginePayloadParameter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/EnginePayloadParameter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/EnginePayloadParameter.java index 1834b99a5db..355f7b218c7 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/EnginePayloadParameter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/EnginePayloadParameter.java @@ -86,7 +86,7 @@ public EnginePayloadParameter( @JsonProperty("withdrawals") final List withdrawals, @JsonProperty("blobGasUsed") final UnsignedLongParameter blobGasUsed, @JsonProperty("excessBlobGas") final String excessBlobGas, - @JsonProperty("deposits") final List deposits) { + @JsonProperty("depositReceipts") final List deposits) { this.blockHash = blockHash; this.parentHash = parentHash; this.feeRecipient = feeRecipient; From 9d624a4412073dfdaffeb3fe68797358058a70f2 Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Fri, 7 Jul 2023 12:18:13 +0800 Subject: [PATCH 02/36] Define engine_newPayloadV6110 Signed-off-by: Navie Chan --- .../besu/ethereum/api/jsonrpc/RpcMethod.java | 1 + .../methods/engine/EngineNewPayloadV6110.java | 76 +++++++++++++++++++ .../ExecutionEngineJsonRpcMethods.java | 22 ++++++ .../engine/EngineNewPayloadV6110Test.java | 58 ++++++++++++++ 4 files changed, 157 insertions(+) create mode 100644 ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java create mode 100644 ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java index 979ff433688..da7c318ec10 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java @@ -56,6 +56,7 @@ public enum RpcMethod { ENGINE_NEW_PAYLOAD_V1("engine_newPayloadV1"), ENGINE_NEW_PAYLOAD_V2("engine_newPayloadV2"), ENGINE_NEW_PAYLOAD_V3("engine_newPayloadV3"), + ENGINE_NEW_PAYLOAD_V6110("engine_newPayloadV6110"), ENGINE_FORKCHOICE_UPDATED_V1("engine_forkchoiceUpdatedV1"), ENGINE_FORKCHOICE_UPDATED_V2("engine_forkchoiceUpdatedV2"), ENGINE_FORKCHOICE_UPDATED_V3("engine_forkchoiceUpdatedV3"), diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java new file mode 100644 index 00000000000..dc12b7e8e58 --- /dev/null +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java @@ -0,0 +1,76 @@ +/* + * Copyright Hyperledger Besu Contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ +package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine; + +import io.vertx.core.Vertx; +import org.apache.tuweni.bytes.Bytes32; +import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator; +import org.hyperledger.besu.datatypes.VersionedHash; +import org.hyperledger.besu.ethereum.ProtocolContext; +import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadParameter; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; +import org.hyperledger.besu.ethereum.core.Transaction; +import org.hyperledger.besu.ethereum.eth.manager.EthPeers; +import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID; +import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.INVALID_PARAMS; +import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.UNSUPPORTED_FORK; + +public class EngineNewPayloadV6110 extends EngineNewPayloadV3 { + + private final ProtocolSchedule timestampSchedule; + + public EngineNewPayloadV6110( + final Vertx vertx, + final ProtocolSchedule timestampSchedule, + final ProtocolContext protocolContext, + final MergeMiningCoordinator mergeCoordinator, + final EthPeers ethPeers, + final EngineCallListener engineCallListener) { + super( + vertx, timestampSchedule, protocolContext, mergeCoordinator, ethPeers, engineCallListener); + this.timestampSchedule = timestampSchedule; + } + + @Override + public String getName() { + return RpcMethod.ENGINE_NEW_PAYLOAD_V6110.getMethodName(); + } + + @Override + protected Optional validateForkSupported( + final Object reqId, final EnginePayloadParameter payloadParameter) { + var eip6110 = timestampSchedule.hardforkFor(s -> s.fork().name().equalsIgnoreCase("ExperimentalEips")); + + // TODO-6110: Need to double check the condition on returning UNSUPPORTED_FORK + if (eip6110.isPresent() && payloadParameter.getTimestamp() >= eip6110.get().milestone()) { + if (payloadParameter.getDataGasUsed() == null + || payloadParameter.getExcessDataGas() == null) { + return Optional.of(new JsonRpcErrorResponse(reqId, INVALID_PARAMS)); + } else { + return Optional.empty(); + } + } else { + return Optional.of(new JsonRpcErrorResponse(reqId, UNSUPPORTED_FORK)); + } + } +} diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/ExecutionEngineJsonRpcMethods.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/ExecutionEngineJsonRpcMethods.java index c3c31533b36..def8490fe78 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/ExecutionEngineJsonRpcMethods.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/ExecutionEngineJsonRpcMethods.java @@ -28,9 +28,11 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineGetPayloadV1; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineGetPayloadV2; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineGetPayloadV3; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineGetPayloadV6110; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineNewPayloadV1; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineNewPayloadV2; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineNewPayloadV3; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineNewPayloadV6110; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EnginePreparePayloadDebug; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineQosTimer; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlockResultFactory; @@ -157,6 +159,26 @@ protected Map create() { protocolSchedule)); } + if (protocolSchedule.anyMatch(p -> p.spec().getName().equalsIgnoreCase("ExperimentalEips"))) { + executionEngineApisSupported.add( + new EngineGetPayloadV6110( + consensusEngineServer, + protocolContext, + mergeCoordinator.get(), + blockResultFactory, + engineQosTimer, + protocolSchedule)); + + executionEngineApisSupported.add( + new EngineNewPayloadV6110( + consensusEngineServer, + protocolSchedule, + protocolContext, + mergeCoordinator.get(), + ethPeers, + engineQosTimer)); + } + return mapOf(executionEngineApisSupported); } else { return mapOf( diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java new file mode 100644 index 00000000000..7982bc071c8 --- /dev/null +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java @@ -0,0 +1,58 @@ +/* + * Copyright Hyperledger Besu Contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ +package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine; + +import org.apache.tuweni.bytes.Bytes; +import org.assertj.core.api.Assertions; +import org.hyperledger.besu.datatypes.DataGas; +import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadParameter; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponseType; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; +import org.hyperledger.besu.ethereum.core.BlockHeader; +import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; +import org.hyperledger.besu.ethereum.mainnet.ScheduledProtocolSpec; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; + +import java.util.List; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +@RunWith(MockitoJUnitRunner.class) +public class EngineNewPayloadV6110Test extends AbstractEngineNewPayloadTest { + + public EngineNewPayloadV6110Test() { + super(EngineNewPayloadV6110::new); + } + + @Override + @Test + public void shouldReturnExpectedMethodName() { + assertThat(method.getName()).isEqualTo("engine_newPayloadV6110"); + } + +} From 4c0404ff81b15cbbedc9521e3ecb7160023df6b0 Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Fri, 7 Jul 2023 12:09:00 +0800 Subject: [PATCH 03/36] Remove deposit related stuff on engine_getPayloadV2 Signed-off-by: Navie Chan --- .../internal/results/BlockResultFactory.java | 1 - .../results/EngineGetPayloadResultV2.java | 19 +-------- .../engine/EngineGetPayloadV2Test.java | 42 ------------------- 3 files changed, 2 insertions(+), 60 deletions(-) diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResultFactory.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResultFactory.java index 2d52c31b093..c7d8bff4bcd 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResultFactory.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResultFactory.java @@ -115,7 +115,6 @@ public EngineGetPayloadResultV2 payloadTransactionCompleteV2( blockWithReceipts.getHeader(), txs, blockWithReceipts.getBlock().getBody().getWithdrawals(), - blockWithReceipts.getBlock().getBody().getDeposits(), Quantity.create(blockValue)); } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV2.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV2.java index b5e9fafabe2..e3919517f3b 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV2.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV2.java @@ -14,10 +14,8 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.Deposit; import org.hyperledger.besu.ethereum.core.Withdrawal; import java.util.List; @@ -41,9 +39,8 @@ public EngineGetPayloadResultV2( final BlockHeader header, final List transactions, final Optional> withdrawals, - final Optional> deposits, final String blockValue) { - this.executionPayload = new PayloadResult(header, transactions, withdrawals, deposits); + this.executionPayload = new PayloadResult(header, transactions, withdrawals); this.blockValue = blockValue; } @@ -74,13 +71,11 @@ public static class PayloadResult { private final String baseFeePerGas; protected final List transactions; private final List withdrawals; - private final List deposits; public PayloadResult( final BlockHeader header, final List transactions, - final Optional> withdrawals, - final Optional> deposits) { + final Optional> withdrawals) { this.blockNumber = Quantity.create(header.getNumber()); this.blockHash = header.getHash().toString(); this.parentHash = header.getParentHash().toString(); @@ -103,11 +98,6 @@ public PayloadResult( .map(WithdrawalParameter::fromWithdrawal) .collect(Collectors.toList())) .orElse(null); - this.deposits = - deposits - .map( - ds -> ds.stream().map(DepositParameter::fromDeposit).collect(Collectors.toList())) - .orElse(null); } @JsonGetter(value = "blockNumber") @@ -180,11 +170,6 @@ public List getWithdrawals() { return withdrawals; } - @JsonGetter(value = "deposits") - public List getDeposits() { - return deposits; - } - @JsonGetter(value = "feeRecipient") @JsonInclude(JsonInclude.Include.NON_NULL) public String getFeeRecipient() { diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV2Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV2Test.java index 0ba7380496e..09ad6bf91ed 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV2Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV2Test.java @@ -72,29 +72,6 @@ public void shouldReturnBlockForKnownPayloadId() { verify(engineCallListener, times(1)).executionEngineCalled(); } - @Test - public void shouldReturnBlockForKnownPayloadIdPostV6110() { - // should return deposits for a post-V6110 block - when(mergeContext.retrieveBlockById(mockPid)) - .thenReturn(Optional.of(mockBlockWithReceiptsAndDeposits)); - - final var resp = resp(RpcMethod.ENGINE_GET_PAYLOAD_V2.getMethodName(), mockPid); - assertThat(resp).isInstanceOf(JsonRpcSuccessResponse.class); - Optional.of(resp) - .map(JsonRpcSuccessResponse.class::cast) - .ifPresent( - r -> { - assertThat(r.getResult()).isInstanceOf(EngineGetPayloadResultV2.class); - final EngineGetPayloadResultV2 res = (EngineGetPayloadResultV2) r.getResult(); - assertThat(res.getExecutionPayload().getDeposits()).isNotNull(); - assertThat(res.getExecutionPayload().getHash()) - .isEqualTo(mockHeader.getHash().toString()); - assertThat(res.getBlockValue()).isEqualTo(Quantity.create(0)); - assertThat(res.getExecutionPayload().getPrevRandao()) - .isEqualTo(mockHeader.getPrevRandao().map(Bytes32::toString).orElse("")); - }); - verify(engineCallListener, times(1)).executionEngineCalled(); - } @Test public void shouldReturnExecutionPayloadWithoutWithdrawals_PreShanghaiBlock() { @@ -107,25 +84,6 @@ public void shouldReturnExecutionPayloadWithoutWithdrawals_PreShanghaiBlock() { assertThat(r.getResult()).isInstanceOf(EngineGetPayloadResultV2.class); final EngineGetPayloadResultV2 res = (EngineGetPayloadResultV2) r.getResult(); assertThat(res.getExecutionPayload().getWithdrawals()).isNull(); - assertThat(res.getExecutionPayload().getDeposits()).isNull(); - }); - verify(engineCallListener, times(1)).executionEngineCalled(); - } - - @Test - public void shouldReturnExecutionPayloadWithoutDeposits_PreV6110Block() { - when(mergeContext.retrieveBlockById(mockPid)) - .thenReturn(Optional.of(mockBlockWithReceiptsAndWithdrawals)); - - final var resp = resp(RpcMethod.ENGINE_GET_PAYLOAD_V2.getMethodName(), mockPid); - assertThat(resp).isInstanceOf(JsonRpcSuccessResponse.class); - Optional.of(resp) - .map(JsonRpcSuccessResponse.class::cast) - .ifPresent( - r -> { - assertThat(r.getResult()).isInstanceOf(EngineGetPayloadResultV2.class); - final EngineGetPayloadResultV2 res = (EngineGetPayloadResultV2) r.getResult(); - assertThat(res.getExecutionPayload().getDeposits()).isNull(); }); verify(engineCallListener, times(1)).executionEngineCalled(); } From 27669f161642ab74f1ce9877592d723bac3b9904 Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Fri, 7 Jul 2023 12:07:54 +0800 Subject: [PATCH 04/36] Define engine_getPayloadV6110 Signed-off-by: Navie Chan --- .../besu/ethereum/api/jsonrpc/RpcMethod.java | 1 + .../methods/engine/EngineGetPayloadV6110.java | 90 ++++++++ .../internal/results/BlockResultFactory.java | 21 ++ .../results/EngineGetPayloadResultV6110.java | 216 ++++++++++++++++++ .../engine/EngineGetPayloadV6110Test.java | 156 +++++++++++++ 5 files changed, 484 insertions(+) create mode 100644 ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java create mode 100644 ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV6110.java create mode 100644 ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java index da7c318ec10..fe7e432081b 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java @@ -53,6 +53,7 @@ public enum RpcMethod { ENGINE_GET_PAYLOAD_V1("engine_getPayloadV1"), ENGINE_GET_PAYLOAD_V2("engine_getPayloadV2"), ENGINE_GET_PAYLOAD_V3("engine_getPayloadV3"), + ENGINE_GET_PAYLOAD_V6110("engine_getPayloadV6110"), ENGINE_NEW_PAYLOAD_V1("engine_newPayloadV1"), ENGINE_NEW_PAYLOAD_V2("engine_newPayloadV2"), ENGINE_NEW_PAYLOAD_V3("engine_newPayloadV3"), diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java new file mode 100644 index 00000000000..18c255bdffb --- /dev/null +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java @@ -0,0 +1,90 @@ +/* + * Copyright Hyperledger Besu Contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ +package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine; + +import io.vertx.core.Vertx; +import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator; +import org.hyperledger.besu.consensus.merge.blockcreation.PayloadIdentifier; +import org.hyperledger.besu.ethereum.ProtocolContext; +import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlockResultFactory; +import org.hyperledger.besu.ethereum.core.BlockWithReceipts; +import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; +import org.hyperledger.besu.ethereum.mainnet.ScheduledProtocolSpec; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Optional; + +public class EngineGetPayloadV6110 extends AbstractEngineGetPayload { + + private static final Logger LOG = LoggerFactory.getLogger(EngineGetPayloadV6110.class); + private final Optional eip6110; + + public EngineGetPayloadV6110( + final Vertx vertx, + final ProtocolContext protocolContext, + final MergeMiningCoordinator mergeMiningCoordinator, + final BlockResultFactory blockResultFactory, + final EngineCallListener engineCallListener) { + super(vertx, protocolContext, mergeMiningCoordinator, blockResultFactory, engineCallListener); + this.eip6110 = Optional.empty(); + } + + public EngineGetPayloadV6110( + final Vertx vertx, + final ProtocolContext protocolContext, + final MergeMiningCoordinator mergeMiningCoordinator, + final BlockResultFactory blockResultFactory, + final EngineCallListener engineCallListener, + final ProtocolSchedule schedule) { + super(vertx, protocolContext, mergeMiningCoordinator, blockResultFactory, engineCallListener); + this.eip6110 = schedule.hardforkFor(s -> s.fork().name().equalsIgnoreCase("ExperimentalEips")); + } + + @Override + public String getName() { + return RpcMethod.ENGINE_GET_PAYLOAD_V6110.getMethodName(); + } + + @Override + protected JsonRpcResponse createResponse( + final JsonRpcRequestContext request, + final PayloadIdentifier payloadId, + final BlockWithReceipts blockWithReceipts) { + + try { + long builtAt = blockWithReceipts.getHeader().getTimestamp(); + + if (eip6110.isPresent() && builtAt >= eip6110.get().milestone()) { + return new JsonRpcSuccessResponse( + request.getRequest().getId(), + blockResultFactory.payloadTransactionCompleteV6110(blockWithReceipts)); + } else { + LOG.error("Timestamp of the built payload is less than EIP-6110 activation timestamp"); + return new JsonRpcErrorResponse(request.getRequest().getId(), JsonRpcError.UNSUPPORTED_FORK); + } + + } catch (ClassCastException e) { + LOG.error("configuration error, can't call V6110 endpoint with non-default protocol schedule"); + return new JsonRpcErrorResponse(request.getRequest().getId(), JsonRpcError.INTERNAL_ERROR); + } + } +} diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResultFactory.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResultFactory.java index c7d8bff4bcd..5188863a5c3 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResultFactory.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResultFactory.java @@ -147,6 +147,27 @@ public EngineGetPayloadResultV3 payloadTransactionCompleteV3( blobsBundleV1); } + public EngineGetPayloadResultV6110 payloadTransactionCompleteV6110( + final BlockWithReceipts blockWithReceipts) { + final List txs = + blockWithReceipts.getBlock().getBody().getTransactions().stream() + .map(TransactionEncoder::encodeOpaqueBytes) + .map(Bytes::toHexString) + .collect(Collectors.toList()); + + final Wei blockValue = new BlockValueCalculator().calculateBlockValue(blockWithReceipts); + + final BlobsBundleV1 blobsBundleV1 = + new BlobsBundleV1(blockWithReceipts.getBlock().getBody().getTransactions()); + return new EngineGetPayloadResultV6110( + blockWithReceipts.getHeader(), + txs, + blockWithReceipts.getBlock().getBody().getWithdrawals(), + blockWithReceipts.getBlock().getBody().getDeposits(), + Quantity.create(blockValue), + blobsBundleV1); + } + public BlockResult transactionHash(final BlockWithMetadata blockWithMetadata) { return transactionHash(blockWithMetadata, false); } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV6110.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV6110.java new file mode 100644 index 00000000000..8916b066738 --- /dev/null +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV6110.java @@ -0,0 +1,216 @@ +/* + * Copyright Hyperledger Besu Contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ +package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results; + +import com.fasterxml.jackson.annotation.JsonGetter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.apache.tuweni.bytes.Bytes32; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameter; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter; +import org.hyperledger.besu.ethereum.core.BlockHeader; +import org.hyperledger.besu.ethereum.core.Deposit; +import org.hyperledger.besu.ethereum.core.Withdrawal; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +@JsonPropertyOrder({"executionPayload", "blockValue", "blobsBundle"}) +public class EngineGetPayloadResultV6110 { + protected final PayloadResult executionPayload; + private final String blockValue; + private final BlobsBundleV1 blobsBundle; + + public EngineGetPayloadResultV6110( + final BlockHeader header, + final List transactions, + final Optional> withdrawals, + final Optional> deposits, + final String blockValue, + final BlobsBundleV1 blobsBundle) { + this.executionPayload = new PayloadResult(header, transactions, withdrawals, deposits); + this.blockValue = blockValue; + this.blobsBundle = blobsBundle; + } + + @JsonGetter(value = "executionPayload") + public PayloadResult getExecutionPayload() { + return executionPayload; + } + + @JsonGetter(value = "blockValue") + public String getBlockValue() { + return blockValue; + } + + @JsonGetter(value = "blobsBundle") + public BlobsBundleV1 getBlobsBundle() { + return blobsBundle; + } + + public static class PayloadResult { + + protected final String blockHash; + private final String parentHash; + private final String feeRecipient; + private final String stateRoot; + private final String receiptsRoot; + private final String logsBloom; + private final String prevRandao; + private final String blockNumber; + private final String gasLimit; + private final String gasUsed; + private final String timestamp; + private final String extraData; + private final String baseFeePerGas; + + private final String excessDataGas; + + private final String dataGasUsed; + + protected final List transactions; + private final List withdrawals; + private final List deposits; + + public PayloadResult( + final BlockHeader header, + final List transactions, + final Optional> withdrawals, + final Optional> deposits) { + this.blockNumber = Quantity.create(header.getNumber()); + this.blockHash = header.getHash().toString(); + this.parentHash = header.getParentHash().toString(); + this.logsBloom = header.getLogsBloom().toString(); + this.stateRoot = header.getStateRoot().toString(); + this.receiptsRoot = header.getReceiptsRoot().toString(); + this.extraData = header.getExtraData().toString(); + this.baseFeePerGas = header.getBaseFee().map(Quantity::create).orElse(null); + this.gasLimit = Quantity.create(header.getGasLimit()); + this.gasUsed = Quantity.create(header.getGasUsed()); + this.timestamp = Quantity.create(header.getTimestamp()); + this.transactions = transactions; + this.feeRecipient = header.getCoinbase().toString(); + this.prevRandao = header.getPrevRandao().map(Bytes32::toHexString).orElse(null); + this.withdrawals = + withdrawals + .map( + ws -> + ws.stream() + .map(WithdrawalParameter::fromWithdrawal) + .collect(Collectors.toList())) + .orElse(null); + this.dataGasUsed = header.getDataGasUsed().map(Quantity::create).orElse(Quantity.HEX_ZERO); + this.excessDataGas = + header.getExcessDataGas().map(Quantity::create).orElse(Quantity.HEX_ZERO); + this.deposits = + deposits + .map( + ds -> ds.stream().map(DepositParameter::fromDeposit).collect(Collectors.toList())) + .orElse(null); + } + + @JsonGetter(value = "blockNumber") + public String getNumber() { + return blockNumber; + } + + @JsonGetter(value = "blockHash") + public String getHash() { + return blockHash; + } + + @JsonGetter(value = "parentHash") + public String getParentHash() { + return parentHash; + } + + @JsonGetter(value = "logsBloom") + public String getLogsBloom() { + return logsBloom; + } + + @JsonGetter(value = "prevRandao") + public String getPrevRandao() { + return prevRandao; + } + + @JsonGetter(value = "stateRoot") + public String getStateRoot() { + return stateRoot; + } + + @JsonGetter(value = "receiptsRoot") + public String getReceiptRoot() { + return receiptsRoot; + } + + @JsonGetter(value = "extraData") + public String getExtraData() { + return extraData; + } + + @JsonGetter(value = "baseFeePerGas") + public String getBaseFeePerGas() { + return baseFeePerGas; + } + + @JsonGetter(value = "gasLimit") + public String getGasLimit() { + return gasLimit; + } + + @JsonGetter(value = "gasUsed") + public String getGasUsed() { + return gasUsed; + } + + @JsonGetter(value = "timestamp") + public String getTimestamp() { + return timestamp; + } + + @JsonGetter(value = "transactions") + public List getTransactions() { + return transactions; + } + + @JsonGetter(value = "withdrawals") + public List getWithdrawals() { + return withdrawals; + } + + @JsonGetter(value = "feeRecipient") + @JsonInclude(JsonInclude.Include.NON_NULL) + public String getFeeRecipient() { + return feeRecipient; + } + + @JsonGetter(value = "excessDataGas") + public String getExcessDataGas() { + return excessDataGas; + } + + @JsonGetter(value = "dataGasUsed") + public String getDataGasUseds() { + return dataGasUsed; + } + + @JsonGetter(value = "depositReceipts") + public List getDeposits() { + return deposits; + } + } +} diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java new file mode 100644 index 00000000000..1703bb63b46 --- /dev/null +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java @@ -0,0 +1,156 @@ +/* + * Copyright Hyperledger Besu Contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ +package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine; + +import org.apache.tuweni.bytes.Bytes; +import org.apache.tuweni.bytes.Bytes32; +import org.hyperledger.besu.consensus.merge.blockcreation.PayloadIdentifier; +import org.hyperledger.besu.datatypes.Address; +import org.hyperledger.besu.datatypes.DataGas; +import org.hyperledger.besu.datatypes.Hash; +import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlobsBundleV1; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EngineGetPayloadResultV6110; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity; +import org.hyperledger.besu.ethereum.core.Block; +import org.hyperledger.besu.ethereum.core.BlockBody; +import org.hyperledger.besu.ethereum.core.BlockHeader; +import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; +import org.hyperledger.besu.ethereum.core.BlockWithReceipts; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; + +import java.security.InvalidParameterException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +@RunWith( + MockitoJUnitRunner.Silent + .class) // mocks in parent class may not be used, throwing unnecessary stubbing +public class EngineGetPayloadV6110Test extends AbstractEngineGetPayloadTest { + + private static final long EIP_6110_AT = 31337L; + + public EngineGetPayloadV6110Test() { + super(EngineGetPayloadV6110::new); + } + + @Before + @Override + public void before() { + super.before(); + this.method = + new EngineGetPayloadV6110( + vertx, + protocolContext, + mergeMiningCoordinator, + factory, + engineCallListener, + protocolSchedule); + } + + @Override + @Test + public void shouldReturnExpectedMethodName() { + assertThat(method.getName()).isEqualTo("engine_getPayloadV6110"); + } + + @Override + @Test + public void shouldReturnBlockForKnownPayloadId() { + + BlockHeader eip6110Header = + new BlockHeaderTestFixture() + .prevRandao(Bytes32.random()) + .timestamp(EIP_6110_AT + 1) + .excessDataGas(DataGas.of(10L)) + .buildHeader(); + // should return withdrawals and excessGas for a post-eip6110 block + PayloadIdentifier postEip6110Pid = + PayloadIdentifier.forPayloadParams( + Hash.ZERO, + EIP_6110_AT, + Bytes32.random(), + Address.fromHexString("0x42"), + Optional.empty()); + + BlockWithReceipts postEip6110Block = + new BlockWithReceipts( + new Block( + eip6110Header, + new BlockBody( + Collections.emptyList(), + Collections.emptyList(), + Optional.of(Collections.emptyList()), + Optional.empty())), + Collections.emptyList()); + + when(mergeContext.retrieveBlockById(postEip6110Pid)).thenReturn(Optional.of(postEip6110Block)); + + final var resp = resp(RpcMethod.ENGINE_GET_PAYLOAD_V6110.getMethodName(), postEip6110Pid); + assertThat(resp).isInstanceOf(JsonRpcSuccessResponse.class); + Optional.of(resp) + .map(JsonRpcSuccessResponse.class::cast) + .ifPresent( + r -> { + assertThat(r.getResult()).isInstanceOf(EngineGetPayloadResultV6110.class); + final EngineGetPayloadResultV6110 res = (EngineGetPayloadResultV6110) r.getResult(); + assertThat(res.getExecutionPayload().getWithdrawals()).isNotNull(); + assertThat(res.getExecutionPayload().getDeposits()).isNotNull(); + assertThat(res.getExecutionPayload().getHash()) + .isEqualTo(eip6110Header.getHash().toString()); + assertThat(res.getBlockValue()).isEqualTo(Quantity.create(0)); + assertThat(res.getExecutionPayload().getPrevRandao()) + .isEqualTo(eip6110Header.getPrevRandao().map(Bytes32::toString).orElse("")); + // excessDataGas: QUANTITY, 256 bits + String expectedQuantityOf10 = Bytes32.leftPad(Bytes.of(10)).toQuantityHexString(); + assertThat(res.getExecutionPayload().getExcessDataGas()).isNotEmpty(); + assertThat(res.getExecutionPayload().getExcessDataGas()) + .isEqualTo(expectedQuantityOf10); + }); + verify(engineCallListener, times(1)).executionEngineCalled(); + } + + @Test + public void blobsBundleV1MustHaveSameNumberOfElements() { + String actualMessage = + assertThrows( + InvalidParameterException.class, + () -> new BlobsBundleV1(List.of(""), List.of(""), List.of())) + .getMessage(); + final String expectedMessage = "There must be an equal number of blobs, commitments and proofs"; + assertThat(actualMessage).isEqualTo(expectedMessage); + } + + @Test + public void shouldReturnUnsupportedFork() { + // TODO + } + + @Override + protected String getMethodName() { + return RpcMethod.ENGINE_GET_PAYLOAD_V6110.getMethodName(); + } +} From 2a9721fb7a32c8b15502b4d2d55b0a04bdb3000f Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Fri, 28 Jul 2023 11:54:08 +0800 Subject: [PATCH 05/36] Fix conflict Signed-off-by: Navie Chan --- .../methods/engine/EngineGetPayloadV6110.java | 5 ++-- .../methods/engine/EngineNewPayloadV6110.java | 26 ++++++------------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java index 18c255bdffb..588e00aab6e 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java @@ -24,6 +24,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlockResultFactory; import org.hyperledger.besu.ethereum.core.BlockWithReceipts; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; @@ -79,12 +80,12 @@ protected JsonRpcResponse createResponse( blockResultFactory.payloadTransactionCompleteV6110(blockWithReceipts)); } else { LOG.error("Timestamp of the built payload is less than EIP-6110 activation timestamp"); - return new JsonRpcErrorResponse(request.getRequest().getId(), JsonRpcError.UNSUPPORTED_FORK); + return new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INTERNAL_ERROR); // TODO: For now } } catch (ClassCastException e) { LOG.error("configuration error, can't call V6110 endpoint with non-default protocol schedule"); - return new JsonRpcErrorResponse(request.getRequest().getId(), JsonRpcError.INTERNAL_ERROR); + return new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INTERNAL_ERROR); } } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java index dc12b7e8e58..1a0ef8d9069 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java @@ -14,27 +14,16 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine; -import io.vertx.core.Vertx; -import org.apache.tuweni.bytes.Bytes32; import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator; -import org.hyperledger.besu.datatypes.VersionedHash; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadParameter; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; -import org.hyperledger.besu.ethereum.core.Transaction; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; import org.hyperledger.besu.ethereum.eth.manager.EthPeers; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; +import org.hyperledger.besu.ethereum.mainnet.ValidationResult; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.INVALID_PARAMS; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.UNSUPPORTED_FORK; - +import io.vertx.core.Vertx; public class EngineNewPayloadV6110 extends EngineNewPayloadV3 { private final ProtocolSchedule timestampSchedule; @@ -57,20 +46,21 @@ public String getName() { } @Override - protected Optional validateForkSupported( + protected ValidationResult validateForkSupported( final Object reqId, final EnginePayloadParameter payloadParameter) { var eip6110 = timestampSchedule.hardforkFor(s -> s.fork().name().equalsIgnoreCase("ExperimentalEips")); + // TODO-6110: Need to double check the condition on returning UNSUPPORTED_FORK if (eip6110.isPresent() && payloadParameter.getTimestamp() >= eip6110.get().milestone()) { if (payloadParameter.getDataGasUsed() == null || payloadParameter.getExcessDataGas() == null) { - return Optional.of(new JsonRpcErrorResponse(reqId, INVALID_PARAMS)); + return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing data gas fields"); } else { - return Optional.empty(); + return ValidationResult.valid(); } } else { - return Optional.of(new JsonRpcErrorResponse(reqId, UNSUPPORTED_FORK)); + return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Fork not supported"); } } } From 7e31e641e4bdcd0d00ea70bb30e8faef834177d8 Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Fri, 28 Jul 2023 18:11:16 +0800 Subject: [PATCH 06/36] Rebase 6110 acceptance to Cancun Signed-off-by: Navie Chan --- .../jsonrpc/engine/eip6110/genesis.json | 6 ++- .../test-cases/01_cancun_prepare_payload.json | 33 +++++++++++++ .../01_shanghai_prepare_payload.json | 46 ------------------- ...oadV2.json => 02_cancun_getPayloadV3.json} | 37 ++++++--------- ...oadV2.json => 03_cancun_newPayloadV3.json} | 32 +++++-------- .../04_cancun_forkchoiceUpdatedV2.json | 28 +++++++++++ .../04_shanghai_forkchoiceUpdatedV2.json | 28 ----------- .../05_eip6110_prepare_payload.json | 23 ++-------- .../test-cases/06_eip6110_get_payload.json | 38 +++++++-------- ...invalid_null_deposits_execute_payload.json | 31 ++++--------- .../08_eip6110_execute_payload.json | 31 ++++--------- 11 files changed, 132 insertions(+), 201 deletions(-) create mode 100644 acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/01_cancun_prepare_payload.json delete mode 100644 acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/01_shanghai_prepare_payload.json rename acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/{02_shanghai_getPayloadV2.json => 02_cancun_getPayloadV3.json} (58%) rename acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/{03_shanghai_newPayloadV2.json => 03_cancun_newPayloadV3.json} (58%) create mode 100644 acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV2.json delete mode 100644 acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_shanghai_forkchoiceUpdatedV2.json diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/genesis.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/genesis.json index 12f58a81bfa..fc86ab8c425 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/genesis.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/genesis.json @@ -1,6 +1,6 @@ { "config": { - "chainId":1, + "chainId":6110, "homesteadBlock":0, "eip150Block":0, "eip155Block":0, @@ -29,7 +29,9 @@ "mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000", "coinbase":"0x0000000000000000000000000000000000000000", "alloc":{ - "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b":{"balance":"0x6d6172697573766477000000"} + "0xa4664C40AACeBD82A2Db79f0ea36C06Bc6A19Adb": { + "balance": "1000000000000000000000000000" + } }, "number":"0x0", "gasUsed":"0x0", diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/01_cancun_prepare_payload.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/01_cancun_prepare_payload.json new file mode 100644 index 00000000000..419badcb4d4 --- /dev/null +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/01_cancun_prepare_payload.json @@ -0,0 +1,33 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "engine_forkchoiceUpdatedV2", + "params": [ + { + "headBlockHash": "0x1074f86f925fbb9ba16d09e1695186895ef11891361b236c09c17a2975b0f1bf", + "safeBlockHash": "0x1074f86f925fbb9ba16d09e1695186895ef11891361b236c09c17a2975b0f1bf", + "finalizedBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "timestamp": "0x10", + "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", + "suggestedFeeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "withdrawals": [] + } + ], + "id": 67 + }, + "response": { + "jsonrpc": "2.0", + "id": 67, + "result": { + "payloadStatus": { + "status": "VALID", + "latestValidHash": "0x1074f86f925fbb9ba16d09e1695186895ef11891361b236c09c17a2975b0f1bf", + "validationError": null + }, + "payloadId": "0x0065bd2bec446911" + } + }, + "statusCode" : 200 +} \ No newline at end of file diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/01_shanghai_prepare_payload.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/01_shanghai_prepare_payload.json deleted file mode 100644 index 960194fcae0..00000000000 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/01_shanghai_prepare_payload.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "request": { - "jsonrpc": "2.0", - "method": "engine_forkchoiceUpdatedV2", - "params": [ - { - "headBlockHash": "0xfe950635b1bd2a416ff6283b0bbd30176e1b1125ad06fa729da9f3f4c1c61710", - "safeBlockHash": "0xfe950635b1bd2a416ff6283b0bbd30176e1b1125ad06fa729da9f3f4c1c61710", - "finalizedBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000" - }, - { - "timestamp": "0x10", - "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", - "suggestedFeeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "withdrawals": [ - { - "index": "0x0", - "validatorIndex": "0x0", - "address": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "amount": "0x3" - }, - { - "index": "0x1", - "validatorIndex": "0x1", - "address": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", - "amount": "0x4" - } - ] - } - ], - "id": 67 - }, - "response": { - "jsonrpc": "2.0", - "id": 67, - "result": { - "payloadStatus": { - "status": "VALID", - "latestValidHash": "0xfe950635b1bd2a416ff6283b0bbd30176e1b1125ad06fa729da9f3f4c1c61710", - "validationError": null - }, - "payloadId": "0x0065bd1bbeaff359" - } - }, - "statusCode" : 200 -} \ No newline at end of file diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/02_shanghai_getPayloadV2.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/02_cancun_getPayloadV3.json similarity index 58% rename from acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/02_shanghai_getPayloadV2.json rename to acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/02_cancun_getPayloadV3.json index 9d25e3f5e84..97435db1947 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/02_shanghai_getPayloadV2.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/02_cancun_getPayloadV3.json @@ -1,9 +1,9 @@ { "request": { "jsonrpc": "2.0", - "method": "engine_getPayloadV2", + "method": "engine_getPayloadV3", "params": [ - "0x0065bd1bbeaff359" + "0x0065bd2bec446911" ], "id": 67 }, @@ -12,9 +12,9 @@ "id": 67, "result": { "executionPayload": { - "parentHash": "0xfe950635b1bd2a416ff6283b0bbd30176e1b1125ad06fa729da9f3f4c1c61710", + "parentHash": "0x1074f86f925fbb9ba16d09e1695186895ef11891361b236c09c17a2975b0f1bf", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0xc8c8e840369eac89a610bfe2ec21fcdee4c9c43bec4876f0129fcd4b5311f6dd", + "stateRoot": "0xafe7b02da3d8cfc9a18b3494ffbf12a18e65e09010159d034741315473849b9a", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -22,27 +22,20 @@ "timestamp": "0x10", "extraData": "0x", "baseFeePerGas": "0x7", + "excessDataGas" : "0x0", "transactions": [], - "withdrawals": [ - { - "index": "0x0", - "validatorIndex": "0x0", - "address": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "amount": "0x3" - }, - { - "index": "0x1", - "validatorIndex": "0x1", - "address": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", - "amount": "0x4" - } - ], - "deposits": null, + "withdrawals": [], "blockNumber": "0x1", - "blockHash": "0xfdd94e3620a88f08927bffb318981a36b663a26e6fd62ab273eb800b90723c13", - "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" + "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "blockHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", + "dataGasUsed" : "0x0" }, - "blockValue": "0x0" + "blockValue": "0x0", + "blobsBundle" : { + "commitments" : [], + "proofs" : [], + "blobs" : [] + } } }, "statusCode": 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/03_shanghai_newPayloadV2.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/03_cancun_newPayloadV3.json similarity index 58% rename from acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/03_shanghai_newPayloadV2.json rename to acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/03_cancun_newPayloadV3.json index 938362327ba..40828dd7242 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/03_shanghai_newPayloadV2.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/03_cancun_newPayloadV3.json @@ -1,12 +1,12 @@ { "request": { "jsonrpc": "2.0", - "method": "engine_newPayloadV2", + "method": "engine_newPayloadV3", "params": [ { - "parentHash": "0xfe950635b1bd2a416ff6283b0bbd30176e1b1125ad06fa729da9f3f4c1c61710", + "parentHash": "0x1074f86f925fbb9ba16d09e1695186895ef11891361b236c09c17a2975b0f1bf", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0xc8c8e840369eac89a610bfe2ec21fcdee4c9c43bec4876f0129fcd4b5311f6dd", + "stateRoot": "0xafe7b02da3d8cfc9a18b3494ffbf12a18e65e09010159d034741315473849b9a", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -15,24 +15,14 @@ "extraData": "0x", "baseFeePerGas": "0x7", "transactions": [], - "withdrawals": [ - { - "index": "0x0", - "validatorIndex": "0x0", - "address": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "amount": "0x3" - }, - { - "index": "0x1", - "validatorIndex": "0x1", - "address": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", - "amount": "0x4" - } - ], + "withdrawals": [], "blockNumber": "0x1", - "blockHash": "0xfdd94e3620a88f08927bffb318981a36b663a26e6fd62ab273eb800b90723c13", - "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" - } + "blockHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", + "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "excessDataGas" : "0x0", + "dataGasUsed" : "0x0" + }, + [] ], "id": 67 }, @@ -41,7 +31,7 @@ "id": 67, "result": { "status": "VALID", - "latestValidHash": "0xfdd94e3620a88f08927bffb318981a36b663a26e6fd62ab273eb800b90723c13", + "latestValidHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", "validationError": null } }, diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV2.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV2.json new file mode 100644 index 00000000000..ef2b4e85913 --- /dev/null +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV2.json @@ -0,0 +1,28 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "engine_forkchoiceUpdatedV2", + "params": [ + { + "headBlockHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", + "safeBlockHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", + "finalizedBlockHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6" + }, + null + ], + "id": 67 + }, + "response": { + "jsonrpc": "2.0", + "id": 67, + "result": { + "payloadStatus": { + "status": "VALID", + "latestValidHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", + "validationError": null + }, + "payloadId": null + } + }, + "statusCode": 200 +} \ No newline at end of file diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_shanghai_forkchoiceUpdatedV2.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_shanghai_forkchoiceUpdatedV2.json deleted file mode 100644 index 871832b9c99..00000000000 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_shanghai_forkchoiceUpdatedV2.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "request": { - "jsonrpc": "2.0", - "method": "engine_forkchoiceUpdatedV2", - "params": [ - { - "headBlockHash": "0xfdd94e3620a88f08927bffb318981a36b663a26e6fd62ab273eb800b90723c13", - "safeBlockHash": "0xfdd94e3620a88f08927bffb318981a36b663a26e6fd62ab273eb800b90723c13", - "finalizedBlockHash": "0xfdd94e3620a88f08927bffb318981a36b663a26e6fd62ab273eb800b90723c13" - }, - null - ], - "id": 67 - }, - "response": { - "jsonrpc": "2.0", - "id": 67, - "result": { - "payloadStatus": { - "status": "VALID", - "latestValidHash": "0xfdd94e3620a88f08927bffb318981a36b663a26e6fd62ab273eb800b90723c13", - "validationError": null - }, - "payloadId": null - } - }, - "statusCode": 200 -} \ No newline at end of file diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_prepare_payload.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_prepare_payload.json index d3d7ee37e30..60cc03e220d 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_prepare_payload.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_prepare_payload.json @@ -4,28 +4,15 @@ "method": "engine_forkchoiceUpdatedV2", "params": [ { - "headBlockHash": "0xfdd94e3620a88f08927bffb318981a36b663a26e6fd62ab273eb800b90723c13", - "safeBlockHash": "0xfdd94e3620a88f08927bffb318981a36b663a26e6fd62ab273eb800b90723c13", + "headBlockHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", + "safeBlockHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", "finalizedBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "timestamp": "0x20", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "suggestedFeeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "withdrawals": [ - { - "index": "0x0", - "validatorIndex": "0x0", - "address": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "amount": "0x1" - }, - { - "index": "0x1", - "validatorIndex": "0x0", - "address": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", - "amount": "0x2" - } - ] + "withdrawals": [] } ], "id": 67 @@ -36,10 +23,10 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0xfdd94e3620a88f08927bffb318981a36b663a26e6fd62ab273eb800b90723c13", + "latestValidHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", "validationError": null }, - "payloadId": "0x0065bd63871ad606" + "payloadId": "0x0065bd031ac6ca21" } }, "statusCode" : 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/06_eip6110_get_payload.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/06_eip6110_get_payload.json index 8b311c2841c..987a7c61d41 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/06_eip6110_get_payload.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/06_eip6110_get_payload.json @@ -1,9 +1,9 @@ { "request": { "jsonrpc": "2.0", - "method": "engine_getPayloadV2", + "method": "engine_getPayloadV6110", "params": [ - "0x0065bd63871ad606" + "0x0065bd031ac6ca21" ], "id": 67 }, @@ -12,9 +12,9 @@ "id": 67, "result": { "executionPayload": { - "parentHash": "0xfdd94e3620a88f08927bffb318981a36b663a26e6fd62ab273eb800b90723c13", + "parentHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x21395692fae33414143728c9ffc0aed8dcc76eb6731dd0f5a3239977478ca969", + "stateRoot": "0xafe7b02da3d8cfc9a18b3494ffbf12a18e65e09010159d034741315473849b9a", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -22,27 +22,21 @@ "timestamp": "0x20", "extraData": "0x", "baseFeePerGas": "0x7", + "excessDataGas" : "0x0", "transactions": [], - "withdrawals": [ - { - "index": "0x0", - "validatorIndex": "0x0", - "address": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "amount": "0x1" - }, - { - "index": "0x1", - "validatorIndex": "0x0", - "address": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", - "amount": "0x2" - } - ], - "deposits" : [], + "withdrawals": [], + "depositReceipts" : [], "blockNumber": "0x2", - "blockHash": "0x4c4418c408aeadb4659d31d1c05108f26fabf713bb6f8cc487dba8424a725bf5", - "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" + "blockHash": "0xf35fe237e1d7bb99f2e955c41f768f5e7cd7a4673a9409ab5e755f22026b1d15", + "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "dataGasUsed" : "0x0" }, - "blockValue": "0x0" + "blockValue": "0x0", + "blobsBundle" : { + "commitments" : [], + "proofs" : [], + "blobs" : [] + } } }, "statusCode": 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/07_eip6110_invalid_null_deposits_execute_payload.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/07_eip6110_invalid_null_deposits_execute_payload.json index ebdd0ad81c2..834714f7772 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/07_eip6110_invalid_null_deposits_execute_payload.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/07_eip6110_invalid_null_deposits_execute_payload.json @@ -1,12 +1,12 @@ { "request": { "jsonrpc": "2.0", - "method": "engine_newPayloadV2", + "method": "engine_newPayloadV6110", "params": [ { - "parentHash": "0x4f88d512a0045bc6d447ba74a18eac0ed2ebb8d9faca325f5f55b2ca84be0705", + "parentHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x1a10dba514dc4faff7ec13edd9b5ef653c1cd14eb26608bfc2b37717730a55a4", + "stateRoot": "0xafe7b02da3d8cfc9a18b3494ffbf12a18e65e09010159d034741315473849b9a", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -14,25 +14,14 @@ "timestamp": "0x20", "extraData": "0x", "baseFeePerGas": "0x7", + "excessDataGas" : "0x0", "transactions": [], - "withdrawals": [ - { - "index": "0x0", - "validatorIndex": "0x0", - "address": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "amount": "0x1" - }, - { - "index": "0x1", - "validatorIndex": "0x0", - "address": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", - "amount": "0x2" - } - ], - "deposits": null, - "blockNumber": "0x3", - "blockHash": "0x1475ca311179652e44b10b7e2d7b72f3708f3201f8d729880a83f3eb397910e8", - "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" + "withdrawals": [], + "depositReceipts" : null, + "blockNumber": "0x2", + "blockHash": "0xf35fe237e1d7bb99f2e955c41f768f5e7cd7a4673a9409ab5e755f22026b1d15", + "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "dataGasUsed" : "0x0" } ], "id": 67 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_execute_payload.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_execute_payload.json index 6fe5f5a5640..a711a6e56aa 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_execute_payload.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_execute_payload.json @@ -1,12 +1,12 @@ { "request": { "jsonrpc": "2.0", - "method": "engine_newPayloadV2", + "method": "engine_newPayloadV6110", "params": [ { - "parentHash": "0xfdd94e3620a88f08927bffb318981a36b663a26e6fd62ab273eb800b90723c13", + "parentHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x21395692fae33414143728c9ffc0aed8dcc76eb6731dd0f5a3239977478ca969", + "stateRoot": "0xafe7b02da3d8cfc9a18b3494ffbf12a18e65e09010159d034741315473849b9a", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -14,25 +14,14 @@ "timestamp": "0x20", "extraData": "0x", "baseFeePerGas": "0x7", + "excessDataGas" : "0x0", "transactions": [], - "withdrawals": [ - { - "index": "0x0", - "validatorIndex": "0x0", - "address": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "amount": "0x1" - }, - { - "index": "0x1", - "validatorIndex": "0x0", - "address": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", - "amount": "0x2" - } - ], - "deposits": [], + "withdrawals": [], + "depositReceipts" : [], "blockNumber": "0x2", - "blockHash": "0xdfdf57a09e352c38bb2873c5fd7d0d199481c6e13661c4a004d116417377b2e5", - "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" + "blockHash": "0xf35fe237e1d7bb99f2e955c41f768f5e7cd7a4673a9409ab5e755f22026b1d15", + "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "dataGasUsed" : "0x0" } ], "id": 67 @@ -42,7 +31,7 @@ "id": 67, "result": { "status": "VALID", - "latestValidHash": "0xdfdf57a09e352c38bb2873c5fd7d0d199481c6e13661c4a004d116417377b2e5", + "latestValidHash": "0xf35fe237e1d7bb99f2e955c41f768f5e7cd7a4673a9409ab5e755f22026b1d15", "validationError": null } }, From 21a402c1fa8d1b6e0301bb404308151a7f985e99 Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Fri, 28 Jul 2023 18:13:28 +0800 Subject: [PATCH 07/36] Rename 6110 acceptance tests Signed-off-by: Navie Chan --- ...orkchoiceUpdatedV2.json => 04_cancun_forkchoiceUpdatedV3.json} | 0 ...repare_payload.json => 05_eip6110_forkchoiceUpdatedV6110.json} | 0 ...6_eip6110_get_payload.json => 06_eip6110_getPayloadV6110.json} | 0 ...p6110_execute_payload.json => 08_eip6110_newPayloadV6110.json} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/{04_cancun_forkchoiceUpdatedV2.json => 04_cancun_forkchoiceUpdatedV3.json} (100%) rename acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/{05_eip6110_prepare_payload.json => 05_eip6110_forkchoiceUpdatedV6110.json} (100%) rename acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/{06_eip6110_get_payload.json => 06_eip6110_getPayloadV6110.json} (100%) rename acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/{08_eip6110_execute_payload.json => 08_eip6110_newPayloadV6110.json} (100%) diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV2.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV3.json similarity index 100% rename from acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV2.json rename to acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV3.json diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_prepare_payload.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_forkchoiceUpdatedV6110.json similarity index 100% rename from acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_prepare_payload.json rename to acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_forkchoiceUpdatedV6110.json diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/06_eip6110_get_payload.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/06_eip6110_getPayloadV6110.json similarity index 100% rename from acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/06_eip6110_get_payload.json rename to acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/06_eip6110_getPayloadV6110.json diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_execute_payload.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_newPayloadV6110.json similarity index 100% rename from acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_execute_payload.json rename to acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_newPayloadV6110.json From 323178cba8bd96f47fc0cbc8e4d0c3a4014d1bb0 Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Fri, 4 Aug 2023 16:28:50 +0800 Subject: [PATCH 08/36] Update 6110 acceptance test Signed-off-by: Navie Chan --- .../ExecutionEngineEip6110AcceptanceTest.java | 2 +- ...son => 04_cancun_forkchoiceUpdatedV2.json} | 0 ...on => 05_eip6110_forkchoiceUpdatedV2.json} | 0 .../07_eip6110_send_raw_transaction.json | 14 ++++++ ...nvalid_null_deposits_execute_payload.json} | 0 .../09_eip6110_newPayloadV6110.json | 43 +++++++++++++++++++ .../10_eip6110_forkchoiceUpdatedV2.json | 33 ++++++++++++++ ...0.json => 11_eip6110_getPayloadV6110.json} | 36 +++++++++------- 8 files changed, 111 insertions(+), 17 deletions(-) rename acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/{04_cancun_forkchoiceUpdatedV3.json => 04_cancun_forkchoiceUpdatedV2.json} (100%) rename acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/{05_eip6110_forkchoiceUpdatedV6110.json => 05_eip6110_forkchoiceUpdatedV2.json} (100%) create mode 100644 acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/07_eip6110_send_raw_transaction.json rename acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/{07_eip6110_invalid_null_deposits_execute_payload.json => 08_eip6110_invalid_null_deposits_execute_payload.json} (100%) create mode 100644 acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/09_eip6110_newPayloadV6110.json create mode 100644 acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/10_eip6110_forkchoiceUpdatedV2.json rename acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/{08_eip6110_newPayloadV6110.json => 11_eip6110_getPayloadV6110.json} (74%) diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineEip6110AcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineEip6110AcceptanceTest.java index fb2abde25d4..40fe22686b4 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineEip6110AcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineEip6110AcceptanceTest.java @@ -25,7 +25,7 @@ import org.junit.runners.Parameterized; @RunWith(Parameterized.class) -@Ignore("EIP-6110 is not yet implemented") +//@Ignore("EIP-6110 is not yet implemented") public class ExecutionEngineEip6110AcceptanceTest extends AbstractJsonRpcTest { private static final String GENESIS_FILE = "/jsonrpc/engine/eip6110/genesis.json"; private static final String TEST_CASE_PATH = "/jsonrpc/engine/eip6110/test-cases/"; diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV2.json similarity index 100% rename from acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV3.json rename to acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV2.json diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_forkchoiceUpdatedV6110.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_forkchoiceUpdatedV2.json similarity index 100% rename from acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_forkchoiceUpdatedV6110.json rename to acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_forkchoiceUpdatedV2.json diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/07_eip6110_send_raw_transaction.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/07_eip6110_send_raw_transaction.json new file mode 100644 index 00000000000..90072c28e0e --- /dev/null +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/07_eip6110_send_raw_transaction.json @@ -0,0 +1,14 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "eth_sendRawTransaction", + "params": ["0x02f9021c8217de808459682f008459682f0e830271009442424242424242424242424242424242424242428901bc16d674ec800000b901a422895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120749715de5d1226545c6b3790f515d551a5cc5bf1d49c87a696860554d2fc4f14000000000000000000000000000000000000000000000000000000000000003096a96086cff07df17668f35f7418ef8798079167e3f4f9b72ecde17b28226137cf454ab1dd20ef5d924786ab3483c2f9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020003f5102dabe0a27b1746098d1dc17a5d3fbd478759fea9287e4e419b3c3cef20000000000000000000000000000000000000000000000000000000000000060b1acdb2c4d3df3f1b8d3bfd33421660df358d84d78d16c4603551935f4b67643373e7eb63dcb16ec359be0ec41fee33b03a16e80745f2374ff1d3c352508ac5d857c6476d3c3bcf7e6ca37427c9209f17be3af5264c0e2132b3dd1156c28b4e9c080a09f597089338d7f44f5c59f8230bb38f243849228a8d4e9d2e2956e6050f5b2c7a076486996c7e62802b8f95eee114783e4b403fd11093ba96286ff42c595f24452"], + "id": 67 + }, + "response": { + "jsonrpc": "2.0", + "id": 67, + "result": "0x8ff1a50169f52f14cc1cf0300ec037c054a9b99df462e6372c7ca655bf1f00cd" + }, + "statusCode": 200 +} \ No newline at end of file diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/07_eip6110_invalid_null_deposits_execute_payload.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_invalid_null_deposits_execute_payload.json similarity index 100% rename from acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/07_eip6110_invalid_null_deposits_execute_payload.json rename to acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_invalid_null_deposits_execute_payload.json diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/09_eip6110_newPayloadV6110.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/09_eip6110_newPayloadV6110.json new file mode 100644 index 00000000000..99ff6f0090b --- /dev/null +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/09_eip6110_newPayloadV6110.json @@ -0,0 +1,43 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "engine_newPayloadV6110", + "params": [ + { + "parentHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", + "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "stateRoot": "0xac7f8402d971059174d7b5408346555f2914e088c15d7d7c32636d7e0597ac7d", + "logsBloom": "0x10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000", + "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", + "gasLimit": "0x1c9c380", + "gasUsed": "0x62D0", + "timestamp": "0x20", + "extraData": "0x", + "baseFeePerGas": "0x7", + "excessDataGas" : "0x0", + "transactions": [ + "0x02f9021c8217de808459682f008459682f0e830271009442424242424242424242424242424242424242428901bc16d674ec800000b901a422895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120749715de5d1226545c6b3790f515d551a5cc5bf1d49c87a696860554d2fc4f14000000000000000000000000000000000000000000000000000000000000003096a96086cff07df17668f35f7418ef8798079167e3f4f9b72ecde17b28226137cf454ab1dd20ef5d924786ab3483c2f9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020003f5102dabe0a27b1746098d1dc17a5d3fbd478759fea9287e4e419b3c3cef20000000000000000000000000000000000000000000000000000000000000060b1acdb2c4d3df3f1b8d3bfd33421660df358d84d78d16c4603551935f4b67643373e7eb63dcb16ec359be0ec41fee33b03a16e80745f2374ff1d3c352508ac5d857c6476d3c3bcf7e6ca37427c9209f17be3af5264c0e2132b3dd1156c28b4e9c080a09f597089338d7f44f5c59f8230bb38f243849228a8d4e9d2e2956e6050f5b2c7a076486996c7e62802b8f95eee114783e4b403fd11093ba96286ff42c595f24452" + ], + "withdrawals": [], + "depositReceipts" : [ + {"amount":"0x773594000","index":"0x182b8","pubkey":"0x96a96086cff07df17668f35f7418ef8798079167e3f4f9b72ecde17b28226137cf454ab1dd20ef5d924786ab3483c2f9","signature":"0xb1acdb2c4d3df3f1b8d3bfd33421660df358d84d78d16c4603551935f4b67643373e7eb63dcb16ec359be0ec41fee33b03a16e80745f2374ff1d3c352508ac5d857c6476d3c3bcf7e6ca37427c9209f17be3af5264c0e2132b3dd1156c28b4e9","withdrawalCredentials":"0x003f5102dabe0a27b1746098d1dc17a5d3fbd478759fea9287e4e419b3c3cef2"} + ], + "blockNumber": "0x2", + "blockHash": "0xa0d38d4cbfd80d7a4bebc271963161c04432f2568cdbba7ffa86c44edd6d3fe1", + "receiptsRoot": "0x3e0b69cee514173ba545e2f770fd3852d848c26c0b94b85d3c7ddb96da60b058", + "dataGasUsed" : "0x0" + } + ], + "id": 67 + }, + "response": { + "jsonrpc": "2.0", + "id": 67, + "result": { + "status": "VALID", + "latestValidHash": "0x302adfee13bf3137b252e667725c676958277d1132830a573920c029e65fb667", + "validationError": null + } + }, + "statusCode": 200 +} \ No newline at end of file diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/10_eip6110_forkchoiceUpdatedV2.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/10_eip6110_forkchoiceUpdatedV2.json new file mode 100644 index 00000000000..b7bc6583356 --- /dev/null +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/10_eip6110_forkchoiceUpdatedV2.json @@ -0,0 +1,33 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "engine_forkchoiceUpdatedV2", + "params": [ + { + "headBlockHash": "0x302adfee13bf3137b252e667725c676958277d1132830a573920c029e65fb667", + "safeBlockHash": "0x302adfee13bf3137b252e667725c676958277d1132830a573920c029e65fb667", + "finalizedBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "timestamp": "0x30", + "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", + "suggestedFeeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "withdrawals": [] + } + ], + "id": 67 + }, + "response": { + "jsonrpc": "2.0", + "id": 67, + "result": { + "payloadStatus": { + "status": "VALID", + "latestValidHash": "0x302adfee13bf3137b252e667725c676958277d1132830a573920c029e65fb667", + "validationError": null + }, + "payloadId": "0x0065bd0cd58ce331" + } + }, + "statusCode" : 200 +} \ No newline at end of file diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_newPayloadV6110.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/11_eip6110_getPayloadV6110.json similarity index 74% rename from acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_newPayloadV6110.json rename to acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/11_eip6110_getPayloadV6110.json index a711a6e56aa..a0a87a804fe 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_newPayloadV6110.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/11_eip6110_getPayloadV6110.json @@ -1,38 +1,42 @@ { "request": { "jsonrpc": "2.0", - "method": "engine_newPayloadV6110", + "method": "engine_getPayloadV6110", "params": [ - { - "parentHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", + "0x0065bd0cd58ce331" + ], + "id": 67 + }, + "response": { + "jsonrpc": "2.0", + "id": 67, + "result": { + "executionPayload": { + "parentHash": "0x302adfee13bf3137b252e667725c676958277d1132830a573920c029e65fb667", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "stateRoot": "0xafe7b02da3d8cfc9a18b3494ffbf12a18e65e09010159d034741315473849b9a", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", "gasUsed": "0x0", - "timestamp": "0x20", + "timestamp": "0x30", "extraData": "0x", "baseFeePerGas": "0x7", "excessDataGas" : "0x0", "transactions": [], "withdrawals": [], "depositReceipts" : [], - "blockNumber": "0x2", - "blockHash": "0xf35fe237e1d7bb99f2e955c41f768f5e7cd7a4673a9409ab5e755f22026b1d15", + "blockNumber": "0x3", + "blockHash": "0x14ac73efcfd4c2f02619bce8b3d196d6d1fed96053f54ec4eed59f90b56c37ba", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "dataGasUsed" : "0x0" + }, + "blockValue": "0x0", + "blobsBundle" : { + "commitments" : [], + "proofs" : [], + "blobs" : [] } - ], - "id": 67 - }, - "response": { - "jsonrpc": "2.0", - "id": 67, - "result": { - "status": "VALID", - "latestValidHash": "0xf35fe237e1d7bb99f2e955c41f768f5e7cd7a4673a9409ab5e755f22026b1d15", - "validationError": null } }, "statusCode": 200 From a835f73136fb5605f8821b1246b6b629c93ae1d6 Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Fri, 4 Aug 2023 16:31:29 +0800 Subject: [PATCH 09/36] Update 6110 acceptance tests Signed-off-by: Navie Chan --- .../engine/eip6110/test-cases/09_eip6110_newPayloadV6110.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/09_eip6110_newPayloadV6110.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/09_eip6110_newPayloadV6110.json index 99ff6f0090b..7f6dfcf4886 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/09_eip6110_newPayloadV6110.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/09_eip6110_newPayloadV6110.json @@ -7,7 +7,7 @@ "parentHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "stateRoot": "0xac7f8402d971059174d7b5408346555f2914e088c15d7d7c32636d7e0597ac7d", - "logsBloom": "0x10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", "gasUsed": "0x62D0", @@ -23,7 +23,7 @@ {"amount":"0x773594000","index":"0x182b8","pubkey":"0x96a96086cff07df17668f35f7418ef8798079167e3f4f9b72ecde17b28226137cf454ab1dd20ef5d924786ab3483c2f9","signature":"0xb1acdb2c4d3df3f1b8d3bfd33421660df358d84d78d16c4603551935f4b67643373e7eb63dcb16ec359be0ec41fee33b03a16e80745f2374ff1d3c352508ac5d857c6476d3c3bcf7e6ca37427c9209f17be3af5264c0e2132b3dd1156c28b4e9","withdrawalCredentials":"0x003f5102dabe0a27b1746098d1dc17a5d3fbd478759fea9287e4e419b3c3cef2"} ], "blockNumber": "0x2", - "blockHash": "0xa0d38d4cbfd80d7a4bebc271963161c04432f2568cdbba7ffa86c44edd6d3fe1", + "blockHash": "0xce621862a1f866f3f54b5d6d714f9582efa085fd1d0b770b7a230a02e8374a40", "receiptsRoot": "0x3e0b69cee514173ba545e2f770fd3852d848c26c0b94b85d3c7ddb96da60b058", "dataGasUsed" : "0x0" } From ee77f08dd1d730252df57079ea7fd67d08cf6aa1 Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Fri, 4 Aug 2023 17:36:42 +0800 Subject: [PATCH 10/36] Payload related apis return UNSUPPORTED_FORK Signed-off-by: Navie Chan --- .../methods/engine/EngineGetPayloadV6110.java | 2 +- .../methods/engine/EngineNewPayloadV6110.java | 8 +- .../internal/response/RpcErrorType.java | 1 + .../engine/EngineGetPayloadV6110Test.java | 20 +-- .../engine/EngineNewPayloadV6110Test.java | 122 ++++++++++++++---- 5 files changed, 111 insertions(+), 42 deletions(-) diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java index 588e00aab6e..c4cd965e235 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java @@ -80,7 +80,7 @@ protected JsonRpcResponse createResponse( blockResultFactory.payloadTransactionCompleteV6110(blockWithReceipts)); } else { LOG.error("Timestamp of the built payload is less than EIP-6110 activation timestamp"); - return new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INTERNAL_ERROR); // TODO: For now + return new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.UNSUPPORTED_FORK); } } catch (ClassCastException e) { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java index 1a0ef8d9069..27ce4144dc7 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java @@ -51,16 +51,14 @@ protected ValidationResult validateForkSupported( var eip6110 = timestampSchedule.hardforkFor(s -> s.fork().name().equalsIgnoreCase("ExperimentalEips")); - // TODO-6110: Need to double check the condition on returning UNSUPPORTED_FORK if (eip6110.isPresent() && payloadParameter.getTimestamp() >= eip6110.get().milestone()) { - if (payloadParameter.getDataGasUsed() == null - || payloadParameter.getExcessDataGas() == null) { - return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing data gas fields"); + if (payloadParameter.getDeposits() == null) { + return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing deposit receipts"); } else { return ValidationResult.valid(); } } else { - return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Fork not supported"); + return ValidationResult.invalid(RpcErrorType.UNSUPPORTED_FORK, "Fork not supported"); } } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/RpcErrorType.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/RpcErrorType.java index c3ef46016d9..acad01a1731 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/RpcErrorType.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/RpcErrorType.java @@ -24,6 +24,7 @@ public enum RpcErrorType { TIMEOUT_ERROR(-32603, "Timeout expired"), METHOD_NOT_ENABLED(-32604, "Method not enabled"), + UNSUPPORTED_FORK(-38005, "Unsupported fork"), // Resource unavailable error TX_POOL_DISABLED(-32002, "Transaction pool not enabled"), diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java index 1703bb63b46..c4f334f8b0f 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java @@ -30,10 +30,6 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.BlockWithReceipts; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; import java.security.InvalidParameterException; import java.util.Collections; @@ -46,9 +42,13 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -@RunWith( - MockitoJUnitRunner.Silent - .class) // mocks in parent class may not be used, throwing unnecessary stubbing +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith( + MockitoExtension.class) // mocks in parent class may not be used, throwing unnecessary stubbing public class EngineGetPayloadV6110Test extends AbstractEngineGetPayloadTest { private static final long EIP_6110_AT = 31337L; @@ -57,7 +57,7 @@ public EngineGetPayloadV6110Test() { super(EngineGetPayloadV6110::new); } - @Before + @BeforeEach @Override public void before() { super.before(); @@ -146,7 +146,9 @@ public void blobsBundleV1MustHaveSameNumberOfElements() { @Test public void shouldReturnUnsupportedFork() { - // TODO + final var resp = resp(RpcMethod.ENGINE_GET_PAYLOAD_V6110.getMethodName(), mockPid); + + assertThat(resp).isInstanceOf(JsonRpcSuccessResponse.class); } @Override diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java index 7982bc071c8..a06afcda833 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java @@ -14,45 +14,113 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine; -import org.apache.tuweni.bytes.Bytes; -import org.assertj.core.api.Assertions; -import org.hyperledger.besu.datatypes.DataGas; -import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadParameter; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hyperledger.besu.ethereum.api.graphql.internal.response.GraphQLError.INVALID_PARAMS; +import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameterTestFixture.DEPOSIT_PARAM_1; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.when; + +import org.hyperledger.besu.datatypes.Address; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponseType; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; -import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.mainnet.ScheduledProtocolSpec; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +import org.hyperledger.besu.ethereum.core.Deposit; +import org.hyperledger.besu.ethereum.mainnet.DepositsValidator; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; +import java.util.Collections; import java.util.List; import java.util.Optional; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -@RunWith(MockitoJUnitRunner.class) -public class EngineNewPayloadV6110Test extends AbstractEngineNewPayloadTest { +import static org.mockito.Mockito.lenient; +import static org.mockito.Mockito.verify; - public EngineNewPayloadV6110Test() { - super(EngineNewPayloadV6110::new); - } +import org.hyperledger.besu.ethereum.BlockProcessingOutputs; +import org.hyperledger.besu.ethereum.BlockProcessingResult; +import org.hyperledger.besu.ethereum.core.BlockHeader; + +@ExtendWith(MockitoExtension.class) +public class EngineNewPayloadV6110Test extends EngineNewPayloadV2Test { + + public EngineNewPayloadV6110Test() {} @Override @Test public void shouldReturnExpectedMethodName() { assertThat(method.getName()).isEqualTo("engine_newPayloadV6110"); } + @Test + public void shouldReturnValidIfDepositsIsNotNull_WhenDepositsAllowed() { + final List depositsParam = List.of(DEPOSIT_PARAM_1); + final List deposits = List.of(DEPOSIT_PARAM_1.toDeposit()); + when(protocolSpec.getDepositsValidator()) + .thenReturn(new DepositsValidator.AllowedDeposits(Address.ZERO)); + BlockHeader mockHeader = + setupValidPayload( + new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), + Optional.empty(), + Optional.of(deposits)); + + var resp = resp(mockPayload(mockHeader, Collections.emptyList(), null, depositsParam)); + + assertValidResponse(mockHeader, resp); + } + + @Test + public void shouldReturnValidIfDepositsIsNull_WhenDepositsProhibited() { + final List deposits = null; + when(protocolSpec.getDepositsValidator()) + .thenReturn(new DepositsValidator.ProhibitedDeposits()); + BlockHeader mockHeader = + setupValidPayload( + new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), + Optional.empty(), + Optional.empty()); + + var resp = resp(mockPayload(mockHeader, Collections.emptyList(), null, deposits, null)); + + assertValidResponse(mockHeader, resp); + } + + @Test + public void shouldReturnInvalidIfDepositsIsNotNull_WhenDepositsProhibited() { + final List deposits = List.of(); + lenient() + .when(protocolSpec.getDepositsValidator()) + .thenReturn(new DepositsValidator.ProhibitedDeposits()); + + var resp = + resp( + mockPayload( + createBlockHeader(Optional.of(Collections.emptyList()), Optional.empty()), + Collections.emptyList(), + null, + deposits, + null)); + + final JsonRpcError jsonRpcError = fromErrorResp(resp); + assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode()); + verify(engineCallListener, times(1)).executionEngineCalled(); + } + + @Test + public void shouldReturnInvalidIfDepositsIsNull_WhenDepositsAllowed() { + final List deposits = null; + when(protocolSpec.getDepositsValidator()) + .thenReturn(new DepositsValidator.AllowedDeposits(Address.ZERO)); + + var resp = + resp( + mockPayload( + createBlockHeader(Optional.empty(), Optional.empty()), + Collections.emptyList(), + null, + deposits)); + + assertThat(fromErrorResp(resp).getCode()).isEqualTo(INVALID_PARAMS.getCode()); + verify(engineCallListener, times(1)).executionEngineCalled(); + } } From 31042243fec8ac290ca134f925c8a29e51c3b944 Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Fri, 4 Aug 2023 17:44:17 +0800 Subject: [PATCH 11/36] SpotlessApply Signed-off-by: Navie Chan --- .../ExecutionEngineEip6110AcceptanceTest.java | 3 +-- .../methods/engine/EngineGetPayloadV6110.java | 14 +++++++------ .../methods/engine/EngineNewPayloadV6110.java | 5 +++-- .../results/EngineGetPayloadResultV6110.java | 9 +++++---- .../engine/EngineGetPayloadV2Test.java | 1 - .../engine/EngineGetPayloadV6110Test.java | 16 +++++++-------- .../engine/EngineNewPayloadV6110Test.java | 20 +++++++++---------- 7 files changed, 34 insertions(+), 34 deletions(-) diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineEip6110AcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineEip6110AcceptanceTest.java index 40fe22686b4..3dc773f83e0 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineEip6110AcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineEip6110AcceptanceTest.java @@ -20,12 +20,11 @@ import org.junit.AfterClass; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @RunWith(Parameterized.class) -//@Ignore("EIP-6110 is not yet implemented") +// @Ignore("EIP-6110 is not yet implemented") public class ExecutionEngineEip6110AcceptanceTest extends AbstractJsonRpcTest { private static final String GENESIS_FILE = "/jsonrpc/engine/eip6110/genesis.json"; private static final String TEST_CASE_PATH = "/jsonrpc/engine/eip6110/test-cases/"; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java index c4cd965e235..c3be61fefd6 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java @@ -14,13 +14,11 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine; -import io.vertx.core.Vertx; import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator; import org.hyperledger.besu.consensus.merge.blockcreation.PayloadIdentifier; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; @@ -29,11 +27,13 @@ import org.hyperledger.besu.ethereum.core.BlockWithReceipts; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ScheduledProtocolSpec; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.Optional; +import io.vertx.core.Vertx; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class EngineGetPayloadV6110 extends AbstractEngineGetPayload { private static final Logger LOG = LoggerFactory.getLogger(EngineGetPayloadV6110.class); @@ -80,11 +80,13 @@ protected JsonRpcResponse createResponse( blockResultFactory.payloadTransactionCompleteV6110(blockWithReceipts)); } else { LOG.error("Timestamp of the built payload is less than EIP-6110 activation timestamp"); - return new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.UNSUPPORTED_FORK); + return new JsonRpcErrorResponse( + request.getRequest().getId(), RpcErrorType.UNSUPPORTED_FORK); } } catch (ClassCastException e) { - LOG.error("configuration error, can't call V6110 endpoint with non-default protocol schedule"); + LOG.error( + "configuration error, can't call V6110 endpoint with non-default protocol schedule"); return new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INTERNAL_ERROR); } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java index 27ce4144dc7..fdc3d643f06 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java @@ -24,6 +24,7 @@ import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import io.vertx.core.Vertx; + public class EngineNewPayloadV6110 extends EngineNewPayloadV3 { private final ProtocolSchedule timestampSchedule; @@ -48,8 +49,8 @@ public String getName() { @Override protected ValidationResult validateForkSupported( final Object reqId, final EnginePayloadParameter payloadParameter) { - var eip6110 = timestampSchedule.hardforkFor(s -> s.fork().name().equalsIgnoreCase("ExperimentalEips")); - + var eip6110 = + timestampSchedule.hardforkFor(s -> s.fork().name().equalsIgnoreCase("ExperimentalEips")); if (eip6110.isPresent() && payloadParameter.getTimestamp() >= eip6110.get().milestone()) { if (payloadParameter.getDeposits() == null) { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV6110.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV6110.java index 8916b066738..f6fcae7e157 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV6110.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV6110.java @@ -14,10 +14,6 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import org.apache.tuweni.bytes.Bytes32; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter; import org.hyperledger.besu.ethereum.core.BlockHeader; @@ -28,6 +24,11 @@ import java.util.Optional; import java.util.stream.Collectors; +import com.fasterxml.jackson.annotation.JsonGetter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.apache.tuweni.bytes.Bytes32; + @JsonPropertyOrder({"executionPayload", "blockValue", "blobsBundle"}) public class EngineGetPayloadResultV6110 { protected final PayloadResult executionPayload; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV2Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV2Test.java index 09ad6bf91ed..9f8e5f709d3 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV2Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV2Test.java @@ -72,7 +72,6 @@ public void shouldReturnBlockForKnownPayloadId() { verify(engineCallListener, times(1)).executionEngineCalled(); } - @Test public void shouldReturnExecutionPayloadWithoutWithdrawals_PreShanghaiBlock() { final var resp = resp(RpcMethod.ENGINE_GET_PAYLOAD_V2.getMethodName(), mockPid); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java index c4f334f8b0f..ef91ffebdbb 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java @@ -14,8 +14,12 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine; -import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.bytes.Bytes32; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + import org.hyperledger.besu.consensus.merge.blockcreation.PayloadIdentifier; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.DataGas; @@ -36,12 +40,8 @@ import java.util.List; import java.util.Optional; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - +import org.apache.tuweni.bytes.Bytes; +import org.apache.tuweni.bytes.Bytes32; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java index a06afcda833..f9f5f15d917 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java @@ -17,29 +17,27 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.hyperledger.besu.ethereum.api.graphql.internal.response.GraphQLError.INVALID_PARAMS; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameterTestFixture.DEPOSIT_PARAM_1; +import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import org.hyperledger.besu.datatypes.Address; +import org.hyperledger.besu.ethereum.BlockProcessingOutputs; +import org.hyperledger.besu.ethereum.BlockProcessingResult; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError; +import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Deposit; import org.hyperledger.besu.ethereum.mainnet.DepositsValidator; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; import java.util.Collections; import java.util.List; import java.util.Optional; - -import static org.mockito.Mockito.lenient; -import static org.mockito.Mockito.verify; - -import org.hyperledger.besu.ethereum.BlockProcessingOutputs; -import org.hyperledger.besu.ethereum.BlockProcessingResult; -import org.hyperledger.besu.ethereum.core.BlockHeader; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) public class EngineNewPayloadV6110Test extends EngineNewPayloadV2Test { @@ -51,6 +49,7 @@ public EngineNewPayloadV6110Test() {} public void shouldReturnExpectedMethodName() { assertThat(method.getName()).isEqualTo("engine_newPayloadV6110"); } + @Test public void shouldReturnValidIfDepositsIsNotNull_WhenDepositsAllowed() { final List depositsParam = List.of(DEPOSIT_PARAM_1); @@ -122,5 +121,4 @@ public void shouldReturnInvalidIfDepositsIsNull_WhenDepositsAllowed() { assertThat(fromErrorResp(resp).getCode()).isEqualTo(INVALID_PARAMS.getCode()); verify(engineCallListener, times(1)).executionEngineCalled(); } - } From c7896efb2fac349e93260542de204986891df98b Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Fri, 4 Aug 2023 20:48:32 +0800 Subject: [PATCH 12/36] Update 6110 Acceptance Test Signed-off-by: Navie Chan --- .../jsonrpc/engine/eip6110/genesis.json | 39 ++++++++++++++++++- .../test-cases/01_cancun_prepare_payload.json | 8 ++-- .../test-cases/02_cancun_getPayloadV3.json | 8 ++-- .../test-cases/03_cancun_newPayloadV3.json | 8 ++-- .../04_cancun_forkchoiceUpdatedV2.json | 8 ++-- .../05_eip6110_forkchoiceUpdatedV2.json | 8 ++-- .../06_eip6110_getPayloadV6110.json | 8 ++-- ...invalid_null_deposits_execute_payload.json | 6 +-- .../09_eip6110_newPayloadV6110.json | 16 ++++---- .../10_eip6110_forkchoiceUpdatedV2.json | 8 ++-- .../11_eip6110_getPayloadV6110.json | 8 ++-- .../engine/EngineGetPayloadV6110Test.java | 5 ++- 12 files changed, 85 insertions(+), 45 deletions(-) diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/genesis.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/genesis.json index fc86ab8c425..232c577f6c8 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/genesis.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/genesis.json @@ -19,7 +19,7 @@ "period": 5, "epoch": 30000 }, - "depositContractAddress": "0x00000000219ab540356cbb839cbe05303d7705fa" + "depositContractAddress": "0x4242424242424242424242424242424242424242" }, "nonce":"0x42", "timestamp":"0x0", @@ -31,6 +31,43 @@ "alloc":{ "0xa4664C40AACeBD82A2Db79f0ea36C06Bc6A19Adb": { "balance": "1000000000000000000000000000" + }, + "0x4242424242424242424242424242424242424242": { + "balance": "0", + "code": "0x60806040526004361061003f5760003560e01c806301ffc9a71461004457806322895118146100a4578063621fd130146101ba578063c5f2892f14610244575b600080fd5b34801561005057600080fd5b506100906004803603602081101561006757600080fd5b50357fffffffff000000000000000000000000000000000000000000000000000000001661026b565b604080519115158252519081900360200190f35b6101b8600480360360808110156100ba57600080fd5b8101906020810181356401000000008111156100d557600080fd5b8201836020820111156100e757600080fd5b8035906020019184600183028401116401000000008311171561010957600080fd5b91939092909160208101903564010000000081111561012757600080fd5b82018360208201111561013957600080fd5b8035906020019184600183028401116401000000008311171561015b57600080fd5b91939092909160208101903564010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b919350915035610304565b005b3480156101c657600080fd5b506101cf6110b5565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102095781810151838201526020016101f1565b50505050905090810190601f1680156102365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025057600080fd5b506102596110c7565b60408051918252519081900360200190f35b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f8564090700000000000000000000000000000000000000000000000000000000145b92915050565b6030861461035d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118056026913960400191505060405180910390fd5b602084146103b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061179c6036913960400191505060405180910390fd5b6060821461040f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806118786029913960400191505060405180910390fd5b670de0b6b3a7640000341015610470576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118526026913960400191505060405180910390fd5b633b9aca003406156104cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806117d26033913960400191505060405180910390fd5b633b9aca00340467ffffffffffffffff811115610535576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061182b6027913960400191505060405180910390fd5b6060610540826114ba565b90507f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c589898989858a8a6105756020546114ba565b6040805160a0808252810189905290819060208201908201606083016080840160c085018e8e80828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910187810386528c815260200190508c8c808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690920188810386528c5181528c51602091820193918e019250908190849084905b83811015610648578181015183820152602001610630565b50505050905090810190601f1680156106755780820380516001836020036101000a031916815260200191505b5086810383528881526020018989808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018881038452895181528951602091820193918b019250908190849084905b838110156106ef5781810151838201526020016106d7565b50505050905090810190601f16801561071c5780820380516001836020036101000a031916815260200191505b509d505050505050505050505050505060405180910390a1600060028a8a600060801b604051602001808484808284377fffffffffffffffffffffffffffffffff0000000000000000000000000000000090941691909301908152604080517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0818403018152601090920190819052815191955093508392506020850191508083835b602083106107fc57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016107bf565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610859573d6000803e3d6000fd5b5050506040513d602081101561086e57600080fd5b5051905060006002806108846040848a8c6116fe565b6040516020018083838082843780830192505050925050506040516020818303038152906040526040518082805190602001908083835b602083106108f857805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016108bb565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610955573d6000803e3d6000fd5b5050506040513d602081101561096a57600080fd5b5051600261097b896040818d6116fe565b60405160009060200180848480828437919091019283525050604080518083038152602092830191829052805190945090925082918401908083835b602083106109f457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016109b7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610a51573d6000803e3d6000fd5b5050506040513d6020811015610a6657600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610ada57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610a9d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610b37573d6000803e3d6000fd5b5050506040513d6020811015610b4c57600080fd5b50516040805160208101858152929350600092600292839287928f928f92018383808284378083019250505093505050506040516020818303038152906040526040518082805190602001908083835b60208310610bd957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610b9c565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610c36573d6000803e3d6000fd5b5050506040513d6020811015610c4b57600080fd5b50516040518651600291889160009188916020918201918291908601908083835b60208310610ca957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610c6c565b6001836020036101000a0380198251168184511680821785525050505050509050018367ffffffffffffffff191667ffffffffffffffff1916815260180182815260200193505050506040516020818303038152906040526040518082805190602001908083835b60208310610d4e57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610d11565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610dab573d6000803e3d6000fd5b5050506040513d6020811015610dc057600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610e3457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610df7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610e91573d6000803e3d6000fd5b5050506040513d6020811015610ea657600080fd5b50519050858114610f02576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260548152602001806117486054913960600191505060405180910390fd5b60205463ffffffff11610f60576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806117276021913960400191505060405180910390fd5b602080546001019081905560005b60208110156110a9578160011660011415610fa0578260008260208110610f9157fe5b0155506110ac95505050505050565b600260008260208110610faf57fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061102557805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610fe8565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015611082573d6000803e3d6000fd5b5050506040513d602081101561109757600080fd5b50519250600282049150600101610f6e565b50fe5b50505050505050565b60606110c26020546114ba565b905090565b6020546000908190815b60208110156112f05781600116600114156111e6576002600082602081106110f557fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061116b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161112e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156111c8573d6000803e3d6000fd5b5050506040513d60208110156111dd57600080fd5b505192506112e2565b600283602183602081106111f657fe5b015460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061126b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161122e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156112c8573d6000803e3d6000fd5b5050506040513d60208110156112dd57600080fd5b505192505b6002820491506001016110d1565b506002826112ff6020546114ba565b600060401b6040516020018084815260200183805190602001908083835b6020831061135a57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161131d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790527fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000095909516920191825250604080518083037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8018152601890920190819052815191955093508392850191508083835b6020831061143f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611402565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa15801561149c573d6000803e3d6000fd5b5050506040513d60208110156114b157600080fd5b50519250505090565b60408051600880825281830190925260609160208201818036833701905050905060c082901b8060071a60f81b826000815181106114f457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060061a60f81b8260018151811061153757fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060051a60f81b8260028151811061157a57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060041a60f81b826003815181106115bd57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060031a60f81b8260048151811061160057fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060021a60f81b8260058151811061164357fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060011a60f81b8260068151811061168657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060001a60f81b826007815181106116c957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050919050565b6000808585111561170d578182fd5b83861115611719578182fd5b505082019391909203915056fe4465706f736974436f6e74726163743a206d65726b6c6520747265652066756c6c4465706f736974436f6e74726163743a207265636f6e7374727563746564204465706f7369744461746120646f6573206e6f74206d6174636820737570706c696564206465706f7369745f646174615f726f6f744465706f736974436f6e74726163743a20696e76616c6964207769746864726177616c5f63726564656e7469616c73206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c7565206e6f74206d756c7469706c65206f6620677765694465706f736974436f6e74726163743a20696e76616c6964207075626b6579206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f20686967684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f206c6f774465706f736974436f6e74726163743a20696e76616c6964207369676e6174757265206c656e677468a26469706673582212201dd26f37a621703009abf16e77e69c93dc50c79db7f6cc37543e3e0e3decdc9764736f6c634300060b0033", + "storage": { + "0x0000000000000000000000000000000000000000000000000000000000000022": "0xf5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b", + "0x0000000000000000000000000000000000000000000000000000000000000023": "0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71", + "0x0000000000000000000000000000000000000000000000000000000000000024": "0xc78009fdf07fc56a11f122370658a353aaa542ed63e44c4bc15ff4cd105ab33c", + "0x0000000000000000000000000000000000000000000000000000000000000025": "0x536d98837f2dd165a55d5eeae91485954472d56f246df256bf3cae19352a123c", + "0x0000000000000000000000000000000000000000000000000000000000000026": "0x9efde052aa15429fae05bad4d0b1d7c64da64d03d7a1854a588c2cb8430c0d30", + "0x0000000000000000000000000000000000000000000000000000000000000027": "0xd88ddfeed400a8755596b21942c1497e114c302e6118290f91e6772976041fa1", + "0x0000000000000000000000000000000000000000000000000000000000000028": "0x87eb0ddba57e35f6d286673802a4af5975e22506c7cf4c64bb6be5ee11527f2c", + "0x0000000000000000000000000000000000000000000000000000000000000029": "0x26846476fd5fc54a5d43385167c95144f2643f533cc85bb9d16b782f8d7db193", + "0x000000000000000000000000000000000000000000000000000000000000002a": "0x506d86582d252405b840018792cad2bf1259f1ef5aa5f887e13cb2f0094f51e1", + "0x000000000000000000000000000000000000000000000000000000000000002b": "0xffff0ad7e659772f9534c195c815efc4014ef1e1daed4404c06385d11192e92b", + "0x000000000000000000000000000000000000000000000000000000000000002c": "0x6cf04127db05441cd833107a52be852868890e4317e6a02ab47683aa75964220", + "0x000000000000000000000000000000000000000000000000000000000000002d": "0xb7d05f875f140027ef5118a2247bbb84ce8f2f0f1123623085daf7960c329f5f", + "0x000000000000000000000000000000000000000000000000000000000000002e": "0xdf6af5f5bbdb6be9ef8aa618e4bf8073960867171e29676f8b284dea6a08a85e", + "0x000000000000000000000000000000000000000000000000000000000000002f": "0xb58d900f5e182e3c50ef74969ea16c7726c549757cc23523c369587da7293784", + "0x0000000000000000000000000000000000000000000000000000000000000030": "0xd49a7502ffcfb0340b1d7885688500ca308161a7f96b62df9d083b71fcc8f2bb", + "0x0000000000000000000000000000000000000000000000000000000000000031": "0x8fe6b1689256c0d385f42f5bbe2027a22c1996e110ba97c171d3e5948de92beb", + "0x0000000000000000000000000000000000000000000000000000000000000032": "0x8d0d63c39ebade8509e0ae3c9c3876fb5fa112be18f905ecacfecb92057603ab", + "0x0000000000000000000000000000000000000000000000000000000000000033": "0x95eec8b2e541cad4e91de38385f2e046619f54496c2382cb6cacd5b98c26f5a4", + "0x0000000000000000000000000000000000000000000000000000000000000034": "0xf893e908917775b62bff23294dbbe3a1cd8e6cc1c35b4801887b646a6f81f17f", + "0x0000000000000000000000000000000000000000000000000000000000000035": "0xcddba7b592e3133393c16194fac7431abf2f5485ed711db282183c819e08ebaa", + "0x0000000000000000000000000000000000000000000000000000000000000036": "0x8a8d7fe3af8caa085a7639a832001457dfb9128a8061142ad0335629ff23ff9c", + "0x0000000000000000000000000000000000000000000000000000000000000037": "0xfeb3c337d7a51a6fbf00b9e34c52e1c9195c969bd4e7a0bfd51d5c5bed9c1167", + "0x0000000000000000000000000000000000000000000000000000000000000038": "0xe71f0aa83cc32edfbefa9f4d3e0174ca85182eec9f3a09f6a6c0df6377a510d7", + "0x0000000000000000000000000000000000000000000000000000000000000039": "0x31206fa80a50bb6abe29085058f16212212a60eec8f049fecb92d8c8e0a84bc0", + "0x000000000000000000000000000000000000000000000000000000000000003a": "0x21352bfecbeddde993839f614c3dac0a3ee37543f9b412b16199dc158e23b544", + "0x000000000000000000000000000000000000000000000000000000000000003b": "0x619e312724bb6d7c3153ed9de791d764a366b389af13c58bf8a8d90481a46765", + "0x000000000000000000000000000000000000000000000000000000000000003c": "0x7cdd2986268250628d0c10e385c58c6191e6fbe05191bcc04f133f2cea72c1c4", + "0x000000000000000000000000000000000000000000000000000000000000003d": "0x848930bd7ba8cac54661072113fb278869e07bb8587f91392933374d017bcbe1", + "0x000000000000000000000000000000000000000000000000000000000000003e": "0x8869ff2c22b28cc10510d9853292803328be4fb0e80495e8bb8d271f5b889636", + "0x000000000000000000000000000000000000000000000000000000000000003f": "0xb5fe28e79f1b850f8658246ce9b6a1e7b49fc06db7143e8fe0b4f2b0c5523a5c", + "0x0000000000000000000000000000000000000000000000000000000000000040": "0x985e929f70af28d0bdd1a90a808f977f597c7c778c489e98d3bd8910d31ac0f7" + } } }, "number":"0x0", diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/01_cancun_prepare_payload.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/01_cancun_prepare_payload.json index 419badcb4d4..72790bf9ed7 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/01_cancun_prepare_payload.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/01_cancun_prepare_payload.json @@ -4,8 +4,8 @@ "method": "engine_forkchoiceUpdatedV2", "params": [ { - "headBlockHash": "0x1074f86f925fbb9ba16d09e1695186895ef11891361b236c09c17a2975b0f1bf", - "safeBlockHash": "0x1074f86f925fbb9ba16d09e1695186895ef11891361b236c09c17a2975b0f1bf", + "headBlockHash": "0x28ffbc2f90499c058a5c87efc87bf33e420a46ac183d1e7d32a022025e73d72c", + "safeBlockHash": "0x28ffbc2f90499c058a5c87efc87bf33e420a46ac183d1e7d32a022025e73d72c", "finalizedBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { @@ -23,10 +23,10 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0x1074f86f925fbb9ba16d09e1695186895ef11891361b236c09c17a2975b0f1bf", + "latestValidHash": "0x28ffbc2f90499c058a5c87efc87bf33e420a46ac183d1e7d32a022025e73d72c", "validationError": null }, - "payloadId": "0x0065bd2bec446911" + "payloadId": "0x0065bd17c7d19011" } }, "statusCode" : 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/02_cancun_getPayloadV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/02_cancun_getPayloadV3.json index 97435db1947..817e64c7411 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/02_cancun_getPayloadV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/02_cancun_getPayloadV3.json @@ -3,7 +3,7 @@ "jsonrpc": "2.0", "method": "engine_getPayloadV3", "params": [ - "0x0065bd2bec446911" + "0x0065bd17c7d19011" ], "id": 67 }, @@ -12,9 +12,9 @@ "id": 67, "result": { "executionPayload": { - "parentHash": "0x1074f86f925fbb9ba16d09e1695186895ef11891361b236c09c17a2975b0f1bf", + "parentHash": "0x28ffbc2f90499c058a5c87efc87bf33e420a46ac183d1e7d32a022025e73d72c", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0xafe7b02da3d8cfc9a18b3494ffbf12a18e65e09010159d034741315473849b9a", + "stateRoot": "0x9b8c4a9a86cb49252075c0db2f0e72fb1e49350a0f70ea36f26f700201961e62", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -27,7 +27,7 @@ "withdrawals": [], "blockNumber": "0x1", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "blockHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", + "blockHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", "dataGasUsed" : "0x0" }, "blockValue": "0x0", diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/03_cancun_newPayloadV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/03_cancun_newPayloadV3.json index 40828dd7242..203f05c6a57 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/03_cancun_newPayloadV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/03_cancun_newPayloadV3.json @@ -4,9 +4,9 @@ "method": "engine_newPayloadV3", "params": [ { - "parentHash": "0x1074f86f925fbb9ba16d09e1695186895ef11891361b236c09c17a2975b0f1bf", + "parentHash": "0x28ffbc2f90499c058a5c87efc87bf33e420a46ac183d1e7d32a022025e73d72c", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0xafe7b02da3d8cfc9a18b3494ffbf12a18e65e09010159d034741315473849b9a", + "stateRoot": "0x9b8c4a9a86cb49252075c0db2f0e72fb1e49350a0f70ea36f26f700201961e62", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -17,7 +17,7 @@ "transactions": [], "withdrawals": [], "blockNumber": "0x1", - "blockHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", + "blockHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "excessDataGas" : "0x0", "dataGasUsed" : "0x0" @@ -31,7 +31,7 @@ "id": 67, "result": { "status": "VALID", - "latestValidHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", + "latestValidHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", "validationError": null } }, diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV2.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV2.json index ef2b4e85913..48f663732a4 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV2.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV2.json @@ -4,9 +4,9 @@ "method": "engine_forkchoiceUpdatedV2", "params": [ { - "headBlockHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", - "safeBlockHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", - "finalizedBlockHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6" + "headBlockHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", + "safeBlockHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", + "finalizedBlockHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b" }, null ], @@ -18,7 +18,7 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", + "latestValidHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", "validationError": null }, "payloadId": null diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_forkchoiceUpdatedV2.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_forkchoiceUpdatedV2.json index 60cc03e220d..07b46847d43 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_forkchoiceUpdatedV2.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_forkchoiceUpdatedV2.json @@ -4,8 +4,8 @@ "method": "engine_forkchoiceUpdatedV2", "params": [ { - "headBlockHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", - "safeBlockHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", + "headBlockHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", + "safeBlockHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", "finalizedBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { @@ -23,10 +23,10 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", + "latestValidHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", "validationError": null }, - "payloadId": "0x0065bd031ac6ca21" + "payloadId": "0x0065bd13a5f68adf" } }, "statusCode" : 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/06_eip6110_getPayloadV6110.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/06_eip6110_getPayloadV6110.json index 987a7c61d41..5cf99fbcadd 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/06_eip6110_getPayloadV6110.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/06_eip6110_getPayloadV6110.json @@ -3,7 +3,7 @@ "jsonrpc": "2.0", "method": "engine_getPayloadV6110", "params": [ - "0x0065bd031ac6ca21" + "0x0065bd13a5f68adf" ], "id": 67 }, @@ -12,9 +12,9 @@ "id": 67, "result": { "executionPayload": { - "parentHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", + "parentHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0xafe7b02da3d8cfc9a18b3494ffbf12a18e65e09010159d034741315473849b9a", + "stateRoot": "0x9b8c4a9a86cb49252075c0db2f0e72fb1e49350a0f70ea36f26f700201961e62", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -27,7 +27,7 @@ "withdrawals": [], "depositReceipts" : [], "blockNumber": "0x2", - "blockHash": "0xf35fe237e1d7bb99f2e955c41f768f5e7cd7a4673a9409ab5e755f22026b1d15", + "blockHash": "0xdc9071c29433b9fa11729e745edf225ed470207e1b9e520505cf9f42de8ccb65", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "dataGasUsed" : "0x0" }, diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_invalid_null_deposits_execute_payload.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_invalid_null_deposits_execute_payload.json index 834714f7772..578407fc90d 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_invalid_null_deposits_execute_payload.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_invalid_null_deposits_execute_payload.json @@ -4,9 +4,9 @@ "method": "engine_newPayloadV6110", "params": [ { - "parentHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", + "parentHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0xafe7b02da3d8cfc9a18b3494ffbf12a18e65e09010159d034741315473849b9a", + "stateRoot": "0x9b8c4a9a86cb49252075c0db2f0e72fb1e49350a0f70ea36f26f700201961e62", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -19,7 +19,7 @@ "withdrawals": [], "depositReceipts" : null, "blockNumber": "0x2", - "blockHash": "0xf35fe237e1d7bb99f2e955c41f768f5e7cd7a4673a9409ab5e755f22026b1d15", + "blockHash": "0xdc9071c29433b9fa11729e745edf225ed470207e1b9e520505cf9f42de8ccb65", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "dataGasUsed" : "0x0" } diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/09_eip6110_newPayloadV6110.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/09_eip6110_newPayloadV6110.json index 7f6dfcf4886..2d642395c3f 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/09_eip6110_newPayloadV6110.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/09_eip6110_newPayloadV6110.json @@ -4,13 +4,13 @@ "method": "engine_newPayloadV6110", "params": [ { - "parentHash": "0x86be585a81cf0855b7a90735bc529530e658018b9da550c941cb37698dfa3fa6", + "parentHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0xac7f8402d971059174d7b5408346555f2914e088c15d7d7c32636d7e0597ac7d", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "stateRoot": "0x14208ac0e218167936e220b72d5d5887a963cb858ea2f2d268518f014a3da3fa", + "logsBloom": "0x10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", - "gasUsed": "0x62D0", + "gasUsed": "0x14B6E", "timestamp": "0x20", "extraData": "0x", "baseFeePerGas": "0x7", @@ -20,11 +20,11 @@ ], "withdrawals": [], "depositReceipts" : [ - {"amount":"0x773594000","index":"0x182b8","pubkey":"0x96a96086cff07df17668f35f7418ef8798079167e3f4f9b72ecde17b28226137cf454ab1dd20ef5d924786ab3483c2f9","signature":"0xb1acdb2c4d3df3f1b8d3bfd33421660df358d84d78d16c4603551935f4b67643373e7eb63dcb16ec359be0ec41fee33b03a16e80745f2374ff1d3c352508ac5d857c6476d3c3bcf7e6ca37427c9209f17be3af5264c0e2132b3dd1156c28b4e9","withdrawalCredentials":"0x003f5102dabe0a27b1746098d1dc17a5d3fbd478759fea9287e4e419b3c3cef2"} + {"amount":"0x773594000","index":"0x0","pubkey":"0x96a96086cff07df17668f35f7418ef8798079167e3f4f9b72ecde17b28226137cf454ab1dd20ef5d924786ab3483c2f9","signature":"0xb1acdb2c4d3df3f1b8d3bfd33421660df358d84d78d16c4603551935f4b67643373e7eb63dcb16ec359be0ec41fee33b03a16e80745f2374ff1d3c352508ac5d857c6476d3c3bcf7e6ca37427c9209f17be3af5264c0e2132b3dd1156c28b4e9","withdrawalCredentials":"0x003f5102dabe0a27b1746098d1dc17a5d3fbd478759fea9287e4e419b3c3cef2"} ], "blockNumber": "0x2", - "blockHash": "0xce621862a1f866f3f54b5d6d714f9582efa085fd1d0b770b7a230a02e8374a40", - "receiptsRoot": "0x3e0b69cee514173ba545e2f770fd3852d848c26c0b94b85d3c7ddb96da60b058", + "blockHash": "0xfca60892dd40a173234db1cc6187ae65c285f5880238d9816efa2721e403388d", + "receiptsRoot": "0x79ee3424eb720a3ad4b1c5a372bb8160580cbe4d893778660f34213c685627a9", "dataGasUsed" : "0x0" } ], @@ -35,7 +35,7 @@ "id": 67, "result": { "status": "VALID", - "latestValidHash": "0x302adfee13bf3137b252e667725c676958277d1132830a573920c029e65fb667", + "latestValidHash": "0xfca60892dd40a173234db1cc6187ae65c285f5880238d9816efa2721e403388d", "validationError": null } }, diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/10_eip6110_forkchoiceUpdatedV2.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/10_eip6110_forkchoiceUpdatedV2.json index b7bc6583356..2b52e72ae24 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/10_eip6110_forkchoiceUpdatedV2.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/10_eip6110_forkchoiceUpdatedV2.json @@ -4,8 +4,8 @@ "method": "engine_forkchoiceUpdatedV2", "params": [ { - "headBlockHash": "0x302adfee13bf3137b252e667725c676958277d1132830a573920c029e65fb667", - "safeBlockHash": "0x302adfee13bf3137b252e667725c676958277d1132830a573920c029e65fb667", + "headBlockHash": "0xfca60892dd40a173234db1cc6187ae65c285f5880238d9816efa2721e403388d", + "safeBlockHash": "0xfca60892dd40a173234db1cc6187ae65c285f5880238d9816efa2721e403388d", "finalizedBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { @@ -23,10 +23,10 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0x302adfee13bf3137b252e667725c676958277d1132830a573920c029e65fb667", + "latestValidHash": "0xfca60892dd40a173234db1cc6187ae65c285f5880238d9816efa2721e403388d", "validationError": null }, - "payloadId": "0x0065bd0cd58ce331" + "payloadId": "0x0065bd45f0044131" } }, "statusCode" : 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/11_eip6110_getPayloadV6110.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/11_eip6110_getPayloadV6110.json index a0a87a804fe..197fac440d0 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/11_eip6110_getPayloadV6110.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/11_eip6110_getPayloadV6110.json @@ -3,7 +3,7 @@ "jsonrpc": "2.0", "method": "engine_getPayloadV6110", "params": [ - "0x0065bd0cd58ce331" + "0x0065bd45f0044131" ], "id": 67 }, @@ -12,9 +12,9 @@ "id": 67, "result": { "executionPayload": { - "parentHash": "0x302adfee13bf3137b252e667725c676958277d1132830a573920c029e65fb667", + "parentHash": "0xfca60892dd40a173234db1cc6187ae65c285f5880238d9816efa2721e403388d", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0xafe7b02da3d8cfc9a18b3494ffbf12a18e65e09010159d034741315473849b9a", + "stateRoot": "0x14208ac0e218167936e220b72d5d5887a963cb858ea2f2d268518f014a3da3fa", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -27,7 +27,7 @@ "withdrawals": [], "depositReceipts" : [], "blockNumber": "0x3", - "blockHash": "0x14ac73efcfd4c2f02619bce8b3d196d6d1fed96053f54ec4eed59f90b56c37ba", + "blockHash": "0x77930ea7e70be6cedd338f2996a281f03078029d4c9ebb6786b3f981aa4a7ca5", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "dataGasUsed" : "0x0" }, diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java index ef91ffebdbb..e91efba0a27 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java @@ -25,7 +25,9 @@ import org.hyperledger.besu.datatypes.DataGas; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlobsBundleV1; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EngineGetPayloadResultV6110; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity; @@ -148,7 +150,8 @@ public void blobsBundleV1MustHaveSameNumberOfElements() { public void shouldReturnUnsupportedFork() { final var resp = resp(RpcMethod.ENGINE_GET_PAYLOAD_V6110.getMethodName(), mockPid); - assertThat(resp).isInstanceOf(JsonRpcSuccessResponse.class); + assertThat(resp).isInstanceOf(JsonRpcErrorResponse.class); + assertThat(((JsonRpcErrorResponse) resp).getErrorType()).isEqualTo(RpcErrorType.UNSUPPORTED_FORK); } @Override From b61caf78e0aa1e699c8fc997bb83db44ad2f8f58 Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Wed, 9 Aug 2023 18:43:45 +0800 Subject: [PATCH 13/36] Fix up Shanghai Acceptance Test Signed-off-by: Navie Chan --- .../engine/shanghai/test-cases/08_shanghai_getPayloadV2.json | 1 - 1 file changed, 1 deletion(-) diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/shanghai/test-cases/08_shanghai_getPayloadV2.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/shanghai/test-cases/08_shanghai_getPayloadV2.json index 2da9be48f4e..072e5146d0a 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/shanghai/test-cases/08_shanghai_getPayloadV2.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/shanghai/test-cases/08_shanghai_getPayloadV2.json @@ -37,7 +37,6 @@ "amount": "0x2" } ], - "deposits": null, "blockNumber": "0x2", "blockHash": "0x612abd8615f544759d4aeb3dbab32f5f198a8b818e9c5436e9f7a674ef3b0f20", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" From f57a8f91be6813ad9337139a08f31397ee40687e Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Wed, 9 Aug 2023 18:57:27 +0800 Subject: [PATCH 14/36] SpotlessApply Signed-off-by: Navie Chan --- .../internal/methods/engine/EngineGetPayloadV6110Test.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java index e91efba0a27..fe61a37fc5c 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java @@ -151,7 +151,8 @@ public void shouldReturnUnsupportedFork() { final var resp = resp(RpcMethod.ENGINE_GET_PAYLOAD_V6110.getMethodName(), mockPid); assertThat(resp).isInstanceOf(JsonRpcErrorResponse.class); - assertThat(((JsonRpcErrorResponse) resp).getErrorType()).isEqualTo(RpcErrorType.UNSUPPORTED_FORK); + assertThat(((JsonRpcErrorResponse) resp).getErrorType()) + .isEqualTo(RpcErrorType.UNSUPPORTED_FORK); } @Override From 147094c9123c68a3a454b395ff5bc543548d966a Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Thu, 10 Aug 2023 12:50:55 +0800 Subject: [PATCH 15/36] Update EngineNewPayloadV6110Test Signed-off-by: Navie Chan --- .../engine/EngineNewPayloadEIP6110Test.java | 191 ------------------ .../engine/EngineNewPayloadV6110Test.java | 59 +++++- 2 files changed, 57 insertions(+), 193 deletions(-) delete mode 100644 ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadEIP6110Test.java diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadEIP6110Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadEIP6110Test.java deleted file mode 100644 index f7ff7894969..00000000000 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadEIP6110Test.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright Hyperledger Besu Contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameterTestFixture.DEPOSIT_PARAM_1; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INVALID_PARAMS; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.lenient; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BlobGas; -import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.BlockProcessingOutputs; -import org.hyperledger.besu.ethereum.BlockProcessingResult; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameter; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError; -import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.Deposit; -import org.hyperledger.besu.ethereum.core.Withdrawal; -import org.hyperledger.besu.ethereum.mainnet.BodyValidation; -import org.hyperledger.besu.ethereum.mainnet.DepositsValidator; -import org.hyperledger.besu.evm.gascalculator.CancunGasCalculator; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -import org.apache.tuweni.bytes.Bytes32; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -public class EngineNewPayloadEIP6110Test extends EngineNewPayloadV3Test { - private static final Address depositContractAddress = - Address.fromHexString("0x00000000219ab540356cbb839cbe05303d7705fa"); - - public EngineNewPayloadEIP6110Test() {} - - @BeforeEach - @Override - public void before() { - super.before(); - maybeParentBeaconBlockRoot = Optional.of(Bytes32.ZERO); - this.method = - new EngineNewPayloadV3( - vertx, - protocolSchedule, - protocolContext, - mergeCoordinator, - ethPeers, - engineCallListener); - lenient() - .when(protocolSchedule.hardforkFor(any())) - .thenReturn(Optional.of(super.cancunHardfork)); - lenient().when(protocolSpec.getGasCalculator()).thenReturn(new CancunGasCalculator()); - } - - @Override - public void shouldReturnExpectedMethodName() { - assertThat(method.getName()).isEqualTo("engine_newPayloadV3"); - } - - @Test - public void shouldReturnValidIfDepositsIsNull_WhenDepositsProhibited() { - final List deposits = null; - when(protocolSpec.getDepositsValidator()) - .thenReturn(new DepositsValidator.ProhibitedDeposits()); - - BlockHeader mockHeader = - setupValidPayload( - new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), - Optional.empty(), - Optional.empty()); - when(blockchain.getBlockHeader(mockHeader.getParentHash())) - .thenReturn(Optional.of(mock(BlockHeader.class))); - when(mergeCoordinator.getLatestValidAncestor(mockHeader)) - .thenReturn(Optional.of(mockHeader.getHash())); - - var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList(), null, deposits)); - - assertValidResponse(mockHeader, resp); - } - - @Test - public void shouldReturnInvalidIfDepositsIsNull_WhenDepositsAllowed() { - final List deposits = null; - lenient() - .when(protocolSpec.getDepositsValidator()) - .thenReturn(new DepositsValidator.AllowedDeposits(depositContractAddress)); - - var resp = - resp( - mockEnginePayload( - createBlockHeader(Optional.empty(), Optional.empty()), - Collections.emptyList(), - null, - deposits)); - - assertThat(fromErrorResp(resp).getCode()).isEqualTo(INVALID_PARAMS.getCode()); - verify(engineCallListener, times(1)).executionEngineCalled(); - } - - @Test - public void shouldReturnValidIfDepositsIsNotNull_WhenDepositsAllowed() { - final List depositsParam = List.of(DEPOSIT_PARAM_1); - final List deposits = List.of(DEPOSIT_PARAM_1.toDeposit()); - when(protocolSpec.getDepositsValidator()) - .thenReturn(new DepositsValidator.AllowedDeposits(depositContractAddress)); - BlockHeader mockHeader = - setupValidPayload( - new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), - Optional.empty(), - Optional.of(deposits)); - when(blockchain.getBlockHeader(mockHeader.getParentHash())) - .thenReturn(Optional.of(mock(BlockHeader.class))); - when(mergeCoordinator.getLatestValidAncestor(mockHeader)) - .thenReturn(Optional.of(mockHeader.getHash())); - var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList(), null, depositsParam)); - - assertValidResponse(mockHeader, resp); - } - - @Test - public void shouldReturnInvalidIfDepositsIsNotNull_WhenDepositsProhibited() { - final List deposits = List.of(); - lenient() - .when(protocolSpec.getDepositsValidator()) - .thenReturn(new DepositsValidator.ProhibitedDeposits()); - - var resp = - resp( - mockEnginePayload( - createBlockHeader(Optional.empty(), Optional.of(Collections.emptyList())), - Collections.emptyList(), - null, - deposits)); - - final JsonRpcError jsonRpcError = fromErrorResp(resp); - assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode()); - verify(engineCallListener, times(1)).executionEngineCalled(); - } - - @Override - protected BlockHeader createBlockHeader( - final Optional> maybeWithdrawals, - final Optional> maybeDeposits) { - BlockHeader parentBlockHeader = - new BlockHeaderTestFixture() - .baseFeePerGas(Wei.ONE) - .timestamp(super.experimentalHardfork.milestone()) - .excessBlobGas(BlobGas.ZERO) - .blobGasUsed(100L) - .buildHeader(); - - BlockHeader mockHeader = - new BlockHeaderTestFixture() - .baseFeePerGas(Wei.ONE) - .parentHash(parentBlockHeader.getParentHash()) - .number(parentBlockHeader.getNumber() + 1) - .timestamp(parentBlockHeader.getTimestamp() + 1) - .withdrawalsRoot(maybeWithdrawals.map(BodyValidation::withdrawalsRoot).orElse(null)) - .excessBlobGas(BlobGas.ZERO) - .blobGasUsed(100L) - .depositsRoot(maybeDeposits.map(BodyValidation::depositsRoot).orElse(null)) - .parentBeaconBlockRoot( - maybeParentBeaconBlockRoot.isPresent() ? maybeParentBeaconBlockRoot : null) - .buildHeader(); - return mockHeader; - } -} diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java index f9f5f15d917..9b6268c527d 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java @@ -15,35 +15,64 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine; import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.api.graphql.internal.response.GraphQLError.INVALID_PARAMS; +import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INVALID_PARAMS; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameterTestFixture.DEPOSIT_PARAM_1; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import org.hyperledger.besu.datatypes.Address; +import org.hyperledger.besu.datatypes.DataGas; +import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.BlockProcessingOutputs; import org.hyperledger.besu.ethereum.BlockProcessingResult; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError; import org.hyperledger.besu.ethereum.core.BlockHeader; +import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.Deposit; +import org.hyperledger.besu.ethereum.core.Withdrawal; +import org.hyperledger.besu.ethereum.mainnet.BodyValidation; import org.hyperledger.besu.ethereum.mainnet.DepositsValidator; import java.util.Collections; import java.util.List; import java.util.Optional; +import org.hyperledger.besu.ethereum.mainnet.ScheduledProtocolSpec; +import org.hyperledger.besu.evm.gascalculator.CancunGasCalculator; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -public class EngineNewPayloadV6110Test extends EngineNewPayloadV2Test { +public class EngineNewPayloadV6110Test extends EngineNewPayloadV3Test { public EngineNewPayloadV6110Test() {} + @Override + @BeforeEach + public void before() { + super.before(); + this.method = + new EngineNewPayloadV6110( + vertx, + protocolSchedule, + protocolContext, + mergeCoordinator, + ethPeers, + engineCallListener); + + lenient().when(protocolSpec.getGasCalculator()).thenReturn(new CancunGasCalculator()); + lenient() + .when(protocolSchedule.hardforkFor(any())) + .thenReturn( + Optional.of(new ScheduledProtocolSpec.Hardfork("6110", super.EXPERIMENTAL_TIMESTAMP))); + } + @Override @Test public void shouldReturnExpectedMethodName() { @@ -121,4 +150,30 @@ public void shouldReturnInvalidIfDepositsIsNull_WhenDepositsAllowed() { assertThat(fromErrorResp(resp).getCode()).isEqualTo(INVALID_PARAMS.getCode()); verify(engineCallListener, times(1)).executionEngineCalled(); } + + @Override + protected BlockHeader createBlockHeader( + final Optional> maybeWithdrawals, + final Optional> maybeDeposits) { + BlockHeader parentBlockHeader = + new BlockHeaderTestFixture() + .baseFeePerGas(Wei.ONE) + .timestamp(super.EXPERIMENTAL_TIMESTAMP) + .excessDataGas(DataGas.ZERO) + .dataGasUsed(100L) + .buildHeader(); + + BlockHeader mockHeader = + new BlockHeaderTestFixture() + .baseFeePerGas(Wei.ONE) + .parentHash(parentBlockHeader.getParentHash()) + .number(parentBlockHeader.getNumber() + 1) + .timestamp(parentBlockHeader.getTimestamp() + 1) + .withdrawalsRoot(maybeWithdrawals.map(BodyValidation::withdrawalsRoot).orElse(null)) + .excessDataGas(DataGas.ZERO) + .dataGasUsed(100L) + .depositsRoot(maybeDeposits.map(BodyValidation::depositsRoot).orElse(null)) + .buildHeader(); + return mockHeader; + } } From 8c24aeed73ba59fdc49f641fca034644c9754212 Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Thu, 10 Aug 2023 13:01:06 +0800 Subject: [PATCH 16/36] Spotless Apply Signed-off-by: Navie Chan --- .../internal/methods/engine/EngineNewPayloadV6110Test.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java index 9b6268c527d..3fd92479c2c 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java @@ -15,8 +15,8 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine; import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INVALID_PARAMS; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameterTestFixture.DEPOSIT_PARAM_1; +import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INVALID_PARAMS; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.times; @@ -36,13 +36,13 @@ import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.mainnet.BodyValidation; import org.hyperledger.besu.ethereum.mainnet.DepositsValidator; +import org.hyperledger.besu.ethereum.mainnet.ScheduledProtocolSpec; +import org.hyperledger.besu.evm.gascalculator.CancunGasCalculator; import java.util.Collections; import java.util.List; import java.util.Optional; -import org.hyperledger.besu.ethereum.mainnet.ScheduledProtocolSpec; -import org.hyperledger.besu.evm.gascalculator.CancunGasCalculator; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; From ae075476362eb0de8250338cd0e55a63feaa7f97 Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Thu, 10 Aug 2023 14:02:59 +0800 Subject: [PATCH 17/36] Update EngineGetPayloadV6110Test Signed-off-by: Navie Chan --- .../engine/EngineGetPayloadV6110Test.java | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java index fe61a37fc5c..a7c90609ee8 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java @@ -15,7 +15,8 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -28,7 +29,6 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlobsBundleV1; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EngineGetPayloadResultV6110; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity; import org.hyperledger.besu.ethereum.core.Block; @@ -36,10 +36,9 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.BlockWithReceipts; +import org.hyperledger.besu.ethereum.mainnet.ScheduledProtocolSpec; -import java.security.InvalidParameterException; import java.util.Collections; -import java.util.List; import java.util.Optional; import org.apache.tuweni.bytes.Bytes; @@ -62,7 +61,12 @@ public EngineGetPayloadV6110Test() { @BeforeEach @Override public void before() { - super.before(); + lenient() + .when(mergeContext.retrieveBlockById(mockPid)) + .thenReturn(Optional.of(mockBlockWithReceiptsAndDeposits)); + when(protocolContext.safeConsensusContext(any())).thenReturn(Optional.of(mergeContext)); + when(protocolSchedule.hardforkFor(any())) + .thenReturn(Optional.of(new ScheduledProtocolSpec.Hardfork("6110", EIP_6110_AT))); this.method = new EngineGetPayloadV6110( vertx, @@ -106,7 +110,7 @@ public void shouldReturnBlockForKnownPayloadId() { Collections.emptyList(), Collections.emptyList(), Optional.of(Collections.emptyList()), - Optional.empty())), + Optional.of(Collections.emptyList()))), Collections.emptyList()); when(mergeContext.retrieveBlockById(postEip6110Pid)).thenReturn(Optional.of(postEip6110Block)); @@ -135,17 +139,6 @@ public void shouldReturnBlockForKnownPayloadId() { verify(engineCallListener, times(1)).executionEngineCalled(); } - @Test - public void blobsBundleV1MustHaveSameNumberOfElements() { - String actualMessage = - assertThrows( - InvalidParameterException.class, - () -> new BlobsBundleV1(List.of(""), List.of(""), List.of())) - .getMessage(); - final String expectedMessage = "There must be an equal number of blobs, commitments and proofs"; - assertThat(actualMessage).isEqualTo(expectedMessage); - } - @Test public void shouldReturnUnsupportedFork() { final var resp = resp(RpcMethod.ENGINE_GET_PAYLOAD_V6110.getMethodName(), mockPid); From 89b4be53fd3876ed70dc8cd5b00320d0355b997f Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Thu, 7 Sep 2023 19:02:26 +0800 Subject: [PATCH 18/36] Fix conflict Signed-off-by: Navie Chan --- .../internal/response/RpcErrorType.java | 1 - .../engine/EngineNewPayloadEIP6110Test.java | 191 ++++++++++++++++++ 2 files changed, 191 insertions(+), 1 deletion(-) create mode 100644 ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadEIP6110Test.java diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/RpcErrorType.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/RpcErrorType.java index acad01a1731..c3ef46016d9 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/RpcErrorType.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/RpcErrorType.java @@ -24,7 +24,6 @@ public enum RpcErrorType { TIMEOUT_ERROR(-32603, "Timeout expired"), METHOD_NOT_ENABLED(-32604, "Method not enabled"), - UNSUPPORTED_FORK(-38005, "Unsupported fork"), // Resource unavailable error TX_POOL_DISABLED(-32002, "Transaction pool not enabled"), diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadEIP6110Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadEIP6110Test.java new file mode 100644 index 00000000000..2339cfec9f5 --- /dev/null +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadEIP6110Test.java @@ -0,0 +1,191 @@ +/* + * Copyright Hyperledger Besu Contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameterTestFixture.DEPOSIT_PARAM_1; +import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INVALID_PARAMS; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.lenient; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import org.hyperledger.besu.datatypes.Address; +import org.hyperledger.besu.datatypes.BlobGas; +import org.hyperledger.besu.datatypes.Wei; +import org.hyperledger.besu.ethereum.BlockProcessingOutputs; +import org.hyperledger.besu.ethereum.BlockProcessingResult; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameter; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError; +import org.hyperledger.besu.ethereum.core.BlockHeader; +import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; +import org.hyperledger.besu.ethereum.core.Deposit; +import org.hyperledger.besu.ethereum.core.Withdrawal; +import org.hyperledger.besu.ethereum.mainnet.BodyValidation; +import org.hyperledger.besu.ethereum.mainnet.DepositsValidator; +import org.hyperledger.besu.evm.gascalculator.CancunGasCalculator; + +import java.util.Collections; +import java.util.List; +import java.util.Optional; + +import org.apache.tuweni.bytes.Bytes32; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +public class EngineNewPayloadEIP6110Test extends EngineNewPayloadV3Test { + private static final Address depositContractAddress = + Address.fromHexString("0x00000000219ab540356cbb839cbe05303d7705fa"); + + public EngineNewPayloadEIP6110Test() {} + + @BeforeEach + @Override + public void before() { + super.before(); + maybeParentBeaconBlockRoot = Optional.of(Bytes32.ZERO); + this.method = + new EngineNewPayloadV3( + vertx, + protocolSchedule, + protocolContext, + mergeCoordinator, + ethPeers, + engineCallListener); + lenient() + .when(protocolSchedule.hardforkFor(any())) + .thenReturn(Optional.of(super.cancunHardfork)); + lenient().when(protocolSpec.getGasCalculator()).thenReturn(new CancunGasCalculator()); + } + + @Override + public void shouldReturnExpectedMethodName() { + assertThat(method.getName()).isEqualTo("engine_newPayloadV3"); + } + + @Test + public void shouldReturnValidIfDepositsIsNull_WhenDepositsProhibited() { + final List deposits = null; + when(protocolSpec.getDepositsValidator()) + .thenReturn(new DepositsValidator.ProhibitedDeposits()); + + BlockHeader mockHeader = + setupValidPayload( + new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), + Optional.empty(), + Optional.empty()); + when(blockchain.getBlockHeader(mockHeader.getParentHash())) + .thenReturn(Optional.of(mock(BlockHeader.class))); + when(mergeCoordinator.getLatestValidAncestor(mockHeader)) + .thenReturn(Optional.of(mockHeader.getHash())); + + var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList(), null, deposits)); + + assertValidResponse(mockHeader, resp); + } + + @Test + public void shouldReturnInvalidIfDepositsIsNull_WhenDepositsAllowed() { + final List deposits = null; + lenient() + .when(protocolSpec.getDepositsValidator()) + .thenReturn(new DepositsValidator.AllowedDeposits(depositContractAddress)); + + var resp = + resp( + mockEnginePayload( + createBlockHeader(Optional.empty(), Optional.empty()), + Collections.emptyList(), + null, + deposits)); + + assertThat(fromErrorResp(resp).getCode()).isEqualTo(INVALID_PARAMS.getCode()); + verify(engineCallListener, times(1)).executionEngineCalled(); + } + + @Test + public void shouldReturnValidIfDepositsIsNotNull_WhenDepositsAllowed() { + final List depositsParam = List.of(DEPOSIT_PARAM_1); + final List deposits = List.of(DEPOSIT_PARAM_1.toDeposit()); + when(protocolSpec.getDepositsValidator()) + .thenReturn(new DepositsValidator.AllowedDeposits(depositContractAddress)); + BlockHeader mockHeader = + setupValidPayload( + new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), + Optional.empty(), + Optional.of(deposits)); + when(blockchain.getBlockHeader(mockHeader.getParentHash())) + .thenReturn(Optional.of(mock(BlockHeader.class))); + when(mergeCoordinator.getLatestValidAncestor(mockHeader)) + .thenReturn(Optional.of(mockHeader.getHash())); + var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList(), null, depositsParam)); + + assertValidResponse(mockHeader, resp); + } + + @Test + public void shouldReturnInvalidIfDepositsIsNotNull_WhenDepositsProhibited() { + final List deposits = List.of(); + lenient() + .when(protocolSpec.getDepositsValidator()) + .thenReturn(new DepositsValidator.ProhibitedDeposits()); + + var resp = + resp( + mockEnginePayload( + createBlockHeader(Optional.empty(), Optional.of(Collections.emptyList())), + Collections.emptyList(), + null, + deposits)); + + final JsonRpcError jsonRpcError = fromErrorResp(resp); + assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode()); + verify(engineCallListener, times(1)).executionEngineCalled(); + } + + @Override + protected BlockHeader createBlockHeader( + final Optional> maybeWithdrawals, + final Optional> maybeDeposits) { + BlockHeader parentBlockHeader = + new BlockHeaderTestFixture() + .baseFeePerGas(Wei.ONE) + .timestamp(super.experimentalHardfork.milestone()) + .excessBlobGas(BlobGas.ZERO) + .blobGasUsed(100L) + .buildHeader(); + + BlockHeader mockHeader = + new BlockHeaderTestFixture() + .baseFeePerGas(Wei.ONE) + .parentHash(parentBlockHeader.getParentHash()) + .number(parentBlockHeader.getNumber() + 1) + .timestamp(parentBlockHeader.getTimestamp() + 1) + .withdrawalsRoot(maybeWithdrawals.map(BodyValidation::withdrawalsRoot).orElse(null)) + .excessBlobGas(BlobGas.ZERO) + .blobGasUsed(100L) + .depositsRoot(maybeDeposits.map(BodyValidation::depositsRoot).orElse(null)) + .parentBeaconBlockRoot( + maybeParentBeaconBlockRoot.isPresent() ? maybeParentBeaconBlockRoot : null) + .buildHeader(); + return mockHeader; + } +} \ No newline at end of file From 447230c06c25ae4c282c65ff47e92e759c06e4e5 Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Thu, 7 Sep 2023 20:20:43 +0800 Subject: [PATCH 19/36] Update EngineNewPayloadEIP6110Test Signed-off-by: Navie Chan --- .../internal/methods/engine/EngineNewPayloadEIP6110Test.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadEIP6110Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadEIP6110Test.java index 2339cfec9f5..f7ff7894969 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadEIP6110Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadEIP6110Test.java @@ -188,4 +188,4 @@ protected BlockHeader createBlockHeader( .buildHeader(); return mockHeader; } -} \ No newline at end of file +} From bdcf1ad4cc65f684bc2e048f96b9da873158af32 Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Thu, 7 Sep 2023 20:48:58 +0800 Subject: [PATCH 20/36] Update 6110 code from 4844 Signed-off-by: Navie Chan --- .../results/EngineGetPayloadResultV6110.java | 47 +++-- .../engine/EngineGetPayloadV6110Test.java | 57 ++++-- .../engine/EngineNewPayloadEIP6110Test.java | 191 ------------------ .../engine/EngineNewPayloadV6110Test.java | 107 +++++----- plugin-api/build.gradle | 2 +- 5 files changed, 129 insertions(+), 275 deletions(-) delete mode 100644 ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadEIP6110Test.java diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV6110.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV6110.java index f6fcae7e157..25e1f9c121e 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV6110.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV6110.java @@ -29,11 +29,12 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; import org.apache.tuweni.bytes.Bytes32; -@JsonPropertyOrder({"executionPayload", "blockValue", "blobsBundle"}) +@JsonPropertyOrder({"executionPayload", "blockValue", "blobsBundle", "shouldOverrideBuilder"}) public class EngineGetPayloadResultV6110 { protected final PayloadResult executionPayload; private final String blockValue; private final BlobsBundleV1 blobsBundle; + private final boolean shouldOverrideBuilder; public EngineGetPayloadResultV6110( final BlockHeader header, @@ -45,6 +46,7 @@ public EngineGetPayloadResultV6110( this.executionPayload = new PayloadResult(header, transactions, withdrawals, deposits); this.blockValue = blockValue; this.blobsBundle = blobsBundle; + this.shouldOverrideBuilder = false; } @JsonGetter(value = "executionPayload") @@ -62,6 +64,11 @@ public BlobsBundleV1 getBlobsBundle() { return blobsBundle; } + @JsonGetter(value = "shouldOverrideBuilder") + public boolean shouldOverrideBuilder() { + return shouldOverrideBuilder; + } + public static class PayloadResult { protected final String blockHash; @@ -77,10 +84,9 @@ public static class PayloadResult { private final String timestamp; private final String extraData; private final String baseFeePerGas; - - private final String excessDataGas; - - private final String dataGasUsed; + private final String excessBlobGas; + private final String blobGasUsed; + private final String parentBeaconBlockRoot; protected final List transactions; private final List withdrawals; @@ -113,14 +119,16 @@ public PayloadResult( .map(WithdrawalParameter::fromWithdrawal) .collect(Collectors.toList())) .orElse(null); - this.dataGasUsed = header.getDataGasUsed().map(Quantity::create).orElse(Quantity.HEX_ZERO); - this.excessDataGas = - header.getExcessDataGas().map(Quantity::create).orElse(Quantity.HEX_ZERO); this.deposits = deposits .map( ds -> ds.stream().map(DepositParameter::fromDeposit).collect(Collectors.toList())) .orElse(null); + this.blobGasUsed = header.getBlobGasUsed().map(Quantity::create).orElse(Quantity.HEX_ZERO); + this.excessBlobGas = + header.getExcessBlobGas().map(Quantity::create).orElse(Quantity.HEX_ZERO); + this.parentBeaconBlockRoot = + header.getParentBeaconBlockRoot().map(Bytes32::toHexString).orElse(null); } @JsonGetter(value = "blockNumber") @@ -193,25 +201,30 @@ public List getWithdrawals() { return withdrawals; } + @JsonGetter(value = "deposits") + public List getDeposits() { + return deposits; + } + @JsonGetter(value = "feeRecipient") @JsonInclude(JsonInclude.Include.NON_NULL) public String getFeeRecipient() { return feeRecipient; } - @JsonGetter(value = "excessDataGas") - public String getExcessDataGas() { - return excessDataGas; + @JsonGetter(value = "excessBlobGas") + public String getExcessBlobGas() { + return excessBlobGas; } - @JsonGetter(value = "dataGasUsed") - public String getDataGasUseds() { - return dataGasUsed; + @JsonGetter(value = "blobGasUsed") + public String getBlobGasUseds() { + return blobGasUsed; } - @JsonGetter(value = "depositReceipts") - public List getDeposits() { - return deposits; + @JsonGetter(value = "parentBeaconBlockRoot") + public String getParentBeaconBlockRoot() { + return parentBeaconBlockRoot; } } } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java index a7c90609ee8..a024ddda921 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java @@ -15,30 +15,38 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.lenient; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import org.hyperledger.besu.consensus.merge.blockcreation.PayloadIdentifier; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.DataGas; +import org.hyperledger.besu.datatypes.BlobGas; +import org.hyperledger.besu.datatypes.BlobsWithCommitments; import org.hyperledger.besu.datatypes.Hash; +import org.hyperledger.besu.datatypes.TransactionType; +import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EngineGetPayloadResultV6110; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity; +import org.hyperledger.besu.ethereum.core.BlobTestFixture; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.BlockWithReceipts; -import org.hyperledger.besu.ethereum.mainnet.ScheduledProtocolSpec; +import org.hyperledger.besu.ethereum.core.Transaction; +import org.hyperledger.besu.ethereum.core.TransactionReceipt; +import org.hyperledger.besu.ethereum.core.TransactionTestFixture; +import java.math.BigInteger; import java.util.Collections; +import java.util.List; import java.util.Optional; import org.apache.tuweni.bytes.Bytes; @@ -46,14 +54,13 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith( MockitoExtension.class) // mocks in parent class may not be used, throwing unnecessary stubbing public class EngineGetPayloadV6110Test extends AbstractEngineGetPayloadTest { - private static final long EIP_6110_AT = 31337L; - public EngineGetPayloadV6110Test() { super(EngineGetPayloadV6110::new); } @@ -64,9 +71,7 @@ public void before() { lenient() .when(mergeContext.retrieveBlockById(mockPid)) .thenReturn(Optional.of(mockBlockWithReceiptsAndDeposits)); - when(protocolContext.safeConsensusContext(any())).thenReturn(Optional.of(mergeContext)); - when(protocolSchedule.hardforkFor(any())) - .thenReturn(Optional.of(new ScheduledProtocolSpec.Hardfork("6110", EIP_6110_AT))); + when(protocolContext.safeConsensusContext(Mockito.any())).thenReturn(Optional.of(mergeContext)); this.method = new EngineGetPayloadV6110( vertx, @@ -90,28 +95,44 @@ public void shouldReturnBlockForKnownPayloadId() { BlockHeader eip6110Header = new BlockHeaderTestFixture() .prevRandao(Bytes32.random()) - .timestamp(EIP_6110_AT + 1) - .excessDataGas(DataGas.of(10L)) + .timestamp(experimentalHardfork.milestone() + 1) + .excessBlobGas(BlobGas.of(10L)) .buildHeader(); - // should return withdrawals and excessGas for a post-eip6110 block + // should return withdrawals, deposits and excessGas for a post-6110 block PayloadIdentifier postEip6110Pid = PayloadIdentifier.forPayloadParams( Hash.ZERO, - EIP_6110_AT, + experimentalHardfork.milestone(), Bytes32.random(), Address.fromHexString("0x42"), + Optional.empty(), Optional.empty()); + BlobTestFixture blobTestFixture = new BlobTestFixture(); + BlobsWithCommitments bwc = blobTestFixture.createBlobsWithCommitments(1); + Transaction blobTx = + new TransactionTestFixture() + .to(Optional.of(Address.fromHexString("0xDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF"))) + .type(TransactionType.BLOB) + .chainId(Optional.of(BigInteger.ONE)) + .maxFeePerGas(Optional.of(Wei.of(15))) + .maxFeePerBlobGas(Optional.of(Wei.of(128))) + .maxPriorityFeePerGas(Optional.of(Wei.of(1))) + .blobsWithCommitments(Optional.of(bwc)) + .versionedHashes(Optional.of(bwc.getVersionedHashes())) + .createTransaction(senderKeys); + TransactionReceipt blobReceipt = mock(TransactionReceipt.class); + when(blobReceipt.getCumulativeGasUsed()).thenReturn(100L); BlockWithReceipts postEip6110Block = new BlockWithReceipts( new Block( eip6110Header, new BlockBody( - Collections.emptyList(), + List.of(blobTx), Collections.emptyList(), Optional.of(Collections.emptyList()), - Optional.of(Collections.emptyList()))), - Collections.emptyList()); + Optional.empty())), + List.of(blobReceipt)); when(mergeContext.retrieveBlockById(postEip6110Pid)).thenReturn(Optional.of(postEip6110Block)); @@ -130,10 +151,10 @@ public void shouldReturnBlockForKnownPayloadId() { assertThat(res.getBlockValue()).isEqualTo(Quantity.create(0)); assertThat(res.getExecutionPayload().getPrevRandao()) .isEqualTo(eip6110Header.getPrevRandao().map(Bytes32::toString).orElse("")); - // excessDataGas: QUANTITY, 256 bits + // excessBlobGas: QUANTITY, 256 bits String expectedQuantityOf10 = Bytes32.leftPad(Bytes.of(10)).toQuantityHexString(); - assertThat(res.getExecutionPayload().getExcessDataGas()).isNotEmpty(); - assertThat(res.getExecutionPayload().getExcessDataGas()) + assertThat(res.getExecutionPayload().getExcessBlobGas()).isNotEmpty(); + assertThat(res.getExecutionPayload().getExcessBlobGas()) .isEqualTo(expectedQuantityOf10); }); verify(engineCallListener, times(1)).executionEngineCalled(); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadEIP6110Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadEIP6110Test.java deleted file mode 100644 index f7ff7894969..00000000000 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadEIP6110Test.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright Hyperledger Besu Contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameterTestFixture.DEPOSIT_PARAM_1; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INVALID_PARAMS; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.lenient; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BlobGas; -import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.BlockProcessingOutputs; -import org.hyperledger.besu.ethereum.BlockProcessingResult; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameter; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError; -import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.Deposit; -import org.hyperledger.besu.ethereum.core.Withdrawal; -import org.hyperledger.besu.ethereum.mainnet.BodyValidation; -import org.hyperledger.besu.ethereum.mainnet.DepositsValidator; -import org.hyperledger.besu.evm.gascalculator.CancunGasCalculator; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -import org.apache.tuweni.bytes.Bytes32; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -public class EngineNewPayloadEIP6110Test extends EngineNewPayloadV3Test { - private static final Address depositContractAddress = - Address.fromHexString("0x00000000219ab540356cbb839cbe05303d7705fa"); - - public EngineNewPayloadEIP6110Test() {} - - @BeforeEach - @Override - public void before() { - super.before(); - maybeParentBeaconBlockRoot = Optional.of(Bytes32.ZERO); - this.method = - new EngineNewPayloadV3( - vertx, - protocolSchedule, - protocolContext, - mergeCoordinator, - ethPeers, - engineCallListener); - lenient() - .when(protocolSchedule.hardforkFor(any())) - .thenReturn(Optional.of(super.cancunHardfork)); - lenient().when(protocolSpec.getGasCalculator()).thenReturn(new CancunGasCalculator()); - } - - @Override - public void shouldReturnExpectedMethodName() { - assertThat(method.getName()).isEqualTo("engine_newPayloadV3"); - } - - @Test - public void shouldReturnValidIfDepositsIsNull_WhenDepositsProhibited() { - final List deposits = null; - when(protocolSpec.getDepositsValidator()) - .thenReturn(new DepositsValidator.ProhibitedDeposits()); - - BlockHeader mockHeader = - setupValidPayload( - new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), - Optional.empty(), - Optional.empty()); - when(blockchain.getBlockHeader(mockHeader.getParentHash())) - .thenReturn(Optional.of(mock(BlockHeader.class))); - when(mergeCoordinator.getLatestValidAncestor(mockHeader)) - .thenReturn(Optional.of(mockHeader.getHash())); - - var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList(), null, deposits)); - - assertValidResponse(mockHeader, resp); - } - - @Test - public void shouldReturnInvalidIfDepositsIsNull_WhenDepositsAllowed() { - final List deposits = null; - lenient() - .when(protocolSpec.getDepositsValidator()) - .thenReturn(new DepositsValidator.AllowedDeposits(depositContractAddress)); - - var resp = - resp( - mockEnginePayload( - createBlockHeader(Optional.empty(), Optional.empty()), - Collections.emptyList(), - null, - deposits)); - - assertThat(fromErrorResp(resp).getCode()).isEqualTo(INVALID_PARAMS.getCode()); - verify(engineCallListener, times(1)).executionEngineCalled(); - } - - @Test - public void shouldReturnValidIfDepositsIsNotNull_WhenDepositsAllowed() { - final List depositsParam = List.of(DEPOSIT_PARAM_1); - final List deposits = List.of(DEPOSIT_PARAM_1.toDeposit()); - when(protocolSpec.getDepositsValidator()) - .thenReturn(new DepositsValidator.AllowedDeposits(depositContractAddress)); - BlockHeader mockHeader = - setupValidPayload( - new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), - Optional.empty(), - Optional.of(deposits)); - when(blockchain.getBlockHeader(mockHeader.getParentHash())) - .thenReturn(Optional.of(mock(BlockHeader.class))); - when(mergeCoordinator.getLatestValidAncestor(mockHeader)) - .thenReturn(Optional.of(mockHeader.getHash())); - var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList(), null, depositsParam)); - - assertValidResponse(mockHeader, resp); - } - - @Test - public void shouldReturnInvalidIfDepositsIsNotNull_WhenDepositsProhibited() { - final List deposits = List.of(); - lenient() - .when(protocolSpec.getDepositsValidator()) - .thenReturn(new DepositsValidator.ProhibitedDeposits()); - - var resp = - resp( - mockEnginePayload( - createBlockHeader(Optional.empty(), Optional.of(Collections.emptyList())), - Collections.emptyList(), - null, - deposits)); - - final JsonRpcError jsonRpcError = fromErrorResp(resp); - assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode()); - verify(engineCallListener, times(1)).executionEngineCalled(); - } - - @Override - protected BlockHeader createBlockHeader( - final Optional> maybeWithdrawals, - final Optional> maybeDeposits) { - BlockHeader parentBlockHeader = - new BlockHeaderTestFixture() - .baseFeePerGas(Wei.ONE) - .timestamp(super.experimentalHardfork.milestone()) - .excessBlobGas(BlobGas.ZERO) - .blobGasUsed(100L) - .buildHeader(); - - BlockHeader mockHeader = - new BlockHeaderTestFixture() - .baseFeePerGas(Wei.ONE) - .parentHash(parentBlockHeader.getParentHash()) - .number(parentBlockHeader.getNumber() + 1) - .timestamp(parentBlockHeader.getTimestamp() + 1) - .withdrawalsRoot(maybeWithdrawals.map(BodyValidation::withdrawalsRoot).orElse(null)) - .excessBlobGas(BlobGas.ZERO) - .blobGasUsed(100L) - .depositsRoot(maybeDeposits.map(BodyValidation::depositsRoot).orElse(null)) - .parentBeaconBlockRoot( - maybeParentBeaconBlockRoot.isPresent() ? maybeParentBeaconBlockRoot : null) - .buildHeader(); - return mockHeader; - } -} diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java index 3fd92479c2c..d2b016260d1 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110Test.java @@ -19,12 +19,13 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INVALID_PARAMS; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.lenient; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.DataGas; +import org.hyperledger.besu.datatypes.BlobGas; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.BlockProcessingOutputs; import org.hyperledger.besu.ethereum.BlockProcessingResult; @@ -36,13 +37,13 @@ import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.mainnet.BodyValidation; import org.hyperledger.besu.ethereum.mainnet.DepositsValidator; -import org.hyperledger.besu.ethereum.mainnet.ScheduledProtocolSpec; import org.hyperledger.besu.evm.gascalculator.CancunGasCalculator; import java.util.Collections; import java.util.List; import java.util.Optional; +import org.apache.tuweni.bytes.Bytes32; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -50,50 +51,33 @@ @ExtendWith(MockitoExtension.class) public class EngineNewPayloadV6110Test extends EngineNewPayloadV3Test { + private static final Address depositContractAddress = + Address.fromHexString("0x00000000219ab540356cbb839cbe05303d7705fa"); public EngineNewPayloadV6110Test() {} - @Override @BeforeEach + @Override public void before() { super.before(); + maybeParentBeaconBlockRoot = Optional.of(Bytes32.ZERO); this.method = - new EngineNewPayloadV6110( + new EngineNewPayloadV3( vertx, protocolSchedule, protocolContext, mergeCoordinator, ethPeers, engineCallListener); - - lenient().when(protocolSpec.getGasCalculator()).thenReturn(new CancunGasCalculator()); lenient() .when(protocolSchedule.hardforkFor(any())) - .thenReturn( - Optional.of(new ScheduledProtocolSpec.Hardfork("6110", super.EXPERIMENTAL_TIMESTAMP))); + .thenReturn(Optional.of(super.cancunHardfork)); + lenient().when(protocolSpec.getGasCalculator()).thenReturn(new CancunGasCalculator()); } @Override - @Test public void shouldReturnExpectedMethodName() { - assertThat(method.getName()).isEqualTo("engine_newPayloadV6110"); - } - - @Test - public void shouldReturnValidIfDepositsIsNotNull_WhenDepositsAllowed() { - final List depositsParam = List.of(DEPOSIT_PARAM_1); - final List deposits = List.of(DEPOSIT_PARAM_1.toDeposit()); - when(protocolSpec.getDepositsValidator()) - .thenReturn(new DepositsValidator.AllowedDeposits(Address.ZERO)); - BlockHeader mockHeader = - setupValidPayload( - new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), - Optional.empty(), - Optional.of(deposits)); - - var resp = resp(mockPayload(mockHeader, Collections.emptyList(), null, depositsParam)); - - assertValidResponse(mockHeader, resp); + assertThat(method.getName()).isEqualTo("engine_newPayloadV3"); } @Test @@ -101,53 +85,78 @@ public void shouldReturnValidIfDepositsIsNull_WhenDepositsProhibited() { final List deposits = null; when(protocolSpec.getDepositsValidator()) .thenReturn(new DepositsValidator.ProhibitedDeposits()); + BlockHeader mockHeader = setupValidPayload( new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), Optional.empty(), Optional.empty()); + when(blockchain.getBlockHeader(mockHeader.getParentHash())) + .thenReturn(Optional.of(mock(BlockHeader.class))); + when(mergeCoordinator.getLatestValidAncestor(mockHeader)) + .thenReturn(Optional.of(mockHeader.getHash())); - var resp = resp(mockPayload(mockHeader, Collections.emptyList(), null, deposits, null)); + var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList(), null, deposits)); assertValidResponse(mockHeader, resp); } @Test - public void shouldReturnInvalidIfDepositsIsNotNull_WhenDepositsProhibited() { - final List deposits = List.of(); + public void shouldReturnInvalidIfDepositsIsNull_WhenDepositsAllowed() { + final List deposits = null; lenient() .when(protocolSpec.getDepositsValidator()) - .thenReturn(new DepositsValidator.ProhibitedDeposits()); + .thenReturn(new DepositsValidator.AllowedDeposits(depositContractAddress)); var resp = resp( - mockPayload( - createBlockHeader(Optional.of(Collections.emptyList()), Optional.empty()), + mockEnginePayload( + createBlockHeader(Optional.empty(), Optional.empty()), Collections.emptyList(), null, - deposits, - null)); + deposits)); - final JsonRpcError jsonRpcError = fromErrorResp(resp); - assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode()); + assertThat(fromErrorResp(resp).getCode()).isEqualTo(INVALID_PARAMS.getCode()); verify(engineCallListener, times(1)).executionEngineCalled(); } @Test - public void shouldReturnInvalidIfDepositsIsNull_WhenDepositsAllowed() { - final List deposits = null; + public void shouldReturnValidIfDepositsIsNotNull_WhenDepositsAllowed() { + final List depositsParam = List.of(DEPOSIT_PARAM_1); + final List deposits = List.of(DEPOSIT_PARAM_1.toDeposit()); when(protocolSpec.getDepositsValidator()) - .thenReturn(new DepositsValidator.AllowedDeposits(Address.ZERO)); + .thenReturn(new DepositsValidator.AllowedDeposits(depositContractAddress)); + BlockHeader mockHeader = + setupValidPayload( + new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), + Optional.empty(), + Optional.of(deposits)); + when(blockchain.getBlockHeader(mockHeader.getParentHash())) + .thenReturn(Optional.of(mock(BlockHeader.class))); + when(mergeCoordinator.getLatestValidAncestor(mockHeader)) + .thenReturn(Optional.of(mockHeader.getHash())); + var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList(), null, depositsParam)); + + assertValidResponse(mockHeader, resp); + } + + @Test + public void shouldReturnInvalidIfDepositsIsNotNull_WhenDepositsProhibited() { + final List deposits = List.of(); + lenient() + .when(protocolSpec.getDepositsValidator()) + .thenReturn(new DepositsValidator.ProhibitedDeposits()); var resp = resp( - mockPayload( - createBlockHeader(Optional.empty(), Optional.empty()), + mockEnginePayload( + createBlockHeader(Optional.empty(), Optional.of(Collections.emptyList())), Collections.emptyList(), null, deposits)); - assertThat(fromErrorResp(resp).getCode()).isEqualTo(INVALID_PARAMS.getCode()); + final JsonRpcError jsonRpcError = fromErrorResp(resp); + assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode()); verify(engineCallListener, times(1)).executionEngineCalled(); } @@ -158,9 +167,9 @@ protected BlockHeader createBlockHeader( BlockHeader parentBlockHeader = new BlockHeaderTestFixture() .baseFeePerGas(Wei.ONE) - .timestamp(super.EXPERIMENTAL_TIMESTAMP) - .excessDataGas(DataGas.ZERO) - .dataGasUsed(100L) + .timestamp(super.experimentalHardfork.milestone()) + .excessBlobGas(BlobGas.ZERO) + .blobGasUsed(100L) .buildHeader(); BlockHeader mockHeader = @@ -170,9 +179,11 @@ protected BlockHeader createBlockHeader( .number(parentBlockHeader.getNumber() + 1) .timestamp(parentBlockHeader.getTimestamp() + 1) .withdrawalsRoot(maybeWithdrawals.map(BodyValidation::withdrawalsRoot).orElse(null)) - .excessDataGas(DataGas.ZERO) - .dataGasUsed(100L) + .excessBlobGas(BlobGas.ZERO) + .blobGasUsed(100L) .depositsRoot(maybeDeposits.map(BodyValidation::depositsRoot).orElse(null)) + .parentBeaconBlockRoot( + maybeParentBeaconBlockRoot.isPresent() ? maybeParentBeaconBlockRoot : null) .buildHeader(); return mockHeader; } diff --git a/plugin-api/build.gradle b/plugin-api/build.gradle index 4e8c697e158..76581e39658 100644 --- a/plugin-api/build.gradle +++ b/plugin-api/build.gradle @@ -69,7 +69,7 @@ Calculated : ${currentHash} tasks.register('checkAPIChanges', FileStateChecker) { description = "Checks that the API for the Plugin-API project does not change without deliberate thought" files = sourceSets.main.allJava.files - knownHash = 'W/4RHhLwUOWYDqwT3oZVKdRAnu/CEFCtqNDOT9cdPNk=' + knownHash = 'Hf8KV7jOyZN2yihVax0QOFUROQm6MO3X1kMp0QWbrzU=' } check.dependsOn('checkAPIChanges') From 522f9de4b6417f8707eca36a286bbdf40f1b200c Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Thu, 7 Sep 2023 20:59:33 +0800 Subject: [PATCH 21/36] Update 6110 code from 4844 Signed-off-by: Navie Chan --- .../ExecutionEngineEip6110AcceptanceTest.java | 1 - .../methods/engine/EngineNewPayloadV6110.java | 28 ++++++++++--------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineEip6110AcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineEip6110AcceptanceTest.java index 3dc773f83e0..d1771ac5990 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineEip6110AcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineEip6110AcceptanceTest.java @@ -24,7 +24,6 @@ import org.junit.runners.Parameterized; @RunWith(Parameterized.class) -// @Ignore("EIP-6110 is not yet implemented") public class ExecutionEngineEip6110AcceptanceTest extends AbstractJsonRpcTest { private static final String GENESIS_FILE = "/jsonrpc/engine/eip6110/genesis.json"; private static final String TEST_CASE_PATH = "/jsonrpc/engine/eip6110/test-cases/"; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java index fdc3d643f06..e9b4ca0266c 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java @@ -17,17 +17,19 @@ import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; import org.hyperledger.besu.ethereum.eth.manager.EthPeers; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; +import org.hyperledger.besu.ethereum.mainnet.ScheduledProtocolSpec; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; +import java.util.Optional; + import io.vertx.core.Vertx; public class EngineNewPayloadV6110 extends EngineNewPayloadV3 { - private final ProtocolSchedule timestampSchedule; + private final Optional eip6110; public EngineNewPayloadV6110( final Vertx vertx, @@ -38,7 +40,8 @@ public EngineNewPayloadV6110( final EngineCallListener engineCallListener) { super( vertx, timestampSchedule, protocolContext, mergeCoordinator, ethPeers, engineCallListener); - this.timestampSchedule = timestampSchedule; + this.eip6110 = + timestampSchedule.hardforkFor(s -> s.fork().name().equalsIgnoreCase("ExperimentalEips")); } @Override @@ -47,19 +50,18 @@ public String getName() { } @Override - protected ValidationResult validateForkSupported( - final Object reqId, final EnginePayloadParameter payloadParameter) { - var eip6110 = - timestampSchedule.hardforkFor(s -> s.fork().name().equalsIgnoreCase("ExperimentalEips")); - - if (eip6110.isPresent() && payloadParameter.getTimestamp() >= eip6110.get().milestone()) { - if (payloadParameter.getDeposits() == null) { - return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing deposit receipts"); - } else { + protected ValidationResult validateForkSupported(final long blockTimestamp) { + if (protocolSchedule.isPresent()) { + if (eip6110.isPresent() && blockTimestamp >= eip6110.get().milestone()) { return ValidationResult.valid(); + } else { + return ValidationResult.invalid( + RpcErrorType.UNSUPPORTED_FORK, + "EIP-6110 configured to start at timestamp: " + eip6110.get().milestone()); } } else { - return ValidationResult.invalid(RpcErrorType.UNSUPPORTED_FORK, "Fork not supported"); + return ValidationResult.invalid( + RpcErrorType.UNSUPPORTED_FORK, "Configuration error, no schedule for EIP-6110 fork set"); } } } From b40809bb9f22824decdbcab484d1c7170ba03264 Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Thu, 7 Sep 2023 21:42:39 +0800 Subject: [PATCH 22/36] Update hash Signed-off-by: naviechan --- plugin-api/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin-api/build.gradle b/plugin-api/build.gradle index 76581e39658..4e8c697e158 100644 --- a/plugin-api/build.gradle +++ b/plugin-api/build.gradle @@ -69,7 +69,7 @@ Calculated : ${currentHash} tasks.register('checkAPIChanges', FileStateChecker) { description = "Checks that the API for the Plugin-API project does not change without deliberate thought" files = sourceSets.main.allJava.files - knownHash = 'Hf8KV7jOyZN2yihVax0QOFUROQm6MO3X1kMp0QWbrzU=' + knownHash = 'W/4RHhLwUOWYDqwT3oZVKdRAnu/CEFCtqNDOT9cdPNk=' } check.dependsOn('checkAPIChanges') From 7ecfbcd23ee6addda88905ff038636ca13e4b1ce Mon Sep 17 00:00:00 2001 From: naviechan Date: Fri, 22 Sep 2023 14:18:46 +0800 Subject: [PATCH 23/36] Remove acceptance test due to active development of cancun Signed-off-by: naviechan --- .../ExecutionEngineEip6110AcceptanceTest.java | 51 ------------------- 1 file changed, 51 deletions(-) delete mode 100644 acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineEip6110AcceptanceTest.java diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineEip6110AcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineEip6110AcceptanceTest.java deleted file mode 100644 index d1771ac5990..00000000000 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineEip6110AcceptanceTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.tests.acceptance.jsonrpc; - -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -@RunWith(Parameterized.class) -public class ExecutionEngineEip6110AcceptanceTest extends AbstractJsonRpcTest { - private static final String GENESIS_FILE = "/jsonrpc/engine/eip6110/genesis.json"; - private static final String TEST_CASE_PATH = "/jsonrpc/engine/eip6110/test-cases/"; - - private static JsonRpcTestsContext testsContext; - - public ExecutionEngineEip6110AcceptanceTest(final String ignored, final URI testCaseFileURI) { - super(ignored, testsContext, testCaseFileURI); - } - - @BeforeClass - public static void init() throws IOException { - testsContext = new JsonRpcTestsContext(GENESIS_FILE); - } - - @Parameterized.Parameters(name = "{0}") - public static Iterable testCases() throws URISyntaxException { - return testCases(TEST_CASE_PATH); - } - - @AfterClass - public static void tearDown() { - testsContext.cluster.close(); - } -} From 1f2d83457e516a18f666a1a6324f5d3408b62ae8 Mon Sep 17 00:00:00 2001 From: naviechan Date: Fri, 22 Sep 2023 14:23:24 +0800 Subject: [PATCH 24/36] Fix conflict Signed-off-by: naviechan --- .../api/jsonrpc/internal/results/BlockResultFactory.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResultFactory.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResultFactory.java index 8cd659c9d60..9596151bdfe 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResultFactory.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResultFactory.java @@ -158,7 +158,9 @@ public EngineGetPayloadResultV6110 payloadTransactionCompleteV6110( final BlockWithReceipts blockWithReceipts) { final List txs = blockWithReceipts.getBlock().getBody().getTransactions().stream() - .map(TransactionEncoder::encodeOpaqueBytes) + .map( + transaction -> + TransactionEncoder.encodeOpaqueBytes(transaction, EncodingContext.BLOCK_BODY)) .map(Bytes::toHexString) .collect(Collectors.toList()); From ee45314bfef48866604288b93d64f48349d263e6 Mon Sep 17 00:00:00 2001 From: naviechan Date: Fri, 22 Sep 2023 20:43:14 +0800 Subject: [PATCH 25/36] Revert "Remove acceptance test due to active development of cancun" This reverts commit 7ecfbcd23ee6addda88905ff038636ca13e4b1ce. Signed-off-by: naviechan --- .../ExecutionEngineEip6110AcceptanceTest.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineEip6110AcceptanceTest.java diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineEip6110AcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineEip6110AcceptanceTest.java new file mode 100644 index 00000000000..d1771ac5990 --- /dev/null +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineEip6110AcceptanceTest.java @@ -0,0 +1,51 @@ +/* + * Copyright contributors to Hyperledger Besu. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ +package org.hyperledger.besu.tests.acceptance.jsonrpc; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(Parameterized.class) +public class ExecutionEngineEip6110AcceptanceTest extends AbstractJsonRpcTest { + private static final String GENESIS_FILE = "/jsonrpc/engine/eip6110/genesis.json"; + private static final String TEST_CASE_PATH = "/jsonrpc/engine/eip6110/test-cases/"; + + private static JsonRpcTestsContext testsContext; + + public ExecutionEngineEip6110AcceptanceTest(final String ignored, final URI testCaseFileURI) { + super(ignored, testsContext, testCaseFileURI); + } + + @BeforeClass + public static void init() throws IOException { + testsContext = new JsonRpcTestsContext(GENESIS_FILE); + } + + @Parameterized.Parameters(name = "{0}") + public static Iterable testCases() throws URISyntaxException { + return testCases(TEST_CASE_PATH); + } + + @AfterClass + public static void tearDown() { + testsContext.cluster.close(); + } +} From 091353a032f5631d15527cfc2999781a6ab90374 Mon Sep 17 00:00:00 2001 From: naviechan Date: Fri, 22 Sep 2023 21:27:03 +0800 Subject: [PATCH 26/36] Update 6110 acceptance test Signed-off-by: naviechan --- .../test-cases/01_cancun_prepare_payload.json | 11 ++++++----- .../test-cases/02_cancun_getPayloadV3.json | 16 +++++++++------- .../test-cases/03_cancun_newPayloadV3.json | 15 ++++++++------- .../04_cancun_forkchoiceUpdatedV2.json | 8 ++++---- .../05_eip6110_forkchoiceUpdatedV2.json | 11 ++++++----- .../test-cases/06_eip6110_getPayloadV6110.json | 16 +++++++++------- ...0_invalid_null_deposits_execute_payload.json | 17 ++++++++++------- .../test-cases/09_eip6110_newPayloadV6110.json | 16 +++++++++------- .../10_eip6110_forkchoiceUpdatedV2.json | 11 ++++++----- .../test-cases/11_eip6110_getPayloadV6110.json | 16 +++++++++------- .../results/EngineGetPayloadResultV6110.java | 2 +- 11 files changed, 77 insertions(+), 62 deletions(-) diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/01_cancun_prepare_payload.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/01_cancun_prepare_payload.json index 72790bf9ed7..afd5f908715 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/01_cancun_prepare_payload.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/01_cancun_prepare_payload.json @@ -4,15 +4,16 @@ "method": "engine_forkchoiceUpdatedV2", "params": [ { - "headBlockHash": "0x28ffbc2f90499c058a5c87efc87bf33e420a46ac183d1e7d32a022025e73d72c", - "safeBlockHash": "0x28ffbc2f90499c058a5c87efc87bf33e420a46ac183d1e7d32a022025e73d72c", + "headBlockHash": "0x26118cf71453320edcebbc4ebb34af5b578087a32385b80108bf691fa23efc42", + "safeBlockHash": "0x26118cf71453320edcebbc4ebb34af5b578087a32385b80108bf691fa23efc42", "finalizedBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "timestamp": "0x10", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "suggestedFeeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "withdrawals": [] + "withdrawals": [], + "parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000" } ], "id": 67 @@ -23,10 +24,10 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0x28ffbc2f90499c058a5c87efc87bf33e420a46ac183d1e7d32a022025e73d72c", + "latestValidHash": "0x26118cf71453320edcebbc4ebb34af5b578087a32385b80108bf691fa23efc42", "validationError": null }, - "payloadId": "0x0065bd17c7d19011" + "payloadId": "0x282643c14de2dfef" } }, "statusCode" : 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/02_cancun_getPayloadV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/02_cancun_getPayloadV3.json index 817e64c7411..51f4488c797 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/02_cancun_getPayloadV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/02_cancun_getPayloadV3.json @@ -3,7 +3,7 @@ "jsonrpc": "2.0", "method": "engine_getPayloadV3", "params": [ - "0x0065bd17c7d19011" + "0x282643c14de2dfef" ], "id": 67 }, @@ -12,9 +12,9 @@ "id": 67, "result": { "executionPayload": { - "parentHash": "0x28ffbc2f90499c058a5c87efc87bf33e420a46ac183d1e7d32a022025e73d72c", + "parentHash": "0x26118cf71453320edcebbc4ebb34af5b578087a32385b80108bf691fa23efc42", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x9b8c4a9a86cb49252075c0db2f0e72fb1e49350a0f70ea36f26f700201961e62", + "stateRoot": "0xb36663735d6f69f1122ee2172054a3e38f66e3c7e7812299758ec4300468a520", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -22,20 +22,22 @@ "timestamp": "0x10", "extraData": "0x", "baseFeePerGas": "0x7", - "excessDataGas" : "0x0", + "excessBlobGas" : "0x0", + "parentBeaconBlockRoot" : "0x0000000000000000000000000000000000000000000000000000000000000000", "transactions": [], "withdrawals": [], "blockNumber": "0x1", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "blockHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", - "dataGasUsed" : "0x0" + "blockHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", + "blobGasUsed" : "0x0" }, "blockValue": "0x0", "blobsBundle" : { "commitments" : [], "proofs" : [], "blobs" : [] - } + }, + "shouldOverrideBuilder" : false } }, "statusCode": 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/03_cancun_newPayloadV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/03_cancun_newPayloadV3.json index 203f05c6a57..6acd396a08f 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/03_cancun_newPayloadV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/03_cancun_newPayloadV3.json @@ -4,9 +4,9 @@ "method": "engine_newPayloadV3", "params": [ { - "parentHash": "0x28ffbc2f90499c058a5c87efc87bf33e420a46ac183d1e7d32a022025e73d72c", + "parentHash": "0x26118cf71453320edcebbc4ebb34af5b578087a32385b80108bf691fa23efc42", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x9b8c4a9a86cb49252075c0db2f0e72fb1e49350a0f70ea36f26f700201961e62", + "stateRoot": "0xb36663735d6f69f1122ee2172054a3e38f66e3c7e7812299758ec4300468a520", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -17,12 +17,13 @@ "transactions": [], "withdrawals": [], "blockNumber": "0x1", - "blockHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", + "blockHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "excessDataGas" : "0x0", - "dataGasUsed" : "0x0" + "excessBlobGas" : "0x0", + "blobGasUsed" : "0x0" }, - [] + [], + "0x0000000000000000000000000000000000000000000000000000000000000000" ], "id": 67 }, @@ -31,7 +32,7 @@ "id": 67, "result": { "status": "VALID", - "latestValidHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", + "latestValidHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", "validationError": null } }, diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV2.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV2.json index 48f663732a4..cb09a220893 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV2.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV2.json @@ -4,9 +4,9 @@ "method": "engine_forkchoiceUpdatedV2", "params": [ { - "headBlockHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", - "safeBlockHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", - "finalizedBlockHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b" + "headBlockHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", + "safeBlockHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", + "finalizedBlockHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673" }, null ], @@ -18,7 +18,7 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", + "latestValidHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", "validationError": null }, "payloadId": null diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_forkchoiceUpdatedV2.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_forkchoiceUpdatedV2.json index 07b46847d43..7244bb292fb 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_forkchoiceUpdatedV2.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_forkchoiceUpdatedV2.json @@ -4,15 +4,16 @@ "method": "engine_forkchoiceUpdatedV2", "params": [ { - "headBlockHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", - "safeBlockHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", + "headBlockHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", + "safeBlockHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", "finalizedBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "timestamp": "0x20", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "suggestedFeeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "withdrawals": [] + "withdrawals": [], + "parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000" } ], "id": 67 @@ -23,10 +24,10 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", + "latestValidHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", "validationError": null }, - "payloadId": "0x0065bd13a5f68adf" + "payloadId": "0x282643c1a76ef021" } }, "statusCode" : 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/06_eip6110_getPayloadV6110.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/06_eip6110_getPayloadV6110.json index 5cf99fbcadd..556ade6a922 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/06_eip6110_getPayloadV6110.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/06_eip6110_getPayloadV6110.json @@ -3,7 +3,7 @@ "jsonrpc": "2.0", "method": "engine_getPayloadV6110", "params": [ - "0x0065bd13a5f68adf" + "0x282643c1a76ef021" ], "id": 67 }, @@ -12,9 +12,9 @@ "id": 67, "result": { "executionPayload": { - "parentHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", + "parentHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x9b8c4a9a86cb49252075c0db2f0e72fb1e49350a0f70ea36f26f700201961e62", + "stateRoot": "0xf9a161f9c492e21bb58308b06a9135106aa366ffd780854cac6166fe896f7006", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -22,21 +22,23 @@ "timestamp": "0x20", "extraData": "0x", "baseFeePerGas": "0x7", - "excessDataGas" : "0x0", + "excessBlobGas" : "0x0", + "parentBeaconBlockRoot" : "0x0000000000000000000000000000000000000000000000000000000000000000", "transactions": [], "withdrawals": [], "depositReceipts" : [], "blockNumber": "0x2", - "blockHash": "0xdc9071c29433b9fa11729e745edf225ed470207e1b9e520505cf9f42de8ccb65", + "blockHash": "0xea5ba94ce019a6bd3315857e855cdab6a7a9bd80e8c1f47a472135e5c07a40e5", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "dataGasUsed" : "0x0" + "blobGasUsed" : "0x0" }, "blockValue": "0x0", "blobsBundle" : { "commitments" : [], "proofs" : [], "blobs" : [] - } + }, + "shouldOverrideBuilder" : false } }, "statusCode": 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_invalid_null_deposits_execute_payload.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_invalid_null_deposits_execute_payload.json index 578407fc90d..1136764eac2 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_invalid_null_deposits_execute_payload.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_invalid_null_deposits_execute_payload.json @@ -4,9 +4,9 @@ "method": "engine_newPayloadV6110", "params": [ { - "parentHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", + "parentHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x9b8c4a9a86cb49252075c0db2f0e72fb1e49350a0f70ea36f26f700201961e62", + "stateRoot": "0xf9a161f9c492e21bb58308b06a9135106aa366ffd780854cac6166fe896f7006", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -14,15 +14,17 @@ "timestamp": "0x20", "extraData": "0x", "baseFeePerGas": "0x7", - "excessDataGas" : "0x0", + "excessBlobGas" : "0x0", "transactions": [], "withdrawals": [], "depositReceipts" : null, "blockNumber": "0x2", - "blockHash": "0xdc9071c29433b9fa11729e745edf225ed470207e1b9e520505cf9f42de8ccb65", + "blockHash": "0xea5ba94ce019a6bd3315857e855cdab6a7a9bd80e8c1f47a472135e5c07a40e5", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "dataGasUsed" : "0x0" - } + "blobGasUsed" : "0x0" + }, + [], + "0x0000000000000000000000000000000000000000000000000000000000000000" ], "id": 67 }, @@ -31,7 +33,8 @@ "id": 67, "error": { "code": -32602, - "message": "Invalid params" + "message": "Invalid params", + "data" : "Invalid deposits" } }, "statusCode": 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/09_eip6110_newPayloadV6110.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/09_eip6110_newPayloadV6110.json index 2d642395c3f..6b868bde2a3 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/09_eip6110_newPayloadV6110.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/09_eip6110_newPayloadV6110.json @@ -4,9 +4,9 @@ "method": "engine_newPayloadV6110", "params": [ { - "parentHash": "0xd7b9bdb295332fab111b36605fc59b57146e3fd22d970a6e147c193c74e0bc1b", + "parentHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x14208ac0e218167936e220b72d5d5887a963cb858ea2f2d268518f014a3da3fa", + "stateRoot": "0xa78bb828a9a90729de2d236a057a415fc635ef98e3209a634285713b34d278e8", "logsBloom": "0x10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -14,7 +14,7 @@ "timestamp": "0x20", "extraData": "0x", "baseFeePerGas": "0x7", - "excessDataGas" : "0x0", + "excessBlobGas" : "0x0", "transactions": [ "0x02f9021c8217de808459682f008459682f0e830271009442424242424242424242424242424242424242428901bc16d674ec800000b901a422895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120749715de5d1226545c6b3790f515d551a5cc5bf1d49c87a696860554d2fc4f14000000000000000000000000000000000000000000000000000000000000003096a96086cff07df17668f35f7418ef8798079167e3f4f9b72ecde17b28226137cf454ab1dd20ef5d924786ab3483c2f9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020003f5102dabe0a27b1746098d1dc17a5d3fbd478759fea9287e4e419b3c3cef20000000000000000000000000000000000000000000000000000000000000060b1acdb2c4d3df3f1b8d3bfd33421660df358d84d78d16c4603551935f4b67643373e7eb63dcb16ec359be0ec41fee33b03a16e80745f2374ff1d3c352508ac5d857c6476d3c3bcf7e6ca37427c9209f17be3af5264c0e2132b3dd1156c28b4e9c080a09f597089338d7f44f5c59f8230bb38f243849228a8d4e9d2e2956e6050f5b2c7a076486996c7e62802b8f95eee114783e4b403fd11093ba96286ff42c595f24452" ], @@ -23,10 +23,12 @@ {"amount":"0x773594000","index":"0x0","pubkey":"0x96a96086cff07df17668f35f7418ef8798079167e3f4f9b72ecde17b28226137cf454ab1dd20ef5d924786ab3483c2f9","signature":"0xb1acdb2c4d3df3f1b8d3bfd33421660df358d84d78d16c4603551935f4b67643373e7eb63dcb16ec359be0ec41fee33b03a16e80745f2374ff1d3c352508ac5d857c6476d3c3bcf7e6ca37427c9209f17be3af5264c0e2132b3dd1156c28b4e9","withdrawalCredentials":"0x003f5102dabe0a27b1746098d1dc17a5d3fbd478759fea9287e4e419b3c3cef2"} ], "blockNumber": "0x2", - "blockHash": "0xfca60892dd40a173234db1cc6187ae65c285f5880238d9816efa2721e403388d", + "blockHash": "0xd1ba8d4c47dd83ea145f39e27ef680ee3db132af6f71727e291bfd34dda66ce4", "receiptsRoot": "0x79ee3424eb720a3ad4b1c5a372bb8160580cbe4d893778660f34213c685627a9", - "dataGasUsed" : "0x0" - } + "blobGasUsed" : "0x0" + }, + [], + "0x0000000000000000000000000000000000000000000000000000000000000000" ], "id": 67 }, @@ -35,7 +37,7 @@ "id": 67, "result": { "status": "VALID", - "latestValidHash": "0xfca60892dd40a173234db1cc6187ae65c285f5880238d9816efa2721e403388d", + "latestValidHash": "0xd1ba8d4c47dd83ea145f39e27ef680ee3db132af6f71727e291bfd34dda66ce4", "validationError": null } }, diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/10_eip6110_forkchoiceUpdatedV2.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/10_eip6110_forkchoiceUpdatedV2.json index 2b52e72ae24..7672635f31d 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/10_eip6110_forkchoiceUpdatedV2.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/10_eip6110_forkchoiceUpdatedV2.json @@ -4,15 +4,16 @@ "method": "engine_forkchoiceUpdatedV2", "params": [ { - "headBlockHash": "0xfca60892dd40a173234db1cc6187ae65c285f5880238d9816efa2721e403388d", - "safeBlockHash": "0xfca60892dd40a173234db1cc6187ae65c285f5880238d9816efa2721e403388d", + "headBlockHash": "0xd1ba8d4c47dd83ea145f39e27ef680ee3db132af6f71727e291bfd34dda66ce4", + "safeBlockHash": "0xd1ba8d4c47dd83ea145f39e27ef680ee3db132af6f71727e291bfd34dda66ce4", "finalizedBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "timestamp": "0x30", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "suggestedFeeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "withdrawals": [] + "withdrawals": [], + "parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000" } ], "id": 67 @@ -23,10 +24,10 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0xfca60892dd40a173234db1cc6187ae65c285f5880238d9816efa2721e403388d", + "latestValidHash": "0xd1ba8d4c47dd83ea145f39e27ef680ee3db132af6f71727e291bfd34dda66ce4", "validationError": null }, - "payloadId": "0x0065bd45f0044131" + "payloadId": "0x282643cf8bd0e531" } }, "statusCode" : 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/11_eip6110_getPayloadV6110.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/11_eip6110_getPayloadV6110.json index 197fac440d0..51acf67661e 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/11_eip6110_getPayloadV6110.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/11_eip6110_getPayloadV6110.json @@ -3,7 +3,7 @@ "jsonrpc": "2.0", "method": "engine_getPayloadV6110", "params": [ - "0x0065bd45f0044131" + "0x282643cf8bd0e531" ], "id": 67 }, @@ -12,9 +12,9 @@ "id": 67, "result": { "executionPayload": { - "parentHash": "0xfca60892dd40a173234db1cc6187ae65c285f5880238d9816efa2721e403388d", + "parentHash": "0xd1ba8d4c47dd83ea145f39e27ef680ee3db132af6f71727e291bfd34dda66ce4", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x14208ac0e218167936e220b72d5d5887a963cb858ea2f2d268518f014a3da3fa", + "stateRoot": "0xae366f0fe1bd4beb05788e0f97f3317507d900d865a508fdaa3511f85137478a", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -22,21 +22,23 @@ "timestamp": "0x30", "extraData": "0x", "baseFeePerGas": "0x7", - "excessDataGas" : "0x0", + "excessBlobGas" : "0x0", + "parentBeaconBlockRoot" : "0x0000000000000000000000000000000000000000000000000000000000000000", "transactions": [], "withdrawals": [], "depositReceipts" : [], "blockNumber": "0x3", - "blockHash": "0x77930ea7e70be6cedd338f2996a281f03078029d4c9ebb6786b3f981aa4a7ca5", + "blockHash": "0xb503a338de7f63271a398f215cc00d8037efdb6bbe74667a4b42648e2ffb72e6", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "dataGasUsed" : "0x0" + "blobGasUsed" : "0x0" }, "blockValue": "0x0", "blobsBundle" : { "commitments" : [], "proofs" : [], "blobs" : [] - } + }, + "shouldOverrideBuilder" : false } }, "statusCode": 200 diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV6110.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV6110.java index 25e1f9c121e..4b47101fb64 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV6110.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV6110.java @@ -201,7 +201,7 @@ public List getWithdrawals() { return withdrawals; } - @JsonGetter(value = "deposits") + @JsonGetter(value = "depositReceipts") public List getDeposits() { return deposits; } From 6da453990e123b690e833720cd8aadb947135c45 Mon Sep 17 00:00:00 2001 From: naviechan Date: Fri, 22 Sep 2023 21:32:26 +0800 Subject: [PATCH 27/36] Filter out V6110 endpoints in EngineExchangeCapabilities Signed-off-by: naviechan --- .../internal/methods/engine/EngineExchangeCapabilities.java | 1 + 1 file changed, 1 insertion(+) diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeCapabilities.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeCapabilities.java index f59681a3854..fcc26cad641 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeCapabilities.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeCapabilities.java @@ -63,6 +63,7 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext) .filter(e -> e.getMethodName().startsWith("engine_")) .filter(e -> !e.equals(ENGINE_EXCHANGE_CAPABILITIES)) .filter(e -> !e.equals(ENGINE_PREPARE_PAYLOAD_DEBUG)) + .filter(e -> !e.getMethodName().endsWith("6110")) .map(RpcMethod::getMethodName) .collect(Collectors.toList()); From 87fc6bac2c4cdf3a05e3705d00d15d5daf99556c Mon Sep 17 00:00:00 2001 From: naviechan Date: Fri, 22 Sep 2023 22:44:31 +0800 Subject: [PATCH 28/36] Fix typo Signed-off-by: naviechan --- .../internal/methods/engine/AbstractScheduledApiTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractScheduledApiTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractScheduledApiTest.java index 84704e3f2a1..6d71932ff96 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractScheduledApiTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractScheduledApiTest.java @@ -40,7 +40,7 @@ public class AbstractScheduledApiTest { protected final ScheduledProtocolSpec.Hardfork cancunHardfork = new ScheduledProtocolSpec.Hardfork("Cancun", 30); protected final ScheduledProtocolSpec.Hardfork experimentalHardfork = - new ScheduledProtocolSpec.Hardfork("Experimental", 40); + new ScheduledProtocolSpec.Hardfork("ExperimentalEips", 40); @Mock protected DefaultProtocolSchedule protocolSchedule; From 195e093ac8915a4dc1c15e691ad136bf90e6aeb2 Mon Sep 17 00:00:00 2001 From: naviechan Date: Fri, 22 Sep 2023 22:44:36 +0800 Subject: [PATCH 29/36] Update Tests Signed-off-by: naviechan --- .../internal/methods/engine/EngineGetPayloadV6110Test.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java index a024ddda921..90bb22fff84 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java @@ -62,12 +62,13 @@ public class EngineGetPayloadV6110Test extends AbstractEngineGetPayloadTest { public EngineGetPayloadV6110Test() { - super(EngineGetPayloadV6110::new); + super(); } @BeforeEach @Override public void before() { + super.before(); lenient() .when(mergeContext.retrieveBlockById(mockPid)) .thenReturn(Optional.of(mockBlockWithReceiptsAndDeposits)); @@ -131,7 +132,7 @@ public void shouldReturnBlockForKnownPayloadId() { List.of(blobTx), Collections.emptyList(), Optional.of(Collections.emptyList()), - Optional.empty())), + Optional.of(Collections.emptyList()))), List.of(blobReceipt)); when(mergeContext.retrieveBlockById(postEip6110Pid)).thenReturn(Optional.of(postEip6110Block)); @@ -169,6 +170,8 @@ public void shouldReturnUnsupportedFork() { .isEqualTo(RpcErrorType.UNSUPPORTED_FORK); } + + @Override protected String getMethodName() { return RpcMethod.ENGINE_GET_PAYLOAD_V6110.getMethodName(); From 1f9c22e389ed1d750d844526dbfa46a3da19a356 Mon Sep 17 00:00:00 2001 From: naviechan Date: Fri, 22 Sep 2023 22:52:11 +0800 Subject: [PATCH 30/36] SpotlessApply Signed-off-by: naviechan --- .../internal/methods/engine/EngineGetPayloadV6110Test.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java index 90bb22fff84..879f11e724c 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110Test.java @@ -68,7 +68,7 @@ public EngineGetPayloadV6110Test() { @BeforeEach @Override public void before() { - super.before(); + super.before(); lenient() .when(mergeContext.retrieveBlockById(mockPid)) .thenReturn(Optional.of(mockBlockWithReceiptsAndDeposits)); @@ -170,8 +170,6 @@ public void shouldReturnUnsupportedFork() { .isEqualTo(RpcErrorType.UNSUPPORTED_FORK); } - - @Override protected String getMethodName() { return RpcMethod.ENGINE_GET_PAYLOAD_V6110.getMethodName(); From 4b01973f904d2deaf4d291b88c0b0a8f04ab4979 Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Sat, 7 Oct 2023 19:00:28 +0800 Subject: [PATCH 31/36] Address comment Signed-off-by: Navie Chan --- .../methods/engine/EngineNewPayloadV6110.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java index e9b4ca0266c..fa32d79f215 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java @@ -17,17 +17,19 @@ import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; import org.hyperledger.besu.ethereum.eth.manager.EthPeers; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ScheduledProtocolSpec; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; +import java.util.List; import java.util.Optional; import io.vertx.core.Vertx; -public class EngineNewPayloadV6110 extends EngineNewPayloadV3 { +public class EngineNewPayloadV6110 extends AbstractEngineNewPayload { private final Optional eip6110; @@ -49,6 +51,27 @@ public String getName() { return RpcMethod.ENGINE_NEW_PAYLOAD_V6110.getMethodName(); } + @Override + protected ValidationResult validateParameters( + final EnginePayloadParameter payloadParameter, + final Optional> maybeVersionedHashParam, + final Optional maybeBeaconBlockRootParam) { + if (payloadParameter.getBlobGasUsed() == null || payloadParameter.getExcessBlobGas() == null) { + return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing blob gas fields"); + } else if (maybeVersionedHashParam == null) { + return ValidationResult.invalid( + RpcErrorType.INVALID_PARAMS, "Missing versioned hashes field"); + } else if (maybeBeaconBlockRootParam.isEmpty()) { + return ValidationResult.invalid( + RpcErrorType.INVALID_PARAMS, "Missing parent beacon block root field"); + } else if (payloadParameter.getDeposits() == null) { + return ValidationResult.invalid( + RpcErrorType.INVALID_PARAMS, "Missing deposit field"); + } else { + return ValidationResult.valid(); + } + } + @Override protected ValidationResult validateForkSupported(final long blockTimestamp) { if (protocolSchedule.isPresent()) { From 9a6372896f1c7eaa8ae5a691060bfcfd05a60ec6 Mon Sep 17 00:00:00 2001 From: Navie Chan Date: Sat, 7 Oct 2023 19:11:27 +0800 Subject: [PATCH 32/36] Fix conflict Signed-off-by: Navie Chan --- .../methods/engine/EngineGetPayloadV6110.java | 17 +++++++++++++++++ .../methods/engine/EngineNewPayloadV6110.java | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java index c3be61fefd6..945e9ae85f7 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java @@ -31,6 +31,7 @@ import java.util.Optional; import io.vertx.core.Vertx; +import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -90,4 +91,20 @@ protected JsonRpcResponse createResponse( return new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INTERNAL_ERROR); } } + + @Override + protected ValidationResult validateForkSupported(final long blockTimestamp) { + if (protocolSchedule.isPresent()) { + if (eip6110.isPresent() && blockTimestamp >= eip6110.get().milestone()) { + return ValidationResult.valid(); + } else { + return ValidationResult.invalid( + RpcErrorType.UNSUPPORTED_FORK, + "EIP-6110 configured to start at timestamp: " + eip6110.get().milestone()); + } + } else { + return ValidationResult.invalid( + RpcErrorType.UNSUPPORTED_FORK, "Configuration error, no schedule for EIP-6110 fork set"); + } + } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java index fa32d79f215..b12df50c576 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java @@ -58,7 +58,7 @@ protected ValidationResult validateParameters( final Optional maybeBeaconBlockRootParam) { if (payloadParameter.getBlobGasUsed() == null || payloadParameter.getExcessBlobGas() == null) { return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing blob gas fields"); - } else if (maybeVersionedHashParam == null) { + } else if (maybeVersionedHashParam == null || maybeVersionedHashParam.isEmpty()) { return ValidationResult.invalid( RpcErrorType.INVALID_PARAMS, "Missing versioned hashes field"); } else if (maybeBeaconBlockRootParam.isEmpty()) { From 61794e25b6476f295ce2567796e9e4d2116c27b6 Mon Sep 17 00:00:00 2001 From: naviechan Date: Sun, 8 Oct 2023 18:22:22 +0800 Subject: [PATCH 33/36] Spotless Apply Signed-off-by: naviechan --- .../jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java index b12df50c576..84f203c3a73 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV6110.java @@ -65,8 +65,7 @@ protected ValidationResult validateParameters( return ValidationResult.invalid( RpcErrorType.INVALID_PARAMS, "Missing parent beacon block root field"); } else if (payloadParameter.getDeposits() == null) { - return ValidationResult.invalid( - RpcErrorType.INVALID_PARAMS, "Missing deposit field"); + return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing deposit field"); } else { return ValidationResult.valid(); } From 7d4343e1b831a19b91e74c640c188d9a276f851e Mon Sep 17 00:00:00 2001 From: naviechan Date: Sun, 8 Oct 2023 18:35:22 +0800 Subject: [PATCH 34/36] SpotlessApply Signed-off-by: naviechan --- .../jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java index 945e9ae85f7..86c29d732c4 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java @@ -27,11 +27,11 @@ import org.hyperledger.besu.ethereum.core.BlockWithReceipts; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ScheduledProtocolSpec; +import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import java.util.Optional; import io.vertx.core.Vertx; -import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; From d9f4aac54b27ad9308b0bace1454cb9349f38d71 Mon Sep 17 00:00:00 2001 From: naviechan Date: Mon, 9 Oct 2023 15:50:28 +0800 Subject: [PATCH 35/36] Update acceptance test Signed-off-by: naviechan --- .../test-cases/01_cancun_prepare_payload.json | 2 +- .../test-cases/02_cancun_getPayloadV3.json | 4 +- .../test-cases/03_cancun_newPayloadV3.json | 6 +-- .../04_cancun_forkchoiceUpdatedV2.json | 10 ++--- .../05_eip6110_forkchoiceUpdatedV2.json | 10 ++--- .../06_eip6110_getPayloadV6110.json | 8 ++-- ...invalid_null_deposits_execute_payload.json | 8 ++-- .../09_eip6110_newPayloadV6110.json | 8 ++-- .../10_eip6110_forkchoiceUpdatedV2.json | 10 ++--- .../11_eip6110_getPayloadV6110.json | 8 ++-- .../methods/engine/EngineGetPayloadV6110.java | 43 +++++-------------- 11 files changed, 47 insertions(+), 70 deletions(-) diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/01_cancun_prepare_payload.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/01_cancun_prepare_payload.json index afd5f908715..b398cda18af 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/01_cancun_prepare_payload.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/01_cancun_prepare_payload.json @@ -1,7 +1,7 @@ { "request": { "jsonrpc": "2.0", - "method": "engine_forkchoiceUpdatedV2", + "method": "engine_forkchoiceUpdatedV3", "params": [ { "headBlockHash": "0x26118cf71453320edcebbc4ebb34af5b578087a32385b80108bf691fa23efc42", diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/02_cancun_getPayloadV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/02_cancun_getPayloadV3.json index 51f4488c797..805709fe86f 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/02_cancun_getPayloadV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/02_cancun_getPayloadV3.json @@ -14,7 +14,7 @@ "executionPayload": { "parentHash": "0x26118cf71453320edcebbc4ebb34af5b578087a32385b80108bf691fa23efc42", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0xb36663735d6f69f1122ee2172054a3e38f66e3c7e7812299758ec4300468a520", + "stateRoot": "0x23e3e21a839dbba902efaad82e5c3e1ddd64ea067ce0f979a68dabcc46be4e8b", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -28,7 +28,7 @@ "withdrawals": [], "blockNumber": "0x1", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "blockHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", + "blockHash": "0x17da7aea0f4e4ba1d905dbb7d60f6ab4133f3009ae1a1ba99e6e9cb37c15412c", "blobGasUsed" : "0x0" }, "blockValue": "0x0", diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/03_cancun_newPayloadV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/03_cancun_newPayloadV3.json index 6acd396a08f..ba9f69b47ae 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/03_cancun_newPayloadV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/03_cancun_newPayloadV3.json @@ -6,7 +6,7 @@ { "parentHash": "0x26118cf71453320edcebbc4ebb34af5b578087a32385b80108bf691fa23efc42", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0xb36663735d6f69f1122ee2172054a3e38f66e3c7e7812299758ec4300468a520", + "stateRoot": "0x23e3e21a839dbba902efaad82e5c3e1ddd64ea067ce0f979a68dabcc46be4e8b", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -17,7 +17,7 @@ "transactions": [], "withdrawals": [], "blockNumber": "0x1", - "blockHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", + "blockHash": "0x17da7aea0f4e4ba1d905dbb7d60f6ab4133f3009ae1a1ba99e6e9cb37c15412c", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "excessBlobGas" : "0x0", "blobGasUsed" : "0x0" @@ -32,7 +32,7 @@ "id": 67, "result": { "status": "VALID", - "latestValidHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", + "latestValidHash": "0x17da7aea0f4e4ba1d905dbb7d60f6ab4133f3009ae1a1ba99e6e9cb37c15412c", "validationError": null } }, diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV2.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV2.json index cb09a220893..49e803ecc03 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV2.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV2.json @@ -1,12 +1,12 @@ { "request": { "jsonrpc": "2.0", - "method": "engine_forkchoiceUpdatedV2", + "method": "engine_forkchoiceUpdatedV3", "params": [ { - "headBlockHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", - "safeBlockHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", - "finalizedBlockHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673" + "headBlockHash": "0x17da7aea0f4e4ba1d905dbb7d60f6ab4133f3009ae1a1ba99e6e9cb37c15412c", + "safeBlockHash": "0x17da7aea0f4e4ba1d905dbb7d60f6ab4133f3009ae1a1ba99e6e9cb37c15412c", + "finalizedBlockHash": "0x17da7aea0f4e4ba1d905dbb7d60f6ab4133f3009ae1a1ba99e6e9cb37c15412c" }, null ], @@ -18,7 +18,7 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", + "latestValidHash": "0x17da7aea0f4e4ba1d905dbb7d60f6ab4133f3009ae1a1ba99e6e9cb37c15412c", "validationError": null }, "payloadId": null diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_forkchoiceUpdatedV2.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_forkchoiceUpdatedV2.json index 7244bb292fb..e47346cc308 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_forkchoiceUpdatedV2.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_forkchoiceUpdatedV2.json @@ -1,11 +1,11 @@ { "request": { "jsonrpc": "2.0", - "method": "engine_forkchoiceUpdatedV2", + "method": "engine_forkchoiceUpdatedV3", "params": [ { - "headBlockHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", - "safeBlockHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", + "headBlockHash": "0x17da7aea0f4e4ba1d905dbb7d60f6ab4133f3009ae1a1ba99e6e9cb37c15412c", + "safeBlockHash": "0x17da7aea0f4e4ba1d905dbb7d60f6ab4133f3009ae1a1ba99e6e9cb37c15412c", "finalizedBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { @@ -24,10 +24,10 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", + "latestValidHash": "0x17da7aea0f4e4ba1d905dbb7d60f6ab4133f3009ae1a1ba99e6e9cb37c15412c", "validationError": null }, - "payloadId": "0x282643c1a76ef021" + "payloadId": "0x282643962616abdf" } }, "statusCode" : 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/06_eip6110_getPayloadV6110.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/06_eip6110_getPayloadV6110.json index 556ade6a922..eb1bf8a5f80 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/06_eip6110_getPayloadV6110.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/06_eip6110_getPayloadV6110.json @@ -3,7 +3,7 @@ "jsonrpc": "2.0", "method": "engine_getPayloadV6110", "params": [ - "0x282643c1a76ef021" + "0x282643962616abdf" ], "id": 67 }, @@ -12,9 +12,9 @@ "id": 67, "result": { "executionPayload": { - "parentHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", + "parentHash": "0x17da7aea0f4e4ba1d905dbb7d60f6ab4133f3009ae1a1ba99e6e9cb37c15412c", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0xf9a161f9c492e21bb58308b06a9135106aa366ffd780854cac6166fe896f7006", + "stateRoot": "0x6a88816cf7e94f1f44cf82c63521bb7f2e49e99ab0ad2e4e46ef1ab8f6ccad84", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -28,7 +28,7 @@ "withdrawals": [], "depositReceipts" : [], "blockNumber": "0x2", - "blockHash": "0xea5ba94ce019a6bd3315857e855cdab6a7a9bd80e8c1f47a472135e5c07a40e5", + "blockHash": "0x6d4f567f7afe59226a1400fd0c11797f0bb69bec74b8eb99a066f899e0bd1d0f", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "blobGasUsed" : "0x0" }, diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_invalid_null_deposits_execute_payload.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_invalid_null_deposits_execute_payload.json index 1136764eac2..e19897ff471 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_invalid_null_deposits_execute_payload.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/08_eip6110_invalid_null_deposits_execute_payload.json @@ -4,9 +4,9 @@ "method": "engine_newPayloadV6110", "params": [ { - "parentHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", + "parentHash": "0x17da7aea0f4e4ba1d905dbb7d60f6ab4133f3009ae1a1ba99e6e9cb37c15412c", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0xf9a161f9c492e21bb58308b06a9135106aa366ffd780854cac6166fe896f7006", + "stateRoot": "0x6a88816cf7e94f1f44cf82c63521bb7f2e49e99ab0ad2e4e46ef1ab8f6ccad84", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -19,7 +19,7 @@ "withdrawals": [], "depositReceipts" : null, "blockNumber": "0x2", - "blockHash": "0xea5ba94ce019a6bd3315857e855cdab6a7a9bd80e8c1f47a472135e5c07a40e5", + "blockHash": "0x6d4f567f7afe59226a1400fd0c11797f0bb69bec74b8eb99a066f899e0bd1d0f", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "blobGasUsed" : "0x0" }, @@ -34,7 +34,7 @@ "error": { "code": -32602, "message": "Invalid params", - "data" : "Invalid deposits" + "data" : "Missing deposit field" } }, "statusCode": 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/09_eip6110_newPayloadV6110.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/09_eip6110_newPayloadV6110.json index 6b868bde2a3..d0a4c229044 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/09_eip6110_newPayloadV6110.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/09_eip6110_newPayloadV6110.json @@ -4,9 +4,9 @@ "method": "engine_newPayloadV6110", "params": [ { - "parentHash": "0xb9203a1bb9ed08e8160522c78039f4b83c7c932012fc3068db7dc9be537f1673", + "parentHash": "0x17da7aea0f4e4ba1d905dbb7d60f6ab4133f3009ae1a1ba99e6e9cb37c15412c", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0xa78bb828a9a90729de2d236a057a415fc635ef98e3209a634285713b34d278e8", + "stateRoot": "0x7ffa22d9c7d856687bbec0700c17288ee6aff2bfd14e92a8921b08ed1d0c6030", "logsBloom": "0x10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -23,7 +23,7 @@ {"amount":"0x773594000","index":"0x0","pubkey":"0x96a96086cff07df17668f35f7418ef8798079167e3f4f9b72ecde17b28226137cf454ab1dd20ef5d924786ab3483c2f9","signature":"0xb1acdb2c4d3df3f1b8d3bfd33421660df358d84d78d16c4603551935f4b67643373e7eb63dcb16ec359be0ec41fee33b03a16e80745f2374ff1d3c352508ac5d857c6476d3c3bcf7e6ca37427c9209f17be3af5264c0e2132b3dd1156c28b4e9","withdrawalCredentials":"0x003f5102dabe0a27b1746098d1dc17a5d3fbd478759fea9287e4e419b3c3cef2"} ], "blockNumber": "0x2", - "blockHash": "0xd1ba8d4c47dd83ea145f39e27ef680ee3db132af6f71727e291bfd34dda66ce4", + "blockHash": "0xe6763c709abac0b477073c1efd980e12728c1ea22361c03e41db6fbd6a271832", "receiptsRoot": "0x79ee3424eb720a3ad4b1c5a372bb8160580cbe4d893778660f34213c685627a9", "blobGasUsed" : "0x0" }, @@ -37,7 +37,7 @@ "id": 67, "result": { "status": "VALID", - "latestValidHash": "0xd1ba8d4c47dd83ea145f39e27ef680ee3db132af6f71727e291bfd34dda66ce4", + "latestValidHash": "0xe6763c709abac0b477073c1efd980e12728c1ea22361c03e41db6fbd6a271832", "validationError": null } }, diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/10_eip6110_forkchoiceUpdatedV2.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/10_eip6110_forkchoiceUpdatedV2.json index 7672635f31d..9b1c62070bb 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/10_eip6110_forkchoiceUpdatedV2.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/10_eip6110_forkchoiceUpdatedV2.json @@ -1,11 +1,11 @@ { "request": { "jsonrpc": "2.0", - "method": "engine_forkchoiceUpdatedV2", + "method": "engine_forkchoiceUpdatedV3", "params": [ { - "headBlockHash": "0xd1ba8d4c47dd83ea145f39e27ef680ee3db132af6f71727e291bfd34dda66ce4", - "safeBlockHash": "0xd1ba8d4c47dd83ea145f39e27ef680ee3db132af6f71727e291bfd34dda66ce4", + "headBlockHash": "0xe6763c709abac0b477073c1efd980e12728c1ea22361c03e41db6fbd6a271832", + "safeBlockHash": "0xe6763c709abac0b477073c1efd980e12728c1ea22361c03e41db6fbd6a271832", "finalizedBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { @@ -24,10 +24,10 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0xd1ba8d4c47dd83ea145f39e27ef680ee3db132af6f71727e291bfd34dda66ce4", + "latestValidHash": "0xe6763c709abac0b477073c1efd980e12728c1ea22361c03e41db6fbd6a271832", "validationError": null }, - "payloadId": "0x282643cf8bd0e531" + "payloadId": "0x28264382a1f291cf" } }, "statusCode" : 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/11_eip6110_getPayloadV6110.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/11_eip6110_getPayloadV6110.json index 51acf67661e..3aff1f3e40f 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/11_eip6110_getPayloadV6110.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/11_eip6110_getPayloadV6110.json @@ -3,7 +3,7 @@ "jsonrpc": "2.0", "method": "engine_getPayloadV6110", "params": [ - "0x282643cf8bd0e531" + "0x28264382a1f291cf" ], "id": 67 }, @@ -12,9 +12,9 @@ "id": 67, "result": { "executionPayload": { - "parentHash": "0xd1ba8d4c47dd83ea145f39e27ef680ee3db132af6f71727e291bfd34dda66ce4", + "parentHash": "0xe6763c709abac0b477073c1efd980e12728c1ea22361c03e41db6fbd6a271832", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0xae366f0fe1bd4beb05788e0f97f3317507d900d865a508fdaa3511f85137478a", + "stateRoot": "0x2d60598bb65d4a9451c097884d1fb07e015c242e2a3475f4ef902ed23e319d3b", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -28,7 +28,7 @@ "withdrawals": [], "depositReceipts" : [], "blockNumber": "0x3", - "blockHash": "0xb503a338de7f63271a398f215cc00d8037efdb6bbe74667a4b42648e2ffb72e6", + "blockHash": "0xa489adae4826ac6a342c382243e8841d3e3b33168e7fd6e31b2c36c17a25f702", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "blobGasUsed" : "0x0" }, diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java index 86c29d732c4..c9a9737a90a 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV6110.java @@ -19,7 +19,6 @@ import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; @@ -32,24 +31,11 @@ import java.util.Optional; import io.vertx.core.Vertx; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class EngineGetPayloadV6110 extends AbstractEngineGetPayload { - private static final Logger LOG = LoggerFactory.getLogger(EngineGetPayloadV6110.class); private final Optional eip6110; - public EngineGetPayloadV6110( - final Vertx vertx, - final ProtocolContext protocolContext, - final MergeMiningCoordinator mergeMiningCoordinator, - final BlockResultFactory blockResultFactory, - final EngineCallListener engineCallListener) { - super(vertx, protocolContext, mergeMiningCoordinator, blockResultFactory, engineCallListener); - this.eip6110 = Optional.empty(); - } - public EngineGetPayloadV6110( final Vertx vertx, final ProtocolContext protocolContext, @@ -57,7 +43,13 @@ public EngineGetPayloadV6110( final BlockResultFactory blockResultFactory, final EngineCallListener engineCallListener, final ProtocolSchedule schedule) { - super(vertx, protocolContext, mergeMiningCoordinator, blockResultFactory, engineCallListener); + super( + vertx, + schedule, + protocolContext, + mergeMiningCoordinator, + blockResultFactory, + engineCallListener); this.eip6110 = schedule.hardforkFor(s -> s.fork().name().equalsIgnoreCase("ExperimentalEips")); } @@ -72,24 +64,9 @@ protected JsonRpcResponse createResponse( final PayloadIdentifier payloadId, final BlockWithReceipts blockWithReceipts) { - try { - long builtAt = blockWithReceipts.getHeader().getTimestamp(); - - if (eip6110.isPresent() && builtAt >= eip6110.get().milestone()) { - return new JsonRpcSuccessResponse( - request.getRequest().getId(), - blockResultFactory.payloadTransactionCompleteV6110(blockWithReceipts)); - } else { - LOG.error("Timestamp of the built payload is less than EIP-6110 activation timestamp"); - return new JsonRpcErrorResponse( - request.getRequest().getId(), RpcErrorType.UNSUPPORTED_FORK); - } - - } catch (ClassCastException e) { - LOG.error( - "configuration error, can't call V6110 endpoint with non-default protocol schedule"); - return new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INTERNAL_ERROR); - } + return new JsonRpcSuccessResponse( + request.getRequest().getId(), + blockResultFactory.payloadTransactionCompleteV6110(blockWithReceipts)); } @Override From fdcc9afecae3fd1271066044bc2ca88b1b61e11f Mon Sep 17 00:00:00 2001 From: naviechan Date: Mon, 9 Oct 2023 17:27:33 +0800 Subject: [PATCH 36/36] Update acceptance test Signed-off-by: naviechan --- ...orkchoiceUpdatedV2.json => 04_cancun_forkchoiceUpdatedV3.json} | 0 ...rkchoiceUpdatedV2.json => 05_eip6110_forkchoiceUpdatedV3.json} | 0 ...rkchoiceUpdatedV2.json => 10_eip6110_forkchoiceUpdatedV3.json} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/{04_cancun_forkchoiceUpdatedV2.json => 04_cancun_forkchoiceUpdatedV3.json} (100%) rename acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/{05_eip6110_forkchoiceUpdatedV2.json => 05_eip6110_forkchoiceUpdatedV3.json} (100%) rename acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/{10_eip6110_forkchoiceUpdatedV2.json => 10_eip6110_forkchoiceUpdatedV3.json} (100%) diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV2.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV3.json similarity index 100% rename from acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV2.json rename to acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/04_cancun_forkchoiceUpdatedV3.json diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_forkchoiceUpdatedV2.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_forkchoiceUpdatedV3.json similarity index 100% rename from acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_forkchoiceUpdatedV2.json rename to acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_forkchoiceUpdatedV3.json diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/10_eip6110_forkchoiceUpdatedV2.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/10_eip6110_forkchoiceUpdatedV3.json similarity index 100% rename from acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/10_eip6110_forkchoiceUpdatedV2.json rename to acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/10_eip6110_forkchoiceUpdatedV3.json