-
Notifications
You must be signed in to change notification settings - Fork 20.3k
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
core, eth, les, tests, trie: abstract node scheme #25532
Conversation
443ca34
to
4b831b6
Compare
@@ -377,11 +379,11 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par | |||
var recover bool | |||
|
|||
head := bc.CurrentBlock() | |||
if layer := rawdb.ReadSnapshotRecoveryNumber(bc.db); layer != nil && *layer > head.NumberU64() { | |||
if layer := rawdb.ReadSnapshotRecoveryNumber(bc.db); layer != nil && *layer >= head.NumberU64() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a mistake before. If we rewind the chain state to disk layer, then in this case recovery mode should be enabled.
|
||
sz := hexToCompactInPlace(st.key) | ||
n := rawShortNode{Key: st.key[:sz]} | ||
n := rawShortNode{Key: hexToCompact(st.key)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hexToCompactInPlace
is replaced by hexToCompact
for not changing the st.key
. Otherwise the path prefix of children will be affected since they are sharing the same byte slice.
6eb4c1e
to
32791cc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks mostly ok, but it's a kind of complex PR -- the introductin of different node schemes takes some getting used to. I think we should have a review call about this one.
@holiman for sure, we can have a call for it! |
56f9252
to
7065f7e
Compare
7cb0c4e
to
899d4bd
Compare
e952201
to
61f6832
Compare
61f6832
to
b7351bc
Compare
Rebased against the latest master |
for _, name := range []string{"chaindata", "lightchaindata"} { | ||
chaindb, err := stack.OpenDatabaseWithFreezer(name, 0, 0, ctx.String(utils.AncientFlag.Name), "", false) | ||
if err != nil { | ||
utils.Fatalf("Failed to open database: %v", err) | ||
} | ||
_, hash, err := core.SetupGenesisBlock(chaindb, genesis) | ||
triedb := trie.NewDatabaseWithConfig(chaindb, &trie.Config{ | ||
Preimages: ctx.Bool(utils.CachePreimagesFlag.Name), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we enable preimage-recording by default? Or just based on the flags passed by users.
620ef60
to
5d88940
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, I think I've reviewed as far as I can. I think we need to run it a bit, e..g do syncs and generate snapshot.
Perhaps snapshot verify-state
too?
@holiman Yes.
|
b76217e
to
1990893
Compare
Co-authored-by: Martin Holst Swende <[email protected]>
1990893
to
539f809
Compare
This PR introduces a node scheme abstraction. The interface is only implemented by `hashScheme` at the moment, but will be extended by `pathScheme` very soon. Apart from that, a few changes are also included which is worth mentioning: - port the changes in the stacktrie, tracking the path prefix of nodes during commit - use ethdb.Database for constructing trie.Database. This is not necessary right now, but it is required for path-based used to open reverse diff freezer
This PR mainly introduces a node scheme abstraction. The interface is only implemented by
hashScheme
now and will also be implemented bypathScheme
very soon.Apart from that, a few changes are also included and highlight them here:
ethdb.Database
for constructingtrie.Database
, it's not necessary right now, but it's required for path-based used to open reverse diff freezer