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

Fail early on StateDB functions #410

Open
fedekunze opened this issue Aug 6, 2021 · 3 comments
Open

Fail early on StateDB functions #410

fedekunze opened this issue Aug 6, 2021 · 3 comments

Comments

@fedekunze
Copy link
Contributor

@fedekunze fedekunze commented Aug 6, 2021

Most of the functions from statedb.go perform a no-operation (no-op) when an error is encountered. The problem is, that these functions don't have any context of whether previous calls failed or not. For example, both GetCodeHash and GetNonce require the account to exist before returning the value.

Solution:

Introduce a stateErr error field on the Keeper and return early on every StateDB method if there is a previous error registered.

@yihuang
Copy link
Collaborator

@yihuang yihuang commented Aug 12, 2021

Just panic should be good? since the cosmos-sdk call will recover the panic.

@fedekunze
Copy link
Contributor Author

@fedekunze fedekunze commented Aug 12, 2021

no, it shouldn't panic, just fail early

@yihuang
Copy link
Collaborator

@yihuang yihuang commented Aug 16, 2021

https://github.com/ethereum/go-ethereum/blob/master/core/state/statedb.go#L299
In go-ethereum, the query apis just returns a empty value when things not found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants