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

only create one triedb in GenerateVerkleChain #300

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/chain_makers.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,10 @@ func GenerateVerkleChain(config *params.ChainConfig, parent *types.Block, engine
}
return nil, nil
}
triedb := state.NewDatabaseWithConfig(db, nil)
triedb.EndVerkleTransition()
var snaps *snapshot.Tree
for i := 0; i < n; i++ {
triedb := state.NewDatabaseWithConfig(db, nil)
triedb.EndVerkleTransition()
Copy link
Owner Author

Choose a reason for hiding this comment

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

removing EndVerkleTransition from the loop is incorrect in case the status of ended is linked to the root - because then the status has to be marked for every subsequent block. Clearly not a good thing.

Note to self: also write the end and start block number, so that we can tell if a block is in an ended state. We need to pass the block number all over the place and that is complicated. A better approach, to investigate in a different PR, might consist in storing the ending status in the statedb proper, so that you can access is from e.g. OpenTrie without having to pass it the block number.

statedb, err := state.New(parent.Root(), triedb, snaps)
if err != nil {
panic(fmt.Sprintf("could not find state for block %d: err=%v, parent root=%x", i, err, parent.Root()))
Expand Down
Loading