gnosischain / reth_gnosis

22 stars 3 forks source link

Post-merge devnet state root mismatch block 0x1 #10

Closed dapplion closed 1 month ago

dapplion commented 3 months ago

State root mismatch processing first block

Invalid block error on new payload invalid_hash=0xc0f683b61355455d49af3dbb11fe1f65e9ae8670890d6fb1aadcbf5f8acc960b invalid_number=1 error=mismatched block state root: got 0xf642572d6309b2f2ecad2a6a8b24774beff142d46b525465514feba61f8f601a, expected 0xa59f6ea19d9ee6d7e79bcb286e6d8838b47b48351b37960e24c0a72d41fa1629

When asking Reth to produce the test vectors, Reth rejects its own block

Error while processing payload error=Failed to insert block (hash=0x18b4ca61ed1c11c187bc2d9e8e6de0fb54f9c8372dddbbc65c5d5e5aa3f38c14, number=1, parent_hash=0xa7931c99fd2b7b5e323a2fda8a2dd607cea04f03835c3f29bfe7c057c8b5672e): mismatched block state root: got 0xf642572d6309b2f2ecad2a6a8b24774beff142d46b525465514feba61f8f601a expected 0x9ec3eaf4e6188dfbdd6ade76eaa88289b57c63c9a2cde8d35291d5a29e143d31

But note that there are three roots:

dapplion commented 3 months ago

Branch to dump the Reth post state block https://github.com/dapplion/reth_gnosis/compare/gen-blocks-debug?expand=1

BundleState { 
    state: {
        0x2000000000000000000000000000000000000001: BundleAccount { 
            info: Some(AccountInfo { 
                balance: 0, 
                nonce: 1, 
                code_hash: 0x7ffaa84db4424a71bcd0a1b2a45f90eb2f1b177efd0bf7850dd37b012183acf1,
                code: ---
            }), 
            original_info: Some(AccountInfo { 
                balance: 0, 
                nonce: 1, 
                code_hash: 0x7ffaa84db4424a71bcd0a1b2a45f90eb2f1b177efd0bf7850dd37b012183acf1,
                code: None 
            }),
            storage: {
                4: StorageSlot { 
                    previous_or_original_value: 0, 
                    present_value: 1 
                },
                3: StorageSlot { 
                    previous_or_original_value: 0, 
                    present_value: 1461501637330902918203684832716283019655932542976 
                }
            }, 
            status: Changed 
        }
    },
    contracts: {},
    reverts: Reverts([[(0x2000000000000000000000000000000000000001, AccountRevert { account: DoNothing, storage: {3: Some(0), 4: Some(0)}, previous_status: Loaded, wipe_storage: false })]]), 
    state_size: 3,
    reverts_size: 3
}
dapplion commented 3 months ago

The root mismatch at block production is expected

because block building and block execution are two different things ref: https://github.com/paradigmxyz/reth/blob/9f03f8a269b3f23afd0d3aad4f77fd69c864a68b/crates/ethereum/node/src/node.rs#L216-L216

and

https://github.com/paradigmxyz/reth/blob/9f03f8a269b3f23afd0d3aad4f77fd69c864a68b/crates/ethereum/payload/src/lib.rs#L68-L68

TODO:

H

debjit-bw commented 1 month ago

fixed with https://github.com/gnosischain/reth_gnosis/pull/21