From f16d3526db2e5b22e64d0e975b4b98bfec4b09db Mon Sep 17 00:00:00 2001 From: Jason Frame Date: Thu, 24 Oct 2024 19:02:43 +1000 Subject: [PATCH] Change execution requests to use flat encoding (#7771) Signed-off-by: Jason Frame --- .../ethereum/PragueAcceptanceTestHelper.java | 21 +- .../src/test/resources/dev/dev_prague.json | 12 +- .../jsonrpc/engine/prague/genesis.json | 23 +- .../test-cases/00_get_genesis_block_info.json | 4 +- .../test-cases/01_cancun_prepare_payload.json | 8 +- .../test-cases/02_cancun_getPayloadV3.json | 8 +- .../test-cases/03_cancun_newPayloadV3.json | 14 +- .../04_cancun_forkchoiceUpdatedV3.json | 8 +- .../05_prague_forkchoiceUpdatedV3.json | 10 +- .../test-cases/06_prague_getPayloadV4.json | 26 +- ...send_raw_transaction_deposit_request.json} | 0 ...null_deposit_request_execute_payload.json} | 16 +- .../test-cases/09_prague_newPayloadV4.json | 34 +-- .../10_prague_forkchoiceUpdatedV3.json | 10 +- .../test-cases/11_prague_getPayloadV4.json | 20 +- .../test-cases/12_cancun_newPayloadV3.json | 21 +- .../15_prague_forkchoiceUpdatedV3.json | 10 +- .../test-cases/16_prague_getPayloadV4.json | 40 ++- .../services/RlpConverterServiceImplTest.java | 2 +- .../besu/consensus/merge/PayloadWrapper.java | 19 +- .../merge/blockcreation/MergeCoordinator.java | 8 +- .../qbft/messagewrappers/ProposalTest.java | 3 +- .../org/hyperledger/besu/datatypes/Hash.java | 12 + .../hyperledger/besu/datatypes/HashTest.java | 8 + .../api/jsonrpc/JsonRpcResponseKey.java | 2 +- .../api/jsonrpc/JsonRpcResponseUtils.java | 8 +- .../execution/TracedJsonRpcProcessor.java | 1 + .../engine/AbstractEngineNewPayload.java | 97 ++++---- .../methods/engine/EngineNewPayloadV2.java | 3 +- .../methods/engine/EngineNewPayloadV3.java | 3 +- .../methods/engine/EngineNewPayloadV4.java | 8 +- .../engine/RequestValidatorProvider.java | 49 +--- .../ConsolidationRequestParameter.java | 102 -------- .../parameters/DepositRequestParameter.java | 144 ----------- .../parameters/EnginePayloadParameter.java | 28 +-- .../WithdrawalRequestParameter.java | 103 -------- .../internal/response/RpcErrorType.java | 1 + .../internal/results/BlockResultFactory.java | 19 +- .../results/EngineGetPayloadResultV4.java | 81 ++---- .../engine/AbstractEngineGetPayloadTest.java | 15 +- .../engine/AbstractEngineNewPayloadTest.java | 99 ++------ .../EngineGetPayloadBodiesByHashV1Test.java | 7 +- .../EngineGetPayloadBodiesByRangeV1Test.java | 19 +- .../engine/EngineGetPayloadV2Test.java | 3 +- .../engine/EngineGetPayloadV3Test.java | 4 +- .../engine/EngineGetPayloadV4Test.java | 29 ++- .../engine/EngineNewPayloadV2Test.java | 43 +--- .../engine/EngineNewPayloadV3Test.java | 25 +- .../engine/EngineNewPayloadV4Test.java | 225 +++++------------ .../DepositParameterTestFixture.java | 42 ---- .../DepositRequestRequestParameterTest.java | 61 ----- .../WithdrawalRequestParameterTest.java | 52 ---- .../WithdrawalRequestTestFixture.java | 31 --- .../blockcreation/AbstractBlockCreator.java | 7 +- .../AbstractBlockCreatorTest.java | 115 +-------- .../besu/ethereum/BlockProcessingResult.java | 10 + .../besu/ethereum/BlockValidator.java | 4 - .../besu/ethereum/MainnetBlockValidator.java | 5 +- .../besu/ethereum/chain/GenesisState.java | 7 +- .../hyperledger/besu/ethereum/core/Block.java | 5 +- .../besu/ethereum/core/BlockBody.java | 34 +-- .../besu/ethereum/core/BlockHeader.java | 22 +- .../ethereum/core/BlockHeaderBuilder.java | 16 +- .../ethereum/core/ConsolidationRequest.java | 90 ------- .../besu/ethereum/core/DepositRequest.java | 112 --------- .../besu/ethereum/core/Request.java | 23 +- .../ethereum/core/SealableBlockHeader.java | 14 +- .../besu/ethereum/core/WithdrawalRequest.java | 89 ------- .../encoding/ConsolidationRequestDecoder.java | 40 --- .../encoding/ConsolidationRequestEncoder.java | 60 ----- .../core/encoding/DepositLogDecoder.java | 40 +++ .../core/encoding/DepositRequestDecoder.java | 70 ------ .../core/encoding/DepositRequestEncoder.java | 42 ---- .../core/encoding/RequestDecoder.java | 106 -------- .../core/encoding/RequestEncoder.java | 83 ------- .../encoding/WithdrawalRequestDecoder.java | 41 --- .../encoding/WithdrawalRequestEncoder.java | 59 ----- .../mainnet/AbstractBlockProcessor.java | 2 +- .../mainnet/BaseFeeBlockBodyValidator.java | 4 +- .../ethereum/mainnet/BlockBodyValidator.java | 4 - .../besu/ethereum/mainnet/BodyValidation.java | 23 +- .../mainnet/MainnetBlockBodyValidator.java | 19 +- .../mainnet/MainnetBlockImporter.java | 8 +- .../mainnet/MainnetProtocolSpecs.java | 6 +- .../besu/ethereum/mainnet/ProtocolSpec.java | 14 +- .../ethereum/mainnet/ProtocolSpecBuilder.java | 12 +- .../ethereum/mainnet/SystemCallProcessor.java | 5 +- .../AbstractSystemCallRequestProcessor.java | 102 -------- .../ConsolidationRequestProcessor.java | 73 ------ .../ConsolidationRequestValidator.java | 92 ------- .../requests/DepositRequestProcessor.java | 37 ++- .../requests/DepositRequestValidator.java | 86 ------- .../requests/MainnetRequestsProcessor.java | 39 +++ .../requests/MainnetRequestsValidator.java | 67 +++-- .../requests/ProhibitedRequestValidator.java | 38 +++ .../requests/ProhibitedRequestsValidator.java | 53 ---- .../requests/RequestContractAddresses.java | 13 +- .../mainnet/requests/RequestProcessor.java | 5 +- .../requests/RequestProcessorCoordinator.java | 25 +- .../mainnet/requests/RequestUtil.java | 85 ------- ...tValidator.java => RequestsValidator.java} | 12 +- .../RequestsValidatorCoordinator.java | 202 --------------- .../requests/SystemCallRequestProcessor.java | 57 +++++ .../requests/WithdrawalRequestProcessor.java | 79 ------ .../requests/WithdrawalRequestValidator.java | 93 ------- .../ethereum/core/BlockDataGenerator.java | 17 +- .../ethereum/core/BlockHeaderTestFixture.java | 8 +- .../ethereum/core/NonBesuBlockHeader.java | 2 +- .../BlockImportExceptionHandlingTest.java | 6 - .../ethereum/MainnetBlockValidatorTest.java | 13 +- .../besu/ethereum/chain/GenesisStateTest.java | 10 +- .../ConsolidationRequestDecoderTest.java | 46 ---- .../ConsolidationRequestEncoderTest.java | 55 ---- ...erTest.java => DepositLogDecoderTest.java} | 45 +--- .../encoding/DepositRequestEncoderTest.java | 61 ----- .../WithdrawalRequestDecoderTest.java | 46 ---- .../WithdrawalRequestEncoderTest.java | 55 ---- .../mainnet/AbstractBlockProcessorTest.java | 4 - .../ethereum/mainnet/BodyValidationTest.java | 28 +++ ...olidationRequestValidatorTestFixtures.java | 136 ---------- .../mainnet/DepositRequestValidatorTest.java | 234 ------------------ .../MainnetBlockBodyValidatorTest.java | 49 +--- .../mainnet/MainnetBlockProcessorTest.java | 3 - ...agueConsolidationRequestValidatorTest.java | 76 ------ .../mainnet/PragueRequestsValidatorTest.java | 120 --------- .../PragueWithdrawalRequestValidatorTest.java | 83 ------- .../mainnet/SystemCallProcessorTest.java | 4 +- .../ethereum/mainnet/ValidationTestUtils.java | 7 +- .../WithdrawalRequestValidatorTest.java | 87 ------- ...ithdrawalRequestValidatorTestFixtures.java | 186 -------------- .../MainnetRequestsValidatorTest.java | 58 +++++ .../ProhibitedRequestValidatorTest.java | 47 ++++ .../manager/task/GetBodiesFromPeerTask.java | 25 +- .../eth/sync/tasks/CompleteBlocksTask.java | 3 +- .../task/GetBodiesFromPeerTaskTest.java | 55 +--- .../eth/messages/MessageWrapperTest.java | 6 +- .../backwardsync/ChainForTestCreator.java | 2 +- .../sync/tasks/CompleteBlocksTaskTest.java | 17 +- .../hyperledger/besu/evmtool/T8nExecutor.java | 47 +--- .../evmtool/block-test/osaka-eof-rjump.json | 4 +- .../besu/evmtool/t8n/prague-deposit.json | 115 ++++----- .../besu/evmtool/t8n/prague-withdrawal.json | 213 +++++----------- .../BlockchainReferenceTestCaseSpec.java | 10 +- .../referencetests/ReferenceTestEnv.java | 2 +- .../NoRewardProtocolScheduleWrapper.java | 2 +- plugin-api/build.gradle | 2 +- .../besu/plugin/data/BlockBody.java | 9 - .../besu/plugin/data/BlockHeader.java | 2 +- .../plugin/data/ConsolidationRequest.java | 45 ---- .../besu/plugin/data/DepositRequest.java | 68 ----- .../hyperledger/besu/plugin/data/Request.java | 9 + .../besu/plugin/data/WithdrawalRequest.java | 49 ---- 152 files changed, 1094 insertions(+), 5067 deletions(-) rename acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/{07_prague_send_raw_transaction.json => 07_prague_send_raw_transaction_deposit_request.json} (100%) rename acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/{08_prague_invalid_null_deposits_execute_payload.json => 08_prague_invalid_null_deposit_request_execute_payload.json} (88%) delete mode 100644 ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/ConsolidationRequestParameter.java delete mode 100644 ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestParameter.java delete mode 100644 ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestParameter.java delete mode 100644 ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositParameterTestFixture.java delete mode 100644 ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestRequestParameterTest.java delete mode 100644 ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestParameterTest.java delete mode 100644 ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestTestFixture.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/ConsolidationRequest.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/DepositRequest.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/WithdrawalRequest.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestDecoder.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestEncoder.java create mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositLogDecoder.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestDecoder.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestEncoder.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestDecoder.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestEncoder.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestDecoder.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestEncoder.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/AbstractSystemCallRequestProcessor.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ConsolidationRequestProcessor.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ConsolidationRequestValidator.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestValidator.java create mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsProcessor.java create mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestValidator.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestsValidator.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestUtil.java rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/{RequestValidator.java => RequestsValidator.java} (63%) delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestsValidatorCoordinator.java create mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/SystemCallRequestProcessor.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/WithdrawalRequestProcessor.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/WithdrawalRequestValidator.java delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestDecoderTest.java delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestEncoderTest.java rename ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/{DepositRequestDecoderTest.java => DepositLogDecoderTest.java} (51%) delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestEncoderTest.java delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestDecoderTest.java delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestEncoderTest.java delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ConsolidationRequestValidatorTestFixtures.java delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DepositRequestValidatorTest.java delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueConsolidationRequestValidatorTest.java delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueRequestsValidatorTest.java delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueWithdrawalRequestValidatorTest.java delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/WithdrawalRequestValidatorTest.java delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/WithdrawalRequestValidatorTestFixtures.java create mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidatorTest.java create mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestValidatorTest.java delete mode 100644 plugin-api/src/main/java/org/hyperledger/besu/plugin/data/ConsolidationRequest.java delete mode 100644 plugin-api/src/main/java/org/hyperledger/besu/plugin/data/DepositRequest.java delete mode 100644 plugin-api/src/main/java/org/hyperledger/besu/plugin/data/WithdrawalRequest.java diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/ethereum/PragueAcceptanceTestHelper.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/ethereum/PragueAcceptanceTestHelper.java index fa190f3de17..754e28165c8 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/ethereum/PragueAcceptanceTestHelper.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/ethereum/PragueAcceptanceTestHelper.java @@ -22,7 +22,9 @@ import java.io.IOException; import java.util.Optional; +import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import okhttp3.Call; import okhttp3.MediaType; @@ -74,17 +76,15 @@ public void buildNewBlock() throws IOException { final Call getPayloadRequest = createEngineCall(createGetPayloadRequest(payloadId)); final ObjectNode executionPayload; + final ArrayNode executionRequests; final String newBlockHash; final String parentBeaconBlockRoot; try (final Response getPayloadResponse = getPayloadRequest.execute()) { assertThat(getPayloadResponse.code()).isEqualTo(200); - executionPayload = - (ObjectNode) - mapper - .readTree(getPayloadResponse.body().string()) - .get("result") - .get("executionPayload"); + JsonNode result = mapper.readTree(getPayloadResponse.body().string()).get("result"); + executionPayload = (ObjectNode) result.get("executionPayload"); + executionRequests = (ArrayNode) result.get("executionRequests"); newBlockHash = executionPayload.get("blockHash").asText(); parentBeaconBlockRoot = executionPayload.remove("parentBeaconBlockRoot").asText(); @@ -94,7 +94,8 @@ public void buildNewBlock() throws IOException { final Call newPayloadRequest = createEngineCall( - createNewPayloadRequest(executionPayload.toString(), parentBeaconBlockRoot)); + createNewPayloadRequest( + executionPayload.toString(), parentBeaconBlockRoot, executionRequests.toString())); try (final Response newPayloadResponse = newPayloadRequest.execute()) { assertThat(newPayloadResponse.code()).isEqualTo(200); } @@ -168,7 +169,9 @@ private String createGetPayloadRequest(final String payloadId) { } private String createNewPayloadRequest( - final String executionPayload, final String parentBeaconBlockRoot) { + final String executionPayload, + final String parentBeaconBlockRoot, + final String executionRequests) { return "{" + " \"jsonrpc\": \"2.0\"," + " \"method\": \"engine_newPayloadV4\"," @@ -178,6 +181,8 @@ private String createNewPayloadRequest( + "\"" + parentBeaconBlockRoot + "\"" + + "," + + executionRequests + "]," + " \"id\": 67" + "}"; diff --git a/acceptance-tests/tests/src/test/resources/dev/dev_prague.json b/acceptance-tests/tests/src/test/resources/dev/dev_prague.json index 26e59992d16..942edc4e70a 100644 --- a/acceptance-tests/tests/src/test/resources/dev/dev_prague.json +++ b/acceptance-tests/tests/src/test/resources/dev/dev_prague.json @@ -19,7 +19,9 @@ "period": 5, "epoch": 30000 }, - "depositContractAddress": "0x4242424242424242424242424242424242424242" + "depositContractAddress": "0x4242424242424242424242424242424242424242", + "withdrawalRequestContractAddress": "0x00A3ca265EBcb825B45F985A16CEFB49958cE017", + "consolidationRequestContractAddress": "0x00b42dbF2194e931E80326D950320f7d9Dbeac02" }, "nonce":"0x42", "timestamp":"0x0", @@ -53,9 +55,9 @@ "balance": "1000000000000000000000000000" }, "0x00A3ca265EBcb825B45F985A16CEFB49958cE017": { - "comment": "This is the runtime bytecode for the Withdrawal Request Smart Contract. It was created from the deployment transaction in EIP-7002 (https://eips.ethereum.org/EIPS/eip-7002#deployment)", + "comment": "This is the runtime bytecode for the Withdrawal Request Smart Contract. It was created from the generated alloc section of fork_Prague_blockchain_test_engine_single_block_single_withdrawal_request_from_contract spec test", "balance": "0", - "code": "0x3373fffffffffffffffffffffffffffffffffffffffe146090573615156028575f545f5260205ff35b36603814156101215760115f54600182026001905f5b5f82111560595781019083028483029004916001019190603e565b90939004341061012157600154600101600155600354806003026004013381556001015f3581556001016020359055600101600355005b6003546002548082038060101160a4575060105b5f5b81811460dd5780604c02838201600302600401805490600101805490600101549160601b83528260140152906034015260010160a6565b910180921460ed579060025560f8565b90505f6002555f6003555b5f5460015460028282011161010f5750505f610115565b01600290035b5f555f600155604c025ff35b5f5ffd", + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460c7573615156028575f545f5260205ff35b36603814156101f05760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff146101f057600182026001905f5b5f821115608057810190830284830290049160010191906065565b9093900434106101f057600154600101600155600354806003026004013381556001015f35815560010160203590553360601b5f5260385f601437604c5fa0600101600355005b6003546002548082038060101160db575060105b5f5b81811461017f5780604c02838201600302600401805490600101805490600101549160601b83528260140152807fffffffffffffffffffffffffffffffff0000000000000000000000000000000016826034015260401c906044018160381c81600701538160301c81600601538160281c81600501538160201c81600401538160181c81600301538160101c81600201538160081c81600101535360010160dd565b9101809214610191579060025561019c565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14156101c957505f5b6001546002828201116101de5750505f6101e4565b01600290035b5f555f600155604c025ff35b5f5ffd", "storage": { "0x0000000000000000000000000000000000000000000000000000000000000000": "0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000001": "0000000000000000000000000000000000000000000000000000000000000001", @@ -67,9 +69,9 @@ } }, "0x4242424242424242424242424242424242424242": { - "comment": "The deposit contract", + "comment": "This is the runtime bytecode for the Deposit Request Smart Contract. It was created from the generated alloc section of fork_Prague_blockchain_test_engine_single_deposit_from_contract spec test", "balance": "0", - "code": "0x60806040526004361061003f5760003560e01c806301ffc9a71461004457806322895118146100a4578063621fd130146101ba578063c5f2892f14610244575b600080fd5b34801561005057600080fd5b506100906004803603602081101561006757600080fd5b50357fffffffff000000000000000000000000000000000000000000000000000000001661026b565b604080519115158252519081900360200190f35b6101b8600480360360808110156100ba57600080fd5b8101906020810181356401000000008111156100d557600080fd5b8201836020820111156100e757600080fd5b8035906020019184600183028401116401000000008311171561010957600080fd5b91939092909160208101903564010000000081111561012757600080fd5b82018360208201111561013957600080fd5b8035906020019184600183028401116401000000008311171561015b57600080fd5b91939092909160208101903564010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b919350915035610304565b005b3480156101c657600080fd5b506101cf6110b5565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102095781810151838201526020016101f1565b50505050905090810190601f1680156102365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025057600080fd5b506102596110c7565b60408051918252519081900360200190f35b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f8564090700000000000000000000000000000000000000000000000000000000145b92915050565b6030861461035d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118056026913960400191505060405180910390fd5b602084146103b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061179c6036913960400191505060405180910390fd5b6060821461040f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806118786029913960400191505060405180910390fd5b670de0b6b3a7640000341015610470576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118526026913960400191505060405180910390fd5b633b9aca003406156104cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806117d26033913960400191505060405180910390fd5b633b9aca00340467ffffffffffffffff811115610535576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061182b6027913960400191505060405180910390fd5b6060610540826114ba565b90507f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c589898989858a8a6105756020546114ba565b6040805160a0808252810189905290819060208201908201606083016080840160c085018e8e80828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910187810386528c815260200190508c8c808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690920188810386528c5181528c51602091820193918e019250908190849084905b83811015610648578181015183820152602001610630565b50505050905090810190601f1680156106755780820380516001836020036101000a031916815260200191505b5086810383528881526020018989808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018881038452895181528951602091820193918b019250908190849084905b838110156106ef5781810151838201526020016106d7565b50505050905090810190601f16801561071c5780820380516001836020036101000a031916815260200191505b509d505050505050505050505050505060405180910390a1600060028a8a600060801b604051602001808484808284377fffffffffffffffffffffffffffffffff0000000000000000000000000000000090941691909301908152604080517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0818403018152601090920190819052815191955093508392506020850191508083835b602083106107fc57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016107bf565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610859573d6000803e3d6000fd5b5050506040513d602081101561086e57600080fd5b5051905060006002806108846040848a8c6116fe565b6040516020018083838082843780830192505050925050506040516020818303038152906040526040518082805190602001908083835b602083106108f857805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016108bb565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610955573d6000803e3d6000fd5b5050506040513d602081101561096a57600080fd5b5051600261097b896040818d6116fe565b60405160009060200180848480828437919091019283525050604080518083038152602092830191829052805190945090925082918401908083835b602083106109f457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016109b7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610a51573d6000803e3d6000fd5b5050506040513d6020811015610a6657600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610ada57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610a9d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610b37573d6000803e3d6000fd5b5050506040513d6020811015610b4c57600080fd5b50516040805160208101858152929350600092600292839287928f928f92018383808284378083019250505093505050506040516020818303038152906040526040518082805190602001908083835b60208310610bd957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610b9c565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610c36573d6000803e3d6000fd5b5050506040513d6020811015610c4b57600080fd5b50516040518651600291889160009188916020918201918291908601908083835b60208310610ca957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610c6c565b6001836020036101000a0380198251168184511680821785525050505050509050018367ffffffffffffffff191667ffffffffffffffff1916815260180182815260200193505050506040516020818303038152906040526040518082805190602001908083835b60208310610d4e57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610d11565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610dab573d6000803e3d6000fd5b5050506040513d6020811015610dc057600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610e3457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610df7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610e91573d6000803e3d6000fd5b5050506040513d6020811015610ea657600080fd5b50519050858114610f02576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260548152602001806117486054913960600191505060405180910390fd5b60205463ffffffff11610f60576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806117276021913960400191505060405180910390fd5b602080546001019081905560005b60208110156110a9578160011660011415610fa0578260008260208110610f9157fe5b0155506110ac95505050505050565b600260008260208110610faf57fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061102557805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610fe8565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015611082573d6000803e3d6000fd5b5050506040513d602081101561109757600080fd5b50519250600282049150600101610f6e565b50fe5b50505050505050565b60606110c26020546114ba565b905090565b6020546000908190815b60208110156112f05781600116600114156111e6576002600082602081106110f557fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061116b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161112e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156111c8573d6000803e3d6000fd5b5050506040513d60208110156111dd57600080fd5b505192506112e2565b600283602183602081106111f657fe5b015460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061126b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161122e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156112c8573d6000803e3d6000fd5b5050506040513d60208110156112dd57600080fd5b505192505b6002820491506001016110d1565b506002826112ff6020546114ba565b600060401b6040516020018084815260200183805190602001908083835b6020831061135a57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161131d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790527fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000095909516920191825250604080518083037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8018152601890920190819052815191955093508392850191508083835b6020831061143f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611402565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa15801561149c573d6000803e3d6000fd5b5050506040513d60208110156114b157600080fd5b50519250505090565b60408051600880825281830190925260609160208201818036833701905050905060c082901b8060071a60f81b826000815181106114f457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060061a60f81b8260018151811061153757fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060051a60f81b8260028151811061157a57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060041a60f81b826003815181106115bd57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060031a60f81b8260048151811061160057fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060021a60f81b8260058151811061164357fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060011a60f81b8260068151811061168657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060001a60f81b826007815181106116c957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050919050565b6000808585111561170d578182fd5b83861115611719578182fd5b505082019391909203915056fe4465706f736974436f6e74726163743a206d65726b6c6520747265652066756c6c4465706f736974436f6e74726163743a207265636f6e7374727563746564204465706f7369744461746120646f6573206e6f74206d6174636820737570706c696564206465706f7369745f646174615f726f6f744465706f736974436f6e74726163743a20696e76616c6964207769746864726177616c5f63726564656e7469616c73206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c7565206e6f74206d756c7469706c65206f6620677765694465706f736974436f6e74726163743a20696e76616c6964207075626b6579206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f20686967684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f206c6f774465706f736974436f6e74726163743a20696e76616c6964207369676e6174757265206c656e677468a26469706673582212201dd26f37a621703009abf16e77e69c93dc50c79db7f6cc37543e3e0e3decdc9764736f6c634300060b0033", + "code": "0x60806040526004361061003f5760003560e01c806301ffc9a71461004457806322895118146100a4578063621fd130146101ba578063c5f2892f14610244575b600080fd5b34801561005057600080fd5b506100906004803603602081101561006757600080fd5b50357fffffffff000000000000000000000000000000000000000000000000000000001661026b565b604080519115158252519081900360200190f35b6101b8600480360360808110156100ba57600080fd5b8101906020810181356401000000008111156100d557600080fd5b8201836020820111156100e757600080fd5b8035906020019184600183028401116401000000008311171561010957600080fd5b91939092909160208101903564010000000081111561012757600080fd5b82018360208201111561013957600080fd5b8035906020019184600183028401116401000000008311171561015b57600080fd5b91939092909160208101903564010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b919350915035610304565b005b3480156101c657600080fd5b506101cf6110b5565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102095781810151838201526020016101f1565b50505050905090810190601f1680156102365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025057600080fd5b506102596110c7565b60408051918252519081900360200190f35b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f8564090700000000000000000000000000000000000000000000000000000000145b92915050565b6030861461035d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118056026913960400191505060405180910390fd5b602084146103b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061179c6036913960400191505060405180910390fd5b6060821461040f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806118786029913960400191505060405180910390fd5b670de0b6b3a7640000341015610470576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118526026913960400191505060405180910390fd5b633b9aca003406156104cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806117d26033913960400191505060405180910390fd5b633b9aca00340467ffffffffffffffff811115610535576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061182b6027913960400191505060405180910390fd5b6060610540826114ba565b90507f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c589898989858a8a6105756020546114ba565b6040805160a0808252810189905290819060208201908201606083016080840160c085018e8e80828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910187810386528c815260200190508c8c808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690920188810386528c5181528c51602091820193918e019250908190849084905b83811015610648578181015183820152602001610630565b50505050905090810190601f1680156106755780820380516001836020036101000a031916815260200191505b5086810383528881526020018989808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018881038452895181528951602091820193918b019250908190849084905b838110156106ef5781810151838201526020016106d7565b50505050905090810190601f16801561071c5780820380516001836020036101000a031916815260200191505b509d505050505050505050505050505060405180910390a1600060028a8a600060801b604051602001808484808284377fffffffffffffffffffffffffffffffff0000000000000000000000000000000090941691909301908152604080517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0818403018152601090920190819052815191955093508392506020850191508083835b602083106107fc57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016107bf565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610859573d6000803e3d6000fd5b5050506040513d602081101561086e57600080fd5b5051905060006002806108846040848a8c6116fe565b6040516020018083838082843780830192505050925050506040516020818303038152906040526040518082805190602001908083835b602083106108f857805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016108bb565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610955573d6000803e3d6000fd5b5050506040513d602081101561096a57600080fd5b5051600261097b896040818d6116fe565b60405160009060200180848480828437919091019283525050604080518083038152602092830191829052805190945090925082918401908083835b602083106109f457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016109b7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610a51573d6000803e3d6000fd5b5050506040513d6020811015610a6657600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610ada57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610a9d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610b37573d6000803e3d6000fd5b5050506040513d6020811015610b4c57600080fd5b50516040805160208101858152929350600092600292839287928f928f92018383808284378083019250505093505050506040516020818303038152906040526040518082805190602001908083835b60208310610bd957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610b9c565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610c36573d6000803e3d6000fd5b5050506040513d6020811015610c4b57600080fd5b50516040518651600291889160009188916020918201918291908601908083835b60208310610ca957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610c6c565b6001836020036101000a0380198251168184511680821785525050505050509050018367ffffffffffffffff191667ffffffffffffffff1916815260180182815260200193505050506040516020818303038152906040526040518082805190602001908083835b60208310610d4e57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610d11565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610dab573d6000803e3d6000fd5b5050506040513d6020811015610dc057600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610e3457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610df7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610e91573d6000803e3d6000fd5b5050506040513d6020811015610ea657600080fd5b50519050858114610f02576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260548152602001806117486054913960600191505060405180910390fd5b60205463ffffffff11610f60576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806117276021913960400191505060405180910390fd5b602080546001019081905560005b60208110156110a9578160011660011415610fa0578260008260208110610f9157fe5b0155506110ac95505050505050565b600260008260208110610faf57fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061102557805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610fe8565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015611082573d6000803e3d6000fd5b5050506040513d602081101561109757600080fd5b50519250600282049150600101610f6e565b50fe5b50505050505050565b60606110c26020546114ba565b905090565b6020546000908190815b60208110156112f05781600116600114156111e6576002600082602081106110f557fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061116b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161112e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156111c8573d6000803e3d6000fd5b5050506040513d60208110156111dd57600080fd5b505192506112e2565b600283602183602081106111f657fe5b015460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061126b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161122e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156112c8573d6000803e3d6000fd5b5050506040513d60208110156112dd57600080fd5b505192505b6002820491506001016110d1565b506002826112ff6020546114ba565b600060401b6040516020018084815260200183805190602001908083835b6020831061135a57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161131d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790527fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000095909516920191825250604080518083037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8018152601890920190819052815191955093508392850191508083835b6020831061143f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611402565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa15801561149c573d6000803e3d6000fd5b5050506040513d60208110156114b157600080fd5b50519250505090565b60408051600880825281830190925260609160208201818036833701905050905060c082901b8060071a60f81b826000815181106114f457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060061a60f81b8260018151811061153757fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060051a60f81b8260028151811061157a57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060041a60f81b826003815181106115bd57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060031a60f81b8260048151811061160057fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060021a60f81b8260058151811061164357fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060011a60f81b8260068151811061168657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060001a60f81b826007815181106116c957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050919050565b6000808585111561170d578182fd5b83861115611719578182fd5b505082019391909203915056fe4465706f736974436f6e74726163743a206d65726b6c6520747265652066756c6c4465706f736974436f6e74726163743a207265636f6e7374727563746564204465706f7369744461746120646f6573206e6f74206d6174636820737570706c696564206465706f7369745f646174615f726f6f744465706f736974436f6e74726163743a20696e76616c6964207769746864726177616c5f63726564656e7469616c73206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c7565206e6f74206d756c7469706c65206f6620677765694465706f736974436f6e74726163743a20696e76616c6964207075626b6579206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f20686967684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f206c6f774465706f736974436f6e74726163743a20696e76616c6964207369676e6174757265206c656e677468a2646970667358221220dceca8706b29e917dacf25fceef95acac8d90d765ac926663ce4096195952b6164736f6c634300060b0033", "storage": { "0x0000000000000000000000000000000000000000000000000000000000000022": "0xf5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b", "0x0000000000000000000000000000000000000000000000000000000000000023": "0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71", diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/genesis.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/genesis.json index ac474c02453..ef3d2c1be4b 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/genesis.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/genesis.json @@ -19,7 +19,9 @@ "period": 5, "epoch": 30000 }, - "depositContractAddress": "0x4242424242424242424242424242424242424242" + "depositContractAddress": "0x4242424242424242424242424242424242424242", + "withdrawalRequestContractAddress": "0x00A3ca265EBcb825B45F985A16CEFB49958cE017", + "consolidationRequestContractAddress": "0x00b42dbF2194e931E80326D950320f7d9Dbeac02" }, "nonce":"0x42", "timestamp":"0x0", @@ -37,9 +39,10 @@ "balance": "1000000000000000000000000000" }, "0x00A3ca265EBcb825B45F985A16CEFB49958cE017": { - "comment": "This is the runtime bytecode for the Withdrawal Request Smart Contract. It was created from the deployment transaction in EIP-7002 (https://eips.ethereum.org/EIPS/eip-7002#deployment)", - "balance": "0", - "code": "0x3373fffffffffffffffffffffffffffffffffffffffe146090573615156028575f545f5260205ff35b36603814156101215760115f54600182026001905f5b5f82111560595781019083028483029004916001019190603e565b90939004341061012157600154600101600155600354806003026004013381556001015f3581556001016020359055600101600355005b6003546002548082038060101160a4575060105b5f5b81811460dd5780604c02838201600302600401805490600101805490600101549160601b83528260140152906034015260010160a6565b910180921460ed579060025560f8565b90505f6002555f6003555b5f5460015460028282011161010f5750505f610115565b01600290035b5f555f600155604c025ff35b5f5ffd", + "comment": "This is the runtime bytecode for the Withdrawal Request Smart Contract. It was created from the generated alloc section of fork_Prague_blockchain_test_engine_single_block_single_withdrawal_request_from_contract spec test", + "nonce": "0x01", + "balance": "0x00", + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460c7573615156028575f545f5260205ff35b36603814156101f05760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff146101f057600182026001905f5b5f821115608057810190830284830290049160010191906065565b9093900434106101f057600154600101600155600354806003026004013381556001015f35815560010160203590553360601b5f5260385f601437604c5fa0600101600355005b6003546002548082038060101160db575060105b5f5b81811461017f5780604c02838201600302600401805490600101805490600101549160601b83528260140152807fffffffffffffffffffffffffffffffff0000000000000000000000000000000016826034015260401c906044018160381c81600701538160301c81600601538160281c81600501538160201c81600401538160181c81600301538160101c81600201538160081c81600101535360010160dd565b9101809214610191579060025561019c565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14156101c957505f5b6001546002828201116101de5750505f6101e4565b01600290035b5f555f600155604c025ff35b5f5ffd", "storage": { "0x0000000000000000000000000000000000000000000000000000000000000000": "0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000001": "0000000000000000000000000000000000000000000000000000000000000001", @@ -51,9 +54,10 @@ } }, "0x00b42dbF2194e931E80326D950320f7d9Dbeac02": { - "comment": "This is the runtime bytecode for the Consolidation Request Smart Contract. It was created from the deployment transaction in EIP-7251 (https://eips.ethereum.org/EIPS/eip-7251#deployment)", - "balance": "0", - "code": "0x3373fffffffffffffffffffffffffffffffffffffffe146098573615156028575f545f5260205ff35b36606014156101445760115f54600182026001905f5b5f82111560595781019083028483029004916001019190603e565b90939004341061014457600154600101600155600354806004026004013381556001015f35815560010160203581556001016040359055600101600355005b6003546002548082038060011160ac575060015b5f5b81811460f15780607402838201600402600401805490600101805490600101805490600101549260601b84529083601401528260340152906054015260010160ae565b9101809214610103579060025561010e565b90505f6002555f6003555b5f548061049d141561011d57505f5b6001546001828201116101325750505f610138565b01600190035b5f555f6001556074025ff35b5f5ffd", + "comment": "This is the runtime bytecode for the Consolidation Request Smart Contract. It was created from the generated alloc section of fork_Prague_blockchain_test_engine_single_block_single_consolidation_request_from_contract spec test", + "nonce": "0x01", + "balance": "0x0", + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460cf573615156028575f545f5260205ff35b366060141561019a5760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1461019a57600182026001905f5b5f821115608057810190830284830290049160010191906065565b90939004341061019a57600154600101600155600354806004026004013381556001015f358155600101602035815560010160403590553360601b5f5260605f60143760745fa0600101600355005b6003546002548082038060011160e3575060015b5f5b8181146101295780607402838201600402600401805490600101805490600101805490600101549260601b84529083601401528260340152906054015260010160e5565b910180921461013b5790600255610146565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff141561017357505f5b6001546001828201116101885750505f61018e565b01600190035b5f555f6001556074025ff35b5f5ffd", "storage": { "0x0000000000000000000000000000000000000000000000000000000000000000": "0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000001": "0000000000000000000000000000000000000000000000000000000000000000", @@ -65,8 +69,9 @@ } }, "0x4242424242424242424242424242424242424242": { - "balance": "0", - "code": "0x60806040526004361061003f5760003560e01c806301ffc9a71461004457806322895118146100a4578063621fd130146101ba578063c5f2892f14610244575b600080fd5b34801561005057600080fd5b506100906004803603602081101561006757600080fd5b50357fffffffff000000000000000000000000000000000000000000000000000000001661026b565b604080519115158252519081900360200190f35b6101b8600480360360808110156100ba57600080fd5b8101906020810181356401000000008111156100d557600080fd5b8201836020820111156100e757600080fd5b8035906020019184600183028401116401000000008311171561010957600080fd5b91939092909160208101903564010000000081111561012757600080fd5b82018360208201111561013957600080fd5b8035906020019184600183028401116401000000008311171561015b57600080fd5b91939092909160208101903564010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b919350915035610304565b005b3480156101c657600080fd5b506101cf6110b5565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102095781810151838201526020016101f1565b50505050905090810190601f1680156102365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025057600080fd5b506102596110c7565b60408051918252519081900360200190f35b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f8564090700000000000000000000000000000000000000000000000000000000145b92915050565b6030861461035d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118056026913960400191505060405180910390fd5b602084146103b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061179c6036913960400191505060405180910390fd5b6060821461040f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806118786029913960400191505060405180910390fd5b670de0b6b3a7640000341015610470576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118526026913960400191505060405180910390fd5b633b9aca003406156104cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806117d26033913960400191505060405180910390fd5b633b9aca00340467ffffffffffffffff811115610535576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061182b6027913960400191505060405180910390fd5b6060610540826114ba565b90507f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c589898989858a8a6105756020546114ba565b6040805160a0808252810189905290819060208201908201606083016080840160c085018e8e80828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910187810386528c815260200190508c8c808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690920188810386528c5181528c51602091820193918e019250908190849084905b83811015610648578181015183820152602001610630565b50505050905090810190601f1680156106755780820380516001836020036101000a031916815260200191505b5086810383528881526020018989808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018881038452895181528951602091820193918b019250908190849084905b838110156106ef5781810151838201526020016106d7565b50505050905090810190601f16801561071c5780820380516001836020036101000a031916815260200191505b509d505050505050505050505050505060405180910390a1600060028a8a600060801b604051602001808484808284377fffffffffffffffffffffffffffffffff0000000000000000000000000000000090941691909301908152604080517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0818403018152601090920190819052815191955093508392506020850191508083835b602083106107fc57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016107bf565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610859573d6000803e3d6000fd5b5050506040513d602081101561086e57600080fd5b5051905060006002806108846040848a8c6116fe565b6040516020018083838082843780830192505050925050506040516020818303038152906040526040518082805190602001908083835b602083106108f857805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016108bb565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610955573d6000803e3d6000fd5b5050506040513d602081101561096a57600080fd5b5051600261097b896040818d6116fe565b60405160009060200180848480828437919091019283525050604080518083038152602092830191829052805190945090925082918401908083835b602083106109f457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016109b7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610a51573d6000803e3d6000fd5b5050506040513d6020811015610a6657600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610ada57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610a9d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610b37573d6000803e3d6000fd5b5050506040513d6020811015610b4c57600080fd5b50516040805160208101858152929350600092600292839287928f928f92018383808284378083019250505093505050506040516020818303038152906040526040518082805190602001908083835b60208310610bd957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610b9c565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610c36573d6000803e3d6000fd5b5050506040513d6020811015610c4b57600080fd5b50516040518651600291889160009188916020918201918291908601908083835b60208310610ca957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610c6c565b6001836020036101000a0380198251168184511680821785525050505050509050018367ffffffffffffffff191667ffffffffffffffff1916815260180182815260200193505050506040516020818303038152906040526040518082805190602001908083835b60208310610d4e57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610d11565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610dab573d6000803e3d6000fd5b5050506040513d6020811015610dc057600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610e3457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610df7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610e91573d6000803e3d6000fd5b5050506040513d6020811015610ea657600080fd5b50519050858114610f02576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260548152602001806117486054913960600191505060405180910390fd5b60205463ffffffff11610f60576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806117276021913960400191505060405180910390fd5b602080546001019081905560005b60208110156110a9578160011660011415610fa0578260008260208110610f9157fe5b0155506110ac95505050505050565b600260008260208110610faf57fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061102557805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610fe8565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015611082573d6000803e3d6000fd5b5050506040513d602081101561109757600080fd5b50519250600282049150600101610f6e565b50fe5b50505050505050565b60606110c26020546114ba565b905090565b6020546000908190815b60208110156112f05781600116600114156111e6576002600082602081106110f557fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061116b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161112e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156111c8573d6000803e3d6000fd5b5050506040513d60208110156111dd57600080fd5b505192506112e2565b600283602183602081106111f657fe5b015460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061126b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161122e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156112c8573d6000803e3d6000fd5b5050506040513d60208110156112dd57600080fd5b505192505b6002820491506001016110d1565b506002826112ff6020546114ba565b600060401b6040516020018084815260200183805190602001908083835b6020831061135a57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161131d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790527fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000095909516920191825250604080518083037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8018152601890920190819052815191955093508392850191508083835b6020831061143f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611402565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa15801561149c573d6000803e3d6000fd5b5050506040513d60208110156114b157600080fd5b50519250505090565b60408051600880825281830190925260609160208201818036833701905050905060c082901b8060071a60f81b826000815181106114f457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060061a60f81b8260018151811061153757fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060051a60f81b8260028151811061157a57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060041a60f81b826003815181106115bd57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060031a60f81b8260048151811061160057fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060021a60f81b8260058151811061164357fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060011a60f81b8260068151811061168657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060001a60f81b826007815181106116c957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050919050565b6000808585111561170d578182fd5b83861115611719578182fd5b505082019391909203915056fe4465706f736974436f6e74726163743a206d65726b6c6520747265652066756c6c4465706f736974436f6e74726163743a207265636f6e7374727563746564204465706f7369744461746120646f6573206e6f74206d6174636820737570706c696564206465706f7369745f646174615f726f6f744465706f736974436f6e74726163743a20696e76616c6964207769746864726177616c5f63726564656e7469616c73206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c7565206e6f74206d756c7469706c65206f6620677765694465706f736974436f6e74726163743a20696e76616c6964207075626b6579206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f20686967684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f206c6f774465706f736974436f6e74726163743a20696e76616c6964207369676e6174757265206c656e677468a26469706673582212201dd26f37a621703009abf16e77e69c93dc50c79db7f6cc37543e3e0e3decdc9764736f6c634300060b0033", + "comment": "This is the runtime bytecode for the Deposit Request Smart Contract. It was created from the generated alloc section of fork_Prague_blockchain_test_engine_single_deposit_from_contract spec test", + "balance": "0x0", + "code": "0x60806040526004361061003f5760003560e01c806301ffc9a71461004457806322895118146100a4578063621fd130146101ba578063c5f2892f14610244575b600080fd5b34801561005057600080fd5b506100906004803603602081101561006757600080fd5b50357fffffffff000000000000000000000000000000000000000000000000000000001661026b565b604080519115158252519081900360200190f35b6101b8600480360360808110156100ba57600080fd5b8101906020810181356401000000008111156100d557600080fd5b8201836020820111156100e757600080fd5b8035906020019184600183028401116401000000008311171561010957600080fd5b91939092909160208101903564010000000081111561012757600080fd5b82018360208201111561013957600080fd5b8035906020019184600183028401116401000000008311171561015b57600080fd5b91939092909160208101903564010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b919350915035610304565b005b3480156101c657600080fd5b506101cf6110b5565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102095781810151838201526020016101f1565b50505050905090810190601f1680156102365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025057600080fd5b506102596110c7565b60408051918252519081900360200190f35b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f8564090700000000000000000000000000000000000000000000000000000000145b92915050565b6030861461035d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118056026913960400191505060405180910390fd5b602084146103b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061179c6036913960400191505060405180910390fd5b6060821461040f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806118786029913960400191505060405180910390fd5b670de0b6b3a7640000341015610470576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118526026913960400191505060405180910390fd5b633b9aca003406156104cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806117d26033913960400191505060405180910390fd5b633b9aca00340467ffffffffffffffff811115610535576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061182b6027913960400191505060405180910390fd5b6060610540826114ba565b90507f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c589898989858a8a6105756020546114ba565b6040805160a0808252810189905290819060208201908201606083016080840160c085018e8e80828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910187810386528c815260200190508c8c808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690920188810386528c5181528c51602091820193918e019250908190849084905b83811015610648578181015183820152602001610630565b50505050905090810190601f1680156106755780820380516001836020036101000a031916815260200191505b5086810383528881526020018989808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018881038452895181528951602091820193918b019250908190849084905b838110156106ef5781810151838201526020016106d7565b50505050905090810190601f16801561071c5780820380516001836020036101000a031916815260200191505b509d505050505050505050505050505060405180910390a1600060028a8a600060801b604051602001808484808284377fffffffffffffffffffffffffffffffff0000000000000000000000000000000090941691909301908152604080517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0818403018152601090920190819052815191955093508392506020850191508083835b602083106107fc57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016107bf565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610859573d6000803e3d6000fd5b5050506040513d602081101561086e57600080fd5b5051905060006002806108846040848a8c6116fe565b6040516020018083838082843780830192505050925050506040516020818303038152906040526040518082805190602001908083835b602083106108f857805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016108bb565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610955573d6000803e3d6000fd5b5050506040513d602081101561096a57600080fd5b5051600261097b896040818d6116fe565b60405160009060200180848480828437919091019283525050604080518083038152602092830191829052805190945090925082918401908083835b602083106109f457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016109b7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610a51573d6000803e3d6000fd5b5050506040513d6020811015610a6657600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610ada57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610a9d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610b37573d6000803e3d6000fd5b5050506040513d6020811015610b4c57600080fd5b50516040805160208101858152929350600092600292839287928f928f92018383808284378083019250505093505050506040516020818303038152906040526040518082805190602001908083835b60208310610bd957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610b9c565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610c36573d6000803e3d6000fd5b5050506040513d6020811015610c4b57600080fd5b50516040518651600291889160009188916020918201918291908601908083835b60208310610ca957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610c6c565b6001836020036101000a0380198251168184511680821785525050505050509050018367ffffffffffffffff191667ffffffffffffffff1916815260180182815260200193505050506040516020818303038152906040526040518082805190602001908083835b60208310610d4e57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610d11565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610dab573d6000803e3d6000fd5b5050506040513d6020811015610dc057600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610e3457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610df7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610e91573d6000803e3d6000fd5b5050506040513d6020811015610ea657600080fd5b50519050858114610f02576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260548152602001806117486054913960600191505060405180910390fd5b60205463ffffffff11610f60576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806117276021913960400191505060405180910390fd5b602080546001019081905560005b60208110156110a9578160011660011415610fa0578260008260208110610f9157fe5b0155506110ac95505050505050565b600260008260208110610faf57fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061102557805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610fe8565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015611082573d6000803e3d6000fd5b5050506040513d602081101561109757600080fd5b50519250600282049150600101610f6e565b50fe5b50505050505050565b60606110c26020546114ba565b905090565b6020546000908190815b60208110156112f05781600116600114156111e6576002600082602081106110f557fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061116b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161112e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156111c8573d6000803e3d6000fd5b5050506040513d60208110156111dd57600080fd5b505192506112e2565b600283602183602081106111f657fe5b015460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061126b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161122e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156112c8573d6000803e3d6000fd5b5050506040513d60208110156112dd57600080fd5b505192505b6002820491506001016110d1565b506002826112ff6020546114ba565b600060401b6040516020018084815260200183805190602001908083835b6020831061135a57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161131d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790527fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000095909516920191825250604080518083037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8018152601890920190819052815191955093508392850191508083835b6020831061143f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611402565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa15801561149c573d6000803e3d6000fd5b5050506040513d60208110156114b157600080fd5b50519250505090565b60408051600880825281830190925260609160208201818036833701905050905060c082901b8060071a60f81b826000815181106114f457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060061a60f81b8260018151811061153757fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060051a60f81b8260028151811061157a57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060041a60f81b826003815181106115bd57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060031a60f81b8260048151811061160057fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060021a60f81b8260058151811061164357fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060011a60f81b8260068151811061168657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060001a60f81b826007815181106116c957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050919050565b6000808585111561170d578182fd5b83861115611719578182fd5b505082019391909203915056fe4465706f736974436f6e74726163743a206d65726b6c6520747265652066756c6c4465706f736974436f6e74726163743a207265636f6e7374727563746564204465706f7369744461746120646f6573206e6f74206d6174636820737570706c696564206465706f7369745f646174615f726f6f744465706f736974436f6e74726163743a20696e76616c6964207769746864726177616c5f63726564656e7469616c73206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c7565206e6f74206d756c7469706c65206f6620677765694465706f736974436f6e74726163743a20696e76616c6964207075626b6579206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f20686967684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f206c6f774465706f736974436f6e74726163743a20696e76616c6964207369676e6174757265206c656e677468a2646970667358221220dceca8706b29e917dacf25fceef95acac8d90d765ac926663ce4096195952b6164736f6c634300060b0033", "storage": { "0x0000000000000000000000000000000000000000000000000000000000000022": "0xf5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b", "0x0000000000000000000000000000000000000000000000000000000000000023": "0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71", diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/00_get_genesis_block_info.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/00_get_genesis_block_info.json index d1a18826a9e..ca9c3ef7e75 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/00_get_genesis_block_info.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/00_get_genesis_block_info.json @@ -12,14 +12,14 @@ "id": 67, "result": { "number": "0x0", - "hash" : "0x38d7daa68e8bac41a0a237b7cbfcef480cb9bd9adc7b282d7b0d23ff4eb8d6e5", + "hash" : "0x01f5cbf33268c161f1526d704268db760bf82c9772a8f8ca412e0c6ce5684896", "mixHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "nonce" : "0x0000000000000042", "sha3Uncles" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", "logsBloom" : "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "transactionsRoot" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "0x3ed8435adb5f3526144e6babdd3fc8c661a86097cf7e743441b41fda096fc4dd", + "stateRoot" : "0x860be6ab5a8fc2003c3739bfe2cdbcd9dbb273c8ea42951b832a8e1f22fb3a60", "receiptsRoot" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "miner" : "0x0000000000000000000000000000000000000000", "difficulty" : "0x400000000", diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/01_cancun_prepare_payload.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/01_cancun_prepare_payload.json index ad4b9be2d08..e549da3f30e 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/01_cancun_prepare_payload.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/01_cancun_prepare_payload.json @@ -4,8 +4,8 @@ "method": "engine_forkchoiceUpdatedV3", "params": [ { - "headBlockHash": "0x38d7daa68e8bac41a0a237b7cbfcef480cb9bd9adc7b282d7b0d23ff4eb8d6e5", - "safeBlockHash": "0x38d7daa68e8bac41a0a237b7cbfcef480cb9bd9adc7b282d7b0d23ff4eb8d6e5", + "headBlockHash": "0x01f5cbf33268c161f1526d704268db760bf82c9772a8f8ca412e0c6ce5684896", + "safeBlockHash": "0x01f5cbf33268c161f1526d704268db760bf82c9772a8f8ca412e0c6ce5684896", "finalizedBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { @@ -24,10 +24,10 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0x38d7daa68e8bac41a0a237b7cbfcef480cb9bd9adc7b282d7b0d23ff4eb8d6e5", + "latestValidHash": "0x01f5cbf33268c161f1526d704268db760bf82c9772a8f8ca412e0c6ce5684896", "validationError": null }, - "payloadId": "0x28264396eca1deef" + "payloadId": "0x282643b677b85211" } }, "statusCode": 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/02_cancun_getPayloadV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/02_cancun_getPayloadV3.json index 63cfeec26a1..7a29443fefc 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/02_cancun_getPayloadV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/02_cancun_getPayloadV3.json @@ -3,7 +3,7 @@ "jsonrpc": "2.0", "method": "engine_getPayloadV3", "params": [ - "0x28264396eca1deef" + "0x282643b677b85211" ], "id": 67 }, @@ -12,9 +12,9 @@ "id": 67, "result": { "executionPayload": { - "parentHash": "0x38d7daa68e8bac41a0a237b7cbfcef480cb9bd9adc7b282d7b0d23ff4eb8d6e5", + "parentHash": "0x01f5cbf33268c161f1526d704268db760bf82c9772a8f8ca412e0c6ce5684896", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x3ed8435adb5f3526144e6babdd3fc8c661a86097cf7e743441b41fda096fc4dd", + "stateRoot": "0x860be6ab5a8fc2003c3739bfe2cdbcd9dbb273c8ea42951b832a8e1f22fb3a60", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -29,7 +29,7 @@ "blockNumber": "0x1", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "blobGasUsed": "0x0", - "blockHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593" + "blockHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e" }, "blockValue": "0x0", "blobsBundle": { diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/03_cancun_newPayloadV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/03_cancun_newPayloadV3.json index 9f984b2f350..d2191e83123 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/03_cancun_newPayloadV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/03_cancun_newPayloadV3.json @@ -4,9 +4,9 @@ "method": "engine_newPayloadV3", "params": [ { - "parentHash": "0x38d7daa68e8bac41a0a237b7cbfcef480cb9bd9adc7b282d7b0d23ff4eb8d6e5", + "parentHash": "0x01f5cbf33268c161f1526d704268db760bf82c9772a8f8ca412e0c6ce5684896", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x3ed8435adb5f3526144e6babdd3fc8c661a86097cf7e743441b41fda096fc4dd", + "stateRoot": "0x860be6ab5a8fc2003c3739bfe2cdbcd9dbb273c8ea42951b832a8e1f22fb3a60", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -14,13 +14,13 @@ "timestamp": "0x10", "extraData": "0x", "baseFeePerGas": "0x7", + "excessBlobGas": "0x0", "transactions": [], "withdrawals": [], "blockNumber": "0x1", - "blockHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593", - "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "excessBlobGas": "0x0", - "blobGasUsed": "0x0" + "blobGasUsed": "0x0", + "blockHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e", + "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" }, [], "0x0000000000000000000000000000000000000000000000000000000000000000" @@ -32,7 +32,7 @@ "id": 67, "result": { "status": "VALID", - "latestValidHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593", + "latestValidHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e", "validationError": null } }, diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/04_cancun_forkchoiceUpdatedV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/04_cancun_forkchoiceUpdatedV3.json index b0ce0f70c1a..8bbb71be339 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/04_cancun_forkchoiceUpdatedV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/04_cancun_forkchoiceUpdatedV3.json @@ -4,9 +4,9 @@ "method": "engine_forkchoiceUpdatedV3", "params": [ { - "headBlockHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593", - "safeBlockHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593", - "finalizedBlockHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593" + "headBlockHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e", + "safeBlockHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e", + "finalizedBlockHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e" }, null ], @@ -18,7 +18,7 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593", + "latestValidHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e", "validationError": null }, "payloadId": null diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/05_prague_forkchoiceUpdatedV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/05_prague_forkchoiceUpdatedV3.json index 1eae1c881ad..7e70a3bcacc 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/05_prague_forkchoiceUpdatedV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/05_prague_forkchoiceUpdatedV3.json @@ -4,9 +4,9 @@ "method": "engine_forkchoiceUpdatedV3", "params": [ { - "headBlockHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593", - "safeBlockHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593", - "finalizedBlockHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593" + "headBlockHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e", + "safeBlockHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e", + "finalizedBlockHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e" }, { "timestamp": "0x20", @@ -24,10 +24,10 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593", + "latestValidHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e", "validationError": null }, - "payloadId": "0x282643d3a905e721" + "payloadId": "0x282643fdcbcb1ddf" } }, "statusCode": 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/06_prague_getPayloadV4.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/06_prague_getPayloadV4.json index 4cb85d5f546..92c1bbcf2e5 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/06_prague_getPayloadV4.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/06_prague_getPayloadV4.json @@ -3,7 +3,7 @@ "jsonrpc": "2.0", "method": "engine_getPayloadV4", "params": [ - "0x282643d3a905e721" + "0x282643fdcbcb1ddf" ], "id": 67 }, @@ -12,9 +12,9 @@ "id": 67, "result": { "executionPayload": { - "parentHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593", + "parentHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x2e59916a57b535875bcd80d8472aeaa0027aa685d159804e8caa2f12d060155e", + "stateRoot": "0xed4093bcd157ba955245906a1cda7695d3b3f233af709f0adf17689abb4d93b4", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -23,22 +23,13 @@ "extraData": "0x", "baseFeePerGas": "0x7", "excessBlobGas": "0x0", + "blobGasUsed": "0x0", "parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000", "transactions": [], "withdrawals": [], - "depositRequests": [], - "withdrawalRequests": [ - { - "sourceAddress": "0xa4664c40aacebd82a2db79f0ea36c06bc6a19adb", - "validatorPubkey": "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e", - "amount": "0x0" - } - ], - "consolidationRequests" : [], "blockNumber": "0x2", - "blockHash": "0x27a2bc2ac21b3fc796f636bec1ec9cba100435f9a793176a83a5d4fa7cc13006", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "blobGasUsed": "0x0" + "blockHash": "0x303fb51567c090ed3fb7ac50a082ae3a0bcb8ff522d071011a1ca433561a4569" }, "blockValue": "0x0", "blobsBundle": { @@ -46,7 +37,12 @@ "proofs": [], "blobs": [] }, - "shouldOverrideBuilder": false + "shouldOverrideBuilder": false, + "executionRequests": [ + "0x", + "0xa4664c40aacebd82a2db79f0ea36c06bc6a19adbb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e0000000000000000", + "0x" + ] } }, "statusCode": 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/07_prague_send_raw_transaction.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/07_prague_send_raw_transaction_deposit_request.json similarity index 100% rename from acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/07_prague_send_raw_transaction.json rename to acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/07_prague_send_raw_transaction_deposit_request.json diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/08_prague_invalid_null_deposits_execute_payload.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/08_prague_invalid_null_deposit_request_execute_payload.json similarity index 88% rename from acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/08_prague_invalid_null_deposits_execute_payload.json rename to acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/08_prague_invalid_null_deposit_request_execute_payload.json index ed75e54aafb..14b6fc3d9ab 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/08_prague_invalid_null_deposits_execute_payload.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/08_prague_invalid_null_deposit_request_execute_payload.json @@ -17,24 +17,24 @@ "excessBlobGas": "0x0", "transactions": [], "withdrawals": [], - "depositRequests": null, "blockNumber": "0x2", "blockHash": "0x2331b2dc9c453e9a33685099742cbbcd529d42bd5681969f45754f06866c6766", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "blobGasUsed": "0x0" }, [], - "0x0000000000000000000000000000000000000000000000000000000000000000" + "0x0000000000000000000000000000000000000000000000000000000000000000", + null ], "id": 67 }, "response": { - "jsonrpc": "2.0", - "id": 67, - "error": { - "code": -32602, - "message": "Invalid params", - "data": "Missing deposit field" + "jsonrpc" : "2.0", + "id" : 67, + "error" : { + "code" : -32602, + "message" : "Invalid execution requests params", + "data" : "Missing execution requests field" } }, "statusCode": 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/09_prague_newPayloadV4.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/09_prague_newPayloadV4.json index 17496f9ed78..dcbbb3a8dfe 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/09_prague_newPayloadV4.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/09_prague_newPayloadV4.json @@ -4,9 +4,9 @@ "method": "engine_newPayloadV4", "params": [ { - "parentHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593", + "parentHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x961878fdcdff52ea42db0026f59aa414a5ec2835e56ed1a8ae50c80a9fe3a04b", + "stateRoot": "0x176ea6dfa3b8efb148a025f759cccfaab02db38427b12a4ede73491eda397196", "logsBloom": "0x10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -15,34 +15,22 @@ "extraData": "0x", "baseFeePerGas": "0x7", "excessBlobGas": "0x0", + "blobGasUsed": "0x0", "transactions": [ "0x02f9021c8217de808459682f008459682f0e830271009442424242424242424242424242424242424242428901bc16d674ec800000b901a422895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120749715de5d1226545c6b3790f515d551a5cc5bf1d49c87a696860554d2fc4f14000000000000000000000000000000000000000000000000000000000000003096a96086cff07df17668f35f7418ef8798079167e3f4f9b72ecde17b28226137cf454ab1dd20ef5d924786ab3483c2f9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020003f5102dabe0a27b1746098d1dc17a5d3fbd478759fea9287e4e419b3c3cef20000000000000000000000000000000000000000000000000000000000000060b1acdb2c4d3df3f1b8d3bfd33421660df358d84d78d16c4603551935f4b67643373e7eb63dcb16ec359be0ec41fee33b03a16e80745f2374ff1d3c352508ac5d857c6476d3c3bcf7e6ca37427c9209f17be3af5264c0e2132b3dd1156c28b4e9c080a09f597089338d7f44f5c59f8230bb38f243849228a8d4e9d2e2956e6050f5b2c7a076486996c7e62802b8f95eee114783e4b403fd11093ba96286ff42c595f24452" ], "withdrawals": [], - "depositRequests": [ - { - "amount": "0x773594000", - "index": "0x0", - "pubkey": "0x96a96086cff07df17668f35f7418ef8798079167e3f4f9b72ecde17b28226137cf454ab1dd20ef5d924786ab3483c2f9", - "signature": "0xb1acdb2c4d3df3f1b8d3bfd33421660df358d84d78d16c4603551935f4b67643373e7eb63dcb16ec359be0ec41fee33b03a16e80745f2374ff1d3c352508ac5d857c6476d3c3bcf7e6ca37427c9209f17be3af5264c0e2132b3dd1156c28b4e9", - "withdrawalCredentials": "0x003f5102dabe0a27b1746098d1dc17a5d3fbd478759fea9287e4e419b3c3cef2" - } - ], - "withdrawalRequests": [ - { - "sourceAddress": "0xa4664c40aacebd82a2db79f0ea36c06bc6a19adb", - "amount": "0x0", - "validatorPubkey": "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e" - } - ], - "consolidationRequests": [], "blockNumber": "0x2", - "blockHash": "0xc67a660f5d3c20ee603911bdff1e409e976f306883dff8ef4999dca3176f7dca", "receiptsRoot": "0x79ee3424eb720a3ad4b1c5a372bb8160580cbe4d893778660f34213c685627a9", - "blobGasUsed": "0x0" + "blockHash": "0x14ba5ec415d827d9cab33e6097b307131e8119a1cd7dc1f6a4de088ebfa4c1b6" }, [], - "0x0000000000000000000000000000000000000000000000000000000000000000" + "0x0000000000000000000000000000000000000000000000000000000000000000", + [ + "0xf84794a4664c40aacebd82a2db79f0ea36c06bc6a19adbb0b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e80", + "0xa4664c40aacebd82a2db79f0ea36c06bc6a19adbb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e0000000000000000", + "0x" + ] ], "id": 67 }, @@ -51,7 +39,7 @@ "id": 67, "result": { "status": "VALID", - "latestValidHash": "0xc67a660f5d3c20ee603911bdff1e409e976f306883dff8ef4999dca3176f7dca", + "latestValidHash": "0x14ba5ec415d827d9cab33e6097b307131e8119a1cd7dc1f6a4de088ebfa4c1b6", "validationError": null } }, diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/10_prague_forkchoiceUpdatedV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/10_prague_forkchoiceUpdatedV3.json index ba0f1e8e5bd..0c817637b32 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/10_prague_forkchoiceUpdatedV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/10_prague_forkchoiceUpdatedV3.json @@ -4,9 +4,9 @@ "method": "engine_forkchoiceUpdatedV3", "params": [ { - "headBlockHash": "0xc67a660f5d3c20ee603911bdff1e409e976f306883dff8ef4999dca3176f7dca", - "safeBlockHash": "0xc67a660f5d3c20ee603911bdff1e409e976f306883dff8ef4999dca3176f7dca", - "finalizedBlockHash": "0xc67a660f5d3c20ee603911bdff1e409e976f306883dff8ef4999dca3176f7dca" + "headBlockHash": "0x14ba5ec415d827d9cab33e6097b307131e8119a1cd7dc1f6a4de088ebfa4c1b6", + "safeBlockHash": "0x14ba5ec415d827d9cab33e6097b307131e8119a1cd7dc1f6a4de088ebfa4c1b6", + "finalizedBlockHash": "0x14ba5ec415d827d9cab33e6097b307131e8119a1cd7dc1f6a4de088ebfa4c1b6" }, { "timestamp": "0x30", @@ -24,10 +24,10 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0xc67a660f5d3c20ee603911bdff1e409e976f306883dff8ef4999dca3176f7dca", + "latestValidHash": "0x14ba5ec415d827d9cab33e6097b307131e8119a1cd7dc1f6a4de088ebfa4c1b6", "validationError": null }, - "payloadId": "0x282643a16a58b5cf" + "payloadId": "0x282643aeecfdbccf" } }, "statusCode": 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/11_prague_getPayloadV4.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/11_prague_getPayloadV4.json index 3b76fac10a1..df3080a657e 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/11_prague_getPayloadV4.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/11_prague_getPayloadV4.json @@ -3,7 +3,7 @@ "jsonrpc": "2.0", "method": "engine_getPayloadV4", "params": [ - "0x282643a16a58b5cf" + "0x282643aeecfdbccf" ], "id": 67 }, @@ -12,9 +12,9 @@ "id": 67, "result": { "executionPayload": { - "parentHash": "0xc67a660f5d3c20ee603911bdff1e409e976f306883dff8ef4999dca3176f7dca", + "parentHash": "0x14ba5ec415d827d9cab33e6097b307131e8119a1cd7dc1f6a4de088ebfa4c1b6", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x5fc31c01a451fe02f0e938de7ec7044aaba1159a81a1be64357bc70af226f304", + "stateRoot": "0xade3c29cae771ddfa994d3d2994f3bcbe084bc7bb23cdbb9bd7e35b39f007841", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -23,16 +23,13 @@ "extraData": "0x", "baseFeePerGas": "0x7", "excessBlobGas": "0x0", + "blobGasUsed": "0x0", "parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000", "transactions": [], "withdrawals": [], - "depositRequests": [], - "withdrawalRequests": [], - "consolidationRequests" : [], "blockNumber": "0x3", - "blockHash": "0xdbb55a049f14b8152695bf3bbd754aa1fd55bbe10b306eb49caa4bd7d7fcb634", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "blobGasUsed": "0x0" + "blockHash": "0x9f157012bdc439f5fe2bb3b4236eb07043e35d16256557d73e80a95d20054929" }, "blockValue": "0x0", "blobsBundle": { @@ -40,7 +37,12 @@ "proofs": [], "blobs": [] }, - "shouldOverrideBuilder": false + "shouldOverrideBuilder": false, + "executionRequests": [ + "0x", + "0x", + "0x" + ] } }, "statusCode": 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/12_cancun_newPayloadV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/12_cancun_newPayloadV3.json index 546872807c5..e0746e9f7fe 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/12_cancun_newPayloadV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/12_cancun_newPayloadV3.json @@ -4,9 +4,9 @@ "method": "engine_newPayloadV3", "params": [ { - "parentHash": "0xc67a660f5d3c20ee603911bdff1e409e976f306883dff8ef4999dca3176f7dca", + "parentHash": "0x14ba5ec415d827d9cab33e6097b307131e8119a1cd7dc1f6a4de088ebfa4c1b6", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x5fc31c01a451fe02f0e938de7ec7044aaba1159a81a1be64357bc70af226f304", + "stateRoot": "0xade3c29cae771ddfa994d3d2994f3bcbe084bc7bb23cdbb9bd7e35b39f007841", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -14,18 +14,21 @@ "timestamp": "0x30", "extraData": "0x", "baseFeePerGas": "0x7", + "excessBlobGas": "0x0", + "blobGasUsed": "0x0", "transactions": [], "withdrawals": [], - "depositRequests": [], - "withdrawalRequests": [], "blockNumber": "0x3", - "blockHash": "0xdbb55a049f14b8152695bf3bbd754aa1fd55bbe10b306eb49caa4bd7d7fcb634", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "excessBlobGas": "0x0", - "blobGasUsed": "0x0" + "blockHash": "0x9f157012bdc439f5fe2bb3b4236eb07043e35d16256557d73e80a95d20054929" }, [], - "0x0000000000000000000000000000000000000000000000000000000000000000" + "0x0000000000000000000000000000000000000000000000000000000000000000", + [ + "0x", + "0x", + "0x" + ] ], "id": 67 }, @@ -34,7 +37,7 @@ "id": 67, "result": { "status": "VALID", - "latestValidHash": "0xdbb55a049f14b8152695bf3bbd754aa1fd55bbe10b306eb49caa4bd7d7fcb634", + "latestValidHash": "0x9f157012bdc439f5fe2bb3b4236eb07043e35d16256557d73e80a95d20054929", "validationError": null } }, diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/15_prague_forkchoiceUpdatedV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/15_prague_forkchoiceUpdatedV3.json index 61750afbe74..31903a4f96a 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/15_prague_forkchoiceUpdatedV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/15_prague_forkchoiceUpdatedV3.json @@ -4,9 +4,9 @@ "method": "engine_forkchoiceUpdatedV3", "params": [ { - "headBlockHash": "0xdbb55a049f14b8152695bf3bbd754aa1fd55bbe10b306eb49caa4bd7d7fcb634", - "safeBlockHash": "0xdbb55a049f14b8152695bf3bbd754aa1fd55bbe10b306eb49caa4bd7d7fcb634", - "finalizedBlockHash": "0xdbb55a049f14b8152695bf3bbd754aa1fd55bbe10b306eb49caa4bd7d7fcb634" + "headBlockHash": "0x9f157012bdc439f5fe2bb3b4236eb07043e35d16256557d73e80a95d20054929", + "safeBlockHash": "0x9f157012bdc439f5fe2bb3b4236eb07043e35d16256557d73e80a95d20054929", + "finalizedBlockHash": "0x9f157012bdc439f5fe2bb3b4236eb07043e35d16256557d73e80a95d20054929" }, { "timestamp": "0x40", @@ -24,10 +24,10 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0xdbb55a049f14b8152695bf3bbd754aa1fd55bbe10b306eb49caa4bd7d7fcb634", + "latestValidHash": "0x9f157012bdc439f5fe2bb3b4236eb07043e35d16256557d73e80a95d20054929", "validationError": null }, - "payloadId": "0x28264396a9634d41" + "payloadId": "0x282643ae671b03bf" } }, "statusCode": 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/16_prague_getPayloadV4.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/16_prague_getPayloadV4.json index 51843931e7d..2f2d7c355cd 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/16_prague_getPayloadV4.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/16_prague_getPayloadV4.json @@ -3,7 +3,7 @@ "jsonrpc": "2.0", "method": "engine_getPayloadV4", "params": [ - "0x28264396a9634d41" + "0x282643ae671b03bf" ], "id": 67 }, @@ -12,50 +12,40 @@ "id": 67, "result": { "executionPayload": { - "parentHash": "0xdbb55a049f14b8152695bf3bbd754aa1fd55bbe10b306eb49caa4bd7d7fcb634", + "parentHash": "0x9f157012bdc439f5fe2bb3b4236eb07043e35d16256557d73e80a95d20054929", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x49df1f1a1d28a23fa752230d442077768787d392e9edb70c83d727d31e55eaac", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "stateRoot": "0xc7dbe7764cb5edd271a3e7fc4ffad23736aa1b8d4a5703e05a58db88d4ecbdc3", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000100000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000008000000000000000000000000000000000000000800000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", - "gasUsed": "0x3ad4d", + "gasUsed": "0x3b6c5", "timestamp": "0x40", "extraData": "0x", "baseFeePerGas": "0x7", "excessBlobGas": "0x0", + "blobGasUsed": "0x0", "parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000", "transactions": [ "0xf8a08085e8d4a51000832dc6c09400a3ca265ebcb825b45f985a16cefb49958ce01702b8388706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf2430000000000000000822fdfa00476c1a81f80f4c130acb5f8b8075468ba0893d766b7ec51a8d9723c573ad034a03bd3eaedabbaaf745f15023185ba66584ad3ee8bb40b9bef8c0b9ed27f8b1959", "0xf8c80185e8d4a51000832dc6c09400b42dbf2194e931e80326d950320f7d9dbeac0201b860fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe822fe0a05b88b593926d340f448918ef1c6263356c37f2434774e0fdb1cb9d90cfa5a23ba003a86aac4adb774181ba51eda17efb5fbed99ad57895e6eb56ccdf508a88a7cc" ], "withdrawals": [], - "depositRequests": [], - "withdrawalRequests": [ - { - "sourceAddress": "0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f", - "amount": "0x0", - "validatorPubkey": "0x8706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf243" - } - ], - "consolidationRequests": [ - { - "sourceAddress": "0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f", - "sourcePubkey": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "targetPubkey": "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe" - } - ], "blockNumber": "0x4", - "receiptsRoot": "0x970fc81bb3e7fb21435f9a65a184aa9e3fd2f52b89fd859302b46954354266b5", - "blobGasUsed": "0x0", - "blockHash": "0x93df6f3484202f24c692354e2ab96e9948ae45eea6ad85faea121a389e468ea8" + "receiptsRoot": "0x640f4036d53782ca4c5e9273ba6d657db4f5ff4fe526a8ed1997af9d0b8ae2d3", + "blockHash": "0x61642311e6c1e0af50abf17be1fcb6de8bd75af2ca2d188031d074f6e71bf5e6" }, - "blockValue": "0x3581baab15c12e5", + "blockValue": "0x360b8482c4b509d", "blobsBundle": { "commitments": [], "proofs": [], "blobs": [] }, - "shouldOverrideBuilder": false + "shouldOverrideBuilder": false, + "executionRequests": [ + "0x", + "0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f8706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf2430000000000000000", + "0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe" + ] } }, "statusCode": 200, diff --git a/besu/src/test/java/org/hyperledger/besu/services/RlpConverterServiceImplTest.java b/besu/src/test/java/org/hyperledger/besu/services/RlpConverterServiceImplTest.java index 7a3bdbbfe6b..b9ce7ccd5ca 100644 --- a/besu/src/test/java/org/hyperledger/besu/services/RlpConverterServiceImplTest.java +++ b/besu/src/test/java/org/hyperledger/besu/services/RlpConverterServiceImplTest.java @@ -38,7 +38,7 @@ public void testBuildRlpFromHeader() { new BlockHeaderTestFixture() .timestamp(1710338135 + 1) .baseFeePerGas(Wei.of(1000)) - .requestsRoot(Hash.ZERO) + .requestsHash(Hash.ZERO) .withdrawalsRoot(Hash.ZERO) .blobGasUsed(500L) .excessBlobGas(BlobGas.of(500L)) diff --git a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/PayloadWrapper.java b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/PayloadWrapper.java index 4a8588f84ef..603834c8699 100644 --- a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/PayloadWrapper.java +++ b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/PayloadWrapper.java @@ -18,12 +18,17 @@ import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.core.BlockValueCalculator; import org.hyperledger.besu.ethereum.core.BlockWithReceipts; +import org.hyperledger.besu.ethereum.core.Request; + +import java.util.List; +import java.util.Optional; /** Wrapper for payload plus extra info. */ public class PayloadWrapper { private final PayloadIdentifier payloadIdentifier; private final BlockWithReceipts blockWithReceipts; private final Wei blockValue; + private final Optional> requests; /** * Construct a wrapper with the following fields. @@ -32,10 +37,13 @@ public class PayloadWrapper { * @param blockWithReceipts Block with receipts */ public PayloadWrapper( - final PayloadIdentifier payloadIdentifier, final BlockWithReceipts blockWithReceipts) { + final PayloadIdentifier payloadIdentifier, + final BlockWithReceipts blockWithReceipts, + final Optional> requests) { this.blockWithReceipts = blockWithReceipts; this.payloadIdentifier = payloadIdentifier; this.blockValue = BlockValueCalculator.calculateBlockValue(blockWithReceipts); + this.requests = requests; } /** @@ -64,4 +72,13 @@ public PayloadIdentifier payloadIdentifier() { public BlockWithReceipts blockWithReceipts() { return blockWithReceipts; } + + /** + * Get the requests + * + * @return requests + */ + public Optional> requests() { + return requests; + } } diff --git a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java index c62b6e0de88..877d7fb9633 100644 --- a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java +++ b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java @@ -302,7 +302,9 @@ public PayloadIdentifier preparePayload( if (result.isSuccessful()) { mergeContext.putPayloadById( new PayloadWrapper( - payloadIdentifier, new BlockWithReceipts(emptyBlock, result.getReceipts()))); + payloadIdentifier, + new BlockWithReceipts(emptyBlock, result.getReceipts()), + result.getRequests())); LOG.info( "Start building proposals for block {} identified by {}", emptyBlock.getHeader().getNumber(), @@ -469,7 +471,9 @@ private void evaluateNewBlock( mergeContext.putPayloadById( new PayloadWrapper( - payloadIdentifier, new BlockWithReceipts(bestBlock, resultBest.getReceipts()))); + payloadIdentifier, + new BlockWithReceipts(bestBlock, resultBest.getReceipts()), + resultBest.getRequests())); LOG.atDebug() .setMessage( "Successfully built block {} for proposal identified by {}, with {} transactions, in {}ms") diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/messagewrappers/ProposalTest.java b/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/messagewrappers/ProposalTest.java index b3c462656ac..5b7314f94a2 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/messagewrappers/ProposalTest.java +++ b/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/messagewrappers/ProposalTest.java @@ -54,8 +54,7 @@ public class ProposalTest { new BlockBody( Collections.emptyList(), Collections.emptyList(), - Optional.of(Collections.emptyList()), - Optional.empty())); + Optional.of(Collections.emptyList()))); @Test public void canRoundTripProposalMessage() { diff --git a/datatypes/src/main/java/org/hyperledger/besu/datatypes/Hash.java b/datatypes/src/main/java/org/hyperledger/besu/datatypes/Hash.java index a53843a247f..3777169ed4d 100644 --- a/datatypes/src/main/java/org/hyperledger/besu/datatypes/Hash.java +++ b/datatypes/src/main/java/org/hyperledger/besu/datatypes/Hash.java @@ -15,6 +15,7 @@ package org.hyperledger.besu.datatypes; import static org.hyperledger.besu.crypto.Hash.keccak256; +import static org.hyperledger.besu.crypto.Hash.sha256; import org.hyperledger.besu.ethereum.rlp.RLP; @@ -50,6 +51,17 @@ public class Hash extends DelegatingBytes32 { */ public static final Hash EMPTY = hash(Bytes.EMPTY); + /** + * Hash of empty requests or "0x6036c41849da9c076ed79654d434017387a88fb833c2856b32e18218b3341c5f" + */ + public static final Hash EMPTY_REQUESTS_HASH = + Hash.wrap( + sha256( + Bytes.concatenate( + sha256(Bytes.of(RequestType.DEPOSIT.getSerializedType())), + sha256(Bytes.of(RequestType.WITHDRAWAL.getSerializedType())), + sha256(Bytes.of(RequestType.CONSOLIDATION.getSerializedType()))))); + /** * Instantiates a new Hash. * diff --git a/datatypes/src/test/java/org/hyperledger/besu/datatypes/HashTest.java b/datatypes/src/test/java/org/hyperledger/besu/datatypes/HashTest.java index 1ae3b8c14e7..a2ef3fe5591 100644 --- a/datatypes/src/test/java/org/hyperledger/besu/datatypes/HashTest.java +++ b/datatypes/src/test/java/org/hyperledger/besu/datatypes/HashTest.java @@ -26,4 +26,12 @@ public void shouldGetExpectedValueForEmptyHash() { .isEqualTo( Hash.fromHexString("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")); } + + @Test + public void shouldGetExpectedValueForEmptyRequestsHash() { + assertThat(Hash.EMPTY_REQUESTS_HASH) + .isEqualTo( + Hash.fromHexString( + "0x6036c41849da9c076ed79654d434017387a88fb833c2856b32e18218b3341c5f")); + } } diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseKey.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseKey.java index a62cc06ec26..bf5d12804b9 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseKey.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseKey.java @@ -38,5 +38,5 @@ public enum JsonRpcResponseKey { TRANSACTION_ROOT, BASEFEE, WITHDRAWALS_ROOT, - REQUESTS_ROOT + REQUESTS_HASH } diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseUtils.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseUtils.java index 4e067e6ec8a..d72db974b0a 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseUtils.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseUtils.java @@ -27,7 +27,7 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcResponseKey.OMMERS_HASH; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcResponseKey.PARENT_HASH; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcResponseKey.RECEIPTS_ROOT; -import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcResponseKey.REQUESTS_ROOT; +import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcResponseKey.REQUESTS_HASH; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcResponseKey.SIZE; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcResponseKey.STATE_ROOT; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcResponseKey.TIMESTAMP; @@ -104,8 +104,8 @@ public JsonRpcResponse response( final int size = unsignedInt(values.get(SIZE)); final Hash withdrawalsRoot = values.containsKey(WITHDRAWALS_ROOT) ? hash(values.get(WITHDRAWALS_ROOT)) : null; - final Hash requestsRoot = - values.containsKey(REQUESTS_ROOT) ? hash(values.get(REQUESTS_ROOT)) : null; + final Hash requestsHash = + values.containsKey(REQUESTS_HASH) ? hash(values.get(REQUESTS_HASH)) : null; final List ommers = new ArrayList<>(); final BlockHeader header = @@ -130,7 +130,7 @@ public JsonRpcResponse response( null, // ToDo 4844: set with the value of blob_gas_used field null, // ToDo 4844: set with the value of excess_blob_gas field null, // TODO 4788: set with the value of the parent beacon block root field - requestsRoot, + requestsHash, blockHeaderFunctions); return new JsonRpcSuccessResponse( diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/execution/TracedJsonRpcProcessor.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/execution/TracedJsonRpcProcessor.java index ec0e6aef64a..2a38afd630c 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/execution/TracedJsonRpcProcessor.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/execution/TracedJsonRpcProcessor.java @@ -79,6 +79,7 @@ public JsonRpcResponse process( case INVALID_ENGINE_PREPARE_PAYLOAD_PARAMS: case INVALID_ENODE_PARAMS: case INVALID_EXCESS_BLOB_GAS_PARAMS: + case INVALID_EXECUTION_REQUESTS_PARAMS: case INVALID_EXTRA_DATA_PARAMS: case INVALID_FILTER_PARAMS: case INVALID_GAS_PRICE_PARAMS: diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java index 78b96796cbd..308940f16aa 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java @@ -20,15 +20,14 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID_BLOCK_HASH; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.SYNCING; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.VALID; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.RequestValidatorProvider.getConsolidationRequestValidator; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.RequestValidatorProvider.getDepositRequestValidator; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.RequestValidatorProvider.getWithdrawalRequestValidator; +import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.RequestValidatorProvider.getRequestsValidator; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.WithdrawalsValidatorProvider.getWithdrawalsValidator; import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.BlobGas; import org.hyperledger.besu.datatypes.Hash; +import org.hyperledger.besu.datatypes.RequestType; import org.hyperledger.besu.datatypes.VersionedHash; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.BlockProcessingResult; @@ -36,12 +35,9 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcRequestException; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.ConsolidationRequestParameter; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositRequestParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalRequestParameter; 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; @@ -64,7 +60,6 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.mainnet.feemarket.ExcessBlobGasCalculator; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestUtil; import org.hyperledger.besu.ethereum.rlp.RLPException; import org.hyperledger.besu.ethereum.trie.MerkleTrieException; import org.hyperledger.besu.plugin.services.exception.StorageException; @@ -75,6 +70,7 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; +import java.util.stream.IntStream; import io.vertx.core.Vertx; import io.vertx.core.json.Json; @@ -141,8 +137,22 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext) final Optional maybeParentBeaconBlockRoot = maybeParentBeaconBlockRootParam.map(Bytes32::fromHexString); + final Optional> maybeRequestsParam; + try { + maybeRequestsParam = requestContext.getOptionalList(3, String.class); + } catch (JsonRpcParameterException e) { + throw new InvalidJsonRpcRequestException( + "Invalid execution request parameters (index 3)", + RpcErrorType.INVALID_EXECUTION_REQUESTS_PARAMS, + e); + } + final ValidationResult parameterValidationResult = - validateParameters(blockParam, maybeVersionedHashParam, maybeParentBeaconBlockRootParam); + validateParameters( + blockParam, + maybeVersionedHashParam, + maybeParentBeaconBlockRootParam, + maybeRequestsParam); if (!parameterValidationResult.isValid()) { return new JsonRpcErrorResponse(reqId, parameterValidationResult); } @@ -183,45 +193,24 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext) return new JsonRpcErrorResponse(reqId, RpcErrorType.INVALID_WITHDRAWALS_PARAMS); } - final Optional> maybeDepositRequests = - Optional.ofNullable(blockParam.getDepositRequests()) - .map(ds -> ds.stream().map(DepositRequestParameter::toDeposit).collect(toList())); - if (!getDepositRequestValidator( - protocolSchedule.get(), blockParam.getTimestamp(), blockParam.getBlockNumber()) - .validateParameter(maybeDepositRequests)) { - return new JsonRpcErrorResponse(reqId, RpcErrorType.INVALID_DEPOSIT_REQUEST_PARAMS); - } - - final Optional> maybeWithdrawalRequests = - Optional.ofNullable(blockParam.getWithdrawalRequests()) - .map( - withdrawalRequest -> - withdrawalRequest.stream() - .map(WithdrawalRequestParameter::toWithdrawalRequest) - .collect(toList())); - if (!getWithdrawalRequestValidator( - protocolSchedule.get(), blockParam.getTimestamp(), blockParam.getBlockNumber()) - .validateParameter(maybeWithdrawalRequests)) { - return new JsonRpcErrorResponse(reqId, RpcErrorType.INVALID_WITHDRAWALS_PARAMS); + final Optional> maybeRequests; + try { + maybeRequests = extractRequests(maybeRequestsParam); + } catch (RuntimeException ex) { + return respondWithInvalid( + reqId, + blockParam, + mergeCoordinator.getLatestValidAncestor(blockParam.getParentHash()).orElse(null), + INVALID, + "Invalid execution requests"); } - final Optional> maybeConsolidationRequests = - Optional.ofNullable(blockParam.getConsolidationRequests()) - .map( - consolidationRequest -> - consolidationRequest.stream() - .map(ConsolidationRequestParameter::toConsolidationRequest) - .collect(toList())); - if (!getConsolidationRequestValidator( + if (!getRequestsValidator( protocolSchedule.get(), blockParam.getTimestamp(), blockParam.getBlockNumber()) - .validateParameter(maybeConsolidationRequests)) { - return new JsonRpcErrorResponse(reqId, RpcErrorType.INVALID_CONSOLIDATION_REQUEST_PARAMS); + .validate(maybeRequests)) { + return new JsonRpcErrorResponse(reqId, RpcErrorType.INVALID_EXECUTION_REQUESTS_PARAMS); } - Optional> maybeRequests = - RequestUtil.combine( - maybeDepositRequests, maybeWithdrawalRequests, maybeConsolidationRequests); - if (mergeContext.get().isSyncing()) { LOG.debug("We are syncing"); return respondWith(reqId, blockParam, null, SYNCING); @@ -289,7 +278,7 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext) ? null : BlobGas.fromHexString(blockParam.getExcessBlobGas()), maybeParentBeaconBlockRoot.orElse(null), - maybeRequests.map(BodyValidation::requestsRoot).orElse(null), + maybeRequests.map(BodyValidation::requestsHash).orElse(null), headerFunctions); // ensure the block hash matches the blockParam hash @@ -351,8 +340,7 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext) final var block = new Block( - newBlockHeader, - new BlockBody(transactions, Collections.emptyList(), maybeWithdrawals, maybeRequests)); + newBlockHeader, new BlockBody(transactions, Collections.emptyList(), maybeWithdrawals)); if (maybeParentHeader.isEmpty()) { LOG.atDebug() @@ -466,7 +454,8 @@ protected EngineStatus getInvalidBlockHashStatus() { protected ValidationResult validateParameters( final EnginePayloadParameter parameter, final Optional> maybeVersionedHashParam, - final Optional maybeBeaconBlockRootParam) { + final Optional maybeBeaconBlockRootParam, + final Optional> maybeRequestsParam) { return ValidationResult.valid(); } @@ -562,6 +551,18 @@ private Optional> extractVersionedHashes( .collect(Collectors.toList())); } + private Optional> extractRequests(final Optional> maybeRequestsParam) { + if (maybeRequestsParam.isEmpty()) { + return Optional.empty(); + } + + return maybeRequestsParam.map( + requests -> + IntStream.range(0, requests.size()) + .mapToObj(i -> new Request(RequestType.of(i), Bytes.fromHexString(requests.get(i)))) + .collect(Collectors.toList())); + } + private void logImportedBlockInfo(final Block block, final int blobCount, final double timeInS) { final StringBuilder message = new StringBuilder(); message.append("Imported #%,d / %d tx"); @@ -572,10 +573,6 @@ private void logImportedBlockInfo(final Block block, final int blobCount, final message.append(" / %d ws"); messageArgs.add(block.getBody().getWithdrawals().get().size()); } - if (block.getBody().getRequests().isPresent()) { - message.append(" / %d rs"); - messageArgs.add(block.getBody().getRequests().get().size()); - } message.append(" / %d blobs / base fee %s / %,d (%01.1f%%) gas / (%s) in %01.3fs. Peers: %d"); messageArgs.addAll( List.of( diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2.java index acb177c3e03..00b0f830540 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2.java @@ -57,7 +57,8 @@ public String getName() { protected ValidationResult validateParameters( final EnginePayloadParameter payloadParameter, final Optional> maybeVersionedHashParam, - final Optional maybeBeaconBlockRootParam) { + final Optional maybeBeaconBlockRootParam, + final Optional> maybeRequestsParam) { if (payloadParameter.getBlobGasUsed() != null) { return ValidationResult.invalid( RpcErrorType.INVALID_BLOB_GAS_USED_PARAMS, "Missing blob gas used field"); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3.java index 7d13ecc02c4..8710e436274 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3.java @@ -55,7 +55,8 @@ public String getName() { protected ValidationResult validateParameters( final EnginePayloadParameter payloadParameter, final Optional> maybeVersionedHashParam, - final Optional maybeBeaconBlockRootParam) { + final Optional maybeBeaconBlockRootParam, + final Optional> maybeRequestsParam) { if (payloadParameter.getBlobGasUsed() == null) { return ValidationResult.invalid( RpcErrorType.INVALID_BLOB_GAS_USED_PARAMS, "Missing blob gas used field"); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4.java index 904ec08e5c2..0155e3d721a 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4.java @@ -55,7 +55,8 @@ public String getName() { protected ValidationResult validateParameters( final EnginePayloadParameter payloadParameter, final Optional> maybeVersionedHashParam, - final Optional maybeBeaconBlockRootParam) { + final Optional maybeBeaconBlockRootParam, + final Optional> maybeRequestsParam) { if (payloadParameter.getBlobGasUsed() == null) { return ValidationResult.invalid( RpcErrorType.INVALID_BLOB_GAS_USED_PARAMS, "Missing blob gas used field"); @@ -69,8 +70,9 @@ protected ValidationResult validateParameters( return ValidationResult.invalid( RpcErrorType.INVALID_PARENT_BEACON_BLOCK_ROOT_PARAMS, "Missing parent beacon block root field"); - } else if (payloadParameter.getDepositRequests() == null) { - return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing deposit field"); + } else if (maybeRequestsParam.isEmpty()) { + return ValidationResult.invalid( + RpcErrorType.INVALID_EXECUTION_REQUESTS_PARAMS, "Missing execution requests field"); } else { return ValidationResult.valid(); } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/RequestValidatorProvider.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/RequestValidatorProvider.java index c3d9c8376b2..046e630fcc6 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/RequestValidatorProvider.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/RequestValidatorProvider.java @@ -14,64 +14,25 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine; -import org.hyperledger.besu.datatypes.RequestType; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; -import org.hyperledger.besu.ethereum.mainnet.requests.ProhibitedRequestsValidator; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestValidator; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; +import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidator; import java.util.Optional; public class RequestValidatorProvider { - public static RequestValidator getDepositRequestValidator( + public static RequestsValidator getRequestsValidator( final ProtocolSchedule protocolSchedule, final long blockTimestamp, final long blockNumber) { - return getRequestValidator(protocolSchedule, blockTimestamp, blockNumber, RequestType.DEPOSIT); - } - - public static RequestValidator getWithdrawalRequestValidator( - final ProtocolSchedule protocolSchedule, final long blockTimestamp, final long blockNumber) { - return getRequestValidator( - protocolSchedule, blockTimestamp, blockNumber, RequestType.WITHDRAWAL); - } - - public static RequestValidator getConsolidationRequestValidator( - final ProtocolSchedule protocolSchedule, final long blockTimestamp, final long blockNumber) { - return getRequestValidator( - protocolSchedule, blockTimestamp, blockNumber, RequestType.CONSOLIDATION); - } - - private static RequestValidator getRequestValidator( - final ProtocolSchedule protocolSchedule, - final long blockTimestamp, - final long blockNumber, - final RequestType requestType) { - - RequestsValidatorCoordinator requestsValidatorCoordinator = - getRequestValidatorCoordinator(protocolSchedule, blockTimestamp, blockNumber); - return requestsValidatorCoordinator - .getRequestValidator(requestType) - .orElse(new ProhibitedRequestsValidator()); - } - - private static RequestsValidatorCoordinator getRequestValidatorCoordinator( - final ProtocolSchedule protocolSchedule, final long blockTimestamp, final long blockNumber) { - final BlockHeader blockHeader = BlockHeaderBuilder.createDefault() .timestamp(blockTimestamp) .number(blockNumber) .buildBlockHeader(); - return getRequestValidatorCoordinator(protocolSchedule.getByBlockHeader(blockHeader)); - } - - private static RequestsValidatorCoordinator getRequestValidatorCoordinator( - final ProtocolSpec protocolSchedule) { - return Optional.ofNullable(protocolSchedule) - .map(ProtocolSpec::getRequestsValidatorCoordinator) - .orElseGet(RequestsValidatorCoordinator::empty); + return Optional.ofNullable(protocolSchedule.getByBlockHeader(blockHeader)) + .map(ProtocolSpec::getRequestsValidator) + .orElse(v -> true); } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/ConsolidationRequestParameter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/ConsolidationRequestParameter.java deleted file mode 100644 index c6c600329d2..00000000000 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/ConsolidationRequestParameter.java +++ /dev/null @@ -1,102 +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.ethereum.api.jsonrpc.internal.parameters; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.ethereum.core.ConsolidationRequest; - -import java.util.Objects; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class ConsolidationRequestParameter { - - private final String sourceAddress; - private final String sourcePubkey; - private final String targetPubkey; - - @JsonCreator - public ConsolidationRequestParameter( - @JsonProperty("sourceAddress") final String sourceAddress, - @JsonProperty("sourcePubkey") final String sourcePubkey, - @JsonProperty("targetPubkey") final String targetPubkey) { - this.sourceAddress = sourceAddress; - this.sourcePubkey = sourcePubkey; - this.targetPubkey = targetPubkey; - } - - public static ConsolidationRequestParameter fromConsolidationRequest( - final ConsolidationRequest consolidationRequest) { - return new ConsolidationRequestParameter( - consolidationRequest.getSourceAddress().toHexString(), - consolidationRequest.getSourcePubkey().toHexString(), - consolidationRequest.getTargetPubkey().toHexString()); - } - - public ConsolidationRequest toConsolidationRequest() { - return new ConsolidationRequest( - Address.fromHexString(sourceAddress), - BLSPublicKey.fromHexString(sourcePubkey), - BLSPublicKey.fromHexString(targetPubkey)); - } - - @JsonGetter - public String getSourceAddress() { - return sourceAddress; - } - - @JsonGetter - public String getSourcePubkey() { - return sourcePubkey; - } - - @JsonGetter - public String getTargetPubkey() { - return targetPubkey; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final ConsolidationRequestParameter that = (ConsolidationRequestParameter) o; - return Objects.equals(sourceAddress, that.sourceAddress) - && Objects.equals(sourcePubkey, that.sourcePubkey) - && Objects.equals(targetPubkey, that.targetPubkey); - } - - @Override - public int hashCode() { - return Objects.hash(sourceAddress, sourcePubkey, targetPubkey); - } - - @Override - public String toString() { - return "ConsolidationRequestParameter{" - + "sourceAddress='" - + sourceAddress - + '\'' - + ", sourcePubkey='" - + sourcePubkey - + '\'' - + ", targetPubkey='" - + targetPubkey - + '\'' - + '}'; - } -} diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestParameter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestParameter.java deleted file mode 100644 index 39d6476ca46..00000000000 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestParameter.java +++ /dev/null @@ -1,144 +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.ethereum.api.jsonrpc.internal.parameters; - -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.BLSSignature; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.ethereum.core.DepositRequest; - -import java.util.Objects; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.vertx.core.json.JsonObject; -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt64; - -public class DepositRequestParameter { - - private final String pubkey; - - private final String withdrawalCredentials; - private final String amount; - - private final String signature; - private final String index; - - @JsonCreator - public DepositRequestParameter( - @JsonProperty("pubkey") final String pubkey, - @JsonProperty("withdrawalCredentials") final String withdrawalCredentials, - @JsonProperty("amount") final String amount, - @JsonProperty("signature") final String signature, - @JsonProperty("index") final String index) { - this.pubkey = pubkey; - this.withdrawalCredentials = withdrawalCredentials; - this.amount = amount; - this.signature = signature; - this.index = index; - } - - public static DepositRequestParameter fromDeposit(final DepositRequest depositRequest) { - return new DepositRequestParameter( - depositRequest.getPubkey().toString(), - depositRequest.getWithdrawalCredentials().toString(), - depositRequest.getAmount().toShortHexString(), - depositRequest.getSignature().toString(), - depositRequest.getIndex().toBytes().toQuantityHexString()); - } - - public DepositRequest toDeposit() { - return new DepositRequest( - BLSPublicKey.fromHexString(pubkey), - Bytes32.fromHexString(withdrawalCredentials), - GWei.fromHexString(amount), - BLSSignature.fromHexString(signature), - UInt64.fromHexString(index)); - } - - public JsonObject asJsonObject() { - return new JsonObject() - .put("pubkey", pubkey) - .put("withdrawalCredentials", withdrawalCredentials) - .put("amount", amount) - .put("signature", signature) - .put("index", index); - } - - @JsonGetter - public String getPubkey() { - return pubkey; - } - - @JsonGetter - public String getWithdrawalCredentials() { - return withdrawalCredentials; - } - - @JsonGetter - public String getAmount() { - return amount; - } - - @JsonGetter - public String getSignature() { - return signature; - } - - @JsonGetter - public String getIndex() { - return index; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final DepositRequestParameter that = (DepositRequestParameter) o; - return Objects.equals(pubkey, that.pubkey) - && Objects.equals(withdrawalCredentials, that.withdrawalCredentials) - && Objects.equals(amount, that.amount) - && Objects.equals(signature, that.signature) - && Objects.equals(index, that.index); - } - - @Override - public int hashCode() { - return Objects.hash(pubkey, withdrawalCredentials, amount, signature, index); - } - - @Override - public String toString() { - return "DepositRequestParameter{" - + "pubKey='" - + pubkey - + '\'' - + ", withdrawalCredentials='" - + withdrawalCredentials - + '\'' - + ", amount='" - + amount - + '\'' - + ", signature='" - + signature - + '\'' - + ", index='" - + index - + '\'' - + '}'; - } -} 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 fdcec45c6bd..415ba3c69bc 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 @@ -43,9 +43,6 @@ public class EnginePayloadParameter { private final List withdrawals; private final Long blobGasUsed; private final String excessBlobGas; - private final List depositRequests; - private final List withdrawalRequests; - private final List consolidationRequests; /** * Creates an instance of EnginePayloadParameter. @@ -67,9 +64,6 @@ public class EnginePayloadParameter { * @param withdrawals Array of Withdrawal * @param blobGasUsed QUANTITY, 64 Bits * @param excessBlobGas QUANTITY, 64 Bits - * @param depositRequests List of deposit parameters. - * @param withdrawalRequestParameters List of withdrawal requests parameters. - * @param consolidationRequests List of consolidation requests parameters. */ @JsonCreator public EnginePayloadParameter( @@ -89,12 +83,7 @@ public EnginePayloadParameter( @JsonProperty("transactions") final List transactions, @JsonProperty("withdrawals") final List withdrawals, @JsonProperty("blobGasUsed") final UnsignedLongParameter blobGasUsed, - @JsonProperty("excessBlobGas") final String excessBlobGas, - @JsonProperty("depositRequests") final List depositRequests, - @JsonProperty("withdrawalRequests") - final List withdrawalRequestParameters, - @JsonProperty("consolidationRequests") - final List consolidationRequests) { + @JsonProperty("excessBlobGas") final String excessBlobGas) { this.blockHash = blockHash; this.parentHash = parentHash; this.feeRecipient = feeRecipient; @@ -112,9 +101,6 @@ public EnginePayloadParameter( this.withdrawals = withdrawals; this.blobGasUsed = blobGasUsed == null ? null : blobGasUsed.getValue(); this.excessBlobGas = excessBlobGas; - this.depositRequests = depositRequests; - this.withdrawalRequests = withdrawalRequestParameters; - this.consolidationRequests = consolidationRequests; } public Hash getBlockHash() { @@ -184,16 +170,4 @@ public Long getBlobGasUsed() { public String getExcessBlobGas() { return excessBlobGas; } - - public List getDepositRequests() { - return depositRequests; - } - - public List getWithdrawalRequests() { - return withdrawalRequests; - } - - public List getConsolidationRequests() { - return consolidationRequests; - } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestParameter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestParameter.java deleted file mode 100644 index 3561da37a80..00000000000 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestParameter.java +++ /dev/null @@ -1,103 +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.ethereum.api.jsonrpc.internal.parameters; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; - -import java.util.Objects; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class WithdrawalRequestParameter { - - private final String sourceAddress; - private final String validatorPubkey; - private final String amount; - - @JsonCreator - public WithdrawalRequestParameter( - @JsonProperty("sourceAddress") final String sourceAddress, - @JsonProperty("validatorPubkey") final String validatorPubkey, - @JsonProperty("amount") final String amount) { - this.sourceAddress = sourceAddress; - this.validatorPubkey = validatorPubkey; - this.amount = amount; - } - - public static WithdrawalRequestParameter fromWithdrawalRequest( - final WithdrawalRequest withdrawalRequest) { - return new WithdrawalRequestParameter( - withdrawalRequest.getSourceAddress().toHexString(), - withdrawalRequest.getValidatorPubkey().toHexString(), - withdrawalRequest.getAmount().toShortHexString()); - } - - public WithdrawalRequest toWithdrawalRequest() { - return new WithdrawalRequest( - Address.fromHexString(sourceAddress), - BLSPublicKey.fromHexString(validatorPubkey), - GWei.fromHexString(amount)); - } - - @JsonGetter - public String getSourceAddress() { - return sourceAddress; - } - - @JsonGetter - public String getValidatorPubkey() { - return validatorPubkey; - } - - @JsonGetter - public String getAmount() { - return amount; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final WithdrawalRequestParameter that = (WithdrawalRequestParameter) o; - return Objects.equals(sourceAddress, that.sourceAddress) - && Objects.equals(validatorPubkey, that.validatorPubkey) - && Objects.equals(amount, that.amount); - } - - @Override - public int hashCode() { - return Objects.hash(sourceAddress, validatorPubkey, amount); - } - - @Override - public String toString() { - return "WithdrawalRequestParameter{" - + "sourceAddress='" - + sourceAddress - + '\'' - + ", validatorPubkey='" - + validatorPubkey - + '\'' - + ", amount='" - + amount - + '\'' - + '}'; - } -} 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 875eab601ba..a2b7d175918 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 @@ -62,6 +62,7 @@ public enum RpcErrorType implements RpcMethodError { INVALID_ENODE_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid enode params"), INVALID_EXCESS_BLOB_GAS_PARAMS( INVALID_PARAMS_ERROR_CODE, "Invalid excess blob gas params (missing or invalid)"), + INVALID_EXECUTION_REQUESTS_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid execution requests params"), INVALID_EXTRA_DATA_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid extra data params"), INVALID_FILTER_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid filter params"), INVALID_GAS_PRICE_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid gas price params"), 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 b8111c00c76..66bb879569a 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 @@ -14,10 +14,6 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results; -import static org.hyperledger.besu.ethereum.mainnet.requests.RequestUtil.getConsolidationRequests; -import static org.hyperledger.besu.ethereum.mainnet.requests.RequestUtil.getDepositRequests; -import static org.hyperledger.besu.ethereum.mainnet.requests.RequestUtil.getWithdrawalRequests; - import org.hyperledger.besu.consensus.merge.PayloadWrapper; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EngineGetPayloadBodiesResultV1.PayloadBody; @@ -26,10 +22,12 @@ 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.Request; import org.hyperledger.besu.ethereum.core.encoding.EncodingContext; import org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; @@ -162,6 +160,15 @@ public EngineGetPayloadResultV4 payloadTransactionCompleteV4(final PayloadWrappe TransactionEncoder.encodeOpaqueBytes(transaction, EncodingContext.BLOCK_BODY)) .map(Bytes::toHexString) .collect(Collectors.toList()); + final Optional> requestsWithoutRequestId = + payload + .requests() + .map( + rqs -> + rqs.stream() + .sorted(Comparator.comparing(Request::getType)) + .map(r -> r.getData().toHexString()) + .toList()); final BlobsBundleV1 blobsBundleV1 = new BlobsBundleV1(blockWithReceipts.getBlock().getBody().getTransactions()); @@ -169,9 +176,7 @@ public EngineGetPayloadResultV4 payloadTransactionCompleteV4(final PayloadWrappe blockWithReceipts.getHeader(), txs, blockWithReceipts.getBlock().getBody().getWithdrawals(), - getDepositRequests(blockWithReceipts.getBlock().getBody().getRequests()), - getWithdrawalRequests(blockWithReceipts.getBlock().getBody().getRequests()), - getConsolidationRequests(blockWithReceipts.getBlock().getBody().getRequests()), + requestsWithoutRequestId, Quantity.create(payload.blockValue()), blobsBundleV1); } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV4.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV4.java index 39772ff7dbf..017de4653ca 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV4.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV4.java @@ -14,15 +14,9 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.ConsolidationRequestParameter; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositRequestParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalRequestParameter; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.ConsolidationRequest; -import org.hyperledger.besu.ethereum.core.DepositRequest; import org.hyperledger.besu.ethereum.core.Withdrawal; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; import java.util.List; import java.util.Optional; @@ -33,33 +27,32 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; import org.apache.tuweni.bytes.Bytes32; -@JsonPropertyOrder({"executionPayload", "blockValue", "blobsBundle", "shouldOverrideBuilder"}) +@JsonPropertyOrder({ + "executionPayload", + "blockValue", + "blobsBundle", + "shouldOverrideBuilder", + "executionRequests" +}) public class EngineGetPayloadResultV4 { protected final PayloadResult executionPayload; private final String blockValue; private final BlobsBundleV1 blobsBundle; private final boolean shouldOverrideBuilder; + private final List executionRequests; public EngineGetPayloadResultV4( final BlockHeader header, final List transactions, final Optional> withdrawals, - final Optional> depositRequests, - final Optional> withdrawalRequests, - final Optional> consolidationRequests, + final Optional> executionRequests, final String blockValue, final BlobsBundleV1 blobsBundle) { - this.executionPayload = - new PayloadResult( - header, - transactions, - withdrawals, - depositRequests, - withdrawalRequests, - consolidationRequests); + this.executionPayload = new PayloadResult(header, transactions, withdrawals); this.blockValue = blockValue; this.blobsBundle = blobsBundle; this.shouldOverrideBuilder = false; + this.executionRequests = executionRequests.orElse(null); } @JsonGetter(value = "executionPayload") @@ -82,6 +75,11 @@ public boolean shouldOverrideBuilder() { return shouldOverrideBuilder; } + @JsonGetter(value = "executionRequests") + public List getExecutionRequests() { + return executionRequests; + } + public static class PayloadResult { protected final String blockHash; @@ -103,17 +101,11 @@ public static class PayloadResult { protected final List transactions; private final List withdrawals; - private final List depositRequests; - private final List withdrawalRequests; - private final List consolidationRequests; public PayloadResult( final BlockHeader header, final List transactions, - final Optional> withdrawals, - final Optional> depositRequests, - final Optional> withdrawalRequests, - final Optional> consolidationRequests) { + final Optional> withdrawals) { this.blockNumber = Quantity.create(header.getNumber()); this.blockHash = header.getHash().toString(); this.parentHash = header.getParentHash().toString(); @@ -136,30 +128,6 @@ public PayloadResult( .map(WithdrawalParameter::fromWithdrawal) .collect(Collectors.toList())) .orElse(null); - this.depositRequests = - depositRequests - .map( - ds -> - ds.stream() - .map(DepositRequestParameter::fromDeposit) - .collect(Collectors.toList())) - .orElse(null); - this.withdrawalRequests = - withdrawalRequests - .map( - wr -> - wr.stream() - .map(WithdrawalRequestParameter::fromWithdrawalRequest) - .collect(Collectors.toList())) - .orElse(null); - this.consolidationRequests = - consolidationRequests - .map( - wr -> - wr.stream() - .map(ConsolidationRequestParameter::fromConsolidationRequest) - .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); @@ -237,21 +205,6 @@ public List getWithdrawals() { return withdrawals; } - @JsonGetter(value = "depositRequests") - public List getDepositRequests() { - return depositRequests; - } - - @JsonGetter(value = "withdrawalRequests") - public List getWithdrawalRequests() { - return withdrawalRequests; - } - - @JsonGetter(value = "consolidationRequests") - public List getConsolidationRequests() { - return consolidationRequests; - } - @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/AbstractEngineGetPayloadTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineGetPayloadTest.java index f18b5601cf4..1cfc51396d4 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineGetPayloadTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineGetPayloadTest.java @@ -99,32 +99,27 @@ public AbstractEngineGetPayloadTest() { protected static final BlockWithReceipts mockBlockWithReceipts = new BlockWithReceipts(mockBlock, Collections.emptyList()); protected static final PayloadWrapper mockPayload = - new PayloadWrapper(mockPid, mockBlockWithReceipts); + new PayloadWrapper(mockPid, mockBlockWithReceipts, Optional.empty()); private static final Block mockBlockWithWithdrawals = new Block( mockHeader, new BlockBody( Collections.emptyList(), Collections.emptyList(), - Optional.of(Collections.emptyList()), - Optional.empty())); + Optional.of(Collections.emptyList()))); private static final Block mockBlockWithDepositRequests = new Block( mockHeader, - new BlockBody( - Collections.emptyList(), - Collections.emptyList(), - Optional.empty(), - Optional.of(Collections.emptyList()))); + new BlockBody(Collections.emptyList(), Collections.emptyList(), Optional.empty())); protected static final BlockWithReceipts mockBlockWithReceiptsAndWithdrawals = new BlockWithReceipts(mockBlockWithWithdrawals, Collections.emptyList()); protected static final PayloadWrapper mockPayloadWithWithdrawals = - new PayloadWrapper(mockPid, mockBlockWithReceiptsAndWithdrawals); + new PayloadWrapper(mockPid, mockBlockWithReceiptsAndWithdrawals, Optional.empty()); protected static final BlockWithReceipts mockBlockWithReceiptsAndDepositRequests = new BlockWithReceipts(mockBlockWithDepositRequests, Collections.emptyList()); protected static final PayloadWrapper mockPayloadWithDepositRequests = - new PayloadWrapper(mockPid, mockBlockWithReceiptsAndDepositRequests); + new PayloadWrapper(mockPid, mockBlockWithReceiptsAndDepositRequests, Optional.empty()); @Mock protected ProtocolContext protocolContext; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayloadTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayloadTest.java index 9b3e94330eb..e793ee8b577 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayloadTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayloadTest.java @@ -38,12 +38,9 @@ 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.methods.ExecutionEngineJsonRpcMethod; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.ConsolidationRequestParameter; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositRequestParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.UnsignedLongParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalRequestParameter; 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; @@ -54,20 +51,17 @@ 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.DepositRequest; import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Withdrawal; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; import org.hyperledger.besu.ethereum.eth.manager.EthPeers; import org.hyperledger.besu.ethereum.mainnet.BodyValidation; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.mainnet.WithdrawalsValidator; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; +import org.hyperledger.besu.ethereum.mainnet.requests.ProhibitedRequestValidator; import org.hyperledger.besu.ethereum.trie.MerkleTrieException; import org.hyperledger.besu.plugin.services.exception.StorageException; import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Optional; @@ -130,7 +124,6 @@ public void shouldReturnValid() { setupValidPayload( new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), Optional.empty(), - Optional.empty(), Optional.empty()); lenient() .when(blockchain.getBlockHeader(mockHeader.getParentHash())) @@ -144,10 +137,7 @@ public void shouldReturnValid() { public void shouldReturnInvalidOnBlockExecutionError() { BlockHeader mockHeader = setupValidPayload( - new BlockProcessingResult("error 42"), - Optional.empty(), - Optional.empty(), - Optional.empty()); + new BlockProcessingResult("error 42"), Optional.empty(), Optional.empty()); lenient() .when(blockchain.getBlockHeader(mockHeader.getParentHash())) .thenReturn(Optional.of(mock(BlockHeader.class))); @@ -162,8 +152,7 @@ public void shouldReturnInvalidOnBlockExecutionError() { @Test public void shouldReturnAcceptedOnLatestValidAncestorEmpty() { - BlockHeader mockHeader = - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()); + BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty()); when(blockchain.getBlockByHash(mockHeader.getHash())).thenReturn(Optional.empty()); when(blockchain.getBlockHeader(mockHeader.getParentHash())) .thenReturn(Optional.of(mock(BlockHeader.class))); @@ -181,8 +170,7 @@ public void shouldReturnAcceptedOnLatestValidAncestorEmpty() { @Test public void shouldReturnSuccessOnAlreadyPresent() { - BlockHeader mockHeader = - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()); + BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty()); Block mockBlock = new Block(mockHeader, new BlockBody(Collections.emptyList(), Collections.emptyList())); @@ -195,8 +183,7 @@ public void shouldReturnSuccessOnAlreadyPresent() { @Test public void shouldReturnInvalidWithLatestValidHashIsABadBlock() { - BlockHeader mockHeader = - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()); + BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty()); Hash latestValidHash = Hash.hash(Bytes32.fromHexStringLenient("0xcafebabe")); when(blockchain.getBlockByHash(mockHeader.getHash())).thenReturn(Optional.empty()); @@ -218,7 +205,6 @@ public void shouldNotReturnInvalidOnStorageException() { setupValidPayload( new BlockProcessingResult(Optional.empty(), new StorageException("database bedlam")), Optional.empty(), - Optional.empty(), Optional.empty()); lenient() .when(blockchain.getBlockHeader(mockHeader.getParentHash())) @@ -235,7 +221,6 @@ public void shouldNotReturnInvalidOnHandledMerkleTrieException() { setupValidPayload( new BlockProcessingResult(Optional.empty(), new MerkleTrieException("missing leaf")), Optional.empty(), - Optional.empty(), Optional.empty()); lenient() @@ -250,8 +235,7 @@ public void shouldNotReturnInvalidOnHandledMerkleTrieException() { @Test public void shouldNotReturnInvalidOnThrownMerkleTrieException() { - BlockHeader mockHeader = - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()); + BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty()); when(blockchain.getBlockByHash(mockHeader.getHash())).thenReturn(Optional.empty()); when(blockchain.getBlockHeader(mockHeader.getParentHash())) .thenReturn(Optional.of(mock(BlockHeader.class))); @@ -268,8 +252,7 @@ public void shouldNotReturnInvalidOnThrownMerkleTrieException() { @Test public void shouldReturnInvalidBlockHashOnBadHashParameter() { - BlockHeader mockHeader = - spy(createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty())); + BlockHeader mockHeader = spy(createBlockHeader(Optional.empty(), Optional.empty())); lenient() .when(mergeCoordinator.getLatestValidAncestor(mockHeader.getBlockHash())) .thenReturn(Optional.empty()); @@ -286,8 +269,7 @@ public void shouldReturnInvalidBlockHashOnBadHashParameter() { @Test public void shouldCheckBlockValidityBeforeCheckingByHashForExisting() { - BlockHeader realHeader = - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()); + BlockHeader realHeader = createBlockHeader(Optional.empty(), Optional.empty()); BlockHeader paramHeader = spy(realHeader); when(paramHeader.getHash()).thenReturn(Hash.fromHexStringLenient("0x1337")); @@ -301,8 +283,7 @@ public void shouldCheckBlockValidityBeforeCheckingByHashForExisting() { @Test public void shouldReturnInvalidOnMalformedTransactions() { - BlockHeader mockHeader = - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()); + BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty()); when(mergeCoordinator.getLatestValidAncestor(any(Hash.class))) .thenReturn(Optional.of(mockHash)); @@ -317,8 +298,7 @@ public void shouldReturnInvalidOnMalformedTransactions() { @Test public void shouldRespondWithSyncingDuringForwardSync() { - BlockHeader mockHeader = - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()); + BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty()); when(mergeContext.isSyncing()).thenReturn(Boolean.TRUE); var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList())); @@ -331,8 +311,7 @@ public void shouldRespondWithSyncingDuringForwardSync() { @Test public void shouldRespondWithSyncingDuringBackwardsSync() { - BlockHeader mockHeader = - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()); + BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty()); when(mergeCoordinator.appendNewPayloadToSync(any())) .thenReturn(CompletableFuture.completedFuture(null)); var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList())); @@ -346,8 +325,7 @@ public void shouldRespondWithSyncingDuringBackwardsSync() { @Test public void shouldRespondWithInvalidIfExtraDataIsNull() { - BlockHeader realHeader = - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()); + BlockHeader realHeader = createBlockHeader(Optional.empty(), Optional.empty()); BlockHeader paramHeader = spy(realHeader); when(paramHeader.getHash()).thenReturn(Hash.fromHexStringLenient("0x1337")); when(paramHeader.getExtraData().toHexString()).thenReturn(null); @@ -364,8 +342,7 @@ public void shouldRespondWithInvalidIfExtraDataIsNull() { @Test public void shouldReturnInvalidWhenBadBlock() { when(mergeCoordinator.isBadBlock(any(Hash.class))).thenReturn(true); - BlockHeader mockHeader = - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()); + BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty()); var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList())); when(protocolSpec.getWithdrawalsValidator()) .thenReturn(new WithdrawalsValidator.AllowedWithdrawals()); @@ -383,7 +360,6 @@ public void shouldReturnValidIfProtocolScheduleIsEmpty() { setupValidPayload( new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), Optional.empty(), - Optional.empty(), Optional.empty()); lenient() .when(blockchain.getBlockHeader(mockHeader.getParentHash())) @@ -404,16 +380,13 @@ protected JsonRpcResponse resp(final EnginePayloadParameter payload) { protected EnginePayloadParameter mockEnginePayload( final BlockHeader header, final List txs) { - return mockEnginePayload(header, txs, null, null, null, null); + return mockEnginePayload(header, txs, null); } protected EnginePayloadParameter mockEnginePayload( final BlockHeader header, final List txs, - final List withdrawals, - final List depositRequests, - final List withdrawalRequests, - final List consolidationRequests) { + final List withdrawals) { return new EnginePayloadParameter( header.getHash(), header.getParentHash(), @@ -431,23 +404,16 @@ protected EnginePayloadParameter mockEnginePayload( txs, withdrawals, header.getBlobGasUsed().map(UnsignedLongParameter::new).orElse(null), - header.getExcessBlobGas().map(BlobGas::toHexString).orElse(null), - depositRequests, - withdrawalRequests, - consolidationRequests); + header.getExcessBlobGas().map(BlobGas::toHexString).orElse(null)); } protected BlockHeader setupValidPayload( final BlockProcessingResult value, final Optional> maybeWithdrawals, - final Optional> maybeDepositRequests, - final Optional> maybeWithdrawalRequests) { + final Optional> maybeRequests) { - BlockHeader mockHeader = - createBlockHeader(maybeWithdrawals, maybeDepositRequests, maybeWithdrawalRequests); + BlockHeader mockHeader = createBlockHeader(maybeWithdrawals, maybeRequests); when(blockchain.getBlockByHash(mockHeader.getHash())).thenReturn(Optional.empty()); - // when(blockchain.getBlockHeader(mockHeader.getParentHash())) - // .thenReturn(Optional.of(mock(BlockHeader.class))); when(mergeCoordinator.getLatestValidAncestor(any(BlockHeader.class))) .thenReturn(Optional.of(mockHash)); when(mergeCoordinator.rememberBlock(any())).thenReturn(value); @@ -477,27 +443,8 @@ protected JsonRpcError fromErrorResp(final JsonRpcResponse resp) { protected BlockHeader createBlockHeader( final Optional> maybeWithdrawals, - final Optional> maybeDepositRequests, - final Optional> maybeWithdrawalRequests) { - return createBlockHeaderFixture(maybeWithdrawals, maybeDepositRequests, maybeWithdrawalRequests) - .buildHeader(); - } - - protected BlockHeaderTestFixture createBlockHeaderFixture( - final Optional> maybeWithdrawals, - final Optional> maybeDepositRequests, - final Optional> maybeWithdrawalRequests) { - - Optional> maybeRequests; - if (maybeDepositRequests.isPresent() || maybeWithdrawalRequests.isPresent()) { - List requests = new ArrayList<>(); - maybeDepositRequests.ifPresent(requests::addAll); - maybeWithdrawalRequests.ifPresent(requests::addAll); - maybeRequests = Optional.of(requests); - } else { - maybeRequests = Optional.empty(); - } - return createBlockHeaderFixture(maybeWithdrawals, maybeRequests); + final Optional> maybeRequests) { + return createBlockHeaderFixture(maybeWithdrawals, maybeRequests).buildHeader(); } protected BlockHeaderTestFixture createBlockHeaderFixture( @@ -512,7 +459,7 @@ protected BlockHeaderTestFixture createBlockHeaderFixture( .timestamp(parentBlockHeader.getTimestamp() + 1) .withdrawalsRoot(maybeWithdrawals.map(BodyValidation::withdrawalsRoot).orElse(null)) .parentBeaconBlockRoot(maybeParentBeaconBlockRoot) - .requestsRoot(maybeRequests.map(BodyValidation::requestsRoot).orElse(null)); + .requestsHash(maybeRequests.map(BodyValidation::requestsHash).orElse(null)); } protected void assertValidResponse(final BlockHeader mockHeader, final JsonRpcResponse resp) { @@ -524,7 +471,7 @@ protected void assertValidResponse(final BlockHeader mockHeader, final JsonRpcRe } private void mockProhibitedRequestsValidator() { - var validator = RequestsValidatorCoordinator.empty(); - when(protocolSpec.getRequestsValidatorCoordinator()).thenReturn(validator); + var validator = new ProhibitedRequestValidator(); + when(protocolSpec.getRequestsValidator()).thenReturn(validator); } } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByHashV1Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByHashV1Test.java index 8a99fa94392..f7752a7977f 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByHashV1Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByHashV1Test.java @@ -180,7 +180,6 @@ public void shouldReturnWithdrawalNullWhenBlockIsPreShanghai() { new BlockBody( List.of(new TransactionTestFixture().createTransaction(sig.generateKeyPair())), Collections.emptyList(), - Optional.empty(), Optional.empty()); when(blockchain.getBlockBody(blockHash1)).thenReturn(Optional.of(preShanghaiBlockBody)); when(blockchain.getBlockBody(blockHash2)).thenReturn(Optional.of(preShanghaiBlockBody2)); @@ -211,15 +210,13 @@ public void shouldReturnWithdrawalsWhenBlockIsPostShanghai() { new TransactionTestFixture().createTransaction(sig.generateKeyPair()), new TransactionTestFixture().createTransaction(sig.generateKeyPair())), Collections.emptyList(), - Optional.of(List.of(withdrawal)), - Optional.empty()); + Optional.of(List.of(withdrawal))); final BlockBody shanghaiBlockBody2 = new BlockBody( List.of(new TransactionTestFixture().createTransaction(sig.generateKeyPair())), Collections.emptyList(), - Optional.of(List.of(withdrawal2)), - Optional.empty()); + Optional.of(List.of(withdrawal2))); when(blockchain.getBlockBody(blockHash1)).thenReturn(Optional.of(shanghaiBlockBody)); when(blockchain.getBlockBody(blockHash2)).thenReturn(Optional.of(shanghaiBlockBody2)); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByRangeV1Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByRangeV1Test.java index 6bc89ba6791..886903ee090 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByRangeV1Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByRangeV1Test.java @@ -179,7 +179,6 @@ public void shouldReturnNullForWithdrawalsWhenBlockIsPreShanghai() { new BlockBody( List.of(new TransactionTestFixture().createTransaction(sig.generateKeyPair())), Collections.emptyList(), - Optional.empty(), Optional.empty()); when(blockchain.getChainHeadBlockNumber()).thenReturn(Long.valueOf(130)); when(blockchain.getBlockBody(blockHash1)).thenReturn(Optional.of(preShanghaiBlockBody)); @@ -214,15 +213,13 @@ public void shouldReturnWithdrawalsWhenBlockIsPostShanghai() { new TransactionTestFixture().createTransaction(sig.generateKeyPair()), new TransactionTestFixture().createTransaction(sig.generateKeyPair())), Collections.emptyList(), - Optional.of(List.of(withdrawal)), - Optional.empty()); + Optional.of(List.of(withdrawal))); final BlockBody shanghaiBlockBody2 = new BlockBody( List.of(new TransactionTestFixture().createTransaction(sig.generateKeyPair())), Collections.emptyList(), - Optional.of(List.of(withdrawal2)), - Optional.empty()); + Optional.of(List.of(withdrawal2))); when(blockchain.getChainHeadBlockNumber()).thenReturn(Long.valueOf(130)); when(blockchain.getBlockBody(blockHash1)).thenReturn(Optional.of(shanghaiBlockBody)); when(blockchain.getBlockBody(blockHash2)).thenReturn(Optional.of(shanghaiBlockBody2)); @@ -252,8 +249,7 @@ public void shouldNotContainTrailingNullForBlocksPastTheCurrentHead() { new TransactionTestFixture().createTransaction(sig.generateKeyPair()), new TransactionTestFixture().createTransaction(sig.generateKeyPair())), Collections.emptyList(), - Optional.of(List.of(withdrawal)), - Optional.empty()); + Optional.of(List.of(withdrawal))); when(blockchain.getChainHeadBlockNumber()).thenReturn(Long.valueOf(123)); when(blockchain.getBlockBody(blockHash1)).thenReturn(Optional.of(shanghaiBlockBody)); when(blockchain.getBlockHashByNumber(123)).thenReturn(Optional.of(blockHash1)); @@ -276,20 +272,17 @@ public void shouldReturnUpUntilHeadWhenStartBlockPlusCountEqualsHeadNumber() { new BlockBody( List.of(new TransactionTestFixture().createTransaction(sig.generateKeyPair())), Collections.emptyList(), - Optional.of(List.of(withdrawal)), - Optional.empty()); + Optional.of(List.of(withdrawal))); final BlockBody shanghaiBlockBody2 = new BlockBody( List.of(new TransactionTestFixture().createTransaction(sig.generateKeyPair())), Collections.emptyList(), - Optional.of(List.of(withdrawal)), - Optional.empty()); + Optional.of(List.of(withdrawal))); final BlockBody shanghaiBlockBody3 = new BlockBody( List.of(new TransactionTestFixture().createTransaction(sig.generateKeyPair())), Collections.emptyList(), - Optional.of(List.of(withdrawal)), - Optional.empty()); + Optional.of(List.of(withdrawal))); when(blockchain.getChainHeadBlockNumber()).thenReturn(Long.valueOf(125)); when(blockchain.getBlockBody(blockHash1)).thenReturn(Optional.of(shanghaiBlockBody)); when(blockchain.getBlockBody(blockHash2)).thenReturn(Optional.of(shanghaiBlockBody2)); 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 5c455222f17..fcbe179a52a 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 @@ -124,7 +124,8 @@ public void shouldReturnUnsupportedForkIfBlockTimestampIsAfterCancunMilestone() new Block(mockHeader, new BlockBody(Collections.emptyList(), Collections.emptyList())); final BlockWithReceipts mockBlockWithReceipts = new BlockWithReceipts(mockBlock, Collections.emptyList()); - final PayloadWrapper mockPayload = new PayloadWrapper(mockPid, mockBlockWithReceipts); + final PayloadWrapper mockPayload = + new PayloadWrapper(mockPid, mockBlockWithReceipts, Optional.empty()); when(mergeContext.retrievePayloadById(mockPid)).thenReturn(Optional.of(mockPayload)); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV3Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV3Test.java index ac589c11219..1fe3b44d451 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV3Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV3Test.java @@ -128,10 +128,10 @@ public void shouldReturnBlockForKnownPayloadId() { new BlockBody( List.of(blobTx), Collections.emptyList(), - Optional.of(Collections.emptyList()), Optional.of(Collections.emptyList()))), List.of(blobReceipt)); - PayloadWrapper payloadPostCancun = new PayloadWrapper(postCancunPid, postCancunBlock); + PayloadWrapper payloadPostCancun = + new PayloadWrapper(postCancunPid, postCancunBlock, Optional.empty()); when(mergeContext.retrievePayloadById(postCancunPid)) .thenReturn(Optional.of(payloadPostCancun)); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV4Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV4Test.java index 134c7a2c0c6..744600ddca9 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV4Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV4Test.java @@ -14,6 +14,7 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine; +import static java.util.Collections.emptyList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.mock; @@ -27,6 +28,7 @@ import org.hyperledger.besu.datatypes.BlobGas; import org.hyperledger.besu.datatypes.BlobsWithCommitments; import org.hyperledger.besu.datatypes.Hash; +import org.hyperledger.besu.datatypes.RequestType; import org.hyperledger.besu.datatypes.TransactionType; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; @@ -41,12 +43,13 @@ 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.core.Request; 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.Comparator; import java.util.List; import java.util.Optional; @@ -128,19 +131,24 @@ public void shouldReturnBlockForKnownPayloadId() { BlockWithReceipts block = new BlockWithReceipts( new Block( - header, - new BlockBody( - List.of(blobTx), - Collections.emptyList(), - Optional.of(Collections.emptyList()), - Optional.of(Collections.emptyList()))), + header, new BlockBody(List.of(blobTx), emptyList(), Optional.of(emptyList()))), List.of(blobReceipt)); - PayloadWrapper payload = new PayloadWrapper(payloadIdentifier, block); + final List requests = + List.of( + new Request(RequestType.DEPOSIT, Bytes.of(1)), + new Request(RequestType.WITHDRAWAL, Bytes.of(1)), + new Request(RequestType.CONSOLIDATION, Bytes.of(1))); + PayloadWrapper payload = new PayloadWrapper(payloadIdentifier, block, Optional.of(requests)); when(mergeContext.retrievePayloadById(payloadIdentifier)).thenReturn(Optional.of(payload)); final var resp = resp(RpcMethod.ENGINE_GET_PAYLOAD_V4.getMethodName(), payloadIdentifier); assertThat(resp).isInstanceOf(JsonRpcSuccessResponse.class); + final List requestsWithoutRequestId = + requests.stream() + .sorted(Comparator.comparing(Request::getType)) + .map(r -> r.getData().toHexString()) + .toList(); Optional.of(resp) .map(JsonRpcSuccessResponse.class::cast) .ifPresent( @@ -148,9 +156,6 @@ public void shouldReturnBlockForKnownPayloadId() { assertThat(r.getResult()).isInstanceOf(EngineGetPayloadResultV4.class); final EngineGetPayloadResultV4 res = (EngineGetPayloadResultV4) r.getResult(); assertThat(res.getExecutionPayload().getWithdrawals()).isNotNull(); - assertThat(res.getExecutionPayload().getDepositRequests()).isNotNull(); - assertThat(res.getExecutionPayload().getWithdrawalRequests()).isNotNull(); - assertThat(res.getExecutionPayload().getConsolidationRequests()).isNotNull(); assertThat(res.getExecutionPayload().getHash()) .isEqualTo(header.getHash().toString()); assertThat(res.getBlockValue()).isEqualTo(Quantity.create(0)); @@ -161,6 +166,8 @@ public void shouldReturnBlockForKnownPayloadId() { assertThat(res.getExecutionPayload().getExcessBlobGas()).isNotEmpty(); assertThat(res.getExecutionPayload().getExcessBlobGas()) .isEqualTo(expectedQuantityOf10); + assertThat(res.getExecutionRequests()).isNotEmpty(); + assertThat(res.getExecutionRequests()).isEqualTo(requestsWithoutRequestId); }); verify(engineCallListener, times(1)).executionEngineCalled(); } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2Test.java index 4e68cca76cb..abf2c297673 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2Test.java @@ -83,15 +83,11 @@ public void shouldReturnValidIfWithdrawalsIsNotNull_WhenWithdrawalsAllowed() { setupValidPayload( new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), Optional.of(withdrawals), - Optional.empty(), Optional.empty()); lenient() .when(blockchain.getBlockHeader(mockHeader.getParentHash())) .thenReturn(Optional.of(mock(BlockHeader.class))); - var resp = - resp( - mockEnginePayload( - mockHeader, Collections.emptyList(), withdrawalsParam, null, null, null)); + var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList(), withdrawalsParam)); assertValidResponse(mockHeader, resp); } @@ -105,13 +101,11 @@ public void shouldReturnValidIfWithdrawalsIsNull_WhenWithdrawalsProhibited() { setupValidPayload( new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), Optional.empty(), - Optional.empty(), Optional.empty()); lenient() .when(blockchain.getBlockHeader(mockHeader.getParentHash())) .thenReturn(Optional.of(mock(BlockHeader.class))); - var resp = - resp(mockEnginePayload(mockHeader, Collections.emptyList(), withdrawals, null, null, null)); + var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList(), withdrawals)); assertValidResponse(mockHeader, resp); } @@ -126,13 +120,9 @@ public void shouldReturnInvalidIfWithdrawalsIsNotNull_WhenWithdrawalsProhibited( var resp = resp( mockEnginePayload( - createBlockHeader( - Optional.of(Collections.emptyList()), Optional.empty(), Optional.empty()), + createBlockHeader(Optional.of(Collections.emptyList()), Optional.empty()), Collections.emptyList(), - withdrawals, - null, - null, - null)); + withdrawals)); final JsonRpcError jsonRpcError = fromErrorResp(resp); assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode()); @@ -143,13 +133,11 @@ public void shouldReturnInvalidIfWithdrawalsIsNotNull_WhenWithdrawalsProhibited( public void shouldValidateBlobGasUsedCorrectly() { // V2 should return error if non-null blobGasUsed BlockHeader blockHeader = - createBlockHeaderFixture( - Optional.of(Collections.emptyList()), Optional.empty(), Optional.empty()) + createBlockHeaderFixture(Optional.of(Collections.emptyList()), Optional.empty()) .blobGasUsed(100L) .buildHeader(); - var resp = - resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of(), null, null, null)); + var resp = resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of())); final JsonRpcError jsonRpcError = fromErrorResp(resp); assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_BLOB_GAS_USED_PARAMS.getCode()); assertThat(jsonRpcError.getData()).isEqualTo("Missing blob gas used field"); @@ -160,13 +148,11 @@ public void shouldValidateBlobGasUsedCorrectly() { public void shouldValidateExcessBlobGasCorrectly() { // V2 should return error if non-null ExcessBlobGas BlockHeader blockHeader = - createBlockHeaderFixture( - Optional.of(Collections.emptyList()), Optional.empty(), Optional.empty()) + createBlockHeaderFixture(Optional.of(Collections.emptyList()), Optional.empty()) .excessBlobGas(BlobGas.MAX_BLOB_GAS) .buildHeader(); - var resp = - resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of(), null, null, null)); + var resp = resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of())); final JsonRpcError jsonRpcError = fromErrorResp(resp); assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode()); @@ -183,12 +169,9 @@ public void shouldReturnInvalidIfWithdrawalsIsNull_WhenWithdrawalsAllowed() { var resp = resp( mockEnginePayload( - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()), + createBlockHeader(Optional.empty(), Optional.empty()), Collections.emptyList(), - withdrawals, - null, - null, - null)); + withdrawals)); assertThat(fromErrorResp(resp).getCode()).isEqualTo(INVALID_PARAMS.getCode()); verify(engineCallListener, times(1)).executionEngineCalled(); @@ -199,13 +182,11 @@ public void shouldReturnUnsupportedForkIfBlockTimestampIsAfterCancunMilestone() // Cancun starte at timestamp 30 final long blockTimestamp = 31L; BlockHeader blockHeader = - createBlockHeaderFixture( - Optional.of(Collections.emptyList()), Optional.empty(), Optional.empty()) + createBlockHeaderFixture(Optional.of(Collections.emptyList()), Optional.empty()) .timestamp(blockTimestamp) .buildHeader(); - var resp = - resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of(), null, null, null)); + var resp = resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of())); final JsonRpcError jsonRpcError = fromErrorResp(resp); assertThat(jsonRpcError.getCode()).isEqualTo(UNSUPPORTED_FORK.getCode()); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java index d8cf86758f8..b79cb587eb3 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java @@ -44,11 +44,10 @@ import org.hyperledger.besu.ethereum.core.BlobTestFixture; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.DepositRequest; +import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionTestFixture; import org.hyperledger.besu.ethereum.core.Withdrawal; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; import org.hyperledger.besu.ethereum.core.encoding.EncodingContext; import org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder; import org.hyperledger.besu.ethereum.mainnet.BodyValidation; @@ -135,24 +134,23 @@ public void shouldValidVersionedHash_whenListIsEmpty() { setupValidPayload( new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), Optional.empty(), - Optional.empty(), Optional.empty()); final EnginePayloadParameter payload = - mockEnginePayload(mockHeader, Collections.emptyList(), null, null, null, null); + mockEnginePayload(mockHeader, Collections.emptyList(), null); ValidationResult res = method.validateParameters( payload, Optional.of(List.of()), - Optional.of("0x0000000000000000000000000000000000000000000000000000000000000000")); + Optional.of("0x0000000000000000000000000000000000000000000000000000000000000000"), + Optional.empty()); assertThat(res.isValid()).isTrue(); } @Override protected BlockHeader createBlockHeader( final Optional> maybeWithdrawals, - final Optional> maybeDepositRequests, - final Optional> maybeWithdrawalRequests) { + final Optional> maybeRequests) { BlockHeader parentBlockHeader = new BlockHeaderTestFixture() .baseFeePerGas(Wei.ONE) @@ -188,14 +186,12 @@ public void shouldReturnValidIfProtocolScheduleIsEmpty() { public void shouldValidateBlobGasUsedCorrectly() { // V3 must return error if null blobGasUsed BlockHeader blockHeader = - createBlockHeaderFixture( - Optional.of(Collections.emptyList()), Optional.empty(), Optional.empty()) + createBlockHeaderFixture(Optional.of(Collections.emptyList()), Optional.empty()) .excessBlobGas(BlobGas.MAX_BLOB_GAS) .blobGasUsed(null) .buildHeader(); - var resp = - resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of(), null, null, null)); + var resp = resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of())); final JsonRpcError jsonRpcError = fromErrorResp(resp); assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode()); @@ -208,14 +204,12 @@ public void shouldValidateBlobGasUsedCorrectly() { public void shouldValidateExcessBlobGasCorrectly() { // V3 must return error if null excessBlobGas BlockHeader blockHeader = - createBlockHeaderFixture( - Optional.of(Collections.emptyList()), Optional.empty(), Optional.empty()) + createBlockHeaderFixture(Optional.of(Collections.emptyList()), Optional.empty()) .excessBlobGas(null) .blobGasUsed(100L) .buildHeader(); - var resp = - resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of(), null, null, null)); + var resp = resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of())); final JsonRpcError jsonRpcError = fromErrorResp(resp); assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode()); @@ -236,7 +230,6 @@ public void shouldRejectTransactionsWithFullBlobs() { setupValidPayload( new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), Optional.empty(), - Optional.empty(), Optional.empty()); var resp = resp(mockEnginePayload(mockHeader, transactions)); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4Test.java index 9ea17213059..c8504e7451d 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4Test.java @@ -15,9 +15,7 @@ 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.parameters.WithdrawalRequestTestFixture.WITHDRAWAL_REQUEST_PARAMETER_1; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INVALID_PARAMS; +import static org.hyperledger.besu.ethereum.api.graphql.internal.response.GraphQLError.INVALID_PARAMS; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.mock; @@ -25,7 +23,6 @@ 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.RequestType; import org.hyperledger.besu.datatypes.Wei; @@ -33,28 +30,24 @@ import org.hyperledger.besu.ethereum.BlockProcessingResult; 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.DepositRequestParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadParameter; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalRequestParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.DepositRequest; import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Withdrawal; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; import org.hyperledger.besu.ethereum.mainnet.BodyValidation; -import org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestValidator; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; -import org.hyperledger.besu.ethereum.mainnet.requests.WithdrawalRequestValidator; +import org.hyperledger.besu.ethereum.mainnet.requests.MainnetRequestsValidator; +import org.hyperledger.besu.ethereum.mainnet.requests.ProhibitedRequestValidator; import org.hyperledger.besu.evm.gascalculator.PragueGasCalculator; -import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Optional; +import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -63,8 +56,6 @@ @ExtendWith(MockitoExtension.class) public class EngineNewPayloadV4Test extends EngineNewPayloadV3Test { - private static final Address depositContractAddress = - Address.fromHexString("0x00000000219ab540356cbb839cbe05303d7705fa"); public EngineNewPayloadV4Test() {} @@ -92,8 +83,7 @@ public void shouldReturnExpectedMethodName() { } @Test - public void shouldReturnValidIfDepositRequestsIsNull_WhenDepositRequestsProhibited() { - final List depositRequests = null; + public void shouldReturnValidIfRequestsIsNull_WhenRequestsProhibited() { mockProhibitedRequestsValidator(); BlockHeader mockHeader = @@ -101,170 +91,69 @@ public void shouldReturnValidIfDepositRequestsIsNull_WhenDepositRequestsProhibit new BlockProcessingResult( Optional.of(new BlockProcessingOutputs(null, List.of(), Optional.empty()))), Optional.empty(), - 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, depositRequests, null, null)); + var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList())); assertValidResponse(mockHeader, resp); } @Test - public void shouldReturnInvalidIfDepositRequestsIsNull_WhenDepositRequestsAllowed() { - final List depositRequests = null; - mockAllowedDepositRequestsRequestValidator(); + public void shouldReturnInvalidIfRequestsIsNull_WhenRequestsAllowed() { + mockAllowedRequestsValidator(); var resp = resp( mockEnginePayload( - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()), - Collections.emptyList(), - null, - depositRequests, - null, - null)); + createBlockHeader(Optional.empty(), Optional.empty()), Collections.emptyList())); assertThat(fromErrorResp(resp).getCode()).isEqualTo(INVALID_PARAMS.getCode()); verify(engineCallListener, times(1)).executionEngineCalled(); } @Test - public void shouldReturnValidIfDepositRequestsIsNotNull_WhenDepositRequestsAllowed() { - final List depositRequestsParam = List.of(DEPOSIT_PARAM_1); - final List depositRequests = List.of(DEPOSIT_PARAM_1.toDeposit()); - - mockAllowedDepositRequestsRequestValidator(); - BlockHeader mockHeader = - setupValidPayload( - new BlockProcessingResult( - Optional.of( - new BlockProcessingOutputs(null, List.of(), Optional.of(depositRequests)))), - Optional.empty(), - Optional.of(List.of(DEPOSIT_PARAM_1.toDeposit())), - 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, depositRequestsParam, null, null)); - - assertValidResponse(mockHeader, resp); - } - - @Test - public void shouldReturnInvalidIfDepositRequestsIsNotNull_WhenDepositRequestsProhibited() { - final List depositRequests = List.of(); - lenient() - .when(protocolSpec.getRequestsValidatorCoordinator()) - .thenReturn(RequestsValidatorCoordinator.empty()); - - var resp = - resp( - mockEnginePayload( - createBlockHeader( - Optional.empty(), Optional.of(Collections.emptyList()), Optional.empty()), - Collections.emptyList(), - null, - depositRequests, - null, - null)); - - final JsonRpcError jsonRpcError = fromErrorResp(resp); - assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode()); - verify(engineCallListener, times(1)).executionEngineCalled(); - } - - @Test - public void shouldReturnValidIfWithdrawalRequestsIsNull_WhenWithdrawalRequestsAreProhibited() { - mockProhibitedRequestsValidator(); - + public void shouldReturnValidIfRequestsIsNotNull_WhenRequestsAllowed() { + final List requests = + List.of( + new Request(RequestType.DEPOSIT, Bytes.of(1)), + new Request(RequestType.WITHDRAWAL, Bytes.of(1)), + new Request(RequestType.CONSOLIDATION, Bytes.of(1))); + + mockAllowedRequestsValidator(); BlockHeader mockHeader = setupValidPayload( new BlockProcessingResult( - Optional.of(new BlockProcessingOutputs(null, List.of(), Optional.empty()))), - Optional.empty(), + Optional.of(new BlockProcessingOutputs(null, List.of(), Optional.of(requests)))), 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, null, null, null)); + var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList()), requests); assertValidResponse(mockHeader, resp); } @Test - public void shouldReturnInvalidIfWithdrawalRequestsIsNull_WhenWithdrawalRequestsAreAllowed() { - mockAllowedWithdrawalsRequestValidator(); - - var resp = - resp( - mockEnginePayload( - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()), - Collections.emptyList(), - null, - null, - null, - null)); - - assertThat(fromErrorResp(resp).getCode()).isEqualTo(INVALID_PARAMS.getCode()); - verify(engineCallListener, times(1)).executionEngineCalled(); - } - - @Test - public void shouldReturnValidIfWithdrawalRequestsIsNotNull_WhenWithdrawalRequestsAreAllowed() { - final List withdrawalRequestsParams = - List.of(WITHDRAWAL_REQUEST_PARAMETER_1); - final List withdrawalRequests = - List.of(WITHDRAWAL_REQUEST_PARAMETER_1.toWithdrawalRequest()); - mockAllowedWithdrawalsRequestValidator(); - BlockHeader mockHeader = - setupValidPayload( - new BlockProcessingResult( - Optional.of( - new BlockProcessingOutputs(null, List.of(), Optional.of(withdrawalRequests)))), - Optional.empty(), - Optional.empty(), - Optional.of(List.of(WITHDRAWAL_REQUEST_PARAMETER_1.toWithdrawalRequest()))); - 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, null, withdrawalRequestsParams, null)); - - assertValidResponse(mockHeader, resp); - } + public void shouldReturnInvalidIfRequestsIsNotNull_WhenRequestsProhibited() { + final List requests = + List.of( + new Request(RequestType.DEPOSIT, Bytes.of(1)), + new Request(RequestType.WITHDRAWAL, Bytes.of(1)), + new Request(RequestType.CONSOLIDATION, Bytes.of(1))); - @Test - public void - shouldReturnInvalidIfWithdrawalRequestsIsNotNull_WhenWithdrawalRequestsAreProhibited() { - final List withdrawalRequests = List.of(); mockProhibitedRequestsValidator(); var resp = resp( mockEnginePayload( - createBlockHeader( - Optional.empty(), Optional.empty(), Optional.of(Collections.emptyList())), - Collections.emptyList(), - null, - null, - withdrawalRequests, - null)); + createBlockHeader(Optional.empty(), Optional.of(Collections.emptyList())), + Collections.emptyList()), + requests); final JsonRpcError jsonRpcError = fromErrorResp(resp); assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode()); @@ -274,8 +163,7 @@ public void shouldReturnValidIfWithdrawalRequestsIsNotNull_WhenWithdrawalRequest @Override protected BlockHeader createBlockHeader( final Optional> maybeWithdrawals, - final Optional> maybeDepositRequests, - final Optional> maybeWithdrawalRequests) { + final Optional> maybeRequests) { BlockHeader parentBlockHeader = new BlockHeaderTestFixture() .baseFeePerGas(Wei.ONE) @@ -284,16 +172,6 @@ protected BlockHeader createBlockHeader( .blobGasUsed(0L) .buildHeader(); - Optional> maybeRequests; - if (maybeDepositRequests.isPresent() || maybeWithdrawalRequests.isPresent()) { - List requests = new ArrayList<>(); - maybeDepositRequests.ifPresent(requests::addAll); - maybeWithdrawalRequests.ifPresent(requests::addAll); - maybeRequests = Optional.of(requests); - } else { - maybeRequests = Optional.empty(); - } - BlockHeader mockHeader = new BlockHeaderTestFixture() .baseFeePerGas(Wei.ONE) @@ -303,7 +181,7 @@ protected BlockHeader createBlockHeader( .withdrawalsRoot(maybeWithdrawals.map(BodyValidation::withdrawalsRoot).orElse(null)) .excessBlobGas(BlobGas.ZERO) .blobGasUsed(0L) - .requestsRoot(maybeRequests.map(BodyValidation::requestsRoot).orElse(null)) + .requestsHash(maybeRequests.map(BodyValidation::requestsHash).orElse(null)) .parentBeaconBlockRoot( maybeParentBeaconBlockRoot.isPresent() ? maybeParentBeaconBlockRoot : null) .buildHeader(); @@ -320,24 +198,35 @@ protected JsonRpcResponse resp(final EnginePayloadParameter payload) { new JsonRpcRequestContext(new JsonRpcRequest("2.0", this.method.getName(), params))); } - private void mockProhibitedRequestsValidator() { - var validator = RequestsValidatorCoordinator.empty(); - when(protocolSpec.getRequestsValidatorCoordinator()).thenReturn(validator); + protected JsonRpcResponse resp( + final EnginePayloadParameter payload, final List requests) { + final List requestsWithoutRequestId = + requests.stream() + .sorted(Comparator.comparing(Request::getType)) + .map(r -> r.getData().toHexString()) + .toList(); + Object[] params = + maybeParentBeaconBlockRoot + .map( + bytes32 -> + new Object[] { + payload, + Collections.emptyList(), + bytes32.toHexString(), + requestsWithoutRequestId + }) + .orElseGet(() -> new Object[] {payload}); + return method.response( + new JsonRpcRequestContext(new JsonRpcRequest("2.0", this.method.getName(), params))); } - private void mockAllowedDepositRequestsRequestValidator() { - var validator = - new RequestsValidatorCoordinator.Builder() - .addValidator(RequestType.DEPOSIT, new DepositRequestValidator(depositContractAddress)) - .build(); - when(protocolSpec.getRequestsValidatorCoordinator()).thenReturn(validator); + private void mockProhibitedRequestsValidator() { + var validator = new ProhibitedRequestValidator(); + when(protocolSpec.getRequestsValidator()).thenReturn(validator); } - private void mockAllowedWithdrawalsRequestValidator() { - var validator = - new RequestsValidatorCoordinator.Builder() - .addValidator(RequestType.WITHDRAWAL, new WithdrawalRequestValidator()) - .build(); - when(protocolSpec.getRequestsValidatorCoordinator()).thenReturn(validator); + private void mockAllowedRequestsValidator() { + var validator = new MainnetRequestsValidator(); + when(protocolSpec.getRequestsValidator()).thenReturn(validator); } } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositParameterTestFixture.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositParameterTestFixture.java deleted file mode 100644 index f3f5f420bbb..00000000000 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositParameterTestFixture.java +++ /dev/null @@ -1,42 +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.ethereum.api.jsonrpc.internal.parameters; - -public class DepositParameterTestFixture { - - public static final DepositRequestParameter DEPOSIT_PARAM_1 = - createDeposit( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e", - "0x0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483", - "0x773594000", - "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5", - "0x1"); - static final DepositRequestParameter DEPOSIT_PARAM_2 = - createDeposit( - "0x8706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf243", - "0x006a8dc800c6d8dd6977ef53264e2d030350f0145a91bcd167b4f1c3ea21b271", - "0x773594000", - "0x801b08ca107b623eca32ee9f9111b4e50eb9cfe19e38204b72de7dc04c5a5e00f61bab96f10842576f66020ce851083f1583dd9a6b73301bea6c245cf51f27cf96aeb018852c5f70bf485d16b957cfe49ca008913346b431e7653ae3ddb23b07", - "0x3"); - - private static DepositRequestParameter createDeposit( - final String pubKey, - final String withdrawalCredentials, - final String amount, - final String signature, - final String index) { - return new DepositRequestParameter(pubKey, withdrawalCredentials, amount, signature, index); - } -} diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestRequestParameterTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestRequestParameterTest.java deleted file mode 100644 index ce5780641be..00000000000 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestRequestParameterTest.java +++ /dev/null @@ -1,61 +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.ethereum.api.jsonrpc.internal.parameters; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameterTestFixture.DEPOSIT_PARAM_1; - -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.BLSSignature; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.ethereum.core.DepositRequest; - -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt64; -import org.junit.jupiter.api.Test; - -public class DepositRequestRequestParameterTest { - - @Test - public void toDeposit() { - DepositRequest expected = - new DepositRequest( - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - Bytes32.fromHexString( - "0x0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483"), - GWei.of(32000000000L), - BLSSignature.fromHexString( - "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), - UInt64.ONE); - assertThat(DEPOSIT_PARAM_1.toDeposit()).isEqualTo(expected); - } - - @Test - public void fromDeposit() { - DepositRequest depositRequest = - new DepositRequest( - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - Bytes32.fromHexString( - "0x0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483"), - GWei.of(32000000000L), - BLSSignature.fromHexString( - "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), - UInt64.ONE); - - assertThat(DepositRequestParameter.fromDeposit(depositRequest)).isEqualTo(DEPOSIT_PARAM_1); - } -} diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestParameterTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestParameterTest.java deleted file mode 100644 index e3e136cb7a4..00000000000 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestParameterTest.java +++ /dev/null @@ -1,52 +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.ethereum.api.jsonrpc.internal.parameters; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalRequestTestFixture.WITHDRAWAL_REQUEST_PARAMETER_1; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; - -import org.junit.jupiter.api.Test; - -public class WithdrawalRequestParameterTest { - - @Test - public void toWithdrawalRequest() { - WithdrawalRequest expected = - new WithdrawalRequest( - Address.fromHexString("0x814FaE9f487206471B6B0D713cD51a2D35980000"), - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - GWei.ONE); - assertThat(WITHDRAWAL_REQUEST_PARAMETER_1.toWithdrawalRequest()).isEqualTo(expected); - } - - @Test - public void fromWithdrawalRequest() { - WithdrawalRequest withdrawalRequest = - new WithdrawalRequest( - Address.fromHexString("0x814FaE9f487206471B6B0D713cD51a2D35980000"), - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - GWei.ONE); - - assertThat(WithdrawalRequestParameter.fromWithdrawalRequest(withdrawalRequest)) - .isEqualTo(WITHDRAWAL_REQUEST_PARAMETER_1); - } -} diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestTestFixture.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestTestFixture.java deleted file mode 100644 index 2256cc31956..00000000000 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestTestFixture.java +++ /dev/null @@ -1,31 +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.ethereum.api.jsonrpc.internal.parameters; - -import org.hyperledger.besu.datatypes.GWei; - -public class WithdrawalRequestTestFixture { - - public static final WithdrawalRequestParameter WITHDRAWAL_REQUEST_PARAMETER_1 = - new WithdrawalRequestParameter( - "0x814fae9f487206471b6b0d713cd51a2d35980000", - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e", - GWei.ONE.toShortHexString()); - static final WithdrawalRequestParameter WITHDRAWAL_REQUEST_PARAMETER_2 = - new WithdrawalRequestParameter( - "0x758b8178a9a4b7206d1f648c4a77c515cbac7000", - "0x8706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf243", - GWei.ONE.toShortHexString()); -} diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java index b843389c0d3..ad9489daf83 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java @@ -265,7 +265,7 @@ protected BlockCreationResult createBlock( operationTracer); Optional> maybeRequests = - requestProcessor.flatMap(processor -> processor.process(context)); + requestProcessor.map(processor -> processor.process(context)); throwIfStopped(); @@ -304,7 +304,7 @@ protected BlockCreationResult createBlock( withdrawalsCanBeProcessed ? BodyValidation.withdrawalsRoot(maybeWithdrawals.get()) : null) - .requestsRoot(maybeRequests.map(BodyValidation::requestsRoot).orElse(null)); + .requestsHash(maybeRequests.map(BodyValidation::requestsHash).orElse(null)); if (usage != null) { builder.blobGasUsed(usage.used.toLong()).excessBlobGas(usage.excessBlobGas); } @@ -316,8 +316,7 @@ protected BlockCreationResult createBlock( final Optional> withdrawals = withdrawalsCanBeProcessed ? maybeWithdrawals : Optional.empty(); final BlockBody blockBody = - new BlockBody( - transactionResults.getSelectedTransactions(), ommers, withdrawals, maybeRequests); + new BlockBody(transactionResults.getSelectedTransactions(), ommers, withdrawals); final Block block = new Block(blockHeader, blockBody); operationTracer.traceEndBlock(blockHeader, blockBody); diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java index ffab847bbdc..d30349e3d0e 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java @@ -14,9 +14,8 @@ */ package org.hyperledger.besu.ethereum.blockcreation; -import static java.util.Collections.emptyList; import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestProcessor.DEFAULT_DEPOSIT_CONTRACT_ADDRESS; +import static org.hyperledger.besu.ethereum.mainnet.requests.RequestContractAddresses.DEFAULT_DEPOSIT_CONTRACT_ADDRESS; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.RETURNS_DEEP_STUBS; @@ -31,8 +30,6 @@ import org.hyperledger.besu.crypto.SignatureAlgorithm; import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.BLSSignature; import org.hyperledger.besu.datatypes.BlobGas; import org.hyperledger.besu.datatypes.BlobsWithCommitments; import org.hyperledger.besu.datatypes.GWei; @@ -48,7 +45,6 @@ import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; -import org.hyperledger.besu.ethereum.core.DepositRequest; import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture; import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; @@ -81,10 +77,7 @@ import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.mainnet.WithdrawalsProcessor; import org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestProcessor; -import org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestValidator; import org.hyperledger.besu.ethereum.mainnet.requests.ProcessRequestContext; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestProcessorCoordinator; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; import org.hyperledger.besu.evm.account.Account; import org.hyperledger.besu.evm.internal.EvmConfiguration; @@ -141,83 +134,16 @@ void findDepositRequestsFromReceipts() { List receipts = List.of(receiptWithoutDeposit1, receiptWithDeposit, receiptWithoutDeposit2); - DepositRequest expectedDepositRequest = - new DepositRequest( - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - Bytes32.fromHexString( - "0x0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483"), - GWei.of(32000000000L), - BLSSignature.fromHexString( - "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), - UInt64.valueOf(539967)); - final List expectedDepositRequests = List.of(expectedDepositRequest); + Request expectedDepositRequest = + new Request( + RequestType.DEPOSIT, + Bytes.fromHexString( + "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa355894830040597307000000a889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb53f3d080000000000")); var depositRequestsFromReceipts = new DepositRequestProcessor(DEFAULT_DEPOSIT_CONTRACT_ADDRESS) .process(new ProcessRequestContext(null, null, null, receipts, null, null)); - assertThat(depositRequestsFromReceipts.get()).isEqualTo(expectedDepositRequests); - } - - @Test - void withAllowedDepositRequestsAndContractAddress_DepositRequestsAreParsed() { - final CreateOn miningOn = - blockCreatorWithAllowedDepositRequests(DEFAULT_DEPOSIT_CONTRACT_ADDRESS); - - final BlockCreationResult blockCreationResult = - miningOn.blockCreator.createBlock( - Optional.empty(), - Optional.empty(), - Optional.of(emptyList()), - Optional.empty(), - Optional.empty(), - 1L, - false, - miningOn.parentHeader); - - List depositRequests = emptyList(); - final Hash requestsRoot = BodyValidation.requestsRoot(depositRequests); - assertThat(blockCreationResult.getBlock().getHeader().getRequestsRoot()).hasValue(requestsRoot); - assertThat(blockCreationResult.getBlock().getBody().getRequests()).hasValue(depositRequests); - } - - @Test - void withAllowedDepositRequestsAndNoContractAddress_DepositRequestsAreNotParsed() { - final CreateOn miningOn = blockCreatorWithAllowedDepositRequests(null); - - final BlockCreationResult blockCreationResult = - miningOn.blockCreator.createBlock( - Optional.empty(), - Optional.empty(), - Optional.of(emptyList()), - Optional.empty(), - Optional.empty(), - 1L, - false, - miningOn.parentHeader); - - assertThat(blockCreationResult.getBlock().getHeader().getRequestsRoot()).isEmpty(); - assertThat(blockCreationResult.getBlock().getBody().getRequests()).isEmpty(); - } - - @Test - void withProhibitedDepositRequests_DepositRequestsAreNotParsed() { - - final CreateOn miningOn = blockCreatorWithProhibitedDepositRequests(); - - final BlockCreationResult blockCreationResult = - miningOn.blockCreator.createBlock( - Optional.empty(), - Optional.empty(), - Optional.of(emptyList()), - Optional.empty(), - Optional.empty(), - 1L, - false, - miningOn.parentHeader); - - assertThat(blockCreationResult.getBlock().getHeader().getRequestsRoot()).isEmpty(); - assertThat(blockCreationResult.getBlock().getBody().getRequests()).isEmpty(); + assertThat(depositRequestsFromReceipts).isEqualTo(expectedDepositRequest); } @Test @@ -355,12 +281,6 @@ private CreateOn blockCreatorWithBlobGasSupport() { return createBlockCreator(protocolSpecAdapters); } - private CreateOn blockCreatorWithProhibitedDepositRequests() { - final ProtocolSpecAdapters protocolSpecAdapters = - ProtocolSpecAdapters.create(0, specBuilder -> specBuilder); - return createBlockCreator(protocolSpecAdapters); - } - private CreateOn blockCreatorWithWithdrawalsProcessor() { final ProtocolSpecAdapters protocolSpecAdapters = ProtocolSpecAdapters.create( @@ -374,27 +294,6 @@ private CreateOn blockCreatorWithoutWithdrawalsProcessor() { return createBlockCreator(protocolSpecAdapters); } - private CreateOn blockCreatorWithAllowedDepositRequests(final Address depositContractAddress) { - final ProtocolSpecAdapters protocolSpecAdapters = - ProtocolSpecAdapters.create( - 0, - specBuilder -> - specBuilder - .requestsValidator( - new RequestsValidatorCoordinator.Builder() - .addValidator( - RequestType.DEPOSIT, - new DepositRequestValidator((depositContractAddress))) - .build()) - .requestProcessorCoordinator( - new RequestProcessorCoordinator.Builder() - .addProcessor( - RequestType.DEPOSIT, - new DepositRequestProcessor(depositContractAddress)) - .build())); - return createBlockCreator(protocolSpecAdapters); - } - record CreateOn(AbstractBlockCreator blockCreator, BlockHeader parentHeader) {} private CreateOn createBlockCreator(final ProtocolSpecAdapters protocolSpecAdapters) { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/BlockProcessingResult.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/BlockProcessingResult.java index 926dd13abdf..f34bd056c64 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/BlockProcessingResult.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/BlockProcessingResult.java @@ -14,6 +14,7 @@ */ package org.hyperledger.besu.ethereum; +import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import java.util.ArrayList; @@ -134,4 +135,13 @@ public List getReceipts() { return yield.get().getReceipts(); } } + + /** + * Gets the requests of the result. + * + * @return the requests of the result + */ + public Optional> getRequests() { + return yield.flatMap(BlockProcessingOutputs::getRequests); + } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/BlockValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/BlockValidator.java index 8cfafee730b..f74f4a90772 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/BlockValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/BlockValidator.java @@ -15,13 +15,11 @@ package org.hyperledger.besu.ethereum; import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.mainnet.BodyValidationMode; import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode; import java.util.List; -import java.util.Optional; /** * The BlockValidator interface defines the methods for validating and processing blocks in the @@ -90,7 +88,6 @@ BlockProcessingResult validateAndProcessBlock( * @param context the protocol context * @param block the block to validate * @param receipts the transaction receipts - * @param requests the requests * @param headerValidationMode the header validation mode * @param ommerValidationMode the ommer validation mode * @param bodyValidationMode the body validation mode @@ -100,7 +97,6 @@ boolean validateBlockForSyncing( final ProtocolContext context, final Block block, final List receipts, - final Optional> requests, final HeaderValidationMode headerValidationMode, final HeaderValidationMode ommerValidationMode, final BodyValidationMode bodyValidationMode); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java index 9cd014f25aa..b218982c092 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java @@ -171,7 +171,7 @@ public BlockProcessingResult validateAndProcessBlock( Optional> maybeRequests = result.getYield().flatMap(BlockProcessingOutputs::getRequests); if (!blockBodyValidator.validateBody( - context, block, receipts, maybeRequests, worldState.rootHash(), ommerValidationMode)) { + context, block, receipts, worldState.rootHash(), ommerValidationMode)) { result = new BlockProcessingResult("failed to validate output of imported block"); handleFailedBlockProcessing(block, result, shouldRecordBadBlock); return result; @@ -243,7 +243,6 @@ public boolean validateBlockForSyncing( final ProtocolContext context, final Block block, final List receipts, - final Optional> requests, final HeaderValidationMode headerValidationMode, final HeaderValidationMode ommerValidationMode, final BodyValidationMode bodyValidationMode) { @@ -255,7 +254,7 @@ public boolean validateBlockForSyncing( } if (!blockBodyValidator.validateBodyLight( - context, block, receipts, requests, ommerValidationMode, bodyValidationMode)) { + context, block, receipts, ommerValidationMode, bodyValidationMode)) { badBlockManager.addBadBlock( block, BadBlockCause.fromValidationFailure("Failed body validation (light)")); return false; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java index c2243986c22..2ee997f8ccd 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java @@ -28,7 +28,6 @@ import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.MutableWorldState; -import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions; @@ -145,10 +144,8 @@ public static GenesisState fromStorage( private static BlockBody buildBody(final GenesisConfigFile config) { final Optional> withdrawals = isShanghaiAtGenesis(config) ? Optional.of(emptyList()) : Optional.empty(); - final Optional> requests = - isPragueAtGenesis(config) ? Optional.of(emptyList()) : Optional.empty(); - return new BlockBody(emptyList(), emptyList(), withdrawals, requests); + return new BlockBody(emptyList(), emptyList(), withdrawals); } public Block getBlock() { @@ -220,7 +217,7 @@ private static BlockHeader buildHeader( .excessBlobGas(isCancunAtGenesis(genesis) ? parseExcessBlobGas(genesis) : null) .parentBeaconBlockRoot( (isCancunAtGenesis(genesis) ? parseParentBeaconBlockRoot(genesis) : null)) - .requestsRoot(isPragueAtGenesis(genesis) ? Hash.EMPTY_TRIE_HASH : null) + .requestsHash(isPragueAtGenesis(genesis) ? Hash.EMPTY_REQUESTS_HASH : null) .buildBlockHeader(); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Block.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Block.java index 3c90f77d320..41db458334f 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Block.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Block.java @@ -62,7 +62,6 @@ public void writeTo(final RLPOutput out) { out.writeList(body.getTransactions(), Transaction::writeTo); out.writeList(body.getOmmers(), BlockHeader::writeTo); body.getWithdrawals().ifPresent(withdrawals -> out.writeList(withdrawals, Withdrawal::writeTo)); - body.getRequests().ifPresent(requests -> out.writeList(requests, Request::writeTo)); out.endList(); } @@ -74,11 +73,9 @@ public static Block readFrom(final RLPInput in, final BlockHeaderFunctions hashF final List ommers = in.readList(rlp -> BlockHeader.readFrom(rlp, hashFunction)); final Optional> withdrawals = in.isEndOfCurrentList() ? Optional.empty() : Optional.of(in.readList(Withdrawal::readFrom)); - final Optional> requests = - in.isEndOfCurrentList() ? Optional.empty() : Optional.of(in.readList(Request::readFrom)); in.leaveList(); - return new Block(header, new BlockBody(transactions, ommers, withdrawals, requests)); + return new Block(header, new BlockBody(transactions, ommers, withdrawals)); } @Override diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockBody.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockBody.java index 4b8ab926137..7eb49dc04d1 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockBody.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockBody.java @@ -37,24 +37,20 @@ public class BlockBody implements org.hyperledger.besu.plugin.data.BlockBody { private final List ommers; private final Optional> withdrawals; - private final Optional> requests; public BlockBody(final List transactions, final List ommers) { this.transactions = transactions; this.ommers = ommers; this.withdrawals = Optional.empty(); - this.requests = Optional.empty(); } public BlockBody( final List transactions, final List ommers, - final Optional> withdrawals, - final Optional> requests) { + final Optional> withdrawals) { this.transactions = transactions; this.ommers = ommers; this.withdrawals = withdrawals; - this.requests = requests; } public static BlockBody empty() { @@ -87,16 +83,6 @@ public Optional> getWithdrawals() { return withdrawals; } - /** - * Returns the withdrawal requests of the block. - * - * @return The optional list of withdrawal requests included in the block. - */ - @Override - public Optional> getRequests() { - return requests; - } - /** * Writes Block to {@link RLPOutput}. * @@ -112,7 +98,6 @@ public void writeTo(final RLPOutput output) { output.writeList(getTransactions(), Transaction::writeTo); output.writeList(getOmmers(), BlockHeader::writeTo); withdrawals.ifPresent(withdrawals -> output.writeList(withdrawals, Withdrawal::writeTo)); - requests.ifPresent(requests -> output.writeList(requests, Request::writeTo)); } public static BlockBody readWrappedBodyFrom( @@ -161,10 +146,7 @@ public static BlockBody readFrom( input.readList(rlp -> BlockHeader.readFrom(rlp, blockHeaderFunctions)), input.isEndOfCurrentList() ? Optional.empty() - : Optional.of(input.readList(Withdrawal::readFrom)), - input.isEndOfCurrentList() - ? Optional.empty() - : Optional.of(input.readList(Request::readFrom))); + : Optional.of(input.readList(Withdrawal::readFrom))); } @Override @@ -174,20 +156,16 @@ public boolean equals(final Object o) { BlockBody blockBody = (BlockBody) o; return Objects.equals(transactions, blockBody.transactions) && Objects.equals(ommers, blockBody.ommers) - && Objects.equals(withdrawals, blockBody.withdrawals) - && Objects.equals(requests, blockBody.requests); + && Objects.equals(withdrawals, blockBody.withdrawals); } @Override public int hashCode() { - return Objects.hash(transactions, ommers, withdrawals, requests); + return Objects.hash(transactions, ommers, withdrawals); } public boolean isEmpty() { - return transactions.isEmpty() - && ommers.isEmpty() - && withdrawals.isEmpty() - && requests.isEmpty(); + return transactions.isEmpty() && ommers.isEmpty() && withdrawals.isEmpty(); } @Override @@ -199,8 +177,6 @@ public String toString() { + ommers + ", withdrawals=" + withdrawals - + ", withdrawal_requests=" - + requests + '}'; } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java index 7ff841280de..6bd1a2aa588 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java @@ -64,7 +64,7 @@ public BlockHeader( final Long blobGasUsed, final BlobGas excessBlobGas, final Bytes32 parentBeaconBlockRoot, - final Hash requestsRoot, + final Hash requestsHash, final BlockHeaderFunctions blockHeaderFunctions) { super( parentHash, @@ -86,7 +86,7 @@ public BlockHeader( blobGasUsed, excessBlobGas, parentBeaconBlockRoot, - requestsRoot); + requestsHash); this.nonce = nonce; this.hash = Suppliers.memoize(() -> blockHeaderFunctions.hash(this)); this.parsedExtraData = Suppliers.memoize(() -> blockHeaderFunctions.parseExtraData(this)); @@ -100,8 +100,8 @@ public static boolean hasEmptyBlock(final BlockHeader blockHeader) { .map(wsRoot -> wsRoot.equals(Hash.EMPTY_TRIE_HASH)) .orElse(true) && blockHeader - .getRequestsRoot() - .map(reqRoot -> reqRoot.equals(Hash.EMPTY_TRIE_HASH)) + .getRequestsHash() + .map(reqHash -> reqHash.equals(Hash.EMPTY_REQUESTS_HASH)) .orElse(true); } @@ -185,8 +185,8 @@ public void writeTo(final RLPOutput out) { if (parentBeaconBlockRoot == null) break; out.writeBytes(parentBeaconBlockRoot); - if (requestsRoot == null) break; - out.writeBytes(requestsRoot); + if (requestsHash == null) break; + out.writeBytes(requestsHash); } while (false); out.endList(); } @@ -218,7 +218,7 @@ public static BlockHeader readFrom( final BlobGas excessBlobGas = !input.isEndOfCurrentList() ? BlobGas.of(input.readUInt64Scalar()) : null; final Bytes32 parentBeaconBlockRoot = !input.isEndOfCurrentList() ? input.readBytes32() : null; - final Hash requestsRoot = !input.isEndOfCurrentList() ? Hash.wrap(input.readBytes32()) : null; + final Hash requestsHash = !input.isEndOfCurrentList() ? Hash.wrap(input.readBytes32()) : null; input.leaveList(); return new BlockHeader( parentHash, @@ -241,7 +241,7 @@ public static BlockHeader readFrom( blobGasUsed, excessBlobGas, parentBeaconBlockRoot, - requestsRoot, + requestsHash, blockHeaderFunctions); } @@ -292,8 +292,8 @@ public String toString() { if (parentBeaconBlockRoot != null) { sb.append("parentBeaconBlockRoot=").append(parentBeaconBlockRoot).append(", "); } - if (requestsRoot != null) { - sb.append("requestsRoot=").append(requestsRoot); + if (requestsHash != null) { + sb.append("requestsHash=").append(requestsHash); } return sb.append("}").toString(); } @@ -326,7 +326,7 @@ public static org.hyperledger.besu.ethereum.core.BlockHeader convertPluginBlockH pluginBlockHeader.getExcessBlobGas().map(BlobGas.class::cast).orElse(null), pluginBlockHeader.getParentBeaconBlockRoot().orElse(null), pluginBlockHeader - .getRequestsRoot() + .getRequestsHash() .map(h -> Hash.fromHexString(h.toHexString())) .orElse(null), blockHeaderFunctions); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeaderBuilder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeaderBuilder.java index 6f485d19ced..a024d53cd2f 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeaderBuilder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeaderBuilder.java @@ -45,7 +45,7 @@ public class BlockHeaderBuilder { private Hash transactionsRoot; private Hash withdrawalsRoot = null; - private Hash requestsRoot = null; + private Hash requestsHash = null; private Hash receiptsRoot; @@ -124,7 +124,7 @@ public static BlockHeaderBuilder fromHeader(final BlockHeader header) { .blobGasUsed(header.getBlobGasUsed().orElse(null)) .excessBlobGas(header.getExcessBlobGas().orElse(null)) .parentBeaconBlockRoot(header.getParentBeaconBlockRoot().orElse(null)) - .requestsRoot(header.getRequestsRoot().orElse(null)); + .requestsHash(header.getRequestsHash().orElse(null)); } public static BlockHeaderBuilder fromBuilder(final BlockHeaderBuilder fromBuilder) { @@ -148,7 +148,7 @@ public static BlockHeaderBuilder fromBuilder(final BlockHeaderBuilder fromBuilde .withdrawalsRoot(fromBuilder.withdrawalsRoot) .excessBlobGas(fromBuilder.excessBlobGas) .parentBeaconBlockRoot(fromBuilder.parentBeaconBlockRoot) - .requestsRoot(fromBuilder.requestsRoot) + .requestsHash(fromBuilder.requestsHash) .blockHeaderFunctions(fromBuilder.blockHeaderFunctions); toBuilder.nonce = fromBuilder.nonce; return toBuilder; @@ -178,7 +178,7 @@ public BlockHeader buildBlockHeader() { blobGasUsed, excessBlobGas, parentBeaconBlockRoot, - requestsRoot, + requestsHash, blockHeaderFunctions); } @@ -220,7 +220,7 @@ public SealableBlockHeader buildSealableBlockHeader() { blobGasUsed, excessBlobGas, parentBeaconBlockRoot, - requestsRoot); + requestsHash); } private void validateBlockHeader() { @@ -284,7 +284,7 @@ public BlockHeaderBuilder populateFrom(final SealableBlockHeader sealableBlockHe sealableBlockHeader.getBlobGasUsed().ifPresent(this::blobGasUsed); sealableBlockHeader.getExcessBlobGas().ifPresent(this::excessBlobGas); sealableBlockHeader.getParentBeaconBlockRoot().ifPresent(this::parentBeaconBlockRoot); - requestsRoot(sealableBlockHeader.getRequestsRoot().orElse(null)); + requestsHash(sealableBlockHeader.getRequestsHash().orElse(null)); return this; } @@ -399,8 +399,8 @@ public BlockHeaderBuilder withdrawalsRoot(final Hash hash) { return this; } - public BlockHeaderBuilder requestsRoot(final Hash hash) { - this.requestsRoot = hash; + public BlockHeaderBuilder requestsHash(final Hash hash) { + this.requestsHash = hash; return this; } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/ConsolidationRequest.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/ConsolidationRequest.java deleted file mode 100644 index 38345d1a31e..00000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/ConsolidationRequest.java +++ /dev/null @@ -1,90 +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.ethereum.core; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.PublicKey; -import org.hyperledger.besu.datatypes.RequestType; - -import java.util.Objects; - -public class ConsolidationRequest extends Request - implements org.hyperledger.besu.plugin.data.ConsolidationRequest { - - private final Address sourceAddress; - private final BLSPublicKey sourcePubkey; - private final BLSPublicKey targetPubkey; - - public ConsolidationRequest( - final Address sourceAddress, - final BLSPublicKey sourcePubkey, - final BLSPublicKey targetPubkey) { - this.sourceAddress = sourceAddress; - this.sourcePubkey = sourcePubkey; - this.targetPubkey = targetPubkey; - } - - @Override - public RequestType getType() { - return RequestType.CONSOLIDATION; - } - - @Override - public Address getSourceAddress() { - return sourceAddress; - } - - @Override - public PublicKey getSourcePubkey() { - return sourcePubkey; - } - - @Override - public PublicKey getTargetPubkey() { - return targetPubkey; - } - - @Override - public String toString() { - return "ConsolidationRequest{" - + "sourceAddress=" - + sourceAddress - + " sourcePubkey=" - + sourcePubkey - + " targetPubkey=" - + targetPubkey - + '}'; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final ConsolidationRequest that = (ConsolidationRequest) o; - return Objects.equals(sourceAddress, that.sourceAddress) - && Objects.equals(sourcePubkey, that.sourcePubkey) - && Objects.equals(targetPubkey, that.targetPubkey); - } - - @Override - public int hashCode() { - return Objects.hash(sourceAddress, sourcePubkey, targetPubkey); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/DepositRequest.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/DepositRequest.java deleted file mode 100644 index a005fa831e0..00000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/DepositRequest.java +++ /dev/null @@ -1,112 +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.ethereum.core; - -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.BLSSignature; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.datatypes.PublicKey; -import org.hyperledger.besu.datatypes.RequestType; - -import java.util.Objects; - -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt64; - -public class DepositRequest extends Request - implements org.hyperledger.besu.plugin.data.DepositRequest { - - private final BLSPublicKey pubkey; - private final Bytes32 depositWithdrawalCredentials; - private final GWei amount; - private final BLSSignature signature; - private final UInt64 index; - - public DepositRequest( - final BLSPublicKey pubkey, - final Bytes32 depositWithdrawalCredentials, - final GWei amount, - final BLSSignature signature, - final UInt64 index) { - this.pubkey = pubkey; - this.depositWithdrawalCredentials = depositWithdrawalCredentials; - this.amount = amount; - this.signature = signature; - this.index = index; - } - - @Override - public RequestType getType() { - return RequestType.DEPOSIT; - } - - @Override - public PublicKey getPubkey() { - return pubkey; - } - - @Override - public Bytes32 getWithdrawalCredentials() { - return depositWithdrawalCredentials; - } - - @Override - public GWei getAmount() { - return amount; - } - - @Override - public BLSSignature getSignature() { - return signature; - } - - @Override - public UInt64 getIndex() { - return index; - } - - @Override - public String toString() { - return "Deposit{" - + "pubKey=" - + pubkey - + ", withdrawalCredentials=" - + depositWithdrawalCredentials - + ", amount=" - + amount - + ", signature=" - + signature - + ", index=" - + index - + '}'; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final DepositRequest that = (DepositRequest) o; - return Objects.equals(pubkey, that.pubkey) - && Objects.equals(depositWithdrawalCredentials, that.depositWithdrawalCredentials) - && Objects.equals(amount, that.amount) - && Objects.equals(signature, that.signature) - && Objects.equals(index, that.index); - } - - @Override - public int hashCode() { - return Objects.hash(pubkey, depositWithdrawalCredentials, amount, signature, index); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Request.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Request.java index 8f4ea64e314..7d485336ad8 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Request.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Request.java @@ -15,27 +15,18 @@ package org.hyperledger.besu.ethereum.core; import org.hyperledger.besu.datatypes.RequestType; -import org.hyperledger.besu.ethereum.core.encoding.RequestDecoder; -import org.hyperledger.besu.ethereum.core.encoding.RequestEncoder; -import org.hyperledger.besu.ethereum.rlp.RLP; -import org.hyperledger.besu.ethereum.rlp.RLPInput; -import org.hyperledger.besu.ethereum.rlp.RLPOutput; import org.apache.tuweni.bytes.Bytes; -public abstract class Request implements org.hyperledger.besu.plugin.data.Request { +public record Request(RequestType type, Bytes data) + implements org.hyperledger.besu.plugin.data.Request { @Override - public abstract RequestType getType(); - - public static Request readFrom(final Bytes rlpBytes) { - return readFrom(RLP.input(rlpBytes)); - } - - public static Request readFrom(final RLPInput rlpInput) { - return RequestDecoder.decode(rlpInput); + public RequestType getType() { + return type(); } - public void writeTo(final RLPOutput out) { - RequestEncoder.encode(this, out); + @Override + public Bytes getData() { + return data(); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/SealableBlockHeader.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/SealableBlockHeader.java index df3859f2b7c..1934c8f8c0e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/SealableBlockHeader.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/SealableBlockHeader.java @@ -43,7 +43,7 @@ public class SealableBlockHeader extends ProcessableBlockHeader { protected final Hash withdrawalsRoot; - protected final Hash requestsRoot; + protected final Hash requestsHash; protected final Long blobGasUsed; @@ -69,7 +69,7 @@ protected SealableBlockHeader( final Long blobGasUsed, final BlobGas excessBlobGas, final Bytes32 parentBeaconBlockRoot, - final Hash requestsRoot) { + final Hash requestsHash) { super( parentHash, coinbase, @@ -85,7 +85,7 @@ protected SealableBlockHeader( this.transactionsRoot = transactionsRoot; this.withdrawalsRoot = withdrawalsRoot; this.receiptsRoot = receiptsRoot; - this.requestsRoot = requestsRoot; + this.requestsHash = requestsHash; this.logsBloom = logsBloom; this.gasUsed = gasUsed; this.extraData = extraData; @@ -166,12 +166,12 @@ public Optional getWithdrawalsRoot() { } /** - * Returns the block requests root hash. + * Returns the block requests hash. * - * @return the block requests root hash + * @return the block requests hash */ - public Optional getRequestsRoot() { - return Optional.ofNullable(requestsRoot); + public Optional getRequestsHash() { + return Optional.ofNullable(requestsHash); } /** diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/WithdrawalRequest.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/WithdrawalRequest.java deleted file mode 100644 index 0e7afc1595b..00000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/WithdrawalRequest.java +++ /dev/null @@ -1,89 +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.ethereum.core; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.datatypes.PublicKey; -import org.hyperledger.besu.datatypes.RequestType; - -import java.util.Objects; - -public class WithdrawalRequest extends Request - implements org.hyperledger.besu.plugin.data.WithdrawalRequest { - - private final Address sourceAddress; - private final BLSPublicKey validatorPubkey; - private final GWei amount; - - public WithdrawalRequest( - final Address sourceAddress, final BLSPublicKey validatorPubkey, final GWei amount) { - this.sourceAddress = sourceAddress; - this.validatorPubkey = validatorPubkey; - this.amount = amount; - } - - @Override - public RequestType getType() { - return RequestType.WITHDRAWAL; - } - - @Override - public Address getSourceAddress() { - return sourceAddress; - } - - @Override - public PublicKey getValidatorPubkey() { - return validatorPubkey; - } - - @Override - public GWei getAmount() { - return amount; - } - - @Override - public String toString() { - return "WithdrawalRequest{" - + "sourceAddress=" - + sourceAddress - + " validatorPubkey=" - + validatorPubkey - + " amount=" - + amount - + '}'; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final WithdrawalRequest that = (WithdrawalRequest) o; - return Objects.equals(sourceAddress, that.sourceAddress) - && Objects.equals(validatorPubkey, that.validatorPubkey) - && Objects.equals(amount, that.amount); - } - - @Override - public int hashCode() { - return Objects.hash(sourceAddress, validatorPubkey, amount); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestDecoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestDecoder.java deleted file mode 100644 index 29be31f46de..00000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestDecoder.java +++ /dev/null @@ -1,40 +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.ethereum.core.encoding; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.ethereum.core.ConsolidationRequest; -import org.hyperledger.besu.ethereum.rlp.RLP; -import org.hyperledger.besu.ethereum.rlp.RLPInput; - -import org.apache.tuweni.bytes.Bytes; - -public class ConsolidationRequestDecoder { - - public static ConsolidationRequest decode(final RLPInput rlpInput) { - rlpInput.enterList(); - final Address sourceAddress = Address.readFrom(rlpInput); - final BLSPublicKey sourcePublicKey = BLSPublicKey.readFrom(rlpInput); - final BLSPublicKey targetPublicKey = BLSPublicKey.readFrom(rlpInput); - rlpInput.leaveList(); - - return new ConsolidationRequest(sourceAddress, sourcePublicKey, targetPublicKey); - } - - public static ConsolidationRequest decodeOpaqueBytes(final Bytes input) { - return decode(RLP.input(input)); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestEncoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestEncoder.java deleted file mode 100644 index 9551f7b9740..00000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestEncoder.java +++ /dev/null @@ -1,60 +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.ethereum.core.encoding; - -import org.hyperledger.besu.datatypes.RequestType; -import org.hyperledger.besu.ethereum.core.ConsolidationRequest; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.rlp.RLP; -import org.hyperledger.besu.ethereum.rlp.RLPOutput; - -import org.apache.tuweni.bytes.Bytes; - -public class ConsolidationRequestEncoder { - - /** - * Encodes a Request into RLP format if it is a ConsolidationRequest. - * - * @param request The Request to encode, which must be a ConsolidationRequest. - * @param rlpOutput The RLPOutput to write the encoded data to. - * @throws IllegalArgumentException if the provided request is not a ConsolidationRequest. - */ - public static void encode(final Request request, final RLPOutput rlpOutput) { - if (!request.getType().equals(RequestType.CONSOLIDATION)) { - throw new IllegalArgumentException( - "The provided request is not of type ConsolidationRequest."); - } - encodeConsolidationRequest((ConsolidationRequest) request, rlpOutput); - } - - /** - * Encodes the details of a ConsolidationRequest into RLP format. - * - * @param consolidationRequest The ConsolidationRequest to encode. - * @param rlpOutput The RLPOutput to write the encoded data to. - */ - private static void encodeConsolidationRequest( - final ConsolidationRequest consolidationRequest, final RLPOutput rlpOutput) { - rlpOutput.startList(); - rlpOutput.writeBytes(consolidationRequest.getSourceAddress()); - rlpOutput.writeBytes(consolidationRequest.getSourcePubkey()); - rlpOutput.writeBytes(consolidationRequest.getTargetPubkey()); - rlpOutput.endList(); - } - - public static Bytes encodeOpaqueBytes(final Request consolidationRequest) { - return RLP.encode(rlpOutput -> encode(consolidationRequest, rlpOutput)); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositLogDecoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositLogDecoder.java new file mode 100644 index 00000000000..655ee63120e --- /dev/null +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositLogDecoder.java @@ -0,0 +1,40 @@ +/* + * 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.ethereum.core.encoding; + +import org.hyperledger.besu.ethereum.core.DepositContract; +import org.hyperledger.besu.evm.log.Log; + +import org.apache.tuweni.bytes.Bytes; +import org.web3j.tx.Contract; + +public class DepositLogDecoder { + + public static Bytes decodeFromLog(final Log log) { + Contract.EventValuesWithLog eventValues = DepositContract.staticExtractDepositEventWithLog(log); + final Bytes rawPublicKey = + Bytes.wrap((byte[]) eventValues.getNonIndexedValues().get(0).getValue()); + final Bytes rawWithdrawalCredential = + Bytes.wrap((byte[]) eventValues.getNonIndexedValues().get(1).getValue()); + final Bytes rawAmount = + Bytes.wrap((byte[]) eventValues.getNonIndexedValues().get(2).getValue()); + final Bytes rawSignature = + Bytes.wrap((byte[]) eventValues.getNonIndexedValues().get(3).getValue()); + final Bytes rawIndex = Bytes.wrap((byte[]) eventValues.getNonIndexedValues().get(4).getValue()); + + return Bytes.concatenate( + rawPublicKey, rawWithdrawalCredential, rawAmount, rawSignature, rawIndex); + } +} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestDecoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestDecoder.java deleted file mode 100644 index 85b56e1a573..00000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestDecoder.java +++ /dev/null @@ -1,70 +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.ethereum.core.encoding; - -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.BLSSignature; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.ethereum.core.DepositContract; -import org.hyperledger.besu.ethereum.core.DepositRequest; -import org.hyperledger.besu.ethereum.rlp.RLP; -import org.hyperledger.besu.ethereum.rlp.RLPInput; -import org.hyperledger.besu.evm.log.Log; - -import java.nio.ByteOrder; - -import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt64; -import org.web3j.tx.Contract; - -public class DepositRequestDecoder { - - public static DepositRequest decode(final RLPInput rlpInput) { - rlpInput.enterList(); - final BLSPublicKey publicKey = BLSPublicKey.readFrom(rlpInput); - final Bytes32 depositWithdrawalCredential = Bytes32.wrap(rlpInput.readBytes()); - final GWei amount = GWei.of(rlpInput.readUInt64Scalar()); - final BLSSignature signature = BLSSignature.readFrom(rlpInput); - final UInt64 index = UInt64.valueOf(rlpInput.readBigIntegerScalar()); - rlpInput.leaveList(); - - return new DepositRequest(publicKey, depositWithdrawalCredential, amount, signature, index); - } - - public static DepositRequest decodeFromLog(final Log log) { - Contract.EventValuesWithLog eventValues = DepositContract.staticExtractDepositEventWithLog(log); - final byte[] rawPublicKey = (byte[]) eventValues.getNonIndexedValues().get(0).getValue(); - final byte[] rawWithdrawalCredential = - (byte[]) eventValues.getNonIndexedValues().get(1).getValue(); - final byte[] rawAmount = (byte[]) eventValues.getNonIndexedValues().get(2).getValue(); - final byte[] rawSignature = (byte[]) eventValues.getNonIndexedValues().get(3).getValue(); - final byte[] rawIndex = (byte[]) eventValues.getNonIndexedValues().get(4).getValue(); - - return new DepositRequest( - BLSPublicKey.wrap(Bytes.wrap(rawPublicKey)), - Bytes32.wrap(Bytes.wrap(rawWithdrawalCredential)), - GWei.of( - Bytes.wrap(rawAmount) - .toLong( - ByteOrder.LITTLE_ENDIAN)), // Amount is little endian as per Deposit Contract - BLSSignature.wrap(Bytes.wrap(rawSignature)), - UInt64.valueOf(Bytes.wrap(rawIndex).reverse().toLong())); - } - - public static DepositRequest decodeOpaqueBytes(final Bytes input) { - return decode(RLP.input(input)); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestEncoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestEncoder.java deleted file mode 100644 index a99b0b761ce..00000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestEncoder.java +++ /dev/null @@ -1,42 +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.ethereum.core.encoding; - -import org.hyperledger.besu.ethereum.core.DepositRequest; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.rlp.RLP; -import org.hyperledger.besu.ethereum.rlp.RLPOutput; - -import org.apache.tuweni.bytes.Bytes; - -public class DepositRequestEncoder { - - public static void encode(final Request request, final RLPOutput rlpOutput) { - if (!(request instanceof DepositRequest depositRequest)) { - throw new IllegalArgumentException("The provided request is not of type deposit."); - } - rlpOutput.startList(); - rlpOutput.writeBytes(depositRequest.getPubkey()); - rlpOutput.writeBytes(depositRequest.getWithdrawalCredentials()); - rlpOutput.writeUInt64Scalar(depositRequest.getAmount()); - rlpOutput.writeBytes(depositRequest.getSignature()); - rlpOutput.writeUInt64Scalar(depositRequest.getIndex()); - rlpOutput.endList(); - } - - public static Bytes encodeOpaqueBytes(final Request deposit) { - return RLP.encode(rlpOutput -> encode(deposit, rlpOutput)); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestDecoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestDecoder.java deleted file mode 100644 index 64191e104b2..00000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestDecoder.java +++ /dev/null @@ -1,106 +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.ethereum.core.encoding; - -import org.hyperledger.besu.datatypes.RequestType; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.rlp.RLP; -import org.hyperledger.besu.ethereum.rlp.RLPInput; - -import java.util.Optional; - -import com.google.common.collect.ImmutableMap; -import org.apache.tuweni.bytes.Bytes; - -/** - * Decodes a request from its RLP encoded form. - * - *

This class provides functionality to decode requests based on their type. - */ -public class RequestDecoder { - - @FunctionalInterface - interface Decoder { - Request decode(RLPInput input); - } - - private static final ImmutableMap DECODERS = - ImmutableMap.of( - RequestType.WITHDRAWAL, - WithdrawalRequestDecoder::decode, - RequestType.DEPOSIT, - DepositRequestDecoder::decode, - RequestType.CONSOLIDATION, - ConsolidationRequestDecoder::decode); - - /** - * Decodes a request from its RLP encoded bytes. - * - *

This method first determines the type of the request and then decodes the request data - * according to the request type. - * - * @param rlpInput The RLP encoded request. - * @return The decoded Request object. - * @throws IllegalArgumentException if the request type is unsupported or invalid. - */ - public static Request decode(final RLPInput rlpInput) { - final Bytes requestBytes = rlpInput.readBytes(); - return getRequestType(requestBytes) - .map(type -> decodeRequest(requestBytes, type)) - .orElseThrow(() -> new IllegalArgumentException("Unsupported or invalid request type")); - } - - /** - * Decodes the request data according to the request type. - * - * @param requestBytes The bytes representing the request, including the request type byte. - * @param requestType The type of the request to decode. - * @return The decoded Request. - * @throws IllegalStateException if no decoder is found for the specified request type. - */ - private static Request decodeRequest(final Bytes requestBytes, final RequestType requestType) { - // Skip the first byte which is the request type - RLPInput requestInput = RLP.input(requestBytes.slice(1)); - Decoder decoder = - Optional.ofNullable(DECODERS.get(requestType)) - .orElseThrow( - () -> - new IllegalStateException( - "Decoder not found for request type: " + requestType)); - return decoder.decode(requestInput); - } - - /** - * Extracts the request type from the given bytes. - * - * @param bytes The bytes from which to extract the request type. - * @return An Optional containing the RequestType if it could be determined, or an empty Optional - * otherwise. - */ - private static Optional getRequestType(final Bytes bytes) { - try { - byte typeByte = bytes.get(0); - return Optional.of(RequestType.of(typeByte)); - } catch (IllegalArgumentException ex) { - return Optional.empty(); - } - } - - public static Request decodeOpaqueBytes(final Bytes input) { - - RequestType type = getRequestType(input).orElseThrow(); - return decodeRequest(input.slice(1), type); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestEncoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestEncoder.java deleted file mode 100644 index 3c61a77ac03..00000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestEncoder.java +++ /dev/null @@ -1,83 +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.ethereum.core.encoding; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.hyperledger.besu.datatypes.RequestType; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; -import org.hyperledger.besu.ethereum.rlp.RLP; -import org.hyperledger.besu.ethereum.rlp.RLPOutput; - -import com.google.common.collect.ImmutableMap; -import org.apache.tuweni.bytes.Bytes; - -/** Encodes Request objects into RLP format. */ -public class RequestEncoder { - - @FunctionalInterface - interface Encoder { - void encode(Request request, RLPOutput output); - } - - private static final ImmutableMap ENCODERS = - ImmutableMap.of( - RequestType.WITHDRAWAL, - WithdrawalRequestEncoder::encode, - RequestType.DEPOSIT, - DepositRequestEncoder::encode, - RequestType.CONSOLIDATION, - ConsolidationRequestEncoder::encode); - - /** - * Encodes a Request into the provided RLPOutput. - * - * @param request The Request to encode. - * @param rlpOutput The RLPOutput to write the encoded data to. - */ - public static void encode(final Request request, final RLPOutput rlpOutput) { - final RequestEncoder.Encoder encoder = getEncoder(request.getType()); - Bytes requestBytes = RLP.encode(out -> encoder.encode(request, out)); - rlpOutput.writeBytes( - Bytes.concatenate(Bytes.of(request.getType().getSerializedType()), requestBytes)); - } - - /** - * Encodes a Request into a Bytes object representing the RLP-encoded data. - * - * @param request The Request to encode. - * @return The RLP-encoded data as a Bytes object. - */ - public static Bytes encodeOpaqueBytes(final Request request) { - final RequestEncoder.Encoder encoder = getEncoder(request.getType()); - final BytesValueRLPOutput out = new BytesValueRLPOutput(); - out.writeByte(request.getType().getSerializedType()); - encoder.encode(request, out); - return out.encoded(); - } - - /** - * Retrieves the encoder for the specified RequestType. - * - * @param requestType The type of the request. - * @return The encoder for the specified type. - * @throws NullPointerException if no encoder is found for the specified type. - */ - private static RequestEncoder.Encoder getEncoder(final RequestType requestType) { - return checkNotNull( - ENCODERS.get(requestType), "Encoder not found for request type: %s", requestType); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestDecoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestDecoder.java deleted file mode 100644 index 031209284e8..00000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestDecoder.java +++ /dev/null @@ -1,41 +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.ethereum.core.encoding; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; -import org.hyperledger.besu.ethereum.rlp.RLP; -import org.hyperledger.besu.ethereum.rlp.RLPInput; - -import org.apache.tuweni.bytes.Bytes; - -public class WithdrawalRequestDecoder { - - public static WithdrawalRequest decode(final RLPInput rlpInput) { - rlpInput.enterList(); - final Address sourceAddress = Address.readFrom(rlpInput); - final BLSPublicKey validatorPubkey = BLSPublicKey.readFrom(rlpInput); - final GWei amount = GWei.of(rlpInput.readUInt64Scalar()); - rlpInput.leaveList(); - - return new WithdrawalRequest(sourceAddress, validatorPubkey, amount); - } - - public static WithdrawalRequest decodeOpaqueBytes(final Bytes input) { - return decode(RLP.input(input)); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestEncoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestEncoder.java deleted file mode 100644 index c9fdb37fcea..00000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestEncoder.java +++ /dev/null @@ -1,59 +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.ethereum.core.encoding; - -import org.hyperledger.besu.datatypes.RequestType; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; -import org.hyperledger.besu.ethereum.rlp.RLP; -import org.hyperledger.besu.ethereum.rlp.RLPOutput; - -import org.apache.tuweni.bytes.Bytes; - -public class WithdrawalRequestEncoder { - - /** - * Encodes a Request into RLP format if it is a WithdrawalRequest. - * - * @param request The Request to encode, which must be a WithdrawalRequest. - * @param rlpOutput The RLPOutput to write the encoded data to. - * @throws IllegalArgumentException if the provided request is not a WithdrawalRequest. - */ - public static void encode(final Request request, final RLPOutput rlpOutput) { - if (!request.getType().equals(RequestType.WITHDRAWAL)) { - throw new IllegalArgumentException("The provided request is not of type WithdrawalRequest."); - } - encodeWithdrawalRequest((WithdrawalRequest) request, rlpOutput); - } - - /** - * Encodes the details of a WithdrawalRequest into RLP format. - * - * @param withdrawalRequest The WithdrawalRequest to encode. - * @param rlpOutput The RLPOutput to write the encoded data to. - */ - private static void encodeWithdrawalRequest( - final WithdrawalRequest withdrawalRequest, final RLPOutput rlpOutput) { - rlpOutput.startList(); - rlpOutput.writeBytes(withdrawalRequest.getSourceAddress()); - rlpOutput.writeBytes(withdrawalRequest.getValidatorPubkey()); - rlpOutput.writeUInt64Scalar(withdrawalRequest.getAmount()); - rlpOutput.endList(); - } - - public static Bytes encodeOpaqueBytes(final Request withdrawalRequest) { - return RLP.encode(rlpOutput -> encode(withdrawalRequest, rlpOutput)); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java index 480a1d8d7ab..b8863fe142a 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java @@ -218,7 +218,7 @@ public BlockProcessingResult processBlock( blockHashLookup, OperationTracer.NO_TRACING); - maybeRequests = requestProcessor.get().process(context); + maybeRequests = Optional.of(requestProcessor.get().process(context)); } if (!rewardCoinbase(worldState, blockHeader, ommers, skipZeroBlockRewards)) { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BaseFeeBlockBodyValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BaseFeeBlockBodyValidator.java index aabc4ee5d09..0d43a470228 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BaseFeeBlockBodyValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BaseFeeBlockBodyValidator.java @@ -18,7 +18,6 @@ import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; -import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.core.feemarket.TransactionPriceCalculator; @@ -42,12 +41,11 @@ public boolean validateBodyLight( final ProtocolContext context, final Block block, final List receipts, - final Optional> requests, final HeaderValidationMode ommerValidationMode, final BodyValidationMode bodyValidationMode) { return super.validateBodyLight( - context, block, receipts, requests, ommerValidationMode, bodyValidationMode) + context, block, receipts, ommerValidationMode, bodyValidationMode) && validateTransactionGasPrice(block); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BlockBodyValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BlockBodyValidator.java index c84be3771b9..32000d12b96 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BlockBodyValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BlockBodyValidator.java @@ -17,11 +17,9 @@ import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import java.util.List; -import java.util.Optional; /** Validates block bodies. */ public interface BlockBodyValidator { @@ -41,7 +39,6 @@ boolean validateBody( ProtocolContext context, Block block, List receipts, - Optional> requests, Hash worldStateRootHash, final HeaderValidationMode ommerValidationMode); @@ -58,7 +55,6 @@ boolean validateBodyLight( ProtocolContext context, Block block, List receipts, - final Optional> requests, final HeaderValidationMode ommerValidationMode, final BodyValidationMode bodyValidationMode); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BodyValidation.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BodyValidation.java index 15e8c3c804f..f9835c2de5b 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BodyValidation.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BodyValidation.java @@ -15,6 +15,7 @@ package org.hyperledger.besu.ethereum.mainnet; import static org.hyperledger.besu.crypto.Hash.keccak256; +import static org.hyperledger.besu.crypto.Hash.sha256; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.BlockHeader; @@ -23,7 +24,6 @@ import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.core.encoding.EncodingContext; -import org.hyperledger.besu.ethereum.core.encoding.RequestEncoder; import org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder; import org.hyperledger.besu.ethereum.core.encoding.WithdrawalEncoder; import org.hyperledger.besu.ethereum.rlp.RLP; @@ -31,6 +31,7 @@ import org.hyperledger.besu.ethereum.trie.patricia.SimpleMerklePatriciaTrie; import org.hyperledger.besu.evm.log.LogsBloomFilter; +import java.util.ArrayList; import java.util.List; import java.util.stream.IntStream; @@ -89,16 +90,24 @@ public static Hash withdrawalsRoot(final List withdrawals) { } /** - * Generates the requests root for a list of requests + * Generates the requests hash for a list of requests * * @param requests list of request - * @return the requests root + * @return the requests hash */ - public static Hash requestsRoot(final List requests) { - final MerkleTrie trie = trie(); + public static Hash requestsHash(final List requests) { + List requestHashes = new ArrayList<>(); IntStream.range(0, requests.size()) - .forEach(i -> trie.put(indexKey(i), RequestEncoder.encodeOpaqueBytes(requests.get(i)))); - return Hash.wrap(trie.getRootHash()); + .forEach( + i -> { + final Request request = requests.get(i); + final Bytes requestBytes = + Bytes.concatenate( + Bytes.of(request.getType().getSerializedType()), request.getData()); + requestHashes.add(sha256(requestBytes)); + }); + + return Hash.wrap(sha256(Bytes.wrap(requestHashes))); } /** diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidator.java index 68951f9f2a3..1423183e945 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidator.java @@ -19,14 +19,11 @@ 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.Request; import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.util.HashSet; import java.util.List; -import java.util.Optional; import java.util.Set; import com.google.common.annotations.VisibleForTesting; @@ -52,12 +49,11 @@ public boolean validateBody( final ProtocolContext context, final Block block, final List receipts, - final Optional> requests, final Hash worldStateRootHash, final HeaderValidationMode ommerValidationMode) { if (!validateBodyLight( - context, block, receipts, requests, ommerValidationMode, BodyValidationMode.FULL)) { + context, block, receipts, ommerValidationMode, BodyValidationMode.FULL)) { return false; } @@ -78,7 +74,6 @@ public boolean validateBodyLight( final ProtocolContext context, final Block block, final List receipts, - final Optional> requests, final HeaderValidationMode ommerValidationMode, final BodyValidationMode bodyValidationMode) { if (bodyValidationMode == BodyValidationMode.NONE) { @@ -119,9 +114,6 @@ public boolean validateBodyLight( return false; } - if (!validateRequests(block, requests, receipts)) { - return false; - } return true; } @@ -324,13 +316,4 @@ private boolean validateWithdrawals(final Block block) { return true; } - - private boolean validateRequests( - final Block block, - final Optional> requests, - final List receipts) { - final RequestsValidatorCoordinator requestValidator = - protocolSchedule.getByBlockHeader(block.getHeader()).getRequestsValidatorCoordinator(); - return requestValidator.validate(block, requests, receipts); - } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockImporter.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockImporter.java index 8646467a282..7d655ea4c36 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockImporter.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockImporter.java @@ -66,13 +66,7 @@ public BlockImportResult importBlockForSyncing( final BodyValidationMode bodyValidationMode) { if (blockValidator.validateBlockForSyncing( - context, - block, - receipts, - block.getBody().getRequests(), - headerValidationMode, - ommerValidationMode, - bodyValidationMode)) { + context, block, receipts, headerValidationMode, ommerValidationMode, bodyValidationMode)) { context.getBlockchain().appendBlock(block, receipts); return new BlockImportResult(true); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java index 34261714774..23908664f8c 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java @@ -14,8 +14,7 @@ */ package org.hyperledger.besu.ethereum.mainnet; -import static org.hyperledger.besu.ethereum.mainnet.requests.MainnetRequestsValidator.pragueRequestsProcessors; -import static org.hyperledger.besu.ethereum.mainnet.requests.MainnetRequestsValidator.pragueRequestsValidator; +import static org.hyperledger.besu.ethereum.mainnet.requests.MainnetRequestsProcessor.pragueRequestsProcessors; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.config.PowAlgorithm; @@ -39,6 +38,7 @@ import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket; import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import org.hyperledger.besu.ethereum.mainnet.parallelization.MainnetParallelBlockProcessor; +import org.hyperledger.besu.ethereum.mainnet.requests.MainnetRequestsValidator; import org.hyperledger.besu.ethereum.mainnet.requests.RequestContractAddresses; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator; @@ -789,7 +789,7 @@ static ProtocolSpecBuilder pragueDefinition( .precompileContractRegistryBuilder(MainnetPrecompiledContractRegistries::prague) // EIP-7002 Withdrawals / EIP-6610 Deposits / EIP-7685 Requests - .requestsValidator(pragueRequestsValidator(requestContractAddresses)) + .requestsValidator(new MainnetRequestsValidator()) // EIP-7002 Withdrawals / EIP-6610 Deposits / EIP-7685 Requests .requestProcessorCoordinator(pragueRequestsProcessors(requestContractAddresses)) diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpec.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpec.java index b364679aa8b..4f74a893fbf 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpec.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpec.java @@ -22,7 +22,7 @@ import org.hyperledger.besu.ethereum.mainnet.blockhash.BlockHashProcessor; import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import org.hyperledger.besu.ethereum.mainnet.requests.RequestProcessorCoordinator; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; +import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidator; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor; import org.hyperledger.besu.evm.EVM; import org.hyperledger.besu.evm.gascalculator.GasCalculator; @@ -78,7 +78,7 @@ public class ProtocolSpec { private final WithdrawalsValidator withdrawalsValidator; private final Optional withdrawalsProcessor; - private final RequestsValidatorCoordinator requestsValidatorCoordinator; + private final RequestsValidator requestsValidator; private final Optional requestProcessorCoordinator; private final BlockHashProcessor blockHashProcessor; private final boolean isPoS; @@ -110,7 +110,7 @@ public class ProtocolSpec { * @param feeMarket an {@link Optional} wrapping {@link FeeMarket} class if appropriate. * @param powHasher the proof-of-work hasher * @param withdrawalsProcessor the Withdrawals processor to use - * @param requestsValidatorCoordinator the request validator to use + * @param requestsValidator the request validator to use * @param requestProcessorCoordinator the request processor to use * @param blockHashProcessor the blockHash processor to use * @param isPoS indicates whether the current spec is PoS @@ -142,7 +142,7 @@ public ProtocolSpec( final Optional powHasher, final WithdrawalsValidator withdrawalsValidator, final Optional withdrawalsProcessor, - final RequestsValidatorCoordinator requestsValidatorCoordinator, + final RequestsValidator requestsValidator, final Optional requestProcessorCoordinator, final BlockHashProcessor blockHashProcessor, final boolean isPoS, @@ -171,7 +171,7 @@ public ProtocolSpec( this.powHasher = powHasher; this.withdrawalsValidator = withdrawalsValidator; this.withdrawalsProcessor = withdrawalsProcessor; - this.requestsValidatorCoordinator = requestsValidatorCoordinator; + this.requestsValidator = requestsValidator; this.requestProcessorCoordinator = requestProcessorCoordinator; this.blockHashProcessor = blockHashProcessor; this.isPoS = isPoS; @@ -375,8 +375,8 @@ public Optional getWithdrawalsProcessor() { return withdrawalsProcessor; } - public RequestsValidatorCoordinator getRequestsValidatorCoordinator() { - return requestsValidatorCoordinator; + public RequestsValidator getRequestsValidator() { + return requestsValidator; } public Optional getRequestProcessorCoordinator() { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java index 0d792b7870c..c3b5ef6dc05 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java @@ -31,8 +31,9 @@ import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.FlexiblePrivacyPrecompiledContract; import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.PrivacyPluginPrecompiledContract; import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.PrivacyPrecompiledContract; +import org.hyperledger.besu.ethereum.mainnet.requests.ProhibitedRequestValidator; import org.hyperledger.besu.ethereum.mainnet.requests.RequestProcessorCoordinator; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; +import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidator; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator; import org.hyperledger.besu.evm.EVM; @@ -80,8 +81,7 @@ public class ProtocolSpecBuilder { private WithdrawalsValidator withdrawalsValidator = new WithdrawalsValidator.ProhibitedWithdrawals(); private WithdrawalsProcessor withdrawalsProcessor; - private RequestsValidatorCoordinator requestsValidatorCoordinator = - RequestsValidatorCoordinator.empty(); + private RequestsValidator requestsValidator = new ProhibitedRequestValidator(); private RequestProcessorCoordinator requestProcessorCoordinator; protected BlockHashProcessor blockHashProcessor; private FeeMarket feeMarket = FeeMarket.legacy(); @@ -268,8 +268,8 @@ public ProtocolSpecBuilder withdrawalsProcessor(final WithdrawalsProcessor withd } public ProtocolSpecBuilder requestsValidator( - final RequestsValidatorCoordinator requestsValidatorCoordinator) { - this.requestsValidatorCoordinator = requestsValidatorCoordinator; + final RequestsValidator requestsValidatorCoordinator) { + this.requestsValidator = requestsValidatorCoordinator; return this; } @@ -402,7 +402,7 @@ public ProtocolSpec build(final ProtocolSchedule protocolSchedule) { Optional.ofNullable(powHasher), withdrawalsValidator, Optional.ofNullable(withdrawalsProcessor), - requestsValidatorCoordinator, + requestsValidator, Optional.ofNullable(requestProcessorCoordinator), blockHashProcessor, isPoS, diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/SystemCallProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/SystemCallProcessor.java index f74de79442f..06aa3efd8ef 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/SystemCallProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/SystemCallProcessor.java @@ -56,7 +56,8 @@ public SystemCallProcessor(final MainnetTransactionProcessor mainnetTransactionP * @param blockHeader the current block header. * @param operationTracer the operation tracer for tracing EVM operations. * @param blockHashLookup the block hash lookup function. - * @return the output data from the call + * @return the output data from the call. If no code exists at the callAddress then an empty Bytes + * is returned. */ public Bytes process( final Address callAddress, @@ -69,7 +70,7 @@ public Bytes process( final Account maybeContract = worldState.get(callAddress); if (maybeContract == null) { LOG.trace("System call address not found {}", callAddress); - return null; + return Bytes.EMPTY; } final AbstractMessageProcessor messageProcessor = diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/AbstractSystemCallRequestProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/AbstractSystemCallRequestProcessor.java deleted file mode 100644 index a7d959f4b98..00000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/AbstractSystemCallRequestProcessor.java +++ /dev/null @@ -1,102 +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.ethereum.mainnet.requests; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.mainnet.SystemCallProcessor; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -import org.apache.tuweni.bytes.Bytes; - -/** - * Abstract base class for processing system call requests. - * - * @param The type of request to be processed. - */ -public abstract class AbstractSystemCallRequestProcessor - implements RequestProcessor { - - /** - * Processes a system call and converts the result into requests of type T. - * - * @param context The request context being processed. - * @return An {@link Optional} containing a list of {@link T} objects if any are found - */ - @Override - public Optional> process(final ProcessRequestContext context) { - - SystemCallProcessor systemCallProcessor = - new SystemCallProcessor(context.protocolSpec().getTransactionProcessor()); - - Bytes systemCallOutput = - systemCallProcessor.process( - getCallAddress(), - context.mutableWorldState().updater(), - context.blockHeader(), - context.operationTracer(), - context.blockHashLookup()); - - List requests = parseRequests(systemCallOutput); - return Optional.ofNullable(requests); - } - - /** - * Parses the provided bytes into a list of {@link T} objects. - * - * @param bytes The bytes representing requests. - * @return A list of parsed {@link T} objects. - */ - protected List parseRequests(final Bytes bytes) { - if (bytes == null) { - return null; - } - final List requests = new ArrayList<>(); - if (bytes.isEmpty()) { - return requests; - } - int count = bytes.size() / getRequestBytesSize(); - for (int i = 0; i < count; i++) { - Bytes requestBytes = bytes.slice(i * getRequestBytesSize(), getRequestBytesSize()); - requests.add(parseRequest(requestBytes)); - } - return requests; - } - - /** - * Parses a single request from the provided bytes. - * - * @param requestBytes The bytes representing a single request. - * @return A parsed {@link T} object. - */ - protected abstract T parseRequest(final Bytes requestBytes); - - /** - * Gets the call address for the specific request type. - * - * @return The call address. - */ - protected abstract Address getCallAddress(); - - /** - * Gets the size of the bytes representing a single request. - * - * @return The size of the bytes representing a single request. - */ - protected abstract int getRequestBytesSize(); -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ConsolidationRequestProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ConsolidationRequestProcessor.java deleted file mode 100644 index 641720670fb..00000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ConsolidationRequestProcessor.java +++ /dev/null @@ -1,73 +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.ethereum.mainnet.requests; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.ethereum.core.ConsolidationRequest; - -import org.apache.tuweni.bytes.Bytes; - -public class ConsolidationRequestProcessor - extends AbstractSystemCallRequestProcessor { - public static final Address CONSOLIDATION_REQUEST_CONTRACT_ADDRESS = - Address.fromHexString("0x00b42dbF2194e931E80326D950320f7d9Dbeac02"); - - private static final int ADDRESS_BYTES = 20; - private static final int PUBLIC_KEY_BYTES = 48; - private static final int CONSOLIDATION_REQUEST_BYTES_SIZE = - ADDRESS_BYTES + PUBLIC_KEY_BYTES + PUBLIC_KEY_BYTES; - private final Address consolidationRequestContractAddress; - - public ConsolidationRequestProcessor(final Address consolidationRequestContractAddress) { - this.consolidationRequestContractAddress = consolidationRequestContractAddress; - } - - /** - * Gets the call address for consolidation requests. - * - * @return The call address. - */ - @Override - protected Address getCallAddress() { - return consolidationRequestContractAddress; - } - - /** - * Gets the size of the bytes representing a single consolidation request. - * - * @return The size of the bytes representing a single consolidation request. - */ - @Override - protected int getRequestBytesSize() { - return CONSOLIDATION_REQUEST_BYTES_SIZE; - } - - /** - * Parses a single consolidation request from the provided bytes. - * - * @param requestBytes The bytes representing a single consolidation request. - * @return A parsed {@link ConsolidationRequest} object. - */ - @Override - protected ConsolidationRequest parseRequest(final Bytes requestBytes) { - final Address sourceAddress = Address.wrap(requestBytes.slice(0, ADDRESS_BYTES)); - final BLSPublicKey sourcePublicKey = - BLSPublicKey.wrap(requestBytes.slice(ADDRESS_BYTES, PUBLIC_KEY_BYTES)); - final BLSPublicKey targetPublicKey = - BLSPublicKey.wrap(requestBytes.slice(ADDRESS_BYTES + PUBLIC_KEY_BYTES, PUBLIC_KEY_BYTES)); - return new ConsolidationRequest(sourceAddress, sourcePublicKey, targetPublicKey); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ConsolidationRequestValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ConsolidationRequestValidator.java deleted file mode 100644 index f03de5e6b53..00000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ConsolidationRequestValidator.java +++ /dev/null @@ -1,92 +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.ethereum.mainnet.requests; - -import static org.hyperledger.besu.ethereum.mainnet.requests.RequestUtil.getConsolidationRequests; - -import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.ConsolidationRequest; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.TransactionReceipt; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ConsolidationRequestValidator implements RequestValidator { - - private static final Logger LOG = LoggerFactory.getLogger(ConsolidationRequestValidator.class); - - public static final int MAX_CONSOLIDATION_REQUESTS_PER_BLOCK = 1; - - private boolean validateConsolidationRequestParameter( - final Optional> consolidationRequests) { - return consolidationRequests.isPresent(); - } - - private boolean validateConsolidationRequestsInBlock( - final Block block, final List consolidationRequests) { - final Hash blockHash = block.getHash(); - - final List consolidationRequestsInBlock = - block - .getBody() - .getRequests() - .flatMap(requests -> getConsolidationRequests(Optional.of(requests))) - .orElse(Collections.emptyList()); - - if (consolidationRequestsInBlock.size() > MAX_CONSOLIDATION_REQUESTS_PER_BLOCK) { - LOG.warn( - "Block {} has more than the allowed maximum number of consolidation requests", blockHash); - return false; - } - - // Validate ConsolidationRequests - final boolean expectedConsolidationRequestMatch = - consolidationRequests.equals(consolidationRequestsInBlock); - if (!expectedConsolidationRequestMatch) { - LOG.warn( - "Block {} has a mismatch between block consolidations and RPC consolidation requests (in_block = {}, " - + "expected = {})", - blockHash, - consolidationRequestsInBlock, - consolidationRequests); - return false; - } - return true; - } - - @Override - public boolean validate( - final Block block, final List requests, final List receipts) { - var consolidationRequests = - getConsolidationRequests(Optional.of(requests)).orElse(Collections.emptyList()); - return validateConsolidationRequestsInBlock(block, consolidationRequests); - } - - @Override - public boolean validateParameter(final Optional> request) { - if (request.isEmpty()) { - return true; - } - var consolidationRequests = - RequestUtil.filterRequestsOfType(request.get(), ConsolidationRequest.class); - return validateConsolidationRequestParameter(Optional.of(consolidationRequests)); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestProcessor.java index 8902ecc510a..37e266f015b 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestProcessor.java @@ -15,22 +15,19 @@ package org.hyperledger.besu.ethereum.mainnet.requests; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.DepositRequest; +import org.hyperledger.besu.datatypes.RequestType; import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.core.encoding.DepositRequestDecoder; +import org.hyperledger.besu.ethereum.core.encoding.DepositLogDecoder; -import java.util.Collections; import java.util.List; import java.util.Optional; import com.google.common.annotations.VisibleForTesting; +import org.apache.tuweni.bytes.Bytes; public class DepositRequestProcessor implements RequestProcessor { - public static final Address DEFAULT_DEPOSIT_CONTRACT_ADDRESS = - Address.fromHexString("0x00000000219ab540356cbb839cbe05303d7705fa"); - private final Optional

depositContractAddress; public DepositRequestProcessor(final Address depositContractAddress) { @@ -38,26 +35,22 @@ public DepositRequestProcessor(final Address depositContractAddress) { } @Override - public Optional> process(final ProcessRequestContext context) { + public Request process(final ProcessRequestContext context) { if (depositContractAddress.isEmpty()) { - return Optional.empty(); + return new Request(RequestType.DEPOSIT, Bytes.EMPTY); } - List depositRequests = - findDepositRequestsFromReceipts(context.transactionReceipts()); - return Optional.of(depositRequests); + Optional depositRequests = getDepositRequestData(context.transactionReceipts()); + return new Request(RequestType.DEPOSIT, depositRequests.orElse(Bytes.EMPTY)); } @VisibleForTesting - List findDepositRequestsFromReceipts( - final List transactionReceipts) { - return depositContractAddress - .map( - address -> - transactionReceipts.stream() - .flatMap(receipt -> receipt.getLogsList().stream()) - .filter(log -> address.equals(log.getLogger())) - .map(DepositRequestDecoder::decodeFromLog) - .toList()) - .orElse(Collections.emptyList()); + Optional getDepositRequestData(final List transactionReceipts) { + return depositContractAddress.flatMap( + address -> + transactionReceipts.stream() + .flatMap(receipt -> receipt.getLogsList().stream()) + .filter(log -> address.equals(log.getLogger())) + .map(DepositLogDecoder::decodeFromLog) + .reduce(Bytes::concatenate)); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestValidator.java deleted file mode 100644 index 6c9eedf305d..00000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestValidator.java +++ /dev/null @@ -1,86 +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.ethereum.mainnet.requests; - -import static org.hyperledger.besu.ethereum.mainnet.requests.RequestUtil.getDepositRequests; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.DepositRequest; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.core.encoding.DepositRequestDecoder; -import org.hyperledger.besu.evm.log.Log; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DepositRequestValidator implements RequestValidator { - - private static final Logger LOG = LoggerFactory.getLogger(DepositRequestValidator.class); - private final Address depositContractAddress; - - public DepositRequestValidator(final Address depositContractAddress) { - this.depositContractAddress = depositContractAddress; - } - - @Override - public boolean validateParameter(final Optional> depositRequests) { - return depositRequests.isPresent(); - } - - public boolean validateDepositRequests( - final Block block, - final List actualDepositRequests, - final List receipts) { - - List expectedDepositRequests = new ArrayList<>(); - - for (TransactionReceipt receipt : receipts) { - for (Log log : receipt.getLogsList()) { - if (depositContractAddress.equals(log.getLogger())) { - DepositRequest depositRequest = DepositRequestDecoder.decodeFromLog(log); - expectedDepositRequests.add(depositRequest); - } - } - } - - boolean isValid = actualDepositRequests.equals(expectedDepositRequests); - - if (!isValid) { - LOG.warn( - "Deposits validation failed. Deposits from block body do not match deposits from logs. Block hash: {}", - block.getHash()); - LOG.debug( - "Deposits from logs: {}, deposits from block body: {}", - expectedDepositRequests, - actualDepositRequests); - } - - return isValid; - } - - @Override - public boolean validate( - final Block block, final List requests, final List receipts) { - var depositRequests = getDepositRequests(Optional.of(requests)).orElse(Collections.emptyList()); - return validateDepositRequests(block, depositRequests, receipts); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsProcessor.java new file mode 100644 index 00000000000..d1c290c407f --- /dev/null +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsProcessor.java @@ -0,0 +1,39 @@ +/* + * 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.ethereum.mainnet.requests; + +import org.hyperledger.besu.datatypes.RequestType; + +public class MainnetRequestsProcessor { + + public static RequestProcessorCoordinator pragueRequestsProcessors( + final RequestContractAddresses requestContractAddresses) { + return new RequestProcessorCoordinator.Builder() + .addProcessor( + RequestType.WITHDRAWAL, + new SystemCallRequestProcessor( + requestContractAddresses.getWithdrawalRequestContractAddress(), + RequestType.WITHDRAWAL)) + .addProcessor( + RequestType.CONSOLIDATION, + new SystemCallRequestProcessor( + requestContractAddresses.getConsolidationRequestContractAddress(), + RequestType.CONSOLIDATION)) + .addProcessor( + RequestType.DEPOSIT, + new DepositRequestProcessor(requestContractAddresses.getDepositContractAddress())) + .build(); + } +} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidator.java index 9c86d18f7ad..fb49ba71fc1 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidator.java @@ -14,34 +14,47 @@ */ package org.hyperledger.besu.ethereum.mainnet.requests; -import org.hyperledger.besu.datatypes.RequestType; - -public class MainnetRequestsValidator { - public static RequestsValidatorCoordinator pragueRequestsValidator( - final RequestContractAddresses requestContractAddresses) { - return new RequestsValidatorCoordinator.Builder() - .addValidator(RequestType.WITHDRAWAL, new WithdrawalRequestValidator()) - .addValidator(RequestType.CONSOLIDATION, new ConsolidationRequestValidator()) - .addValidator( - RequestType.DEPOSIT, - new DepositRequestValidator(requestContractAddresses.getDepositContractAddress())) - .build(); +import org.hyperledger.besu.ethereum.core.Request; + +import java.util.List; +import java.util.Optional; + +import com.google.common.collect.Ordering; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Validates requests within a block against a set of predefined validators. This class delegates + * the validation of requests of specific types to corresponding validators. It ensures that + * requests are properly ordered, have a valid hash, and meet the criteria defined by their + * validators. + */ +public class MainnetRequestsValidator implements RequestsValidator { + private static final Logger LOG = LoggerFactory.getLogger(MainnetRequestsValidator.class); + + /** + * Validates a block's requests by ensuring they are correctly ordered, have a valid hash, and + * pass their respective type-specific validations. + * + * @param maybeRequests The list of requests to be validated. + * @return true if all validations pass; false otherwise. + */ + @Override + public boolean validate(final Optional> maybeRequests) { + if (maybeRequests.isEmpty()) { + LOG.warn("Must contain requests (even if empty list)"); + return false; + } + + if (!isRequestOrderValid(maybeRequests.get())) { + LOG.warn("Ordering across requests must be ascending by type"); + return false; + } + + return true; } - public static RequestProcessorCoordinator pragueRequestsProcessors( - final RequestContractAddresses requestContractAddresses) { - return new RequestProcessorCoordinator.Builder() - .addProcessor( - RequestType.WITHDRAWAL, - new WithdrawalRequestProcessor( - requestContractAddresses.getWithdrawalRequestContractAddress())) - .addProcessor( - RequestType.CONSOLIDATION, - new ConsolidationRequestProcessor( - requestContractAddresses.getConsolidationRequestContractAddress())) - .addProcessor( - RequestType.DEPOSIT, - new DepositRequestProcessor(requestContractAddresses.getDepositContractAddress())) - .build(); + private static boolean isRequestOrderValid(final List requests) { + return Ordering.natural().onResultOf(Request::getType).isOrdered(requests); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestValidator.java new file mode 100644 index 00000000000..4545ff3530b --- /dev/null +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestValidator.java @@ -0,0 +1,38 @@ +/* + * Copyright contributors to 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.ethereum.mainnet.requests; + +import org.hyperledger.besu.ethereum.core.Request; + +import java.util.List; +import java.util.Optional; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ProhibitedRequestValidator implements RequestsValidator { + private static final Logger LOG = LoggerFactory.getLogger(MainnetRequestsValidator.class); + + @Override + public boolean validate(final Optional> maybeRequests) { + boolean hasRequests = maybeRequests.isPresent(); + + if (hasRequests) { + LOG.warn("There are requests but requests are prohibited"); + } + + return !hasRequests; + } +} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestsValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestsValidator.java deleted file mode 100644 index 362da527283..00000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestsValidator.java +++ /dev/null @@ -1,53 +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.ethereum.mainnet.requests; - -import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.TransactionReceipt; - -import java.util.List; -import java.util.Optional; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** Validates that a block does not contain any prohibited requests. */ -public class ProhibitedRequestsValidator implements RequestValidator { - private static final Logger LOG = LoggerFactory.getLogger(ProhibitedRequestsValidator.class); - - @Override - public boolean validate( - final Block block, final List request, final List receipts) { - boolean hasRequests = block.getBody().getRequests().isPresent(); - boolean hasRequestsRoot = block.getHeader().getRequestsRoot().isPresent(); - - if (hasRequests) { - LOG.warn("Block {} contains requests but requests are prohibited", block.getHash()); - } - - if (hasRequestsRoot) { - LOG.warn( - "Block {} header contains requests_root but requests are prohibited", block.getHash()); - } - - return !(hasRequests || hasRequestsRoot); - } - - @Override - public boolean validateParameter(final Optional> request) { - return request.isEmpty(); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestContractAddresses.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestContractAddresses.java index b75677dda79..d16d1bddbc0 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestContractAddresses.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestContractAddresses.java @@ -14,10 +14,6 @@ */ package org.hyperledger.besu.ethereum.mainnet.requests; -import static org.hyperledger.besu.ethereum.mainnet.requests.ConsolidationRequestProcessor.CONSOLIDATION_REQUEST_CONTRACT_ADDRESS; -import static org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestProcessor.DEFAULT_DEPOSIT_CONTRACT_ADDRESS; -import static org.hyperledger.besu.ethereum.mainnet.requests.WithdrawalRequestProcessor.DEFAULT_WITHDRAWAL_REQUEST_CONTRACT_ADDRESS; - import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.datatypes.Address; @@ -26,6 +22,13 @@ public class RequestContractAddresses { private final Address depositContractAddress; private final Address consolidationRequestContractAddress; + public static final Address DEFAULT_WITHDRAWAL_REQUEST_CONTRACT_ADDRESS = + Address.fromHexString("0x09FC772D0857550724B07B850A4323F39112AAAA"); + public static final Address DEFAULT_CONSOLIDATION_REQUEST_CONTRACT_ADDRESS = + Address.fromHexString("0x01ABEA29659E5E97C95107F20BB753CD3E09BBBB"); + public static final Address DEFAULT_DEPOSIT_CONTRACT_ADDRESS = + Address.fromHexString("0x00000000219ab540356cbb839cbe05303d7705fa"); + public RequestContractAddresses( final Address withdrawalRequestContractAddress, final Address depositContractAddress, @@ -44,7 +47,7 @@ public static RequestContractAddresses fromGenesis( genesisConfigOptions.getDepositContractAddress().orElse(DEFAULT_DEPOSIT_CONTRACT_ADDRESS), genesisConfigOptions .getConsolidationRequestContractAddress() - .orElse(CONSOLIDATION_REQUEST_CONTRACT_ADDRESS)); + .orElse(DEFAULT_CONSOLIDATION_REQUEST_CONTRACT_ADDRESS)); } public Address getWithdrawalRequestContractAddress() { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestProcessor.java index 55f3cd41788..dd471aec1e8 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestProcessor.java @@ -16,9 +16,6 @@ import org.hyperledger.besu.ethereum.core.Request; -import java.util.List; -import java.util.Optional; - public interface RequestProcessor { - Optional> process(final ProcessRequestContext context); + Request process(final ProcessRequestContext context); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestProcessorCoordinator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestProcessorCoordinator.java index b98274729d5..7dd3b5c6dd8 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestProcessorCoordinator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestProcessorCoordinator.java @@ -17,9 +17,7 @@ import org.hyperledger.besu.datatypes.RequestType; import org.hyperledger.besu.ethereum.core.Request; -import java.util.ArrayList; import java.util.List; -import java.util.Optional; import com.google.common.collect.ImmutableSortedMap; @@ -37,18 +35,10 @@ private RequestProcessorCoordinator( this.processors = processors; } - public Optional> process(final ProcessRequestContext context) { - List requests = null; - for (RequestProcessor requestProcessor : processors.values()) { - var r = requestProcessor.process(context); - if (r.isPresent()) { - if (requests == null) { - requests = new ArrayList<>(); - } - requests.addAll(r.get()); - } - } - return Optional.ofNullable(requests); + public List process(final ProcessRequestContext context) { + return processors.values().stream() + .map(requestProcessor -> requestProcessor.process(context)) + .toList(); } public static class Builder { @@ -62,7 +52,12 @@ public RequestProcessorCoordinator.Builder addProcessor( } public RequestProcessorCoordinator build() { - return new RequestProcessorCoordinator(requestProcessorBuilder.build()); + final ImmutableSortedMap processors = + requestProcessorBuilder.build(); + if (processors.isEmpty()) { + throw new IllegalStateException("No processors added to RequestProcessorCoordinator"); + } + return new RequestProcessorCoordinator(processors); } } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestUtil.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestUtil.java deleted file mode 100644 index f3a10161a49..00000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestUtil.java +++ /dev/null @@ -1,85 +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.ethereum.mainnet.requests; - -import org.hyperledger.besu.ethereum.core.ConsolidationRequest; -import org.hyperledger.besu.ethereum.core.DepositRequest; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -public class RequestUtil { - - /** - * Filters and returns a list of requests of a specific type from a given list of requests. - * - * @param The type of the request to filter by, extending Request. - * @param requests The list of requests to filter. - * @param requestType The class of the request type to filter for. - * @return A List containing only requests of the specified type, or an empty list if the input - * list is null or contains no requests of the specified type. - */ - public static List filterRequestsOfType( - final List requests, final Class requestType) { - if (requests == null) { - return Collections.emptyList(); - } - return requests.stream().filter(requestType::isInstance).map(requestType::cast).toList(); - } - - public static Optional> getDepositRequests( - final Optional> requests) { - return requests.map(r -> filterRequestsOfType(r, DepositRequest.class)); - } - - public static Optional> getWithdrawalRequests( - final Optional> requests) { - return requests.map(r -> filterRequestsOfType(r, WithdrawalRequest.class)); - } - - public static Optional> getConsolidationRequests( - final Optional> requests) { - return requests.map(r -> filterRequestsOfType(r, ConsolidationRequest.class)); - } - - /** - * Combines multiple optional lists of requests into a single optional list. - * - * @param maybeDepositRequests Optional list of deposit requests. - * @param maybeWithdrawalRequest Optional list of withdrawal requests. - * @param maybeConsolidationRequest Optional list of withdrawal requests. - * @return An Optional containing the combined list of requests, or an empty Optional if all input - * lists are empty. - */ - public static Optional> combine( - final Optional> maybeDepositRequests, - final Optional> maybeWithdrawalRequest, - final Optional> maybeConsolidationRequest) { - if (maybeDepositRequests.isEmpty() - && maybeWithdrawalRequest.isEmpty() - && maybeConsolidationRequest.isEmpty()) { - return Optional.empty(); - } - List requests = new ArrayList<>(); - maybeDepositRequests.ifPresent(requests::addAll); - maybeWithdrawalRequest.ifPresent(requests::addAll); - maybeConsolidationRequest.ifPresent(requests::addAll); - return Optional.of(requests); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestsValidator.java similarity index 63% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestValidator.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestsValidator.java index 74fd8cd7ebc..a05afa8128e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestsValidator.java @@ -1,5 +1,5 @@ /* - * Copyright contributors to Hyperledger Besu. + * Copyright contributors to 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 @@ -14,17 +14,11 @@ */ package org.hyperledger.besu.ethereum.mainnet.requests; -import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.TransactionReceipt; import java.util.List; import java.util.Optional; -/** Interface for request validation logic. */ -public interface RequestValidator { - boolean validate( - final Block block, final List request, final List receipts); - - boolean validateParameter(final Optional> request); +public interface RequestsValidator { + boolean validate(Optional> maybeRequests); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestsValidatorCoordinator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestsValidatorCoordinator.java deleted file mode 100644 index 7b8f5cf4973..00000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestsValidatorCoordinator.java +++ /dev/null @@ -1,202 +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.ethereum.mainnet.requests; - -import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.datatypes.RequestType; -import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.mainnet.BodyValidation; - -import java.util.List; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -import com.google.common.collect.ImmutableSortedMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Validates requests within a block against a set of predefined validators. This class delegates - * the validation of requests of specific types to corresponding validators. It ensures that - * requests are properly ordered, have a valid root, and meet the criteria defined by their - * validators. - */ -public class RequestsValidatorCoordinator { - private static final Logger LOG = LoggerFactory.getLogger(RequestsValidatorCoordinator.class); - private final ImmutableSortedMap validators; - - public static RequestsValidatorCoordinator empty() { - return new Builder().build(); - } - - /** - * Constructs a new RequestsDelegateValidator with a mapping of request types to their respective - * validators. - * - * @param validators An immutable map of request types to their corresponding validators. - */ - private RequestsValidatorCoordinator( - final ImmutableSortedMap validators) { - this.validators = validators; - } - - /** - * Validates a block's requests by ensuring they are correctly ordered, have a valid root, and - * pass their respective type-specific validations. - * - * @param block The block containing the requests to be validated. - * @param maybeRequests The list of requests contained within the block. - * @param receipts The list of transaction receipts corresponding to the requests. - * @return true if all validations pass; false otherwise. - */ - public boolean validate( - final Block block, - final Optional> maybeRequests, - final List receipts) { - - if (validators.isEmpty()) { - return isRequestsEmpty(block, maybeRequests); - } - - if (!isRequestsRootValid(block, maybeRequests)) { - return false; - } - - if (!isRequestOrderValid(maybeRequests.get())) { - final Hash blockHash = block.getHash(); - LOG.warn("Block {} the ordering across requests must be ascending by type", blockHash); - return false; - } - return validateRequests(block, maybeRequests.get(), receipts); - } - - /** - * Validates the requests contained within a block against their respective type-specific - * validators. - * - * @param block The block containing the requests. - * @param requests The list of requests to be validated. - * @param receipts The list of transaction receipts corresponding to the requests. - * @return true if all requests pass their type-specific validations; false otherwise. - */ - private boolean validateRequests( - final Block block, final List requests, final List receipts) { - return requestTypes(requests).stream() - .allMatch(type -> validateRequestOfType(type, block, requests, receipts)); - } - - private boolean isRequestsRootValid(final Block block, final Optional> requests) { - final Hash blockHash = block.getHash(); - final Optional maybeRequestsRoot = block.getHeader().getRequestsRoot(); - - if (maybeRequestsRoot.isEmpty()) { - LOG.warn("Block {} must contain requests root", blockHash); - return false; - } - - if (block.getBody().getRequests().isEmpty()) { - LOG.warn("Block body {} must contain requests (even if empty list)", blockHash); - return false; - } - - if (requests.isEmpty()) { - LOG.warn("Block {} must contain requests (even if empty list)", blockHash); - return false; - } - - final Hash expectedRequestsRoot = BodyValidation.requestsRoot(requests.get()); - if (!expectedRequestsRoot.equals(maybeRequestsRoot.get())) { - LOG.warn( - "Block {} requests root does not match expected hash root for requests in block", - blockHash); - return false; - } - return true; - } - - private boolean isRequestsEmpty(final Block block, final Optional> requests) { - final Hash blockHash = block.getHash(); - final Optional maybeRequestsRoot = block.getHeader().getRequestsRoot(); - - if (maybeRequestsRoot.isPresent()) { - LOG.warn("Block {} must not contain requests root", blockHash); - return false; - } - - if (block.getBody().getRequests().isPresent()) { - LOG.warn("Block body {} must not contain requests", blockHash); - return false; - } - - if (requests.isPresent()) { - LOG.warn("Block {} must not contain requests", blockHash); - return false; - } - return true; - } - - private boolean validateRequestOfType( - final RequestType type, - final Block block, - final List requests, - final List receipts) { - - Optional requestValidator = getRequestValidator(type); - if (requestValidator.isEmpty()) { - LOG.warn("Block {} contains prohibited requests of type: {}", block.getHash(), type); - return false; - } - List typedRequests = filterRequestsOfType(requests, type); - return requestValidator.get().validate(block, typedRequests, receipts); - } - - public Optional getRequestValidator(final RequestType requestType) { - return Optional.ofNullable(validators.get(requestType)); - } - - private static Set requestTypes(final List requests) { - return requests.stream().map(Request::getType).collect(Collectors.toSet()); - } - - private static boolean isRequestOrderValid(final List requests) { - return IntStream.range(0, requests.size() - 1) - .allMatch(i -> requests.get(i).getType().compareTo(requests.get(i + 1).getType()) <= 0); - } - - private static List filterRequestsOfType( - final List requests, final RequestType type) { - return requests.stream() - .filter(request -> request.getType() == type) - .collect(Collectors.toList()); - } - - public static class Builder { - private final ImmutableSortedMap.Builder validatorsBuilder = - ImmutableSortedMap.naturalOrder(); - - public Builder addValidator(final RequestType type, final RequestValidator validator) { - this.validatorsBuilder.put(type, validator); - return this; - } - - public RequestsValidatorCoordinator build() { - return new RequestsValidatorCoordinator(validatorsBuilder.build()); - } - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/SystemCallRequestProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/SystemCallRequestProcessor.java new file mode 100644 index 00000000000..3bcfe02c2a4 --- /dev/null +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/SystemCallRequestProcessor.java @@ -0,0 +1,57 @@ +/* + * 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.ethereum.mainnet.requests; + +import org.hyperledger.besu.datatypes.Address; +import org.hyperledger.besu.datatypes.RequestType; +import org.hyperledger.besu.ethereum.core.Request; +import org.hyperledger.besu.ethereum.mainnet.SystemCallProcessor; + +import org.apache.tuweni.bytes.Bytes; + +/** Processes system call requests. */ +public class SystemCallRequestProcessor implements RequestProcessor { + + private final Address callAddress; + private final RequestType requestType; + + public SystemCallRequestProcessor(final Address callAddress, final RequestType requestType) { + this.callAddress = callAddress; + this.requestType = requestType; + } + + /** + * Processes a system call and converts the result as a Request. + * + * @param context The request context being processed. + * @return A {@link Request} request + */ + @Override + public Request process(final ProcessRequestContext context) { + + SystemCallProcessor systemCallProcessor = + new SystemCallProcessor(context.protocolSpec().getTransactionProcessor()); + + Bytes systemCallOutput = + systemCallProcessor.process( + callAddress, + context.mutableWorldState().updater(), + context.blockHeader(), + context.operationTracer(), + context.blockHashLookup()); + + return new Request(requestType, systemCallOutput); + } +} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/WithdrawalRequestProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/WithdrawalRequestProcessor.java deleted file mode 100644 index d4021c9a104..00000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/WithdrawalRequestProcessor.java +++ /dev/null @@ -1,79 +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.ethereum.mainnet.requests; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; - -import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.units.bigints.UInt64; - -/** Processor for handling withdrawal requests. */ -public class WithdrawalRequestProcessor - extends AbstractSystemCallRequestProcessor { - - public static final Address DEFAULT_WITHDRAWAL_REQUEST_CONTRACT_ADDRESS = - Address.fromHexString("0x00A3ca265EBcb825B45F985A16CEFB49958cE017"); - - private static final int ADDRESS_BYTES = 20; - private static final int PUBLIC_KEY_BYTES = 48; - private static final int AMOUNT_BYTES = 8; - private static final int WITHDRAWAL_REQUEST_BYTES_SIZE = - ADDRESS_BYTES + PUBLIC_KEY_BYTES + AMOUNT_BYTES; - - private final Address withdrawalRequestContractAddress; - - public WithdrawalRequestProcessor(final Address withdrawalRequestContractAddress) { - this.withdrawalRequestContractAddress = withdrawalRequestContractAddress; - } - - /** - * Gets the call address for withdrawal requests. - * - * @return The call address. - */ - @Override - protected Address getCallAddress() { - return withdrawalRequestContractAddress; - } - - /** - * Gets the size of the bytes representing a single withdrawal request. - * - * @return The size of the bytes representing a single withdrawal request. - */ - @Override - protected int getRequestBytesSize() { - return WITHDRAWAL_REQUEST_BYTES_SIZE; - } - - /** - * Parses a single withdrawal request from the provided bytes. - * - * @param requestBytes The bytes representing a single withdrawal request. - * @return A parsed {@link WithdrawalRequest} object. - */ - @Override - protected WithdrawalRequest parseRequest(final Bytes requestBytes) { - final Address sourceAddress = Address.wrap(requestBytes.slice(0, ADDRESS_BYTES)); - final BLSPublicKey validatorPublicKey = - BLSPublicKey.wrap(requestBytes.slice(ADDRESS_BYTES, PUBLIC_KEY_BYTES)); - final UInt64 amount = - UInt64.fromBytes(requestBytes.slice(ADDRESS_BYTES + PUBLIC_KEY_BYTES, AMOUNT_BYTES)); - return new WithdrawalRequest(sourceAddress, validatorPublicKey, GWei.of(amount)); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/WithdrawalRequestValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/WithdrawalRequestValidator.java deleted file mode 100644 index fc108b798f3..00000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/WithdrawalRequestValidator.java +++ /dev/null @@ -1,93 +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.ethereum.mainnet.requests; - -import static org.hyperledger.besu.ethereum.mainnet.requests.RequestUtil.getWithdrawalRequests; - -import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class WithdrawalRequestValidator implements RequestValidator { - - public static final int MAX_WITHDRAWAL_REQUESTS_PER_BLOCK = 16; - - private static final Logger LOG = LoggerFactory.getLogger(WithdrawalRequestValidator.class); - - private boolean validateWithdrawalRequestParameter( - final Optional> withdrawalRequests) { - return withdrawalRequests.isPresent(); - } - - private boolean validateWithdrawalRequestsInBlock( - final Block block, final List withdrawalRequests) { - final Hash blockHash = block.getHash(); - - final List withdrawalRequestsInBlock = - block - .getBody() - .getRequests() - .flatMap(requests -> getWithdrawalRequests(Optional.of(requests))) - .orElse(Collections.emptyList()); - - // TODO Do we need to allow for customization? (e.g. if the value changes in the next fork) - if (withdrawalRequestsInBlock.size() > MAX_WITHDRAWAL_REQUESTS_PER_BLOCK) { - LOG.warn( - "Block {} has more than the allowed maximum number of withdrawal requests", blockHash); - return false; - } - - // Validate WithdrawalRequests - final boolean expectedWithdrawalRequestMatch = - withdrawalRequests.equals(withdrawalRequestsInBlock); - if (!expectedWithdrawalRequestMatch) { - LOG.warn( - "Block {} has a mismatch between its withdrawal requests and expected withdrawal requests (in_block = {}, " - + "expected = {})", - blockHash, - withdrawalRequestsInBlock, - withdrawalRequests); - return false; - } - return true; - } - - @Override - public boolean validate( - final Block block, final List requests, final List receipts) { - var withdrawalRequests = - getWithdrawalRequests(Optional.of(requests)).orElse(Collections.emptyList()); - return validateWithdrawalRequestsInBlock(block, withdrawalRequests); - } - - @Override - public boolean validateParameter(final Optional> request) { - if (request.isEmpty()) { - return false; - } - var withdrawalRequests = - RequestUtil.filterRequestsOfType(request.get(), WithdrawalRequest.class); - return validateWithdrawalRequestParameter(Optional.of(withdrawalRequests)); - } -} diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockDataGenerator.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockDataGenerator.java index ea62d7f1fa1..acbd8679f41 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockDataGenerator.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockDataGenerator.java @@ -303,7 +303,7 @@ public BlockHeader header(final long number, final BlockBody body, final BlockOp .mixHash(hash()) .nonce(blockNonce) .withdrawalsRoot(options.getWithdrawalsRoot(null)) - .requestsRoot(options.getRequestsRoot(null)) + .requestsHash(options.getRequestsHash(null)) .blockHeaderFunctions( options.getBlockHeaderFunctions(new MainnetBlockHeaderFunctions())); options.getBaseFee(Optional.of(Wei.of(uint256(2)))).ifPresent(blockHeaderBuilder::baseFee); @@ -329,10 +329,7 @@ public BlockBody body(final BlockOptions options) { } return new BlockBody( - options.getTransactions(defaultTxs), - ommers, - options.getWithdrawals(Optional.empty()), - options.getRequests(Optional.empty())); + options.getTransactions(defaultTxs), ommers, options.getWithdrawals(Optional.empty())); } private BlockHeader ommer() { @@ -655,7 +652,7 @@ public static class BlockOptions { private Optional> maybeBaseFee = Optional.empty(); private Optional withdrawalsRoot = Optional.empty(); - private Optional requestsRoot = Optional.empty(); + private Optional requestsHash = Optional.empty(); private Optional> maybeMaxFeePerBlobGas = Optional.empty(); @@ -724,8 +721,8 @@ public Optional> getWithdrawals( return withdrawals.orElse(defaultValue); } - public Hash getRequestsRoot(final Hash defaultValue) { - return requestsRoot.orElse(defaultValue); + public Hash getRequestsHash(final Hash defaultValue) { + return requestsHash.orElse(defaultValue); } public Optional> getRequests(final Optional> defaultValue) { @@ -852,8 +849,8 @@ public BlockOptions setWithdrawalsRoot(final Hash withdrawalsRoot) { return this; } - public BlockOptions setRequestsRoot(final Hash requestsRoot) { - this.requestsRoot = Optional.of(requestsRoot); + public BlockOptions setRequestsHash(final Hash requestsHash) { + this.requestsHash = Optional.of(requestsHash); return this; } diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockHeaderTestFixture.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockHeaderTestFixture.java index 44a4ffd0603..99cf2407b8d 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockHeaderTestFixture.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockHeaderTestFixture.java @@ -50,7 +50,7 @@ public class BlockHeaderTestFixture { private Hash mixHash = Hash.EMPTY; private long nonce = 0; private Optional withdrawalsRoot = Optional.empty(); - private Optional requestsRoot = Optional.empty(); + private Optional requestsHash = Optional.empty(); private BlockHeaderFunctions blockHeaderFunctions = new MainnetBlockHeaderFunctions(); private Optional excessBlobGas = Optional.empty(); private Optional blobGasUsed = Optional.empty(); @@ -78,7 +78,7 @@ public BlockHeader buildHeader() { withdrawalsRoot.ifPresent(builder::withdrawalsRoot); excessBlobGas.ifPresent(builder::excessBlobGas); blobGasUsed.ifPresent(builder::blobGasUsed); - requestsRoot.ifPresent(builder::requestsRoot); + requestsHash.ifPresent(builder::requestsHash); parentBeaconBlockRoot.ifPresent(builder::parentBeaconBlockRoot); builder.blockHeaderFunctions(blockHeaderFunctions); @@ -175,8 +175,8 @@ public BlockHeaderTestFixture withdrawalsRoot(final Hash withdrawalsRoot) { return this; } - public BlockHeaderTestFixture requestsRoot(final Hash requestsRoot) { - this.requestsRoot = Optional.ofNullable(requestsRoot); + public BlockHeaderTestFixture requestsHash(final Hash requestsHash) { + this.requestsHash = Optional.ofNullable(requestsHash); return this; } diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/NonBesuBlockHeader.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/NonBesuBlockHeader.java index 000e727db75..00fbba18334 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/NonBesuBlockHeader.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/NonBesuBlockHeader.java @@ -115,7 +115,7 @@ public Optional getWithdrawalsRoot() { } @Override - public Optional getRequestsRoot() { + public Optional getRequestsHash() { return Optional.empty(); } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/BlockImportExceptionHandlingTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/BlockImportExceptionHandlingTest.java index d3a261803fb..f9a325f3d7e 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/BlockImportExceptionHandlingTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/BlockImportExceptionHandlingTest.java @@ -42,7 +42,6 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.mainnet.blockhash.FrontierBlockHashProcessor; import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; import org.hyperledger.besu.ethereum.storage.StorageProvider; import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.BonsaiWorldStateProvider; import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage; @@ -117,8 +116,6 @@ public void setup() { when(protocolContext.getBlockchain()).thenReturn(blockchain); when(protocolContext.getWorldStateArchive()).thenReturn(worldStateArchive); when(protocolSchedule.getByBlockHeader(any())).thenReturn(protocolSpec); - when(protocolSpec.getRequestsValidatorCoordinator()) - .thenReturn(RequestsValidatorCoordinator.empty()); when(protocolSpec.getBlockHashProcessor()).thenReturn(new FrontierBlockHashProcessor()); when(protocolSpec.getGasCalculator()).thenReturn(gasCalculator); when(protocolSpec.getFeeMarket()).thenReturn(feeMarket); @@ -156,7 +153,6 @@ void shouldNotBadBlockWhenInternalErrorDuringPersisting() { eq(goodBlock), any(), any(), - any(), eq(HeaderValidationMode.DETACHED_ONLY))) .thenReturn(true); assertThat(badBlockManager.getBadBlocks()).isEmpty(); @@ -193,7 +189,6 @@ void shouldNotBadBlockWhenInternalErrorOnBlockLookup() { eq(goodBlock), any(), any(), - any(), eq(HeaderValidationMode.DETACHED_ONLY))) .thenReturn(true); assertThat(badBlockManager.getBadBlocks()).isEmpty(); @@ -262,7 +257,6 @@ void shouldNotBadBlockWhenInternalErrorDuringValidateBody() { eq(goodBlock), any(), any(), - any(), eq(HeaderValidationMode.DETACHED_ONLY))) .thenThrow(new StorageException("database problem")); assertThat(badBlockManager.getBadBlocks()).isEmpty(); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/MainnetBlockValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/MainnetBlockValidatorTest.java index a63b736b0e8..013adae51ea 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/MainnetBlockValidatorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/MainnetBlockValidatorTest.java @@ -99,10 +99,8 @@ public void setup() { when(worldStateArchive.getMutable()).thenReturn(worldState); when(blockHeaderValidator.validateHeader(any(), any(), any())).thenReturn(true); when(blockHeaderValidator.validateHeader(any(), any(), any(), any())).thenReturn(true); - when(blockBodyValidator.validateBody(any(), any(), any(), any(), any(), any())) - .thenReturn(true); - when(blockBodyValidator.validateBodyLight(any(), any(), any(), any(), any(), any())) - .thenReturn(true); + when(blockBodyValidator.validateBody(any(), any(), any(), any(), any())).thenReturn(true); + when(blockBodyValidator.validateBodyLight(any(), any(), any(), any(), any())).thenReturn(true); when(blockProcessor.processBlock(any(), any(), any())).thenReturn(successfulProcessingResult); when(blockProcessor.processBlock(any(), any(), any(), any())) .thenReturn(successfulProcessingResult); @@ -167,8 +165,7 @@ public void validateAndProcessBlock_whenHeaderInvalid() { @Test public void validateAndProcessBlock_whenBlockBodyInvalid() { - when(blockBodyValidator.validateBody(any(), eq(block), any(), any(), any(), any())) - .thenReturn(false); + when(blockBodyValidator.validateBody(any(), eq(block), any(), any(), any())).thenReturn(false); BlockProcessingResult result = mainnetBlockValidator.validateAndProcessBlock( @@ -353,7 +350,6 @@ public void validateBlockForSyncing_onSuccess() { protocolContext, block, Collections.emptyList(), - block.getBody().getRequests(), HeaderValidationMode.FULL, HeaderValidationMode.FULL, BodyValidationMode.FULL); @@ -375,7 +371,6 @@ public void validateBlockValidation_onFailedHeaderForSyncing() { protocolContext, block, Collections.emptyList(), - block.getBody().getRequests(), headerValidationMode, headerValidationMode, bodyValidationMode); @@ -392,7 +387,6 @@ public void validateBlockValidation_onFailedBodyForSyncing() { eq(protocolContext), eq(block), any(), - any(), eq(headerValidationMode), eq(bodyValidationMode))) .thenReturn(false); @@ -402,7 +396,6 @@ public void validateBlockValidation_onFailedBodyForSyncing() { protocolContext, block, Collections.emptyList(), - block.getBody().getRequests(), headerValidationMode, headerValidationMode, bodyValidationMode); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/chain/GenesisStateTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/chain/GenesisStateTest.java index 70c1e64bd1a..ba036347085 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/chain/GenesisStateTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/chain/GenesisStateTest.java @@ -275,7 +275,7 @@ void genesisFromCancun(final DataStorageConfiguration dataStorageConfiguration) assertThat(last).isNotNull(); Wei lastBalance = last.getBalance(); assertThat(lastBalance).isEqualTo(Wei.fromHexString("0x123450000000000000000")); - assertThat(header.getRequestsRoot().isPresent()).isFalse(); + assertThat(header.getRequestsHash().isPresent()).isFalse(); } @ParameterizedTest @@ -290,7 +290,7 @@ void genesisFromPrague(final DataStorageConfiguration dataStorageConfiguration) assertThat(header.getHash()) .isEqualTo( Hash.fromHexString( - "0xaad700fd347070b47165c299dd5b843d0a47d4eaee12d3414a5cb58c5c8a8fe4")); + "0x554807b22674e6d335f734485993857bbad7a9543affb0663a10c14d78135ec7")); assertThat(header.getGasLimit()).isEqualTo(0x2fefd8); assertThat(header.getGasUsed()).isZero(); assertThat(header.getNumber()).isZero(); @@ -326,11 +326,11 @@ void genesisFromPrague(final DataStorageConfiguration dataStorageConfiguration) Wei lastBalance = last.getBalance(); assertThat(lastBalance).isEqualTo(Wei.fromHexString("0x123450000000000000000")); - assertThat(header.getRequestsRoot().isPresent()).isTrue(); - assertThat(header.getRequestsRoot().get()) + assertThat(header.getRequestsHash().isPresent()).isTrue(); + assertThat(header.getRequestsHash().get()) .isEqualTo( Hash.fromHexString( - "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")); + "0x6036c41849da9c076ed79654d434017387a88fb833c2856b32e18218b3341c5f")); } @Test diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestDecoderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestDecoderTest.java deleted file mode 100644 index bb264dfa23f..00000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestDecoderTest.java +++ /dev/null @@ -1,46 +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.ethereum.core.encoding; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.ethereum.core.ConsolidationRequest; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; -import org.hyperledger.besu.ethereum.rlp.RLP; - -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.Test; - -class ConsolidationRequestDecoderTest { - - @Test - public void shouldDecodeWithdrawalRequest() { - final ConsolidationRequest expectedConsolidationRequest = - new ConsolidationRequest( - Address.fromHexString("0x814FaE9f487206471B6B0D713cD51a2D35980000"), - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - BLSPublicKey.fromHexString( - "0xa09a4a15bf67b328c9b101d09e5c6ee6672978f7ad9ef0d9e2c457aee99223555d8601f0cb3bcc4ce1af9864779a416e")); - - final BytesValueRLPOutput out = new BytesValueRLPOutput(); - expectedConsolidationRequest.writeTo(out); - - final Request decodedWithdrawalRequest = RequestDecoder.decode(RLP.input(out.encoded())); - - Assertions.assertThat(decodedWithdrawalRequest).isEqualTo(expectedConsolidationRequest); - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestEncoderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestEncoderTest.java deleted file mode 100644 index 10a53379b83..00000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestEncoderTest.java +++ /dev/null @@ -1,55 +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.ethereum.core.encoding; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.ethereum.core.ConsolidationRequest; - -import org.apache.tuweni.bytes.Bytes; -import org.junit.jupiter.api.Test; - -class ConsolidationRequestEncoderTest { - - private final String expectedEncodedBytes = - "f87794763c396673f9c391dce3361a9a71c8e161388000b0b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416eb0a09a4a15bf67b328c9b101d09e5c6ee6672978f7ad9ef0d9e2c457aee99223555d8601f0cb3bcc4ce1af9864779a416e"; - - final ConsolidationRequest consolidationRequest = - new ConsolidationRequest( - Address.fromHexString("0x763c396673F9c391DCe3361A9A71C8E161388000"), - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - BLSPublicKey.fromHexString( - "0xa09a4a15bf67b328c9b101d09e5c6ee6672978f7ad9ef0d9e2c457aee99223555d8601f0cb3bcc4ce1af9864779a416e")); - - @Test - void shouldEncodeConsolidationRequest() { - final Bytes encoded = ConsolidationRequestEncoder.encodeOpaqueBytes(consolidationRequest); - assertThat(encoded).isEqualTo(Bytes.fromHexString(expectedEncodedBytes)); - } - - @Test - void shouldEncodeRequest() { - final Bytes encoded = RequestEncoder.encodeOpaqueBytes(consolidationRequest); - assertThat(encoded) - .isEqualTo( - Bytes.fromHexString( - String.format( - "0x%02X%s", - consolidationRequest.getType().getSerializedType(), expectedEncodedBytes))); - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestDecoderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositLogDecoderTest.java similarity index 51% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestDecoderTest.java rename to ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositLogDecoderTest.java index 622bd897545..14166553e62 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestDecoderTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositLogDecoderTest.java @@ -17,41 +17,15 @@ import static org.assertj.core.api.Assertions.assertThat; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.BLSSignature; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.ethereum.core.DepositRequest; import org.hyperledger.besu.evm.log.Log; import org.hyperledger.besu.evm.log.LogTopic; import java.util.List; import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt64; import org.junit.jupiter.api.Test; -class DepositRequestDecoderTest { - @Test - void shouldDecodeDeposit() { - final DepositRequest expectedDepositRequest = - new DepositRequest( - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - Bytes32.fromHexString( - "0x0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483"), - GWei.of(32000000000L), - BLSSignature.fromHexString( - "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), - UInt64.ONE); - - final DepositRequest depositRequest = - DepositRequestDecoder.decodeOpaqueBytes( - Bytes.fromHexString( - "0xf8bbb0b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416ea00017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483850773594000b860a889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb501")); - - assertThat(depositRequest).isEqualTo(expectedDepositRequest); - } +class DepositLogDecoderTest { @Test void shouldDecodeDepositFromLog() { @@ -65,19 +39,12 @@ void shouldDecodeDepositFromLog() { "0x00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483000000000000000000000000000000000000000000000000000000000000000800405973070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060a889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb500000000000000000000000000000000000000000000000000000000000000083f3d080000000000000000000000000000000000000000000000000000000000"); final Log log = new Log(address, data, topics); - final DepositRequest depositRequest = DepositRequestDecoder.decodeFromLog(log); + final Bytes requestData = DepositLogDecoder.decodeFromLog(log); - final DepositRequest expectedDepositRequest = - new DepositRequest( - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - Bytes32.fromHexString( - "0x0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483"), - GWei.of(32000000000L), - BLSSignature.fromHexString( - "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), - UInt64.valueOf(539967)); + final Bytes expectedDepositRequestData = + Bytes.fromHexString( + "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa355894830040597307000000a889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb53f3d080000000000"); - assertThat(depositRequest).isEqualTo(expectedDepositRequest); + assertThat(requestData).isEqualTo(expectedDepositRequestData); } } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestEncoderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestEncoderTest.java deleted file mode 100644 index 1e6dde6aa87..00000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestEncoderTest.java +++ /dev/null @@ -1,61 +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.ethereum.core.encoding; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.BLSSignature; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.ethereum.core.DepositRequest; - -import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt64; -import org.junit.jupiter.api.Test; - -class DepositRequestEncoderTest { - private final String expectedDepositEncodedBytes = - "f8bbb0b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416ea00017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483850773594000b860a889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb501"; - - final DepositRequest depositRequest = - new DepositRequest( - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - Bytes32.fromHexString( - "0x0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483"), - GWei.of(32000000000L), - BLSSignature.fromHexString( - "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), - UInt64.ONE); - - @Test - void shouldEncodeDeposit() { - final Bytes encoded = DepositRequestEncoder.encodeOpaqueBytes(depositRequest); - assertThat(encoded).isEqualTo(Bytes.fromHexString(expectedDepositEncodedBytes)); - } - - @Test - void shouldEncodeDepositRequest() { - final Bytes encoded = RequestEncoder.encodeOpaqueBytes(depositRequest); - // Request encoding is Request = RequestType ++ RequestData - assertThat(encoded) - .isEqualTo( - Bytes.fromHexString( - String.format( - "0x%02X%s", - depositRequest.getType().getSerializedType(), expectedDepositEncodedBytes))); - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestDecoderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestDecoderTest.java deleted file mode 100644 index ad6da667c1e..00000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestDecoderTest.java +++ /dev/null @@ -1,46 +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.ethereum.core.encoding; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; -import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; -import org.hyperledger.besu.ethereum.rlp.RLP; - -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.Test; - -class WithdrawalRequestDecoderTest { - - @Test - public void shouldDecodeWithdrawalRequest() { - final WithdrawalRequest expectedWithdrawalRequest = - new WithdrawalRequest( - Address.fromHexString("0x814FaE9f487206471B6B0D713cD51a2D35980000"), - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - GWei.of(5)); - - final BytesValueRLPOutput out = new BytesValueRLPOutput(); - expectedWithdrawalRequest.writeTo(out); - - final Request decodedWithdrawalRequest = RequestDecoder.decode(RLP.input(out.encoded())); - - Assertions.assertThat(decodedWithdrawalRequest).isEqualTo(expectedWithdrawalRequest); - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestEncoderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestEncoderTest.java deleted file mode 100644 index 14c9cfacef2..00000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestEncoderTest.java +++ /dev/null @@ -1,55 +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.ethereum.core.encoding; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; - -import org.apache.tuweni.bytes.Bytes; -import org.junit.jupiter.api.Test; - -class WithdrawalRequestEncoderTest { - - private final String expectedEncodedBytes = - "f84794763c396673f9c391dce3361a9a71c8e161388000b0b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e05"; - - final WithdrawalRequest withdrawalRequest = - new WithdrawalRequest( - Address.fromHexString("0x763c396673F9c391DCe3361A9A71C8E161388000"), - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - GWei.of(5)); - - @Test - void shouldEncodeWithdrawalRequest() { - final Bytes encoded = WithdrawalRequestEncoder.encodeOpaqueBytes(withdrawalRequest); - assertThat(encoded).isEqualTo(Bytes.fromHexString(expectedEncodedBytes)); - } - - @Test - void shouldEncodeRequest() { - final Bytes encoded = RequestEncoder.encodeOpaqueBytes(withdrawalRequest); - assertThat(encoded) - .isEqualTo( - Bytes.fromHexString( - String.format( - "0x%02X%s", - withdrawalRequest.getType().getSerializedType(), expectedEncodedBytes))); - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessorTest.java index 2a66c6e1151..33347929cf0 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessorTest.java @@ -33,7 +33,6 @@ import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.mainnet.blockhash.FrontierBlockHashProcessor; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; import org.hyperledger.besu.ethereum.referencetests.ReferenceTestBlockchain; import org.hyperledger.besu.ethereum.referencetests.ReferenceTestWorldState; @@ -68,9 +67,6 @@ abstract class AbstractBlockProcessorTest { @BeforeEach void baseSetup() { lenient().when(protocolSchedule.getByBlockHeader(any())).thenReturn(protocolSpec); - lenient() - .when(protocolSpec.getRequestsValidatorCoordinator()) - .thenReturn(RequestsValidatorCoordinator.empty()); lenient() .when(protocolSpec.getBlockHashProcessor()) .thenReturn(new FrontierBlockHashProcessor()); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/BodyValidationTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/BodyValidationTest.java index fd5c4387ccd..45ce54f252f 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/BodyValidationTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/BodyValidationTest.java @@ -15,12 +15,16 @@ package org.hyperledger.besu.ethereum.mainnet; import org.hyperledger.besu.datatypes.Hash; +import org.hyperledger.besu.datatypes.RequestType; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; +import org.hyperledger.besu.ethereum.core.Request; import java.io.IOException; import java.util.Arrays; +import java.util.List; +import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; @@ -57,4 +61,28 @@ public void calculateWithdrawalsRoot() throws IOException { Assertions.assertThat(header.getWithdrawalsRoot()).hasValue(Hash.wrap(withdrawalsRoot)); } } + + @Test + public void calculateRequestsHash() { + List requests = + List.of( + new Request( + RequestType.DEPOSIT, + Bytes.fromHexString( + "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100405973070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000")), + new Request( + RequestType.WITHDRAWAL, + Bytes.fromHexString( + "0x6389e7f33ce3b1e94e4325ef02829cd12297ef710000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000")), + new Request( + RequestType.CONSOLIDATION, + Bytes.fromHexString( + "0x8a0a19589531694250d570040a0c4b74576919b8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"))); + + Bytes32 requestHash = BodyValidation.requestsHash(requests); + Assertions.assertThat(requestHash) + .isEqualTo( + Bytes32.fromHexString( + "0x0e53a6857da18cf29c6ae28be10a333fc0eaafbd3f425f09e5e81f29e4d3d766")); + } } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ConsolidationRequestValidatorTestFixtures.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ConsolidationRequestValidatorTestFixtures.java deleted file mode 100644 index fbd304d1cd9..00000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ConsolidationRequestValidatorTestFixtures.java +++ /dev/null @@ -1,136 +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.ethereum.mainnet; - -import static org.hyperledger.besu.ethereum.mainnet.requests.ConsolidationRequestValidator.MAX_CONSOLIDATION_REQUESTS_PER_BLOCK; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.BlockDataGenerator; -import org.hyperledger.besu.ethereum.core.ConsolidationRequest; -import org.hyperledger.besu.ethereum.core.Request; - -import java.util.List; -import java.util.Optional; -import java.util.stream.IntStream; - -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.bytes.Bytes48; - -public class ConsolidationRequestValidatorTestFixtures { - - private static final BlockDataGenerator blockDataGenerator = new BlockDataGenerator(); - - static ConsolidationRequestTestParameter - blockWithConsolidationRequestsAndWithdrawalRequestsRoot() { - final ConsolidationRequest consolidationRequest = createConsolidationRequest(); - final Optional> maybeConsolidationRequests = - Optional.of(List.of(consolidationRequest)); - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequestsRoot(BodyValidation.requestsRoot(maybeConsolidationRequests.get())) - .setRequests(maybeConsolidationRequests); - final Block block = blockDataGenerator.block(blockOptions); - - return new ConsolidationRequestTestParameter( - "Block with consolidation requests and withdrawal_requests_root", - block, - Optional.of(List.of(consolidationRequest))); - } - - static ConsolidationRequestTestParameter blockWithConsolidationRequestsMismatch() { - final ConsolidationRequest consolidationRequest = createConsolidationRequest(); - - final Optional> requests = - Optional.of(List.of(consolidationRequest, consolidationRequest)); - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequestsRoot(BodyValidation.requestsRoot(requests.get())) - .setRequests(requests); - final Block block = blockDataGenerator.block(blockOptions); - - return new ConsolidationRequestTestParameter( - "Block with consolidation requests mismatch", - block, - Optional.of(List.of(consolidationRequest, consolidationRequest)), - List.of(createConsolidationRequest())); - } - - static ConsolidationRequestTestParameter blockWithMoreThanMaximumConsolidationRequests() { - final List consolidationRequests = - IntStream.range(0, MAX_CONSOLIDATION_REQUESTS_PER_BLOCK + 1) - .mapToObj(__ -> createConsolidationRequest()) - .toList(); - - final Optional> maybeConsolidationRequest = - Optional.of(consolidationRequests); - final Optional> maybeRequests = - Optional.of(consolidationRequests.stream().map(r -> (Request) r).toList()); - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequestsRoot(BodyValidation.requestsRoot(maybeRequests.get())) - .setRequests(maybeRequests); - final Block block = blockDataGenerator.block(blockOptions); - - return new ConsolidationRequestTestParameter( - "Block with more than maximum consolidation requests", block, maybeConsolidationRequest); - } - - static ConsolidationRequest createConsolidationRequest() { - return new ConsolidationRequest( - Address.extract(Bytes32.random()), - BLSPublicKey.wrap(Bytes48.random()), - BLSPublicKey.wrap(Bytes48.random())); - } - - static class ConsolidationRequestTestParameter { - - String description; - Block block; - Optional> maybeConsolidationRequest; - List expectedConsolidationRequest; - - public ConsolidationRequestTestParameter( - final String description, - final Block block, - final Optional> maybeConsolidationRequest) { - this( - description, - block, - maybeConsolidationRequest, - maybeConsolidationRequest.orElseGet(List::of)); - } - - public ConsolidationRequestTestParameter( - final String description, - final Block block, - final Optional> maybeConsolidationRequest, - final List expectedConsolidationRequest) { - this.description = description; - this.block = block; - this.maybeConsolidationRequest = maybeConsolidationRequest; - this.expectedConsolidationRequest = expectedConsolidationRequest; - } - - @Override - public String toString() { - return description; - } - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DepositRequestValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DepositRequestValidatorTest.java deleted file mode 100644 index 0360032388b..00000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DepositRequestValidatorTest.java +++ /dev/null @@ -1,234 +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.ethereum.mainnet; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.BLSSignature; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.datatypes.RequestType; -import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.BlockDataGenerator; -import org.hyperledger.besu.ethereum.core.DepositRequest; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestValidator; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; -import org.hyperledger.besu.ethereum.mainnet.requests.WithdrawalRequestValidator; -import org.hyperledger.besu.evm.log.Log; -import org.hyperledger.besu.evm.log.LogTopic; - -import java.util.List; -import java.util.Optional; - -import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt64; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -public class DepositRequestValidatorTest { - private final BlockDataGenerator blockDataGenerator = new BlockDataGenerator(); - private static DepositRequest depositRequest1; - private static DepositRequest depositRequest2; - private static Log LOG_1; - private static Log LOG_2; - private static Address DEPOSIT_CONTRACT_ADDRESS; - private static RequestsValidatorCoordinator requestsValidatorCoordinator; - private static DepositRequestValidator depositRequestValidator; - - @BeforeAll - public static void setup() { - depositRequest1 = - new DepositRequest( - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - Bytes32.fromHexString( - "0x0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483"), - GWei.of(32000000000L), - BLSSignature.fromHexString( - "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), - UInt64.valueOf(539967)); - - depositRequest2 = - new DepositRequest( - BLSPublicKey.fromHexString( - "0x8706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf243"), - Bytes32.fromHexString( - "0x006a8dc800c6d8dd6977ef53264e2d030350f0145a91bcd167b4f1c3ea21b271"), - GWei.of(32000000000L), - BLSSignature.fromHexString( - "0x801b08ca107b623eca32ee9f9111b4e50eb9cfe19e38204b72de7dc04c5a5e00f61bab96f10842576f66020ce851083f1583dd9a6b73301bea6c245cf51f27cf96aeb018852c5f70bf485d16b957cfe49ca008913346b431e7653ae3ddb23b07"), - UInt64.valueOf(559887)); - - LOG_1 = - new Log( - Address.fromHexString("0x00000000219ab540356cbb839cbe05303d7705fa"), - Bytes.fromHexString( - "0x00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483000000000000000000000000000000000000000000000000000000000000000800405973070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060a889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb500000000000000000000000000000000000000000000000000000000000000083f3d080000000000000000000000000000000000000000000000000000000000"), - List.of( - LogTopic.fromHexString( - "0x649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5"))); - - LOG_2 = - new Log( - Address.fromHexString("0x00000000219ab540356cbb839cbe05303d7705fa"), - Bytes.fromHexString( - "0x00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000308706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf243000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020006a8dc800c6d8dd6977ef53264e2d030350f0145a91bcd167b4f1c3ea21b271000000000000000000000000000000000000000000000000000000000000000800405973070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060801b08ca107b623eca32ee9f9111b4e50eb9cfe19e38204b72de7dc04c5a5e00f61bab96f10842576f66020ce851083f1583dd9a6b73301bea6c245cf51f27cf96aeb018852c5f70bf485d16b957cfe49ca008913346b431e7653ae3ddb23b0700000000000000000000000000000000000000000000000000000000000000080f8b080000000000000000000000000000000000000000000000000000000000"), - List.of( - LogTopic.fromHexString( - "0x649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5"))); - DEPOSIT_CONTRACT_ADDRESS = Address.fromHexString("0x00000000219ab540356cbb839cbe05303d7705fa"); - requestsValidatorCoordinator = createAllowDepositValidator(); - } - - @Test - public void validateAllowedDepositRequests() { - final List request = List.of(depositRequest1, depositRequest2); - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequests(Optional.of(request)) - .setRequestsRoot(BodyValidation.requestsRoot(request)); - final Block block = blockDataGenerator.block(blockOptions); - - final TransactionReceipt receipt = - new TransactionReceipt(null, 0L, List.of(LOG_1, LOG_2), Optional.empty()); - - assertThat(requestsValidatorCoordinator.validate(block, Optional.of(request), List.of(receipt))) - .isTrue(); - } - - @Test - public void validateAllowedDepositRequestsSeparateReceipts() { - - final List requests = List.of(depositRequest1, depositRequest2); - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequests(Optional.of(requests)) - .setRequestsRoot(BodyValidation.requestsRoot(requests)); - final Block block = blockDataGenerator.block(blockOptions); - - final TransactionReceipt receipt1 = - new TransactionReceipt(null, 0L, List.of(LOG_1), Optional.empty()); - final TransactionReceipt receipt2 = - new TransactionReceipt(null, 0L, List.of(LOG_2), Optional.empty()); - - assertThat( - requestsValidatorCoordinator.validate( - block, Optional.of(requests), List.of(receipt1, receipt2))) - .isTrue(); - } - - @Test - public void invalidateAllowedDepositRequests() { - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create().setRequests(Optional.of(List.of(depositRequest1))); - final Block block = blockDataGenerator.block(blockOptions); - - final TransactionReceipt receipt1 = - new TransactionReceipt(null, 0L, List.of(LOG_2), Optional.empty()); - - assertThat( - requestsValidatorCoordinator.validate(block, Optional.of(List.of()), List.of(receipt1))) - .isFalse(); - } - - @Test - public void invalidateAllowedDepositRequestsMissingLogInReceipt() { - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequests(Optional.of(List.of(depositRequest1, depositRequest2))); - final Block block = blockDataGenerator.block(blockOptions); - - final TransactionReceipt receipt1 = - new TransactionReceipt(null, 0L, List.of(LOG_2), Optional.empty()); - - assertThat( - requestsValidatorCoordinator.validate(block, Optional.of(List.of()), List.of(receipt1))) - .isFalse(); - } - - @Test - public void invalidateAllowedDepositRequestsExtraLogInReceipt() { - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create().setRequests(Optional.of(List.of(depositRequest1))); - final Block block = blockDataGenerator.block(blockOptions); - - final TransactionReceipt receipt1 = - new TransactionReceipt(null, 0L, List.of(LOG_1, LOG_2), Optional.empty()); - - assertThat( - requestsValidatorCoordinator.validate(block, Optional.of(List.of()), List.of(receipt1))) - .isFalse(); - } - - @Test - public void invalidateAllowedDepositRequestsWrongOrder() { - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequests(Optional.of(List.of(depositRequest1, depositRequest2))); - final Block block = blockDataGenerator.block(blockOptions); - - final TransactionReceipt receipt1 = - new TransactionReceipt(null, 0L, List.of(LOG_2, LOG_1), Optional.empty()); - - assertThat( - requestsValidatorCoordinator.validate(block, Optional.of(List.of()), List.of(receipt1))) - .isFalse(); - } - - @Test - public void invalidateAllowedDepositRequestsMismatchContractAddress() { - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequests(Optional.of(List.of(depositRequest1, depositRequest2))); - final Block block = blockDataGenerator.block(blockOptions); - - final TransactionReceipt receipt1 = - new TransactionReceipt(null, 0L, List.of(LOG_1, LOG_2), Optional.empty()); - - assertThat( - requestsValidatorCoordinator.validate(block, Optional.of(List.of()), List.of(receipt1))) - .isFalse(); - } - - @Test - public void validateAllowedDepositParams() { - final Optional> depositRequests = - Optional.of(List.of(depositRequest1, depositRequest2)); - assertThat(depositRequestValidator.validateParameter(depositRequests)).isTrue(); - - final Optional> emptyDepositRequests = Optional.of(List.of()); - assertThat(depositRequestValidator.validateParameter(emptyDepositRequests)).isTrue(); - } - - @Test - public void invalidateAllowedDepositParams() { - final Optional> depositRequests = Optional.empty(); - assertThat(depositRequestValidator.validateParameter(depositRequests)).isFalse(); - } - - static RequestsValidatorCoordinator createAllowDepositValidator() { - depositRequestValidator = new DepositRequestValidator(DEPOSIT_CONTRACT_ADDRESS); - return new RequestsValidatorCoordinator.Builder() - .addValidator(RequestType.WITHDRAWAL, new WithdrawalRequestValidator()) - .addValidator(RequestType.DEPOSIT, depositRequestValidator) - .build(); - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidatorTest.java index c412a30756b..8c25d4f58ed 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidatorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidatorTest.java @@ -36,8 +36,7 @@ import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.core.Withdrawal; -import org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestValidator; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; +import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidator; import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.util.Collections; @@ -61,8 +60,7 @@ class MainnetBlockBodyValidatorTest { @Mock private ProtocolSchedule protocolSchedule; @Mock private ProtocolSpec protocolSpec; @Mock private WithdrawalsValidator withdrawalsValidator; - @Mock private DepositRequestValidator depositRequestValidator; - @Mock private RequestsValidatorCoordinator requestValidator; + @Mock private RequestsValidator requestValidator; @BeforeEach public void setUp() { @@ -72,12 +70,8 @@ public void setUp() { lenient().when(withdrawalsValidator.validateWithdrawals(any())).thenReturn(true); lenient().when(withdrawalsValidator.validateWithdrawalsRoot(any())).thenReturn(true); - lenient() - .when(depositRequestValidator.validateDepositRequests(any(), any(), any())) - .thenReturn(true); - - lenient().when(protocolSpec.getRequestsValidatorCoordinator()).thenReturn(requestValidator); - lenient().when(requestValidator.validate(any(), any(), any())).thenReturn(true); + lenient().when(protocolSpec.getRequestsValidator()).thenReturn(requestValidator); + lenient().when(requestValidator.validate(any())).thenReturn(true); } @Test @@ -104,7 +98,6 @@ void validatesWithdrawals() { blockchainSetupUtil.getProtocolContext(), block, emptyList(), - any(), NONE, BodyValidationMode.FULL)) .isTrue(); @@ -133,7 +126,6 @@ void validationFailsIfWithdrawalsValidationFails() { blockchainSetupUtil.getProtocolContext(), block, emptyList(), - any(), NONE, BodyValidationMode.FULL)) .isFalse(); @@ -162,36 +154,6 @@ void validationFailsIfWithdrawalsRootValidationFails() { blockchainSetupUtil.getProtocolContext(), block, emptyList(), - any(), - NONE, - BodyValidationMode.FULL)) - .isFalse(); - } - - @Test - public void validationFailsIfWithdrawalRequestsValidationFails() { - final Block block = - blockDataGenerator.block( - new BlockOptions() - .setBlockNumber(1) - .setGasUsed(0) - .hasTransactions(false) - .hasOmmers(false) - .setReceiptsRoot(BodyValidation.receiptsRoot(emptyList())) - .setLogsBloom(LogsBloomFilter.empty()) - .setParentHash(blockchainSetupUtil.getBlockchain().getChainHeadHash()) - .setRequests(Optional.of(List.of()))); - blockchainSetupUtil.getBlockchain().appendBlock(block, Collections.emptyList()); - - when(requestValidator.validate(any(), any(), any())).thenReturn(false); - - assertThat( - new MainnetBlockBodyValidator(protocolSchedule) - .validateBodyLight( - blockchainSetupUtil.getProtocolContext(), - block, - emptyList(), - any(), NONE, BodyValidationMode.FULL)) .isFalse(); @@ -210,7 +172,6 @@ public void noneValidationModeDoesNothing() { blockchainSetupUtil.getProtocolContext(), block, receipts, - Optional.empty(), NONE, BodyValidationMode.NONE)) .isTrue(); @@ -241,7 +202,6 @@ public void lightValidationDoesNotCheckTransactionRootOrReceiptRoot() { blockchainSetupUtil.getProtocolContext(), block, emptyList(), - Optional.empty(), NONE, BodyValidationMode.LIGHT)) .isTrue(); @@ -272,7 +232,6 @@ public void fullValidationChecksTransactionRootAndReceiptRoot() { blockchainSetupUtil.getProtocolContext(), block, emptyList(), - Optional.empty(), NONE, BodyValidationMode.FULL)) .isTrue(); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessorTest.java index a06aece37bd..8baf4d8d037 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessorTest.java @@ -28,7 +28,6 @@ import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.mainnet.blockhash.FrontierBlockHashProcessor; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; import org.hyperledger.besu.ethereum.referencetests.ReferenceTestBlockchain; import org.hyperledger.besu.ethereum.referencetests.ReferenceTestWorldState; @@ -50,8 +49,6 @@ public class MainnetBlockProcessorTest extends AbstractBlockProcessorTest { @BeforeEach public void setup() { when(protocolSchedule.getByBlockHeader(any())).thenReturn(protocolSpec); - when(protocolSpec.getRequestsValidatorCoordinator()) - .thenReturn(RequestsValidatorCoordinator.empty()); when(protocolSpec.getBlockHashProcessor()).thenReturn(new FrontierBlockHashProcessor()); } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueConsolidationRequestValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueConsolidationRequestValidatorTest.java deleted file mode 100644 index 9d0c9588cc8..00000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueConsolidationRequestValidatorTest.java +++ /dev/null @@ -1,76 +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.ethereum.mainnet; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.mainnet.ConsolidationRequestValidatorTestFixtures.blockWithConsolidationRequestsAndWithdrawalRequestsRoot; -import static org.hyperledger.besu.ethereum.mainnet.ConsolidationRequestValidatorTestFixtures.blockWithConsolidationRequestsMismatch; -import static org.hyperledger.besu.ethereum.mainnet.ConsolidationRequestValidatorTestFixtures.blockWithMoreThanMaximumConsolidationRequests; - -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.mainnet.ConsolidationRequestValidatorTestFixtures.ConsolidationRequestTestParameter; -import org.hyperledger.besu.ethereum.mainnet.requests.ConsolidationRequestValidator; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.stream.Stream; - -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - -class PragueConsolidationRequestValidatorTest { - - @ParameterizedTest(name = "{index}: {0}") - @MethodSource("paramsForValidateConsolidationRequestParameter") - public void validateConsolidationRequestParameter( - final String description, - final Optional> maybeRequests, - final boolean expectedValidity) { - assertThat(new ConsolidationRequestValidator().validateParameter(maybeRequests)) - .isEqualTo(expectedValidity); - } - - private static Stream paramsForValidateConsolidationRequestParameter() { - return Stream.of( - Arguments.of( - "Allowed ConsolidationRequests - validating empty ConsolidationRequests", - Optional.empty(), - true), - Arguments.of( - "Allowed ConsolidationRequests - validating present ConsolidationRequests", - Optional.of(List.of()), - true)); - } - - @ParameterizedTest(name = "{index}: {0}") - @MethodSource("validateConsolidationRequestsInBlockParamsForPrague") - public void validateConsolidationRequestsInBlock_WhenPrague( - final ConsolidationRequestTestParameter param, final boolean expectedValidity) { - assertThat( - new ConsolidationRequestValidator() - .validate( - param.block, new ArrayList<>(param.expectedConsolidationRequest), List.of())) - .isEqualTo(expectedValidity); - } - - private static Stream validateConsolidationRequestsInBlockParamsForPrague() { - return Stream.of( - Arguments.of(blockWithConsolidationRequestsAndWithdrawalRequestsRoot(), true), - Arguments.of(blockWithConsolidationRequestsMismatch(), false), - Arguments.of(blockWithMoreThanMaximumConsolidationRequests(), false)); - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueRequestsValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueRequestsValidatorTest.java deleted file mode 100644 index 6158ba44c37..00000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueRequestsValidatorTest.java +++ /dev/null @@ -1,120 +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.ethereum.mainnet; - -import static java.util.Collections.emptyList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode.NONE; -import static org.hyperledger.besu.ethereum.mainnet.requests.ConsolidationRequestProcessor.CONSOLIDATION_REQUEST_CONTRACT_ADDRESS; -import static org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestProcessor.DEFAULT_DEPOSIT_CONTRACT_ADDRESS; -import static org.hyperledger.besu.ethereum.mainnet.requests.MainnetRequestsValidator.pragueRequestsValidator; -import static org.hyperledger.besu.ethereum.mainnet.requests.WithdrawalRequestProcessor.DEFAULT_WITHDRAWAL_REQUEST_CONTRACT_ADDRESS; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.lenient; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.BlockDataGenerator; -import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestContractAddresses; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; -import org.hyperledger.besu.evm.log.LogsBloomFilter; - -import java.util.List; -import java.util.Optional; - -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.bytes.Bytes48; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -class PragueRequestsValidatorTest { - - private final BlockchainSetupUtil blockchainSetupUtil = BlockchainSetupUtil.forMainnet(); - @Mock private ProtocolSchedule protocolSchedule; - @Mock private ProtocolSpec protocolSpec; - @Mock private WithdrawalsValidator withdrawalsValidator; - private final RequestContractAddresses requestContractAddresses = - new RequestContractAddresses( - DEFAULT_WITHDRAWAL_REQUEST_CONTRACT_ADDRESS, - DEFAULT_DEPOSIT_CONTRACT_ADDRESS, - CONSOLIDATION_REQUEST_CONTRACT_ADDRESS); - - RequestsValidatorCoordinator requestValidator = pragueRequestsValidator(requestContractAddresses); - - @BeforeEach - public void setUp() { - lenient().when(protocolSchedule.getByBlockHeader(any())).thenReturn(protocolSpec); - lenient().when(protocolSpec.getWithdrawalsValidator()).thenReturn(withdrawalsValidator); - lenient().when(withdrawalsValidator.validateWithdrawals(any())).thenReturn(true); - lenient().when(withdrawalsValidator.validateWithdrawalsRoot(any())).thenReturn(true); - lenient().when(protocolSpec.getRequestsValidatorCoordinator()).thenReturn(requestValidator); - } - - private static final BlockDataGenerator blockDataGenerator = new BlockDataGenerator(); - - @Test - void shouldValidateRequestsTest() { - WithdrawalRequest request = - new WithdrawalRequest( - Address.extract(Bytes32.fromHexStringLenient("1")), - BLSPublicKey.wrap(Bytes48.fromHexStringLenient("1")), - GWei.ONE); - - WithdrawalRequest requestTwo = - new WithdrawalRequest( - Address.extract(Bytes32.fromHexStringLenient("1")), - BLSPublicKey.wrap(Bytes48.fromHexStringLenient("1")), - GWei.ZERO); - - Optional> blockRequests = Optional.of(List.of(request)); - Optional> expectedRequests = Optional.of(List.of(requestTwo)); - Hash requestsRoot = BodyValidation.requestsRoot(blockRequests.get()); - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequestsRoot(requestsRoot) - .setRequests(blockRequests) - .setGasUsed(0) - .setReceiptsRoot(BodyValidation.receiptsRoot(emptyList())) - .hasTransactions(false) - .hasOmmers(false) - .setReceiptsRoot(BodyValidation.receiptsRoot(emptyList())) - .setLogsBloom(LogsBloomFilter.empty()) - .setParentHash(blockchainSetupUtil.getBlockchain().getChainHeadHash()); - - final Block block = blockDataGenerator.block(blockOptions); - assertThat(block).isNotNull(); - assertThat( - new MainnetBlockBodyValidator(protocolSchedule) - .validateBodyLight( - blockchainSetupUtil.getProtocolContext(), - block, - emptyList(), - expectedRequests, - NONE, - BodyValidationMode.FULL)) - .isFalse(); - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueWithdrawalRequestValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueWithdrawalRequestValidatorTest.java deleted file mode 100644 index 8756f855928..00000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueWithdrawalRequestValidatorTest.java +++ /dev/null @@ -1,83 +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.ethereum.mainnet; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.mainnet.WithdrawalRequestValidatorTestFixtures.blockWithMoreThanMaximumWithdrawalRequests; -import static org.hyperledger.besu.ethereum.mainnet.WithdrawalRequestValidatorTestFixtures.blockWithWithdrawalRequestsAndWithdrawalRequestsRoot; -import static org.hyperledger.besu.ethereum.mainnet.WithdrawalRequestValidatorTestFixtures.blockWithWithdrawalRequestsMismatch; - -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.mainnet.WithdrawalRequestValidatorTestFixtures.WithdrawalRequestTestParameter; -import org.hyperledger.besu.ethereum.mainnet.requests.WithdrawalRequestValidator; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.stream.Stream; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - -class PragueWithdrawalRequestValidatorTest { - - @ParameterizedTest(name = "{index}: {0}") - @MethodSource("paramsForValidateWithdrawalRequestParameter") - public void validateWithdrawalRequestParameter( - final String description, - final Optional> maybeRequests, - final boolean expectedValidity) { - assertThat(new WithdrawalRequestValidator().validateParameter(maybeRequests)) - .isEqualTo(expectedValidity); - } - - private static Stream paramsForValidateWithdrawalRequestParameter() { - return Stream.of( - Arguments.of( - "Allowed WithdrawalRequests - validating empty WithdrawalRequests", - Optional.empty(), - false), - Arguments.of( - "Allowed WithdrawalRequests - validating present WithdrawalRequests", - Optional.of(List.of()), - true)); - } - - @ParameterizedTest(name = "{index}: {0}") - @MethodSource("validateWithdrawalRequestsInBlockParamsForPrague") - public void validateWithdrawalRequestsInBlock_WhenPrague( - final WithdrawalRequestTestParameter param, final boolean expectedValidity) { - assertThat( - new WithdrawalRequestValidator() - .validate(param.block, new ArrayList<>(param.expectedWithdrawalRequest), List.of())) - .isEqualTo(expectedValidity); - } - - private static Stream validateWithdrawalRequestsInBlockParamsForPrague() { - return Stream.of( - Arguments.of(blockWithWithdrawalRequestsAndWithdrawalRequestsRoot(), true), - Arguments.of(blockWithWithdrawalRequestsMismatch(), false), - Arguments.of(blockWithMoreThanMaximumWithdrawalRequests(), false)); - } - - @Test - void dryRunDetector() { - assertThat(true) - .withFailMessage("This test is here so gradle --dry-run executes this class") - .isTrue(); - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/SystemCallProcessorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/SystemCallProcessorTest.java index e1d3906e734..14275f7d12e 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/SystemCallProcessorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/SystemCallProcessorTest.java @@ -87,10 +87,10 @@ void shouldThrowExceptionOnFailedExecution() { } @Test - void shouldReturnNullWhenContractDoesNotExist() { + void shouldReturnEmptyWhenContractDoesNotExist() { final MutableWorldState worldState = InMemoryKeyValueStorageProvider.createInMemoryWorldState(); Bytes actualOutput = processSystemCall(worldState); - assertThat(actualOutput).isNull(); + assertThat(actualOutput).isEqualTo(Bytes.EMPTY); } Bytes processSystemCall(final MutableWorldState worldState) { diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ValidationTestUtils.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ValidationTestUtils.java index fa912a6de87..4e1ac520b52 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ValidationTestUtils.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ValidationTestUtils.java @@ -17,7 +17,6 @@ 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.Request; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; @@ -59,11 +58,7 @@ public static BlockBody readBody(final long num) throws IOException { input.isEndOfCurrentList() ? Optional.empty() : Optional.of(input.readList(Withdrawal::readFrom)); - final Optional> requests = - input.isEndOfCurrentList() - ? Optional.empty() - : Optional.of(input.readList(Request::readFrom)); - return new BlockBody(transactions, ommers, withdrawals, requests); + return new BlockBody(transactions, ommers, withdrawals); } public static Block readBlock(final long num) throws IOException { diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/WithdrawalRequestValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/WithdrawalRequestValidatorTest.java deleted file mode 100644 index f93067d94f2..00000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/WithdrawalRequestValidatorTest.java +++ /dev/null @@ -1,87 +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.ethereum.mainnet; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.mainnet.WithdrawalRequestValidatorTestFixtures.blockWithWithdrawalRequestsAndWithdrawalRequestsRoot; -import static org.hyperledger.besu.ethereum.mainnet.WithdrawalRequestValidatorTestFixtures.blockWithWithdrawalRequestsWithoutWithdrawalRequestsRoot; -import static org.hyperledger.besu.ethereum.mainnet.WithdrawalRequestValidatorTestFixtures.blockWithoutWithdrawalRequestsAndWithdrawalRequestsRoot; -import static org.hyperledger.besu.ethereum.mainnet.WithdrawalRequestValidatorTestFixtures.blockWithoutWithdrawalRequestsWithWithdrawalRequestsRoot; - -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.mainnet.WithdrawalRequestValidatorTestFixtures.WithdrawalRequestTestParameter; -import org.hyperledger.besu.ethereum.mainnet.requests.ProhibitedRequestsValidator; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.stream.Stream; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - -class WithdrawalRequestValidatorTest { - - @ParameterizedTest(name = "{index}: {0}") - @MethodSource("paramsForValidateWithdrawalRequestParameter") - public void validateWithdrawalRequestParameter( - final String description, - final Optional> maybeWithdrawalRequests, - final boolean expectedValidity) { - assertThat(new ProhibitedRequestsValidator().validateParameter(maybeWithdrawalRequests)) - .isEqualTo(expectedValidity); - } - - private static Stream paramsForValidateWithdrawalRequestParameter() { - return Stream.of( - Arguments.of( - "Prohibited WithdrawalRequests - validating empty WithdrawalRequests", - Optional.empty(), - true), - Arguments.of( - "Prohibited WithdrawalRequests - validating present WithdrawalRequests", - Optional.of(List.of()), - false)); - } - - @ParameterizedTest(name = "{index}: {0}") - @MethodSource("validateWithdrawalRequestsInBlockParamsForProhibited") - public void validateWithdrawalRequestsInBlock_WhenProhibited( - final WithdrawalRequestTestParameter param, final boolean expectedValidity) { - - var list = param.expectedWithdrawalRequest; - var requests = new ArrayList(list).stream().toList(); - - assertThat(new ProhibitedRequestsValidator().validate(param.block, requests, List.of())) - .isEqualTo(expectedValidity); - } - - private static Stream validateWithdrawalRequestsInBlockParamsForProhibited() { - return Stream.of( - Arguments.of(blockWithWithdrawalRequestsAndWithdrawalRequestsRoot(), false), - Arguments.of(blockWithWithdrawalRequestsWithoutWithdrawalRequestsRoot(), false), - Arguments.of(blockWithoutWithdrawalRequestsWithWithdrawalRequestsRoot(), false), - Arguments.of(blockWithoutWithdrawalRequestsAndWithdrawalRequestsRoot(), true)); - } - - @Test - void dryRunDetector() { - assertThat(true) - .withFailMessage("This test is here so gradle --dry-run executes this class") - .isTrue(); - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/WithdrawalRequestValidatorTestFixtures.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/WithdrawalRequestValidatorTestFixtures.java deleted file mode 100644 index e719810c282..00000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/WithdrawalRequestValidatorTestFixtures.java +++ /dev/null @@ -1,186 +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.ethereum.mainnet; - -import static org.hyperledger.besu.ethereum.mainnet.requests.WithdrawalRequestValidator.MAX_WITHDRAWAL_REQUESTS_PER_BLOCK; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.BlockDataGenerator; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; - -import java.util.List; -import java.util.Optional; -import java.util.stream.IntStream; - -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.bytes.Bytes48; - -public class WithdrawalRequestValidatorTestFixtures { - - private static final BlockDataGenerator blockDataGenerator = new BlockDataGenerator(); - - static WithdrawalRequestTestParameter blockWithWithdrawalRequestsAndWithdrawalRequestsRoot() { - final WithdrawalRequest withdrawalRequest = createWithdrawalRequest(); - final Optional> maybeWithdrawalRequests = - Optional.of(java.util.List.of(withdrawalRequest)); - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequestsRoot(BodyValidation.requestsRoot(maybeWithdrawalRequests.get())) - .setRequests(maybeWithdrawalRequests); - final Block block = blockDataGenerator.block(blockOptions); - - return new WithdrawalRequestTestParameter( - "Block with withdrawal requests and withdrawal_requests_root", - block, - Optional.of(java.util.List.of(withdrawalRequest))); - } - - static WithdrawalRequestTestParameter blockWithoutWithdrawalRequestsWithWithdrawalRequestsRoot() { - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequestsRoot(Hash.EMPTY) - .setRequests(Optional.empty()); - final Block block = blockDataGenerator.block(blockOptions); - - return new WithdrawalRequestTestParameter( - "Block with withdrawal_requests_root but without withdrawal requests", - block, - Optional.empty()); - } - - static WithdrawalRequestTestParameter blockWithWithdrawalRequestsWithoutWithdrawalRequestsRoot() { - final WithdrawalRequest withdrawalRequest = createWithdrawalRequest(); - final Optional> requests = Optional.of(java.util.List.of(withdrawalRequest)); - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create().setRequests(requests); - final Block block = blockDataGenerator.block(blockOptions); - - return new WithdrawalRequestTestParameter( - "Block with withdrawal requests but without withdrawal_requests_root", - block, - Optional.of(java.util.List.of(withdrawalRequest))); - } - - static WithdrawalRequestTestParameter blockWithoutWithdrawalRequestsAndWithdrawalRequestsRoot() { - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create().setRequests(Optional.empty()); - final Block block = blockDataGenerator.block(blockOptions); - - return new WithdrawalRequestTestParameter( - "Block without withdrawal requests and withdrawal_requests_root", block, Optional.empty()); - } - - static WithdrawalRequestTestParameter blockWithWithdrawalRequestsRootMismatch() { - final WithdrawalRequest withdrawalRequest = createWithdrawalRequest(); - - final Optional> requests = Optional.of(java.util.List.of(withdrawalRequest)); - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create().setRequestsRoot(Hash.EMPTY).setRequests(requests); - final Block block = blockDataGenerator.block(blockOptions); - - return new WithdrawalRequestTestParameter( - "Block with withdrawal_requests_root mismatch", - block, - Optional.of(java.util.List.of(withdrawalRequest))); - } - - static WithdrawalRequestTestParameter blockWithWithdrawalRequestsMismatch() { - final WithdrawalRequest withdrawalRequest = createWithdrawalRequest(); - - final Optional> requests = - Optional.of(java.util.List.of(withdrawalRequest, withdrawalRequest)); - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequestsRoot(BodyValidation.requestsRoot(requests.get())) - .setRequests(requests); - final Block block = blockDataGenerator.block(blockOptions); - - return new WithdrawalRequestTestParameter( - "Block with withdrawal requests mismatch", - block, - Optional.of(java.util.List.of(withdrawalRequest, withdrawalRequest)), - List.of(createWithdrawalRequest())); - } - - static WithdrawalRequestTestParameter blockWithMoreThanMaximumWithdrawalRequests() { - final List withdrawalRequest = - IntStream.range(0, MAX_WITHDRAWAL_REQUESTS_PER_BLOCK + 1) - .mapToObj(__ -> createWithdrawalRequest()) - .toList(); - - final Optional> maybeWithdrawalRequest = Optional.of(withdrawalRequest); - final Optional> maybeRequests = - Optional.of(withdrawalRequest.stream().map(r -> (Request) r).toList()); - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequestsRoot(BodyValidation.requestsRoot(maybeRequests.get())) - .setRequests(maybeRequests); - final Block block = blockDataGenerator.block(blockOptions); - - return new WithdrawalRequestTestParameter( - "Block with more than maximum withdrawal requests", block, maybeWithdrawalRequest); - } - - static WithdrawalRequest createWithdrawalRequest() { - return new WithdrawalRequest( - Address.extract(Bytes32.random()), BLSPublicKey.wrap(Bytes48.random()), GWei.ONE); - } - - static class WithdrawalRequestTestParameter { - - String description; - Block block; - Optional> maybeWithdrawalRequest; - List expectedWithdrawalRequest; - - public WithdrawalRequestTestParameter( - final String description, - final Block block, - final Optional> maybeWithdrawalRequest) { - this( - description, - block, - maybeWithdrawalRequest, - maybeWithdrawalRequest.orElseGet(java.util.List::of)); - } - - public WithdrawalRequestTestParameter( - final String description, - final Block block, - final Optional> maybeWithdrawalRequest, - final List expectedWithdrawalRequest) { - this.description = description; - this.block = block; - this.maybeWithdrawalRequest = maybeWithdrawalRequest; - this.expectedWithdrawalRequest = expectedWithdrawalRequest; - } - - @Override - public String toString() { - return description; - } - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidatorTest.java new file mode 100644 index 00000000000..410a726304f --- /dev/null +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidatorTest.java @@ -0,0 +1,58 @@ +/* + * Copyright contributors to 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.ethereum.mainnet.requests; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.hyperledger.besu.datatypes.RequestType; +import org.hyperledger.besu.ethereum.core.Request; + +import java.util.List; +import java.util.Optional; + +import org.apache.tuweni.bytes.Bytes; +import org.junit.jupiter.api.Test; + +class MainnetRequestsValidatorTest { + + @Test + void validateFalseWhenNoRequests() { + MainnetRequestsValidator validator = new MainnetRequestsValidator(); + assertFalse(validator.validate(Optional.empty())); + } + + @Test + void validateFalseWhenRequestsNotInOrder() { + MainnetRequestsValidator validator = new MainnetRequestsValidator(); + List requests = + List.of( + new Request(RequestType.WITHDRAWAL, Bytes.of(3)), + new Request(RequestType.DEPOSIT, Bytes.of(1)), + new Request(RequestType.CONSOLIDATION, Bytes.of(2))); + assertFalse(validator.validate(Optional.of(requests))); + } + + @Test + void validateTrueForValidRequests() { + MainnetRequestsValidator validator = new MainnetRequestsValidator(); + List requests = + List.of( + new Request(RequestType.DEPOSIT, Bytes.of(1)), + new Request(RequestType.WITHDRAWAL, Bytes.of(2)), + new Request(RequestType.CONSOLIDATION, Bytes.of(3))); + assertTrue(validator.validate(Optional.of(requests))); + } +} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestValidatorTest.java new file mode 100644 index 00000000000..3694a58a4b8 --- /dev/null +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestValidatorTest.java @@ -0,0 +1,47 @@ +/* + * Copyright contributors to 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.ethereum.mainnet.requests; + +import org.hyperledger.besu.datatypes.RequestType; +import org.hyperledger.besu.ethereum.core.Request; + +import java.util.List; +import java.util.Optional; + +import org.apache.tuweni.bytes.Bytes; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class ProhibitedRequestValidatorTest { + + @Test + void validateTrueWhenNoRequests() { + ProhibitedRequestValidator validator = new ProhibitedRequestValidator(); + Assertions.assertThat(validator.validate(Optional.empty())).isTrue(); + } + + @Test + void validateFalseWhenHasEmptyListOfRequests() { + ProhibitedRequestValidator validator = new ProhibitedRequestValidator(); + Assertions.assertThat(validator.validate(Optional.of(List.of()))).isFalse(); + } + + @Test + void validateFalseWhenHasRequests() { + ProhibitedRequestValidator validator = new ProhibitedRequestValidator(); + List requests = List.of(new Request(RequestType.DEPOSIT, Bytes.of(1))); + Assertions.assertThat(validator.validate(Optional.of(requests))).isFalse(); + } +} diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTask.java index 56a85b040b0..dcacb312899 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTask.java @@ -20,7 +20,6 @@ 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.Request; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.eth.manager.EthContext; @@ -151,41 +150,34 @@ static class BodyIdentifier { private final Bytes32 transactionsRoot; private final Bytes32 ommersHash; private final Bytes32 withdrawalsRoot; - private final Bytes32 requestsRoot; + // TODO should requestsHash be included in this? public BodyIdentifier( - final Bytes32 transactionsRoot, - final Bytes32 ommersHash, - final Bytes32 withdrawalsRoot, - final Bytes32 requestsRoot) { + final Bytes32 transactionsRoot, final Bytes32 ommersHash, final Bytes32 withdrawalsRoot) { this.transactionsRoot = transactionsRoot; this.ommersHash = ommersHash; this.withdrawalsRoot = withdrawalsRoot; - this.requestsRoot = requestsRoot; } public BodyIdentifier(final BlockBody body) { - this(body.getTransactions(), body.getOmmers(), body.getWithdrawals(), body.getRequests()); + this(body.getTransactions(), body.getOmmers(), body.getWithdrawals()); } public BodyIdentifier( final List transactions, final List ommers, - final Optional> withdrawals, - final Optional> requests) { + final Optional> withdrawals) { this( BodyValidation.transactionsRoot(transactions), BodyValidation.ommersHash(ommers), - withdrawals.map(BodyValidation::withdrawalsRoot).orElse(null), - requests.map(BodyValidation::requestsRoot).orElse(null)); + withdrawals.map(BodyValidation::withdrawalsRoot).orElse(null)); } public BodyIdentifier(final BlockHeader header) { this( header.getTransactionsRoot(), header.getOmmersHash(), - header.getWithdrawalsRoot().orElse(null), - header.getRequestsRoot().orElse(null)); + header.getWithdrawalsRoot().orElse(null)); } @Override @@ -195,13 +187,12 @@ public boolean equals(final Object o) { BodyIdentifier that = (BodyIdentifier) o; return Objects.equals(transactionsRoot, that.transactionsRoot) && Objects.equals(ommersHash, that.ommersHash) - && Objects.equals(withdrawalsRoot, that.withdrawalsRoot) - && Objects.equals(requestsRoot, that.requestsRoot); + && Objects.equals(withdrawalsRoot, that.withdrawalsRoot); } @Override public int hashCode() { - return Objects.hash(transactionsRoot, ommersHash, withdrawalsRoot, requestsRoot); + return Objects.hash(transactionsRoot, ommersHash, withdrawalsRoot); } } } diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java index ec679e53a14..82216ae09fc 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java @@ -92,8 +92,7 @@ private BlockBody createEmptyBodyBasedOnProtocolSchedule( Collections.emptyList(), isWithdrawalsEnabled(protocolSchedule, header) ? Optional.of(Collections.emptyList()) - : Optional.empty(), - Optional.empty()); + : Optional.empty()); } private boolean isWithdrawalsEnabled( diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTaskTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTaskTest.java index b8546ad532d..38a56bae937 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTaskTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTaskTest.java @@ -18,16 +18,11 @@ import static org.assertj.core.api.Assertions.assertThat; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.BLSSignature; import org.hyperledger.besu.datatypes.GWei; 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.DepositRequest; -import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Withdrawal; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; import org.hyperledger.besu.ethereum.eth.manager.ethtaskutils.PeerMessageTaskTest; import java.util.ArrayList; @@ -35,7 +30,6 @@ import java.util.Optional; import java.util.stream.Collectors; -import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.units.bigints.UInt64; import org.junit.jupiter.api.Test; @@ -80,58 +74,11 @@ public void assertBodyIdentifierUsesWithdrawalsToGenerateBodyIdentifiers() { final BlockBody emptyBodyBlock = BlockBody.empty(); // Block with no tx, no ommers, 1 withdrawal final BlockBody bodyBlockWithWithdrawal = - new BlockBody(emptyList(), emptyList(), Optional.of(List.of(withdrawal)), Optional.empty()); + new BlockBody(emptyList(), emptyList(), Optional.of(List.of(withdrawal))); assertThat( new GetBodiesFromPeerTask.BodyIdentifier(emptyBodyBlock) .equals(new GetBodiesFromPeerTask.BodyIdentifier(bodyBlockWithWithdrawal))) .isFalse(); } - - @Test - public void assertBodyIdentifierUsesDepositRequestsToGenerateBodyIdentifiers() { - final Request deposit = - new DepositRequest( - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - Bytes32.fromHexString( - "0x0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483"), - GWei.of(32000000000L), - BLSSignature.fromHexString( - "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), - UInt64.ONE); - - // Empty body block - final BlockBody emptyBodyBlock = BlockBody.empty(); - // Block with no tx, no ommers, 1 deposit - final BlockBody bodyBlockWithDeposit = - new BlockBody(emptyList(), emptyList(), Optional.empty(), Optional.of(List.of(deposit))); - - assertThat( - new GetBodiesFromPeerTask.BodyIdentifier(emptyBodyBlock) - .equals(new GetBodiesFromPeerTask.BodyIdentifier(bodyBlockWithDeposit))) - .isFalse(); - } - - @Test - public void assertBodyIdentifierUsesWithdrawalRequestsToGenerateBodyIdentifiers() { - final WithdrawalRequest withdrawalRequest = - new WithdrawalRequest( - Address.fromHexString("0x763c396673F9c391DCe3361A9A71C8E161388000"), - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - GWei.ONE); - - // Empty body block - final BlockBody emptyBodyBlock = BlockBody.empty(); - // Block with no tx, no ommers, 1 validator exit - final BlockBody bodyBlockWithValidatorExit = - new BlockBody( - emptyList(), emptyList(), Optional.empty(), Optional.of(List.of(withdrawalRequest))); - - assertThat( - new GetBodiesFromPeerTask.BodyIdentifier(emptyBodyBlock) - .equals(new GetBodiesFromPeerTask.BodyIdentifier(bodyBlockWithValidatorExit))) - .isFalse(); - } } diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/MessageWrapperTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/MessageWrapperTest.java index 78fcbb1c085..2b020cd4ac8 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/MessageWrapperTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/MessageWrapperTest.java @@ -259,8 +259,7 @@ public void readFromExpectsListWrappingBodyFields() { new BlockBody( Collections.emptyList(), Collections.emptyList(), - Optional.of(Collections.emptyList()), - Optional.empty())); + Optional.of(Collections.emptyList()))); } @Test @@ -284,8 +283,7 @@ public void readBodyFieldsExpectsNoListWrappingBodyFields() { new BlockBody( Collections.emptyList(), Collections.emptyList(), - Optional.of(Collections.emptyList()), - Optional.empty())); + Optional.of(Collections.emptyList()))); } @Test diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/ChainForTestCreator.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/ChainForTestCreator.java index 82d5de4f38c..c15f3aa1dcd 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/ChainForTestCreator.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/ChainForTestCreator.java @@ -88,7 +88,7 @@ public static BlockHeader prepareWrongParentHash(final BlockHeader blockHeader) blockHeader.getBlobGasUsed().orElse(null), blockHeader.getExcessBlobGas().orElse(null), blockHeader.getParentBeaconBlockRoot().orElse(null), - blockHeader.getRequestsRoot().orElse(null), + blockHeader.getRequestsHash().orElse(null), new MainnetBlockHeaderFunctions()); } diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTaskTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTaskTest.java index e8049af736e..ba0fad675e1 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTaskTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTaskTest.java @@ -116,19 +116,14 @@ public void shouldCreateWithdrawalsAwareEmptyBlock_whenWithdrawalsAreEnabled() { final Block block1 = new Block( header1, - new BlockBody( - Collections.emptyList(), - Collections.emptyList(), - Optional.empty(), - Optional.empty())); + new BlockBody(Collections.emptyList(), Collections.emptyList(), Optional.empty())); final Block block2 = new Block( header2, new BlockBody( Collections.emptyList(), Collections.emptyList(), - Optional.of(Collections.emptyList()), - Optional.empty())); + Optional.of(Collections.emptyList()))); final List expectedBlocks = asList(block1, block2); final EthTask> task = @@ -164,18 +159,14 @@ public void shouldCompleteBlockThatOnlyContainsWithdrawals_whenWithdrawalsAreEna new Block( header2, new BlockBody( - Collections.emptyList(), - Collections.emptyList(), - Optional.of(withdrawals), - Optional.empty())); + Collections.emptyList(), Collections.emptyList(), Optional.of(withdrawals))); final Block block3 = new Block( header3, new BlockBody( Collections.emptyList(), Collections.emptyList(), - Optional.of(Collections.emptyList()), - Optional.empty())); + Optional.of(Collections.emptyList()))); final List expected = asList(block1, block2, block3); final RespondingEthPeer respondingPeer = diff --git a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java index fb0ccf4912b..ba55fdf29ea 100644 --- a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java +++ b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java @@ -34,19 +34,15 @@ import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.ConsolidationRequest; -import org.hyperledger.besu.ethereum.core.DepositRequest; import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; import org.hyperledger.besu.ethereum.mainnet.BodyValidation; import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams; import org.hyperledger.besu.ethereum.mainnet.requests.ProcessRequestContext; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestUtil; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.referencetests.BonsaiReferenceTestWorldState; import org.hyperledger.besu.ethereum.referencetests.ReferenceTestEnv; @@ -530,41 +526,14 @@ static T8nResult runTest( receipts, new CachingBlockHashLookup(blockHeader, blockchain), OperationTracer.NO_TRACING); - Optional> maybeRequests = rpc.process(context); - Hash requestRoot = BodyValidation.requestsRoot(maybeRequests.orElse(List.of())); - - resultObject.put("requestsRoot", requestRoot.toHexString()); - var deposits = resultObject.putArray("depositRequests"); - RequestUtil.filterRequestsOfType(maybeRequests.orElse(List.of()), DepositRequest.class) - .forEach( - deposit -> { - var obj = deposits.addObject(); - obj.put("pubkey", deposit.getPubkey().toHexString()); - obj.put("withdrawalCredentials", deposit.getWithdrawalCredentials().toHexString()); - obj.put("amount", deposit.getAmount().toHexString()); - obj.put("signature", deposit.getSignature().toHexString()); - obj.put("index", deposit.getIndex().toHexString()); - }); - - var withdrawalRequests = resultObject.putArray("withdrawalRequests"); - RequestUtil.filterRequestsOfType(maybeRequests.orElse(List.of()), WithdrawalRequest.class) - .forEach( - wr -> { - var obj = withdrawalRequests.addObject(); - obj.put("sourceAddress", wr.getSourceAddress().toHexString()); - obj.put("validatorPubkey", wr.getValidatorPubkey().toHexString()); - obj.put("amount", wr.getAmount().toHexString()); - }); - - var consolidationRequests = resultObject.putArray("consolidationRequests"); - RequestUtil.filterRequestsOfType(maybeRequests.orElse(List.of()), ConsolidationRequest.class) - .forEach( - cr -> { - var obj = consolidationRequests.addObject(); - obj.put("sourceAddress", cr.getSourceAddress().toHexString()); - obj.put("sourcePubkey", cr.getSourcePubkey().toHexString()); - obj.put("targetPubkey", cr.getTargetPubkey().toHexString()); - }); + Optional> maybeRequests = Optional.of(rpc.process(context)); + Hash requestsHash = BodyValidation.requestsHash(maybeRequests.orElse(List.of())); + + resultObject.put("requestsHash", requestsHash.toHexString()); + ArrayNode requests = resultObject.putArray("requests"); + maybeRequests + .orElseGet(List::of) + .forEach(request -> requests.add(request.getData().toHexString())); } worldState.persist(blockHeader); diff --git a/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/block-test/osaka-eof-rjump.json b/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/block-test/osaka-eof-rjump.json index 8cca437e349..a6c5bcc62c3 100644 --- a/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/block-test/osaka-eof-rjump.json +++ b/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/block-test/osaka-eof-rjump.json @@ -27,7 +27,7 @@ "blobGasUsed": "0x00", "excessBlobGas": "0x00", "parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000", - "requestsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "requestsHash": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "hash": "0x367310df4a31070aa9a5c92cb61ab8bb2742db0162619ed77594fbec6f0ddbd9" }, "pre": { @@ -219,7 +219,7 @@ "blobGasUsed": "0x00", "excessBlobGas": "0x00", "parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000", - "requestsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "requestsHash": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "hash": "0xfb5d1d0e218fa7873bc188f07f3e0a7c78027ff6e6e199c48ba1facd3c3726fd" }, "transactions": [ diff --git a/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/t8n/prague-deposit.json b/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/t8n/prague-deposit.json index 1a32e50e8b9..771dc870e66 100644 --- a/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/t8n/prague-deposit.json +++ b/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/t8n/prague-deposit.json @@ -132,7 +132,9 @@ "stdout": { "alloc": { "0x00000000219ab540356cbb839cbe05303d7705fa": { + "balance": "0x3782dace9d9000000", "code": "0x60806040526004361061003f5760003560e01c806301ffc9a71461004457806322895118146100a4578063621fd130146101ba578063c5f2892f14610244575b600080fd5b34801561005057600080fd5b506100906004803603602081101561006757600080fd5b50357fffffffff000000000000000000000000000000000000000000000000000000001661026b565b604080519115158252519081900360200190f35b6101b8600480360360808110156100ba57600080fd5b8101906020810181356401000000008111156100d557600080fd5b8201836020820111156100e757600080fd5b8035906020019184600183028401116401000000008311171561010957600080fd5b91939092909160208101903564010000000081111561012757600080fd5b82018360208201111561013957600080fd5b8035906020019184600183028401116401000000008311171561015b57600080fd5b91939092909160208101903564010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b919350915035610304565b005b3480156101c657600080fd5b506101cf6110b5565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102095781810151838201526020016101f1565b50505050905090810190601f1680156102365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025057600080fd5b506102596110c7565b60408051918252519081900360200190f35b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f8564090700000000000000000000000000000000000000000000000000000000145b92915050565b6030861461035d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118056026913960400191505060405180910390fd5b602084146103b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061179c6036913960400191505060405180910390fd5b6060821461040f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806118786029913960400191505060405180910390fd5b670de0b6b3a7640000341015610470576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118526026913960400191505060405180910390fd5b633b9aca003406156104cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806117d26033913960400191505060405180910390fd5b633b9aca00340467ffffffffffffffff811115610535576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061182b6027913960400191505060405180910390fd5b6060610540826114ba565b90507f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c589898989858a8a6105756020546114ba565b6040805160a0808252810189905290819060208201908201606083016080840160c085018e8e80828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910187810386528c815260200190508c8c808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690920188810386528c5181528c51602091820193918e019250908190849084905b83811015610648578181015183820152602001610630565b50505050905090810190601f1680156106755780820380516001836020036101000a031916815260200191505b5086810383528881526020018989808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018881038452895181528951602091820193918b019250908190849084905b838110156106ef5781810151838201526020016106d7565b50505050905090810190601f16801561071c5780820380516001836020036101000a031916815260200191505b509d505050505050505050505050505060405180910390a1600060028a8a600060801b604051602001808484808284377fffffffffffffffffffffffffffffffff0000000000000000000000000000000090941691909301908152604080517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0818403018152601090920190819052815191955093508392506020850191508083835b602083106107fc57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016107bf565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610859573d6000803e3d6000fd5b5050506040513d602081101561086e57600080fd5b5051905060006002806108846040848a8c6116fe565b6040516020018083838082843780830192505050925050506040516020818303038152906040526040518082805190602001908083835b602083106108f857805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016108bb565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610955573d6000803e3d6000fd5b5050506040513d602081101561096a57600080fd5b5051600261097b896040818d6116fe565b60405160009060200180848480828437919091019283525050604080518083038152602092830191829052805190945090925082918401908083835b602083106109f457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016109b7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610a51573d6000803e3d6000fd5b5050506040513d6020811015610a6657600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610ada57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610a9d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610b37573d6000803e3d6000fd5b5050506040513d6020811015610b4c57600080fd5b50516040805160208101858152929350600092600292839287928f928f92018383808284378083019250505093505050506040516020818303038152906040526040518082805190602001908083835b60208310610bd957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610b9c565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610c36573d6000803e3d6000fd5b5050506040513d6020811015610c4b57600080fd5b50516040518651600291889160009188916020918201918291908601908083835b60208310610ca957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610c6c565b6001836020036101000a0380198251168184511680821785525050505050509050018367ffffffffffffffff191667ffffffffffffffff1916815260180182815260200193505050506040516020818303038152906040526040518082805190602001908083835b60208310610d4e57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610d11565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610dab573d6000803e3d6000fd5b5050506040513d6020811015610dc057600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610e3457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610df7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610e91573d6000803e3d6000fd5b5050506040513d6020811015610ea657600080fd5b50519050858114610f02576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260548152602001806117486054913960600191505060405180910390fd5b60205463ffffffff11610f60576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806117276021913960400191505060405180910390fd5b602080546001019081905560005b60208110156110a9578160011660011415610fa0578260008260208110610f9157fe5b0155506110ac95505050505050565b600260008260208110610faf57fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061102557805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610fe8565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015611082573d6000803e3d6000fd5b5050506040513d602081101561109757600080fd5b50519250600282049150600101610f6e565b50fe5b50505050505050565b60606110c26020546114ba565b905090565b6020546000908190815b60208110156112f05781600116600114156111e6576002600082602081106110f557fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061116b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161112e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156111c8573d6000803e3d6000fd5b5050506040513d60208110156111dd57600080fd5b505192506112e2565b600283602183602081106111f657fe5b015460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061126b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161122e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156112c8573d6000803e3d6000fd5b5050506040513d60208110156112dd57600080fd5b505192505b6002820491506001016110d1565b506002826112ff6020546114ba565b600060401b6040516020018084815260200183805190602001908083835b6020831061135a57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161131d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790527fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000095909516920191825250604080518083037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8018152601890920190819052815191955093508392850191508083835b6020831061143f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611402565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa15801561149c573d6000803e3d6000fd5b5050506040513d60208110156114b157600080fd5b50519250505090565b60408051600880825281830190925260609160208201818036833701905050905060c082901b8060071a60f81b826000815181106114f457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060061a60f81b8260018151811061153757fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060051a60f81b8260028151811061157a57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060041a60f81b826003815181106115bd57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060031a60f81b8260048151811061160057fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060021a60f81b8260058151811061164357fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060011a60f81b8260068151811061168657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060001a60f81b826007815181106116c957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050919050565b6000808585111561170d578182fd5b83861115611719578182fd5b505082019391909203915056fe4465706f736974436f6e74726163743a206d65726b6c6520747265652066756c6c4465706f736974436f6e74726163743a207265636f6e7374727563746564204465706f7369744461746120646f6573206e6f74206d6174636820737570706c696564206465706f7369745f646174615f726f6f744465706f736974436f6e74726163743a20696e76616c6964207769746864726177616c5f63726564656e7469616c73206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c7565206e6f74206d756c7469706c65206f6620677765694465706f736974436f6e74726163743a20696e76616c6964207075626b6579206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f20686967684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f206c6f774465706f736974436f6e74726163743a20696e76616c6964207369676e6174757265206c656e677468a2646970667358221220dceca8706b29e917dacf25fceef95acac8d90d765ac926663ce4096195952b6164736f6c634300060b0033", + "nonce": "0x1", "storage": { "0x0000000000000000000000000000000000000000000000000000000000000000": "0x85acb6376c2707b118225da41825974c12b5924a05c6a53b988c9cbc33c55b05", "0x0000000000000000000000000000000000000000000000000000000000000001": "0x2f93f18b1befc457f659e486ce25bbe413fe3943ee7634d2afbe83dc512c3d7a", @@ -168,30 +170,28 @@ "0x000000000000000000000000000000000000000000000000000000000000003e": "0x8869ff2c22b28cc10510d9853292803328be4fb0e80495e8bb8d271f5b889636", "0x000000000000000000000000000000000000000000000000000000000000003f": "0xb5fe28e79f1b850f8658246ce9b6a1e7b49fc06db7143e8fe0b4f2b0c5523a5c", "0x0000000000000000000000000000000000000000000000000000000000000040": "0x985e929f70af28d0bdd1a90a808f977f597c7c778c489e98d3bd8910d31ac0f7" - }, - "balance": "0x3782dace9d9000000", - "nonce": "0x1" - }, - "0x00a3ca265ebcb825b45f985a16cefb49958ce017": { - "code": "0x3373fffffffffffffffffffffffffffffffffffffffe146090573615156028575f545f5260205ff35b366038141561012e5760115f54600182026001905f5b5f82111560595781019083028483029004916001019190603e565b90939004341061012e57600154600101600155600354806003026004013381556001015f3581556001016020359055600101600355005b6003546002548082038060101160a4575060105b5f5b81811460dd5780604c02838201600302600401805490600101805490600101549160601b83528260140152906034015260010160a6565b910180921460ed579060025560f8565b90505f6002555f6003555b5f548061049d141561010757505f5b60015460028282011161011c5750505f610122565b01600290035b5f555f600155604c025ff35b5f5ffd", - "balance": "0x0", - "nonce": "0x1" + } }, "0x000f3df6d732807ef1319fb7b8bb8522d0beac02": { + "balance": "0x0", "code": "0x3373fffffffffffffffffffffffffffffffffffffffe14604d57602036146024575f5ffd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f5260205ff35b5f5ffd5b62001fff42064281555f359062001fff015500", + "nonce": "0x1", "storage": { "0x000000000000000000000000000000000000000000000000000000000000000c": "0x000000000000000000000000000000000000000000000000000000000000000c" - }, + } + }, + "0x00a3ca265ebcb825b45f985a16cefb49958ce017": { "balance": "0x0", + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe146090573615156028575f545f5260205ff35b366038141561012e5760115f54600182026001905f5b5f82111560595781019083028483029004916001019190603e565b90939004341061012e57600154600101600155600354806003026004013381556001015f3581556001016020359055600101600355005b6003546002548082038060101160a4575060105b5f5b81811460dd5780604c02838201600302600401805490600101805490600101549160601b83528260140152906034015260010160a6565b910180921460ed579060025560f8565b90505f6002555f6003555b5f548061049d141561010757505f5b60015460028282011161011c5750505f610122565b01600290035b5f555f600155604c025ff35b5f5ffd", "nonce": "0x1" }, "0x0aae40965e6800cd9b1f4b05ff21581047e3f91e": { + "balance": "0x0", "code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460575767ffffffffffffffff5f3511605357600143035f3511604b575f35612000014311604b57611fff5f3516545f5260205ff35b5f5f5260205ff35b5f5ffd5b5f35611fff60014303165500", + "nonce": "0x1", "storage": { "0x0000000000000000000000000000000000000000000000000000000000000000": "0xe4fb5d47f70d54b4f36777ea4c882cf767f93d8f8170285d97a1b8275dfe4dbb" - }, - "balance": "0x0", - "nonce": "0x1" + } }, "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": { "balance": "0xaa00be18c288efd690", @@ -200,90 +200,77 @@ }, "body": "0xf90404f901ff8007830f42409400000000219ab540356cbb839cbe05303d7705fa8901bc16d674ec800000b9019422895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000d0000000000000000000000000000000000000000000000000000000000000011085acb6376c2707b118225da41825974c12b5924a05c6a53b988c9cbc33c55b05000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000325a0ffeb1d6e7ef8e9ee9b64dcdc3b056f9a1d2b94c1572f1949954e712364604575a03d0f42bad795205de84db8d4ab10b9abd0d081ffe560cbf45f6c281768112a69f901ff0107830f42409400000000219ab540356cbb839cbe05303d7705fa8901bc16d674ec800000b9019422895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000d0000000000000000000000000000000000000000000000000000000000000011085acb6376c2707b118225da41825974c12b5924a05c6a53b988c9cbc33c55b05000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000326a05bb08e348c9c4b0a2e15d04f4a89d1a210d013205de8d3d93e38e5c1b0c8d8aba04300c0f575d9908d2cbc3413ab82895678bb8f3ef356224dd1e7cb972f2c4855", "result": { - "stateRoot": "0x3aa7839837ee1564276a0a05554e35215353a97c4e255c3aacbcd7c7819daefa", - "txRoot": "0x2b790bf82ef7259a0e4513d1b89a77d81e99672ba68758ef2ba3fde32851d023", - "receiptsRoot": "0x9c8d7a917ecb3ff2566f264abbf39131e51b08b07eb2b69cb46989d79d985593", - "logsHash": "0x43e31613bfefc1f55d8b3ca2b61f933f3838d523dc11cb5d7ffdd2ecf0ab5d49", + "blobGasUsed": "0x0", + "currentBaseFee": "0x7", + "currentDifficulty": null, + "currentExcessBlobGas": "0x0", + "gasUsed": "0x24f10", "logsBloom": "0x00000000000000000000400000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000", + "logsHash": "0x43e31613bfefc1f55d8b3ca2b61f933f3838d523dc11cb5d7ffdd2ecf0ab5d49", "receipts": [ { - "root": "0x", - "status": "0x1", + "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "contractAddress": "0x0000000000000000000000000000000000000000", "cumulativeGasUsed": "0x1431e", - "logsBloom": "0x00000000000000000000400000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000", + "gasUsed": "0x1431e", "logs": [ { "address": "0x00000000219ab540356cbb839cbe05303d7705fa", + "blockHash": "0xb7b43f46d6ee34eaaad5ab38807b451e0e85bacbe59893afc625550aa7c65262", + "blockNumber": 1, + "data": "0x00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000080040597307000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000", + "logIndex": "0x0", + "removed": "false", "topics": [ "0x649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000080040597307000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000", - "blockNumber": 1, "transactionHash": "0x1fe5fcd93d503a72e93ef0a4249e6d9c983cecf33474684f62ece959fc3e8212", - "transactionIndex": "0x0", - "blockHash": "0xb7b43f46d6ee34eaaad5ab38807b451e0e85bacbe59893afc625550aa7c65262", - "logIndex": "0x0", - "removed": "false" + "transactionIndex": "0x0" } ], + "logsBloom": "0x00000000000000000000400000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000", + "root": "0x", + "status": "0x1", "transactionHash": "0x1fe5fcd93d503a72e93ef0a4249e6d9c983cecf33474684f62ece959fc3e8212", - "contractAddress": "0x0000000000000000000000000000000000000000", - "gasUsed": "0x1431e", - "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "transactionIndex": "0x0" }, { - "root": "0x", - "status": "0x1", + "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "contractAddress": "0x0000000000000000000000000000000000000000", "cumulativeGasUsed": "0x24f10", - "logsBloom": "0x00000000000000000000400000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000", + "gasUsed": "0x10bf2", "logs": [ { "address": "0x00000000219ab540356cbb839cbe05303d7705fa", + "blockHash": "0xb7b43f46d6ee34eaaad5ab38807b451e0e85bacbe59893afc625550aa7c65262", + "blockNumber": 1, + "data": "0x00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000080040597307000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000080100000000000000000000000000000000000000000000000000000000000000", + "logIndex": "0x0", + "removed": "false", "topics": [ "0x649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000080040597307000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000080100000000000000000000000000000000000000000000000000000000000000", - "blockNumber": 1, "transactionHash": "0x3059d7dbc2df8a05442e50ea529419277c2f45582534f452d2d5676d93273c7d", - "transactionIndex": "0x1", - "blockHash": "0xb7b43f46d6ee34eaaad5ab38807b451e0e85bacbe59893afc625550aa7c65262", - "logIndex": "0x0", - "removed": "false" + "transactionIndex": "0x1" } ], + "logsBloom": "0x00000000000000000000400000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000", + "root": "0x", + "status": "0x1", "transactionHash": "0x3059d7dbc2df8a05442e50ea529419277c2f45582534f452d2d5676d93273c7d", - "contractAddress": "0x0000000000000000000000000000000000000000", - "gasUsed": "0x10bf2", - "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "transactionIndex": "0x1" } ], - "currentDifficulty": null, - "gasUsed": "0x24f10", - "currentBaseFee": "0x7", - "withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "currentExcessBlobGas": "0x0", - "blobGasUsed": "0x0", - "requestsRoot": "0xfba41d6600776bec2258a06e4bc00a34f7a2a1bc0aa802976d038ef4e3379d29", - "depositRequests": [ - { - "pubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", - "withdrawalCredentials": "0x0000000000000000000000000000000000000000000000000000000000000002", - "amount": "0x0000000773594000", - "signature": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003", - "index": "0x0000000000000000" - }, - { - "pubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", - "withdrawalCredentials": "0x0000000000000000000000000000000000000000000000000000000000000002", - "amount": "0x0000000773594000", - "signature": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003", - "index": "0x0000000000000001" - } + "receiptsRoot": "0x9c8d7a917ecb3ff2566f264abbf39131e51b08b07eb2b69cb46989d79d985593", + "requests": [ + "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200405973070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200405973070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030100000000000000", + "0x", + "0x" ], - "withdrawalRequests": [], - "consolidationRequests":[] + "requestsHash": "0x158ac6beda33cd9341831552555f64c95e074e7024f6c4553c1ed7557077b4c7", + "stateRoot": "0x3aa7839837ee1564276a0a05554e35215353a97c4e255c3aacbcd7c7819daefa", + "txRoot": "0x2b790bf82ef7259a0e4513d1b89a77d81e99672ba68758ef2ba3fde32851d023", + "withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" } } } \ No newline at end of file diff --git a/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/t8n/prague-withdrawal.json b/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/t8n/prague-withdrawal.json index 148c7a23e30..35f9843231d 100644 --- a/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/t8n/prague-withdrawal.json +++ b/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/t8n/prague-withdrawal.json @@ -51,23 +51,29 @@ "0x40": "0x985e929f70af28d0bdd1a90a808f977f597c7c778c489e98d3bd8910d31ac0f7" } }, - "0x00a3ca265ebcb825b45f985a16cefb49958ce017": { + "0x09fc772d0857550724b07b850a4323f39112aaaa": { "nonce": "0x01", "balance": "0x00", - "code": "0x3373fffffffffffffffffffffffffffffffffffffffe146090573615156028575f545f5260205ff35b366038141561012e5760115f54600182026001905f5b5f82111560595781019083028483029004916001019190603e565b90939004341061012e57600154600101600155600354806003026004013381556001015f3581556001016020359055600101600355005b6003546002548082038060101160a4575060105b5f5b81811460dd5780604c02838201600302600401805490600101805490600101549160601b83528260140152906034015260010160a6565b910180921460ed579060025560f8565b90505f6002555f6003555b5f548061049d141561010757505f5b60015460028282011161011c5750505f610122565b01600290035b5f555f600155604c025ff35b5f5ffd", - "storage": { - } + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460c7573615156028575f545f5260205ff35b36603814156101f05760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff146101f057600182026001905f5b5f821115608057810190830284830290049160010191906065565b9093900434106101f057600154600101600155600354806003026004013381556001015f35815560010160203590553360601b5f5260385f601437604c5fa0600101600355005b6003546002548082038060101160db575060105b5f5b81811461017f5780604c02838201600302600401805490600101805490600101549160601b83528260140152807fffffffffffffffffffffffffffffffff0000000000000000000000000000000016826034015260401c906044018160381c81600701538160301c81600601538160281c81600501538160201c81600401538160181c81600301538160101c81600201538160081c81600101535360010160dd565b9101809214610191579060025561019c565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14156101c957505f5b6001546002828201116101de5750505f6101e4565b01600290035b5f555f600155604c025ff35b5f5ffd", + "storage": {} }, - "0x000f3df6d732807ef1319fb7b8bb8522d0beac02": { + "0x01abea29659e5e97c95107f20bb753cd3e09bbbb": { "nonce": "0x01", "balance": "0x00", - "code": "0x3373fffffffffffffffffffffffffffffffffffffffe14604d57602036146024575f5ffd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f5260205ff35b5f5ffd5b62001fff42064281555f359062001fff015500", + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460cf573615156028575f545f5260205ff35b366060141561019a5760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1461019a57600182026001905f5b5f821115608057810190830284830290049160010191906065565b90939004341061019a57600154600101600155600354806004026004013381556001015f358155600101602035815560010160403590553360601b5f5260605f60143760745fa0600101600355005b6003546002548082038060011160e3575060015b5f5b8181146101295780607402838201600402600401805490600101805490600101805490600101549260601b84529083601401528260340152906054015260010160e5565b910180921461013b5790600255610146565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff141561017357505f5b6001546001828201116101885750505f61018e565b01600190035b5f555f6001556074025ff35b5f5ffd", "storage": {} }, "0x0aae40965e6800cd9b1f4b05ff21581047e3f91e": { + "nonce": "0x01", + "balance": "0x00", "code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460575767ffffffffffffffff5f3511605357600143035f3511604b575f35612000014311604b57611fff5f3516545f5260205ff35b5f5f5260205ff35b5f5ffd5b5f35611fff60014303165500", - "balance": "0x0", - "nonce": "0x1" + "storage": {} + }, + "0x000f3df6d732807ef1319fb7b8bb8522d0beac02": { + "nonce": "0x01", + "balance": "0x00", + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe14604d57602036146024575f5ffd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f5260205ff35b5f5ffd5b62001fff42064281555f359062001fff015500", + "storage": {} }, "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": { "nonce": "0x00", @@ -75,10 +81,10 @@ "code": "0x", "storage": {} }, - "0x0000000000000000000000000000000000000200": { + "0x0000000000000000000000000000000000001000": { "nonce": "0x01", "balance": "0xad78ebc5ac62000000", - "code": "0x60386000600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386038600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386070600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f150603860a8600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f150603860e0600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610118600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610150600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610188600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386101c0600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386101f8600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610230600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610268600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386102a0600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386102d8600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610310600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610348600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f150", + "code": "0x60386000600037600060006038600060017309fc772d0857550724b07b850a4323f39112aaaa620f4240f150", "storage": {} } }, @@ -89,12 +95,12 @@ "nonce": "0x0", "gasPrice": "0x7", "gas": "0xf4240", - "to": "0x0000000000000000000000000000000000000200", + "to": "0x0000000000000000000000000000000000001000", "value": "0x0", - "input": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001fffffffffffffffe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003fffffffffffffffe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005fffffffffffffffe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007fffffffffffffffe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009fffffffffffffffe00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bfffffffffffffffe00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dfffffffffffffffe00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000", + "input": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000", "v": "0x26", - "r": "0x963cb6620fe5828cbc93bb7139d3f4501067d76275dff648bf48c3c100ca8dd4", - "s": "0x4ac396104a5be4643406718f59a6e74d62a32777f5f6135e55e805e87612013c", + "r": "0xd050db98a60dbe4bbbc6ce154c607f28f1cf803a8882f369b28a5eb4ef1a600f", + "s": "0x7512ca5133bcb887a41f6136cd645839c1bcf0f300325948387a70f3ad9ced1c", "sender": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" } ], @@ -124,9 +130,9 @@ }, "stdout": { "alloc": { - "0x0000000000000000000000000000000000000200": { - "code": "0x60386000600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386038600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386070600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f150603860a8600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f150603860e0600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610118600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610150600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610188600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386101c0600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386101f8600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610230600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610268600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386102a0600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386102d8600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610310600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610348600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f150", - "balance": "0xad78ebc5ac61fffff0", + "0x0000000000000000000000000000000000001000": { + "code": "0x60386000600037600060006038600060017309fc772d0857550724b07b850a4323f39112aaaa620f4240f150", + "balance": "0xad78ebc5ac61ffffff", "nonce": "0x1" }, "0x00000000219ab540356cbb839cbe05303d7705fa": { @@ -175,44 +181,18 @@ "balance": "0x0", "nonce": "0x1" }, - "0x00a3ca265ebcb825b45f985a16cefb49958ce017": { - "code": "0x3373fffffffffffffffffffffffffffffffffffffffe146090573615156028575f545f5260205ff35b366038141561012e5760115f54600182026001905f5b5f82111560595781019083028483029004916001019190603e565b90939004341061012e57600154600101600155600354806003026004013381556001015f3581556001016020359055600101600355005b6003546002548082038060101160a4575060105b5f5b81811460dd5780604c02838201600302600401805490600101805490600101549160601b83528260140152906034015260010160a6565b910180921460ed579060025560f8565b90505f6002555f6003555b5f548061049d141561010757505f5b60015460028282011161011c5750505f610122565b01600290035b5f555f600155604c025ff35b5f5ffd", + "0x01abea29659e5e97c95107f20bb753cd3e09bbbb": { + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460cf573615156028575f545f5260205ff35b366060141561019a5760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1461019a57600182026001905f5b5f821115608057810190830284830290049160010191906065565b90939004341061019a57600154600101600155600354806004026004013381556001015f358155600101602035815560010160403590553360601b5f5260605f60143760745fa0600101600355005b6003546002548082038060011160e3575060015b5f5b8181146101295780607402838201600402600401805490600101805490600101805490600101549260601b84529083601401528260340152906054015260010160e5565b910180921461013b5790600255610146565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff141561017357505f5b6001546001828201116101885750505f61018e565b01600190035b5f555f6001556074025ff35b5f5ffd", + "balance": "0x0", + "nonce": "0x1" + }, + "0x09fc772d0857550724b07b850a4323f39112aaaa": { + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460c7573615156028575f545f5260205ff35b36603814156101f05760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff146101f057600182026001905f5b5f821115608057810190830284830290049160010191906065565b9093900434106101f057600154600101600155600354806003026004013381556001015f35815560010160203590553360601b5f5260385f601437604c5fa0600101600355005b6003546002548082038060101160db575060105b5f5b81811461017f5780604c02838201600302600401805490600101805490600101549160601b83528260140152807fffffffffffffffffffffffffffffffff0000000000000000000000000000000016826034015260401c906044018160381c81600701538160301c81600601538160281c81600501538160201c81600401538160181c81600301538160101c81600201538160081c81600101535360010160dd565b9101809214610191579060025561019c565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14156101c957505f5b6001546002828201116101de5750505f6101e4565b01600290035b5f555f600155604c025ff35b5f5ffd", "storage": { - "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000000000000000000000000000000000000000000e", - "0x0000000000000000000000000000000000000000000000000000000000000004": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x0000000000000000000000000000000000000000000000000000000000000006": "0x00000000000000000000000000000001fffffffffffffffe0000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000007": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x0000000000000000000000000000000000000000000000000000000000000009": "0x0000000000000000000000000000000200000000000000000000000000000000", - "0x000000000000000000000000000000000000000000000000000000000000000a": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x000000000000000000000000000000000000000000000000000000000000000c": "0x00000000000000000000000000000003fffffffffffffffe0000000000000000", - "0x000000000000000000000000000000000000000000000000000000000000000d": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x000000000000000000000000000000000000000000000000000000000000000f": "0x0000000000000000000000000000000400000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000010": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x0000000000000000000000000000000000000000000000000000000000000012": "0x00000000000000000000000000000005fffffffffffffffe0000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000013": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x0000000000000000000000000000000000000000000000000000000000000015": "0x0000000000000000000000000000000600000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000016": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x0000000000000000000000000000000000000000000000000000000000000018": "0x00000000000000000000000000000007fffffffffffffffe0000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000019": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x000000000000000000000000000000000000000000000000000000000000001b": "0x0000000000000000000000000000000800000000000000000000000000000000", - "0x000000000000000000000000000000000000000000000000000000000000001c": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x000000000000000000000000000000000000000000000000000000000000001e": "0x00000000000000000000000000000009fffffffffffffffe0000000000000000", - "0x000000000000000000000000000000000000000000000000000000000000001f": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x0000000000000000000000000000000000000000000000000000000000000021": "0x0000000000000000000000000000000a00000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000022": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x0000000000000000000000000000000000000000000000000000000000000024": "0x0000000000000000000000000000000bfffffffffffffffe0000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000025": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x0000000000000000000000000000000000000000000000000000000000000027": "0x0000000000000000000000000000000c00000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000028": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x000000000000000000000000000000000000000000000000000000000000002a": "0x0000000000000000000000000000000dfffffffffffffffe0000000000000000", - "0x000000000000000000000000000000000000000000000000000000000000002b": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x000000000000000000000000000000000000000000000000000000000000002d": "0x0000000000000000000000000000000e00000000000000000000000000000000", - "0x000000000000000000000000000000000000000000000000000000000000002e": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x0000000000000000000000000000000000000000000000000000000000000030": "0x0000000000000000000000000000000ffffffffffffffffe0000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000031": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x0000000000000000000000000000000000000000000000000000000000000033": "0x0000000000000000000000000000001000000000000000000000000000000000" + "0x0000000000000000000000000000000000000000000000000000000000000004": "0x0000000000000000000000000000000000000000000000000000000000001000", + "0x0000000000000000000000000000000000000000000000000000000000000006": "0x0000000000000000000000000000000100000000000000000000000000000000" }, - "balance": "0x10", + "balance": "0x1", "nonce": "0x1" }, "0x0aae40965e6800cd9b1f4b05ff21581047e3f91e": { @@ -224,118 +204,51 @@ "nonce": "0x1" }, "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": { - "balance": "0xad78ebc5ac619bbcea", + "balance": "0xad78ebc5ac61f2afcb", "nonce": "0x1" } }, - "body": "0xf903e5f903e28007830f424094000000000000000000000000000000000000020080b90380000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001fffffffffffffffe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003fffffffffffffffe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005fffffffffffffffe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007fffffffffffffffe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009fffffffffffffffe00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bfffffffffffffffe00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dfffffffffffffffe00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffe000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000026a0963cb6620fe5828cbc93bb7139d3f4501067d76275dff648bf48c3c100ca8dd4a04ac396104a5be4643406718f59a6e74d62a32777f5f6135e55e805e87612013c", + "body": "0xf89bf8998007830f424094000000000000000000000000000000000000100080b838000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000026a0d050db98a60dbe4bbbc6ce154c607f28f1cf803a8882f369b28a5eb4ef1a600fa07512ca5133bcb887a41f6136cd645839c1bcf0f300325948387a70f3ad9ced1c", "result": { - "requestsRoot": "0x415d33e444f917658fd3bd6d3d8d88a1f501f9b83ace92ddacac823252c9fa47", - "depositRequests": [], - "withdrawalRequests": [ - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", - "amount": "0xfffffffffffffffe" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002", - "amount": "0x0000000000000000" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003", - "amount": "0xfffffffffffffffe" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004", - "amount": "0x0000000000000000" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005", - "amount": "0xfffffffffffffffe" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006", - "amount": "0x0000000000000000" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007", - "amount": "0xfffffffffffffffe" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008", - "amount": "0x0000000000000000" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009", - "amount": "0xfffffffffffffffe" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a", - "amount": "0x0000000000000000" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b", - "amount": "0xfffffffffffffffe" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c", - "amount": "0x0000000000000000" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d", - "amount": "0xfffffffffffffffe" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e", - "amount": "0x0000000000000000" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f", - "amount": "0xfffffffffffffffe" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010", - "amount": "0x0000000000000000" - } + "requestsHash": "0xab205d558af6253557180e19e89356ed4c7d4b13615ee9560840af3df75ddb12", + "requests": [ + "0x", + "0x00000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000", + "0x" ], - "consolidationRequests":[], - "stateRoot": "0xf63d7552dc407993393315e99272781d04eedfcf369a1acd3e386d1e6710229d", - "txRoot": "0x8521df63211790726b6f1a437bb0fd4b27c00e13e7678d324c4cfddb8d834ad2", - "receiptsRoot": "0x4bd8bd5580caf4ed45f873794ad7ff9d6fd2363ae529269b17b891b68d349d75", - "logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "stateRoot": "0x23d988164325beeeea1044c9f104ff4fe108038369f26a3327198ce40f827430", + "txRoot": "0x0d36638e52999b7beafa00eb94f7ca23139774cd14229c011d0edc1fc66125c9", + "receiptsRoot": "0x3d22e243cbebced1fafba149bce09285797af6c66ce901ff3ab1caf073fca791", + "logsHash": "0xf69b003be75aaafefa35aa30e6367f732dd9b31a6c97196febc285ee9289bb60", + "logsBloom": "0x00000000000000000000000008000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "receipts": [ { "root": "0x", "status": "0x1", - "cumulativeGasUsed": "0xe52ba", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "logs": null, - "transactionHash": "0x04a2d3f252dcc98edb684f7f15b572aaf980d0c2eea4c620a9f1ff1d275b2207", + "cumulativeGasUsed": "0x1e6e3", + "logsBloom": "0x00000000000000000000000008000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "logs": [ + { + "address": "0x09fc772d0857550724b07b850a4323f39112aaaa", + "topics": [], + "data": "0x00000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000", + "blockNumber": 1, + "transactionHash": "0xa888ec4587b7ba70d0127004a96fbb0a83ccb611e61405094e6514b970bf37f6", + "transactionIndex": "0x0", + "blockHash": "0xb7b43f46d6ee34eaaad5ab38807b451e0e85bacbe59893afc625550aa7c65262", + "logIndex": "0x0", + "removed": "false" + } + ], + "transactionHash": "0xa888ec4587b7ba70d0127004a96fbb0a83ccb611e61405094e6514b970bf37f6", "contractAddress": "0x0000000000000000000000000000000000000000", - "gasUsed": "0xe52ba", + "gasUsed": "0x1e6e3", "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "transactionIndex": "0x0" } ], "currentDifficulty": null, - "gasUsed": "0xe52ba", + "gasUsed": "0x1e6e3", "currentBaseFee": "0x7", "withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "currentExcessBlobGas": "0x0", diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BlockchainReferenceTestCaseSpec.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BlockchainReferenceTestCaseSpec.java index a30401e17ce..bc60c7ddd08 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BlockchainReferenceTestCaseSpec.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BlockchainReferenceTestCaseSpec.java @@ -31,7 +31,6 @@ import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.ParsedExtraData; -import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; @@ -165,7 +164,7 @@ public ReferenceTestBlockHeader( @JsonProperty("mixHash") final String mixHash, @JsonProperty("nonce") final String nonce, @JsonProperty("withdrawalsRoot") final String withdrawalsRoot, - @JsonProperty("requestsRoot") final String requestsRoot, + @JsonProperty("requestsHash") final String requestsHash, @JsonProperty("blobGasUsed") final String blobGasUsed, @JsonProperty("excessBlobGas") final String excessBlobGas, @JsonProperty("parentBeaconBlockRoot") final String parentBeaconBlockRoot, @@ -195,7 +194,7 @@ public ReferenceTestBlockHeader( blobGasUsed != null ? Long.decode(blobGasUsed) : 0, excessBlobGas != null ? BlobGas.fromHexString(excessBlobGas) : null, parentBeaconBlockRoot != null ? Bytes32.fromHexString(parentBeaconBlockRoot) : null, - requestsRoot != null ? Hash.fromHexString(requestsRoot) : null, + requestsHash != null ? Hash.fromHexString(requestsHash) : null, new BlockHeaderFunctions() { @Override public Hash hash(final BlockHeader header) { @@ -290,10 +289,7 @@ public Block getBlock() { input.readList(inputData -> BlockHeader.readFrom(inputData, blockHeaderFunctions)), input.isEndOfCurrentList() ? Optional.empty() - : Optional.of(input.readList(Withdrawal::readFrom)), - input.isEndOfCurrentList() - ? Optional.empty() - : Optional.of(input.readList(Request::readFrom))); + : Optional.of(input.readList(Withdrawal::readFrom))); return new Block(header, body); } } diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestEnv.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestEnv.java index 636e23f8786..26c124472b5 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestEnv.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestEnv.java @@ -145,7 +145,7 @@ public ReferenceTestEnv( currentBlobGasUsed == null ? null : Long.decode(currentBlobGasUsed), currentExcessBlobGas == null ? null : BlobGas.of(Long.decode(currentExcessBlobGas)), beaconRoot == null ? null : Bytes32.fromHexString(beaconRoot), - null, // requestsRoot + null, // requestsHash new MainnetBlockHeaderFunctions()); this.parentDifficulty = parentDifficulty; this.parentBaseFee = parentBaseFee; diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/NoRewardProtocolScheduleWrapper.java b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/NoRewardProtocolScheduleWrapper.java index 99210f57d29..db1ac943f01 100644 --- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/NoRewardProtocolScheduleWrapper.java +++ b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/NoRewardProtocolScheduleWrapper.java @@ -88,7 +88,7 @@ public ProtocolSpec getByBlockHeader(final ProcessableBlockHeader blockHeader) { Optional.empty(), original.getWithdrawalsValidator(), original.getWithdrawalsProcessor(), - original.getRequestsValidatorCoordinator(), + original.getRequestsValidator(), original.getRequestProcessorCoordinator(), original.getBlockHashProcessor(), original.isPoS(), diff --git a/plugin-api/build.gradle b/plugin-api/build.gradle index 91fb45239dc..d400e5abe22 100644 --- a/plugin-api/build.gradle +++ b/plugin-api/build.gradle @@ -71,7 +71,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 = 'WRdnBaP05fItpWHYSFz/vBBlRWL3sLGqzR3tzd+pOkA=' + knownHash = '1VIGlJuGiaEVUksIjTTHDt7SIjjJE9+DU8rYk/ze3XM=' } check.dependsOn('checkAPIChanges') diff --git a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/BlockBody.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/BlockBody.java index 18a5e07ce6a..7c101f414f9 100644 --- a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/BlockBody.java +++ b/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/BlockBody.java @@ -15,7 +15,6 @@ package org.hyperledger.besu.plugin.data; import org.hyperledger.besu.datatypes.Transaction; -import org.hyperledger.besu.plugin.Unstable; import java.util.List; import java.util.Optional; @@ -47,12 +46,4 @@ public interface BlockBody { * @return The list of withdrawals of the block. */ Optional> getWithdrawals(); - - /** - * Returns the list of requests of the block. - * - * @return The list of requests of the block. - */ - @Unstable - Optional> getRequests(); } diff --git a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/BlockHeader.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/BlockHeader.java index ed8d6b87456..05f0c0304e3 100644 --- a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/BlockHeader.java +++ b/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/BlockHeader.java @@ -128,7 +128,7 @@ public interface BlockHeader extends ProcessableBlockHeader { * request in the request list portion of the block. */ @Unstable - Optional getRequestsRoot(); + Optional getRequestsHash(); /** * The excess_blob_gas of this header. diff --git a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/ConsolidationRequest.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/ConsolidationRequest.java deleted file mode 100644 index 5d7e66b4aeb..00000000000 --- a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/ConsolidationRequest.java +++ /dev/null @@ -1,45 +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.plugin.data; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.PublicKey; -import org.hyperledger.besu.plugin.Unstable; - -/** A consolidation request is an operation sent to the Beacon Node for processing. */ -@Unstable -public interface ConsolidationRequest { - - /** - * Withdrawal credential (0x01) associated with the validator - * - * @return withdrawal credential address - */ - Address getSourceAddress(); - - /** - * Public key of the address that sends the consolidation - * - * @return public key of sender - */ - PublicKey getSourcePubkey(); - - /** - * Public key of the address to receives the consolidation - * - * @return public key of target - */ - PublicKey getTargetPubkey(); -} diff --git a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/DepositRequest.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/DepositRequest.java deleted file mode 100644 index 096554d3c74..00000000000 --- a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/DepositRequest.java +++ /dev/null @@ -1,68 +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.plugin.data; - -import org.hyperledger.besu.datatypes.BLSSignature; -import org.hyperledger.besu.datatypes.PublicKey; -import org.hyperledger.besu.datatypes.Quantity; -import org.hyperledger.besu.plugin.Unstable; - -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt64; - -/** - * A deposit is a system-level operation to support validator deposits that are pushed from the EVM - * to beacon chain. - */ -@Unstable -public interface DepositRequest { - - /** - * Public key of the address that sends the deposit - * - * @return public key of sender - */ - PublicKey getPubkey(); - - /** - * Withdrawal credential that contains info that will be used for verifying the destination of - * valid withdrawals - * - * @return withdrawal credential - */ - Bytes32 getWithdrawalCredentials(); - - /** - * Amount of ether to be sent to the deposit contract - * - * @return deposit ether amount - */ - Quantity getAmount(); - - /** - * Signature that will be used together with the public key to verify the validity of this Deposit - * - * @return signature - */ - BLSSignature getSignature(); - - /** - * A monotonically increasing index, starting from 0 that increments by 1 per deposit to uniquely - * identify each deposit - * - * @return deposit index - */ - UInt64 getIndex(); -} diff --git a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/Request.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/Request.java index 2540f91098b..0e55f399809 100644 --- a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/Request.java +++ b/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/Request.java @@ -17,6 +17,8 @@ import org.hyperledger.besu.datatypes.RequestType; import org.hyperledger.besu.plugin.Unstable; +import org.apache.tuweni.bytes.Bytes; + /** A request is an operation sent to the Beacon Node */ @Unstable public interface Request { @@ -27,4 +29,11 @@ public interface Request { * @return The {@link RequestType} representing the type of this request. */ RequestType getType(); + + /** + * Retrieves the data of this request. + * + * @return The data {@link Bytes} of this request. + */ + Bytes getData(); } diff --git a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/WithdrawalRequest.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/WithdrawalRequest.java deleted file mode 100644 index f07d0d08d03..00000000000 --- a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/WithdrawalRequest.java +++ /dev/null @@ -1,49 +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.plugin.data; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.datatypes.PublicKey; -import org.hyperledger.besu.plugin.Unstable; - -/** - * A withdrawal request is an operation sent to the Beacon Node for processing validator withdrawal - * requests (partial or complete) - */ -@Unstable -public interface WithdrawalRequest { - - /** - * Withdrawal credential (0x01) associated with the validator - * - * @return withdrawal credential address - */ - Address getSourceAddress(); - - /** - * Public key of the validator that is going to request a withdrawal - * - * @return public key of validator - */ - PublicKey getValidatorPubkey(); - - /** - * The amount for withdrawal - * - * @return withdrawal amount - */ - GWei getAmount(); -}