Skip to content

EVM Bytecode Execution / StateManager: How to keep progress? #2338

Discussion options

You must be logged in to vote

Hi, the key idea of this all is that to save the current state of the chain (so all accounts and contracts) is in a thing called the stateRoot. You can think of this (high-level) as a cryptographic hash of the entire chain. To checkpoint or rollback, simply save the stateRoot (to get this, use stateRoot = await vm.stateManager.getRoot()) and if you want to rollback, await vm.stateManager.setRoot(stateRoot). If you wish to persist these changes on disk, you need to instantiate a StateManager with a LevelDB which saves to disk, and pass this along the VM constructor.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@VladChernenko
Comment options

@holgerd77
Comment options

Answer selected by VladChernenko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #2334 on October 07, 2022 15:37.