Conversation
Now we check reth db account trie table for correct state root of the parent instead of checking latest block.
|
Claude finished @dvush's task in 1m 14s —— View job Code Review:
|
| pub fn check_state_root_in_db( | ||
| provider: &impl DBProvider, | ||
| expected_state_root: B256, | ||
| ) -> Result<(), SparseTrieError> { | ||
| let db_state_root = StateRoot::from_tx(provider.tx_ref()) | ||
| .root() | ||
| .map_err(SparseTrieError::other)?; | ||
| if db_state_root == expected_state_root { | ||
| Ok(()) | ||
| } else { | ||
| Err(SparseTrieError::WrongDatabaseTrieError) | ||
| } | ||
| } |
There was a problem hiding this comment.
Performance concern: StateRoot::from_tx(provider.tx_ref()).root() recomputes the state root by walking the trie cursors. This is significantly more expensive than the previous check which was a simple block hash lookup.
This function is called once per storage proof target (in a parallel iterator at line 84) plus once for account proofs (line 119). For blocks with many touched accounts, this could add substantial overhead.
Is this intentional? If the goal is just to verify the DB hasn't been updated underneath, could you read the root node directly from the account trie table instead of recomputing it?
There was a problem hiding this comment.
Is this intentional?
Yes it is, is once per database transaction.
Now we check reth db account trie table for correct state root of the parent instead of checking latest block.
📝 Summary
💡 Motivation and Context
✅ I have completed the following steps:
make lintmake test