Skip to content
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

core: stateDb has no trie and no snap return err #2369

Merged
merged 1 commit into from
Apr 7, 2024

Conversation

weiihann
Copy link
Contributor

@weiihann weiihann commented Apr 3, 2024

Description

This PR adds a check to Blockchain.StateAt() such that if the node is a fast node (i.e. NoTrie = true) and the snap layer cannot be found, then it will return an error.

Rationale

Refer to #2331.

By default, a fast node will have an empty trie for any state. Retrieving a value from an empty trie will give 0x00...00. It may be confusing for users as 0x00...00 could also be the actual value. Hence, it's more useful to throw an error when the state is not available.

Example

Command

curl -H 'Content-Type: application/json'  -X POST --data '{"jsonrpc":"2.0", "method": "eth_getStorageAt", "params": ["0x00020F14443e103A0B72F1f2DFDaac07DDAa6Df5", "0x0", "0x237f199"], "id": 1}' http://127.0.0.1:8545

Output

{"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"state is not available"}}

Changes

  • Add StateDB.GetSnap()

Copy link
Contributor

@flywukong flywukong left a comment

Choose a reason for hiding this comment

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

LGTM

@zzzckck zzzckck merged commit 48f58a5 into bnb-chain:develop Apr 7, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants