-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Accessing the state at height == 0 fails and throws errors #14446
Comments
So am I correct in understanding that Tendermint is calling Versions in the SDK and by proxy Tendermint, start at height 1 (where Genesis is considered 0 but not explicitly saved under 0). Do you see |
We need to handle 0 height in the store, it seems this has come up else where as well |
We could return an empty tree on height 0 and an error whenever height != 0 (and if it doesn't exists; although I don't think there's a case in which a tree will be available when height == 0). |
So we are not passing the block height to prepareProposal https://github.com/cosmos/cosmos-sdk/blob/main/baseapp/abci.go#L250 This might solve the issue of PrepareProposal crashing/rejecting when there's state access. EDIT: I still need to figure out how to test this. Although @thtl33 if you want to test it in the meantime, you can add that and test if you can produce blocks. This is not related to RPC queries failing tho, that sounds like a separate issue |
RE: @alexanderbez
Yes, printing out
Yes, I see |
RE: @facundomedica
I think you can do |
One way to test this is to:
|
Summary of Bug
One issue that we are noticing when upgrading to
v0.47.0
is that accessing IAVL tree store at height 0 returns an error. The bad side effects for this is that RPC calls at height 0 will start resulting in errors.Similarly in
PrepareProposalHandler
, when accessing the state via the context throws a runtime error and halts the chain.IIUC, the state is not ready at height 0. Or perhaps, height 0 is reserved for the app to get initialized.
Previously, this did not cause an error because the default behavior for accessing the state at height == 0 was to return an empty state. But this changed as of this PR
It seems like there are paths that trigger the app to access the state at height 0 and this access should not happen. If so, should there be a better handling of such paths? For example, adding "if height == 0, this access should be rejected, rather than throwing an error".
Shoutout to Lucas for debugging this. He discovered:
Version
v0.47.0-alpha2
Steps to Reproduce
For the RPC path, steps to reproduce:
For the
PrepareProposal
path,PrepareProposalHandler
call a method that accesses state via ctxNote that this might not crash the node after adding panic recovery
The text was updated successfully, but these errors were encountered: