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

fix debug_storageRangeAt #3148

Merged
merged 2 commits into from
Dec 29, 2021
Merged

Conversation

bgelb
Copy link
Contributor

@bgelb bgelb commented Dec 19, 2021

No description provided.

if idx+1 == len(block.Transactions()) {
// Return the state from evaluating all txs in the block, note no msg or TxContext in this case
return nil, BlockContext, vm.TxContext{}, statedb, reader, nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry I did not quite understand this comment.

Copy link
Collaborator

Choose a reason for hiding this comment

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

nevermind

@AlexeyAkhunov
Copy link
Contributor

Thank you for this PR! Does it solve your issue?

@bgelb
Copy link
Contributor Author

bgelb commented Dec 20, 2021

Thank you for this PR! Does it solve your issue?

Yes. We are using in our application now and seems to do what we need.

@bgelb bgelb marked this pull request as ready for review December 22, 2021 20:10
@AskAlexSharov
Copy link
Collaborator

a bit weird that our PlainState class, does remember storage changes, but loosing all other changes...
IntraBlocksState must remember all changes (including storage), for me it's unclear why replacing NoopWriter by PlainState fixed something (smells like "fixed by accident because of even amount of bugs").

@bgelb
Copy link
Contributor Author

bgelb commented Dec 28, 2021

a bit weird that our PlainState class, does remember storage changes, but loosing all other changes... IntraBlocksState must remember all changes (including storage), for me it's unclear why replacing NoopWriter by PlainState fixed something (smells like "fixed by accident because of even amount of bugs").

The reason is that the storage within PlainState is what is used to generate the result of the storageRangeAt call, see:
https://github.com/ledgerwatch/erigon/blob/c913f35c2e42e9cc1a1c31d681f834531cc095bb/cmd/rpcdaemon/commands/storage_range.go#L30

If that storage is not updated, then it reflects the storage as of the beginning of the block, no matter what transaction index is specified, because the storage updates are never committed into the PlainState object ("stateReader").

@AskAlexSharov
Copy link
Collaborator

now I see. then it make more sense.
Please merge devel to your branch and we can merge this PR.

add special case to permit getting state for execution of entire block (i.e. after all txs)
@bgelb bgelb force-pushed the fix-storage-range branch from 67a290b to 63786c6 Compare December 28, 2021 04:46
@bgelb
Copy link
Contributor Author

bgelb commented Dec 28, 2021

now I see. then it make more sense. Please merge devel to your branch and we can merge this PR.

I have merged latest devel.

@AskAlexSharov AskAlexSharov merged commit 2d9fe6c into erigontech:devel Dec 29, 2021
@bgelb
Copy link
Contributor Author

bgelb commented Jan 16, 2022

now I see. then it make more sense. Please merge devel to your branch and we can merge this PR.

I have merged latest devel.

It seems that somehow the change to link

now I see. then it make more sense. Please merge devel to your branch and we can merge this PR.

It appears that the change from NoopWriter -> PlainState (on line 68) did not get merged properly. This is a critical element of the fix. What is the right way to proceed to fix this issue?

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.

3 participants