-
Notifications
You must be signed in to change notification settings - Fork 956
feature: implement eth_simulateV1 #8406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: implement eth_simulateV1 #8406
Conversation
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
…Trintinalia/besu into fill-gaps-between-calls
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements support for eth_simulateV1 by introducing new parameter and result classes, updating related method implementations, and adding accompanying tests. Key changes include:
- New JSON-RPC parameter and result classes for simulation (e.g. JsonBlockStateCallParameter, SimulateV1Parameter, BlockStateCallResult).
- Updates to the EthSimulateV1 method and registration in the RPC methods.
- Modifications in existing classes (e.g. BlockOverridesParameter, TransactionCompleteResult) and test updates to support simulation.
Reviewed Changes
Copilot reviewed 44 out of 44 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/JsonBlockStateCallParameter.java | New parameter class for block state calls in simulation. |
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/SimulateV1Parameter.java | New parameter class for eth_simulateV1. |
ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/bonsai/EthSimulateV1BySpecTest.java | New Bonsai tests for simulation. |
ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/SimulateV1ParameterTest.java | New tests verifying validation errors and parameter ordering. |
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockStateCallResult.java | New result class for simulation responses. |
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionCompleteResult.java | Adjusted access list handling in simulation transaction response. |
ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSimulateV1Test.java | Test cases validating the EthSimulateV1 method behavior. |
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSimulateV1.java | Implementation of the new eth_simulateV1 JSON-RPC method. |
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/BlockOverridesParameter.java | Renamed parameter and updated handling for mixHash/prevRandao input. |
ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpServiceTest.java | Updated service test configuration to use DEFAULT_GAS_CAP. |
besu/src/main/java/org/hyperledger/besu/services/BlockSimulatorServiceImpl.java | Introduced fake signature logic and refactored simulation parameter creation. |
consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validator/ValidatorContractControllerTest.java | Adjusted test calls with additional Optional.empty() parameter. |
datatypes/src/main/java/org/hyperledger/besu/datatypes/StateOverride.java | Added builder method documentation block. |
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResult.java | Removed outdated call processing results field from BlockResult. |
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/CallProcessingResult.java | Refactored error handling to use JsonRpcError. |
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/EthJsonRpcMethods.java | Registered EthSimulateV1 in the available RPC methods. |
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java | Added ETH_SIMULATE_V1 as a supported RPC method. |
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/JsonRpcMethodsFactory.java | Updated method factory to pass miningConfiguration for simulation. |
Comments suppressed due to low confidence (1)
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/BlockOverridesParameter.java:73
- Ensure that falling back to 'prevRandao' when 'mixHash' is not present is appropriate given the changed type from Optional to Optional. Consider applying an explicit type conversion or validation to avoid potential runtime type issues.
mixHash.isPresent() ? mixHash : prevRandao);
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
few comments. needs a changelog entry
.../src/main/java/org/hyperledger/besu/ethereum/transaction/exceptions/BlockStateCallError.java
Outdated
Show resolved
Hide resolved
evm/src/main/java/org/hyperledger/besu/evm/tracing/EthTransferLogOperationTracer.java
Show resolved
Hide resolved
plugin-api/src/main/java/org/hyperledger/besu/plugin/data/BlockOverrides.java
Outdated
Show resolved
Hide resolved
plugin-api/src/main/java/org/hyperledger/besu/plugin/data/BlockOverrides.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial review. A question about support for pending
block tag
} | ||
|
||
@Override | ||
protected BlockParameterOrBlockHash blockParameterOrBlockHash( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this method also support pending as block tag?
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, some minor optimizations, the open question about the behavior of the pending
block tag, and what about the remaining failing Hive tests.
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/BlockSimulator.java
Outdated
Show resolved
Hide resolved
|
||
BlockHeader finalBlockHeader = | ||
BlockHeaderBuilder.createDefault() | ||
.populateFrom(blockHeader) | ||
.ommersHash(BodyValidation.ommersHash(List.of())) | ||
.stateRoot(blockOverrides.getStateRoot().orElseGet(ws::rootHash)) | ||
.stateRoot(blockOverrides.getStateRoot().orElseGet(ws::frontierRootHash)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why frontierRootHash
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fab-10 Good question! Since eth_simulationV1
can simulate up to 256 blocks in the future, I need to retain the changes from each block in the accumulator to build the next block, while also needing the state root to construct the block header. The Frontier Root Hash does not clear the accumulator as the rootHash method does. One option could be to rename it to "intermediateRootHash." Perhaps @matkt has a better suggestion on how I could achieve this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why you need to keep what you have in the accumulator ? you just have to persist in your worldstate for each block and start with empty accumulator for each block . no ?
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
@fab-10 Thanks for the review. I have addressed the suggestions. Regarding the pending block, |
Fine to ship for me |
PR description
Adds support for eth_simulateV1
Spec: ethereum/execution-apis#484
Fixes: #6203
Currently passing 87/97 hive tests