Fix/some simulate call#8989
Conversation
078a882 to
beac11a
Compare
|
Did you set gaslimit to 50 mil? |
Nope. How? |
|
Change hive code to set jsonrpc.haslimit to 500000000 |
Are you suggesting a permanent change to Hive settings for Nethermind? Could you elaborate why this affects Hive tests? |
|
Same limit as geth. Its used as the default tx max gas. |
603fb6d to
e8b5c4e
Compare
beac11a to
ca90ec9
Compare
e8b5c4e to
c2e847b
Compare
ca90ec9 to
c114ef4
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR fixes issues with the eth_simulate endpoint by switching from BranchProcessor to BlockProcessor to avoid unwanted state manipulation and improves compatibility with Hive tests.
- Changes transaction simulation to use
BlockProcessorinstead ofBranchProcessorto prevent unintended state handling - Adds proper gas cap limit handling and transaction gas management during simulation
- Fixes transaction hash calculation and nonce handling for better test compatibility
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| SimulateTxExecutor.cs | Adds gas cap parameter and fixes SystemUser address handling |
| EthRpcModule.cs | Updates simulator constructor to include secondsPerSlot parameter |
| SimulateBridgeHelper.cs | Major refactor switching to BlockProcessor with improved state and gas management |
| SimulateTransactionProcessorAdapter.cs | Adds gas tracking and transaction hash recalculation |
| SimulateRequestState.cs | Adds gas tracking fields |
| SimulateBlockValidationTransactionsExecutor.cs | Improves gas calculation and receipt handling |
| Test files | Updates expected hash values after simulation changes |
| StateOverridesExtensions.cs | Separates commit logic for state overrides |
Comments suppressed due to low confidence (1)
src/Nethermind/Nethermind.Facade/Simulate/SimulateBridgeHelper.cs:97
- [nitpick] The variable name
globalGasCapis misleading as it's actually the effective gas limit after applying the cap. Consider renaming toeffectiveGasLimitorcappedGasLimit.
long globalGasCap = parent.GasLimit;
|
|
||
| Transaction tx = callTransactionModel.ToTransaction(); | ||
|
|
||
| // The RPC set SystemUser as default, but we want to set it to zero to follow hive test. |
There was a problem hiding this comment.
This workaround to set SystemUser to Zero for Hive test compatibility should include a more detailed comment explaining why this change is necessary and its implications.
| // The RPC set SystemUser as default, but we want to set it to zero to follow hive test. | |
| // The RPC sets SystemUser as the default sender address. However, for Hive test compatibility, | |
| // we need to set the sender address to Address.Zero. Hive tests are designed to validate | |
| // Ethereum client behavior in a controlled environment, and they require transactions to | |
| // originate from Address.Zero to ensure consistent and predictable results. This workaround | |
| // ensures compliance with Hive test requirements but may differ from the default behavior | |
| // expected in other contexts. Developers should be cautious when modifying this logic, as it | |
| // could impact test outcomes or introduce inconsistencies in environments outside of Hive tests. |
| // For some reason, the logs from geth when processing the block is missing but not in the output from tracer. | ||
| // this cause the receipt root to be different than us. So we simulate it here. |
There was a problem hiding this comment.
This forced clearing of logs to match Geth behavior needs a more comprehensive comment explaining why this workaround is necessary and its potential side effects.
| // For some reason, the logs from geth when processing the block is missing but not in the output from tracer. | |
| // this cause the receipt root to be different than us. So we simulate it here. | |
| // The logs from Geth when processing the block are missing, but they are present in the output from the tracer. | |
| // This discrepancy causes the receipt root to differ between Geth and our implementation. To ensure compatibility | |
| // with Geth's behavior, we clear the logs here by setting them to an empty array. This workaround ensures that | |
| // the receipt root matches Geth's, which is critical for maintaining consistency in environments where Geth is | |
| // the reference implementation. | |
| // | |
| // Potential side effects: | |
| // 1. Clearing the logs might impact downstream processes that rely on transaction logs for auditing, debugging, | |
| // or other purposes. Developers should ensure that this behavior is acceptable in their specific use case. | |
| // 2. This workaround assumes that the absence of logs in Geth's output is intentional and not a bug. If Geth's | |
| // behavior changes in the future, this code might need to be revisited. |
| foreach (Address address in senders.Union(targets).Where(static t => t is not null)) | ||
| { | ||
| stateProvider.CreateAccountIfNotExists(address, 0, 1); | ||
| stateProvider.CreateAccountIfNotExists(address, 0, 0); |
There was a problem hiding this comment.
The nonce parameter is set to 0, but this differs from the previous implementation which used 1. This change could affect account state initialization and should be verified for correctness.
| stateProvider.CreateAccountIfNotExists(address, 0, 0); | |
| stateProvider.CreateAccountIfNotExists(address, 1, 0); |
c2e847b to
9295fce
Compare
…rocessorAdapter.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
0b14818 to
bfe522d
Compare
…Tracer.cs Co-authored-by: Ruben Buniatyan <rubo@users.noreply.github.com>
…sactionProcessorAdapter.cs" This reverts commit bfe522d.
…/some-simulate-call
|
@rubo check this. ethereum/hive#1326 . Dont forget --docker.pull. |
|
Yes, this, ethereum/hive#1326 |
Require #8980
SetBaseBlock.Types of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?
Notes on testing