mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
save last MPT root for transition
This commit is contained in:
parent
e237c1ecf7
commit
29c8f98329
2 changed files with 19 additions and 1 deletions
|
|
@ -92,6 +92,8 @@ type Database interface {
|
||||||
SetCurrentPreimageOffset(int64)
|
SetCurrentPreimageOffset(int64)
|
||||||
|
|
||||||
AddRootTranslation(originalRoot, translatedRoot common.Hash)
|
AddRootTranslation(originalRoot, translatedRoot common.Hash)
|
||||||
|
|
||||||
|
SetLastMerkleRoot(root common.Hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trie is a Ethereum Merkle Patricia trie.
|
// Trie is a Ethereum Merkle Patricia trie.
|
||||||
|
|
@ -272,6 +274,7 @@ type cachingDB struct {
|
||||||
origRoots [32]common.Hash
|
origRoots [32]common.Hash
|
||||||
translationIndex int
|
translationIndex int
|
||||||
translatedRootsLock sync.RWMutex
|
translatedRootsLock sync.RWMutex
|
||||||
|
LastMerkleRoot common.Hash // root hash of the read-only base tree
|
||||||
|
|
||||||
addrToPoint *utils.PointCache
|
addrToPoint *utils.PointCache
|
||||||
|
|
||||||
|
|
@ -379,6 +382,10 @@ func (db *cachingDB) OpenStorageTrie(stateRoot common.Hash, address common.Addre
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if db.started {
|
if db.started {
|
||||||
|
mpt, err := db.openStorageMPTrie(db.LastMerkleRoot, address, root, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
// Return a "storage trie" that is an adapter between the storge MPT
|
// Return a "storage trie" that is an adapter between the storge MPT
|
||||||
// and the unique verkle tree.
|
// and the unique verkle tree.
|
||||||
switch self := self.(type) {
|
switch self := self.(type) {
|
||||||
|
|
@ -506,3 +513,7 @@ func (db *cachingDB) GetStorageProcessed() bool {
|
||||||
func (db *cachingDB) AddRootTranslation(originalRoot, translatedRoot common.Hash) {
|
func (db *cachingDB) AddRootTranslation(originalRoot, translatedRoot common.Hash) {
|
||||||
db.AddTranslation(originalRoot, translatedRoot)
|
db.AddTranslation(originalRoot, translatedRoot)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (db *cachingDB) SetLastMerkleRoot(root common.Hash) {
|
||||||
|
db.LastMerkleRoot = root
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1051,7 +1051,14 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash {
|
||||||
if metrics.EnabledExpensive {
|
if metrics.EnabledExpensive {
|
||||||
defer func(start time.Time) { s.AccountHashes += time.Since(start) }(time.Now())
|
defer func(start time.Time) { s.AccountHashes += time.Since(start) }(time.Now())
|
||||||
}
|
}
|
||||||
return s.trie.Hash()
|
root := s.trie.Hash()
|
||||||
|
|
||||||
|
// Save the root of the MPT so that it can be used during the transition
|
||||||
|
if !s.Database().InTransition() && !s.Database().Transitioned() {
|
||||||
|
s.Database().SetLastMerkleRoot(root)
|
||||||
|
}
|
||||||
|
|
||||||
|
return root
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetTxContext sets the current transaction hash and index which are
|
// SetTxContext sets the current transaction hash and index which are
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue