core, params: transition tree initialization#33685
core, params: transition tree initialization#33685gballet wants to merge 10 commits intoethereum:masterfrom
Conversation
core/overlay/state_transition.go
Outdated
| ts = &newts | ||
| func LoadTransitionState(db ethdb.KeyValueReader, root common.Hash) *TransitionState { | ||
| stem := bintrie.GetBinaryTreeKeyStorageSlot(params.BinaryTransitionRegistryAddress, conversionProgressAddressKey[:]) | ||
| leaf := rawdb.ReadStorageTrieNode(db, common.Hash{}, stem[:bintrie.StemSize]) |
There was a problem hiding this comment.
There is a chicken-and-egg problem here, when we want to read the conversion progress from the tree, but we need the result to know how the tree must be opened.
Here, I am going to read the data straight from the tree, but this is assuming the state on disk is up to date with all layers, which isn't always the case, so it needs to be aware of the caches, if present.
core/overlay/state_transition.go
Outdated
| } | ||
| ts = &newts | ||
| func LoadTransitionState(db ethdb.KeyValueReader, root common.Hash) *TransitionState { | ||
| stem := bintrie.GetBinaryTreeKeyStorageSlot(params.BinaryTransitionRegistryAddress, conversionProgressAddressKey[:]) |
There was a problem hiding this comment.
When we try to do the state conversion, I would assume the flat states will be available. Actually with the BAL, this assumption is always held that the flat states and associated trie data is all available once the sync is completed, regardless of the type of sync.
We can load the conversion pointers from the contract from the flat state isn't it?
There was a problem hiding this comment.
And also, read trie node directly from the disk is definitely wrong. We must read the progress marker from the associated state reader.
There was a problem hiding this comment.
thought I had responded, yeah I had missed that the "flat reader" is actually reading the tree, and therefore is always present. That changes the outlook of things. I have updated it, I have a build issue that I need to fix but this should be it.
|
getting this in dev mode: |
core/state_processor.go
Outdated
| if config.IsPrague(block.Number(), block.Time()) || config.IsVerkle(block.Number(), block.Time()) { | ||
| ProcessParentBlockHash(block.ParentHash(), evm) | ||
| } | ||
| if config.IsVerkle(header.Number, header.Time) { |
There was a problem hiding this comment.
Can we treat the TransitionRegistry contract like the deposit contract? We can pre-deploy it across all the network with the same address and update it according to the transition status?
It feels wrong to me to manually update it here.
core/state/database.go
Outdated
| ts := overlay.LoadTransitionState(db.TrieDB().Disk(), root, db.triedb.IsVerkle()) | ||
| if ts.InTransition() { | ||
| panic("state tree transition isn't supported yet") | ||
| reader, err := db.StateReader(root) |
There was a problem hiding this comment.
get flat state reader only
…le() checks (#564) - Fix an issue in which the prefetcher was creating a new MPT tree in verkle mode, based on the fact that triedb.IsVerkle() was false. - Also fix the tree bootstrapping in the reader - generally, no longer use db.triedb.IsVerkle() as it's only true if the db is used when starting in verkle mode.
This implements another piece of the binary tree transition: the creation of the transition tree. The conversion itself will be the topic of a further PR, but the tree initialization logic is complex enough to deserve its own review unit.
TODO: