Skip to content

chore(DONOTMERGE): Show tests failing when using history_by_block_hash #15631

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

Closed

Conversation

kevaundray
Copy link
Contributor

CC @rkrasiuk

This PR highlights possibly my misuse of the API.

Tests Passing

  • First we change from the ExecutionStage to ExecutorProvider in commit 52d66c73c572bf02c9f55a7b1a8cddf47c65d202

  • Running make ef-tests here will pass all tests.

Tests fails

  • Next instead of using LatestStateProviderRef to create a state_provider, we switch to using history_by_block_hash in commit afc64a3

  • running make ef-tests here fails with various error messages indicating that the state was not correctly fetched such as :

[!] Case reth/testing/ef-tests/ethereum-tests/BlockchainTests/ValidBlocks/bcRandomBlockhashTest/randomStatetest56BC.json failed (description: no description): test failed: Slot 1950 is missing from the database. Expected 1950

[!] Case reth/testing/ef-tests/ethereum-tests/BlockchainTests/ValidBlocks/bcRandomBlockhashTest/randomStatetest128BC.json failed (description: no description): test failed: Balance does not match
 left `877917874`,
right `0`

[!] Case reth/testing/ef-tests/ethereum-tests/BlockchainTests/ValidBlocks/bcStateTests/ZeroValue_TransactionCALLwithData_ToEmpty_OOGRevert_Paris.json failed (description: no description): test failed: Slot 2000 is missing from the database. Expected 2000

[!] Case reth/testing/ef-tests/ethereum-tests/BlockchainTests/ValidBlocks/bcStateTests/create2collisionwithSelfdestructSameBlock.json failed (description: no description): test failed: Expected account (0x0000000000000000000000000000000000000010) is missing from DB: Account { balance: 1, code: 0x, nonce: 0, storage: {} }

What I am trying to do:

Ultimately, I am trying to execute each block individually and make an ExecutionWitness for each block

@kevaundray
Copy link
Contributor Author

Removed most of the JSON tests and checked in SimpleTX.json from ethereum-tests. Running make ef-tests should now only run that single file

@kevaundray
Copy link
Contributor Author

One thing to note is that if we do:

                    let state_provider = provider.history_by_block_hash(block.parent_hash)?;
                    state_provider
                        .account_balance(&address!("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b"))
                        .unwrap();

The account is not there, but in the simpleTx.json file, we can see that this account should have funds. Going back to:

let state_provider = provider.latest();

and we see that the account is present

Comment on lines +104 to +109

assert_eq!(
chain_spec_genesis_hash,
genesis_block.hash_slow(),
"shouldn't these hashes be the same?"
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have expected these to be the same, I get:

  left: 0xc0f91ac7900ffb638fdf6d1f20dc4a210294debe5bb4e9096390d852ab378304
 right: 0x8cbc69e33bd85b1f8d7bc6cae8f1d4502b74cfd0cd5f24a558c0d0c257c69daa

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah the chain_spec is derived from the ForkId, so it is using the default genesis block for that fork instead of the genesis block header in the json file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can see then:

  • The execution spec tests define a genesis block header, and a network parameter (eg Cancun)
  • There was code to convert the network parameter into a ChainSpec which has a genesis block based off of mainnet
  • history_by_block_hash seemed to have been looking for the genesis block hash based off of the ChainSpec, whereas we saved the genesis block block hash that corresponds to the one in the execution spec test json file.
  • I haven't checked, but I'm guessing latest() was looking at what we saved in the database and ignoring the ChainSpec

@kevaundray
Copy link
Contributor Author

Closing this as it has been fixed on the stateless branch

@kevaundray kevaundray closed this Apr 10, 2025
@github-project-automation github-project-automation bot moved this from Backlog to Done in Reth Tracker Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant