From 14d5c2b378b0f807178e30ef49ee3bb10be5dc5f Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Wed, 6 Dec 2023 13:57:26 +0100 Subject: [PATCH 01/12] fix: save and load transition state for block processing --- core/block_validator.go | 1 + core/blockchain.go | 3 +++ core/state/database.go | 15 ++++++++++++++- core/state/statedb.go | 13 +++++++++++-- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/core/block_validator.go b/core/block_validator.go index b1ceab9d5c6c..d977c1d63d96 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -131,6 +131,7 @@ func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateD if root := statedb.IntermediateRoot(v.config.IsEIP158(header.Number)); header.Root != root { return fmt.Errorf("invalid merkle root (remote: %x local: %x) dberr: %w", header.Root, root, statedb.Error()) } + statedb.Database().SaveTransitionState(header.Root) return nil } diff --git a/core/blockchain.go b/core/blockchain.go index 39485505bb05..4f68186895b0 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1757,6 +1757,9 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error) parent = bc.GetHeader(block.ParentHash(), block.NumberU64()-1) } + if bc.Config().IsPrague(block.Number(), block.Time()) { + bc.stateCache.LoadTransitionState(parent.Root) + } if parent.Number.Uint64() == conversionBlock { bc.StartVerkleTransition(parent.Root, emptyVerkleRoot, bc.Config(), &parent.Time, parent.Root) bc.stateCache.SetLastMerkleRoot(parent.Root) diff --git a/core/state/database.go b/core/state/database.go index 43e0569c638b..2569f78df2e6 100644 --- a/core/state/database.go +++ b/core/state/database.go @@ -209,10 +209,16 @@ func NewDatabaseWithNodeDB(db ethdb.Database, triedb *trie.Database) Database { } func (db *cachingDB) InTransition() bool { + if db.CurrentTransitionState == nil { + fmt.Println("nil transition state in in!") + } return db.CurrentTransitionState != nil && db.CurrentTransitionState.started && !db.CurrentTransitionState.ended } func (db *cachingDB) Transitioned() bool { + if db.CurrentTransitionState == nil { + fmt.Println("nil transition state in ed!") + } return db.CurrentTransitionState != nil && db.CurrentTransitionState.ended } @@ -244,6 +250,7 @@ func (db *cachingDB) ReorgThroughVerkleTransition() { } func (db *cachingDB) InitTransitionStatus(started, ended bool) { + fmt.Println("init-ing status", started, ended) db.CurrentTransitionState = &TransitionState{ ended: ended, started: started, @@ -342,10 +349,12 @@ func (db *cachingDB) OpenTrie(root common.Hash) (Trie, error) { // TODO separate both cases when I can be certain that it won't // find a Verkle trie where is expects a Transitoion trie. - if db.CurrentTransitionState != nil && (db.CurrentTransitionState.started || db.CurrentTransitionState.ended) { + if db.InTransition() || db.Transitioned() { + fmt.Printf("opening tree: root=%x\n", root) // NOTE this is a kaustinen-only change, it will break replay vkt, err := db.openVKTrie(root) if err != nil { + fmt.Println("and vkt failed") return nil, err } @@ -359,6 +368,7 @@ func (db *cachingDB) OpenTrie(root common.Hash) (Trie, error) { // trie and an overlay, verkle trie. mpt, err = db.openMPTTrie(db.baseRoot) if err != nil { + fmt.Println("and mpt failed") return nil, err } @@ -543,15 +553,18 @@ func (db *cachingDB) SaveTransitionState(root common.Hash) { } db.TransitionStatePerRoot[root] = db.CurrentTransitionState + fmt.Printf("saved transition state %x\n", root) } func (db *cachingDB) LoadTransitionState(root common.Hash) { + fmt.Printf("loading transition state %x %d\n", root, len(db.TransitionStatePerRoot)) if db.TransitionStatePerRoot == nil { db.TransitionStatePerRoot = make(map[common.Hash]*TransitionState) } ts, ok := db.TransitionStatePerRoot[root] if !ok || ts == nil { + fmt.Println("starting with a fresh state") // Start with a fresh state ts = &TransitionState{ended: db.triedb.IsVerkle()} } diff --git a/core/state/statedb.go b/core/state/statedb.go index 49fa246593ae..c5640bd63de1 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -21,6 +21,7 @@ import ( "errors" "fmt" "math/big" + "runtime/debug" "sort" "time" @@ -1040,8 +1041,16 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.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) + // if !s.Database().InTransition() && !s.Database().Transitioned() { + // s.Database().SetLastMerkleRoot(root) + // fmt.Printf("computed root=%x\n", root) + // } + _, ismpt := s.trie.(*trie.StateTrie) + _, isvkt := s.trie.(*trie.VerkleTrie) + _, istrn := s.trie.(*trie.TransitionTrie) + fmt.Println("is MPT?", ismpt, isvkt, istrn) + if ismpt { + debug.PrintStack() } return root From 4c3349c7ceffdc72ffeff653ad4a43a5f951a285 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:25:07 +0100 Subject: [PATCH 02/12] log whether the tree is verkle in LoadTransitionState --- core/state/database.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/state/database.go b/core/state/database.go index 2569f78df2e6..7fe32782eff2 100644 --- a/core/state/database.go +++ b/core/state/database.go @@ -564,7 +564,7 @@ func (db *cachingDB) LoadTransitionState(root common.Hash) { ts, ok := db.TransitionStatePerRoot[root] if !ok || ts == nil { - fmt.Println("starting with a fresh state") + fmt.Println("starting with a fresh state", db.triedb.IsVerkle()) // Start with a fresh state ts = &TransitionState{ended: db.triedb.IsVerkle()} } From 5efe06e14e950957e030417dd08801a9e2f3dbd5 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Thu, 7 Dec 2023 16:23:59 +0100 Subject: [PATCH 03/12] fix: ensure the transition is marked as started in insertChain --- core/blockchain.go | 7 +++++++ core/state/database.go | 2 ++ 2 files changed, 9 insertions(+) diff --git a/core/blockchain.go b/core/blockchain.go index 4f68186895b0..09c730ed397e 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1757,8 +1757,15 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error) parent = bc.GetHeader(block.ParentHash(), block.NumberU64()-1) } + fmt.Println("in insertChain is prague?", bc.Config().IsPrague(block.Number(), block.Time())) if bc.Config().IsPrague(block.Number(), block.Time()) { bc.stateCache.LoadTransitionState(parent.Root) + + // pragueTime has been reached. If the transition isn't active, it means this + // is the fork block and that the conversion needs to be marked at started. + if !bc.stateCache.InTransition() && !bc.stateCache.Transitioned() { + bc.stateCache.StartVerkleTransition(parent.Root, emptyVerkleRoot, bc.Config(), bc.Config().PragueTime, parent.Root) + } } if parent.Number.Uint64() == conversionBlock { bc.StartVerkleTransition(parent.Root, emptyVerkleRoot, bc.Config(), &parent.Time, parent.Root) diff --git a/core/state/database.go b/core/state/database.go index 7fe32782eff2..a457f39eaef4 100644 --- a/core/state/database.go +++ b/core/state/database.go @@ -19,6 +19,7 @@ package state import ( "errors" "fmt" + "runtime/debug" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/lru" @@ -564,6 +565,7 @@ func (db *cachingDB) LoadTransitionState(root common.Hash) { ts, ok := db.TransitionStatePerRoot[root] if !ok || ts == nil { + debug.PrintStack() fmt.Println("starting with a fresh state", db.triedb.IsVerkle()) // Start with a fresh state ts = &TransitionState{ended: db.triedb.IsVerkle()} From 87eaa4b7ba001229e71ca0cce1d5c753b5d934c0 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Thu, 7 Dec 2023 17:59:31 +0100 Subject: [PATCH 04/12] dump saved address --- core/state/database.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/state/database.go b/core/state/database.go index a457f39eaef4..eb334e441d5e 100644 --- a/core/state/database.go +++ b/core/state/database.go @@ -554,7 +554,7 @@ func (db *cachingDB) SaveTransitionState(root common.Hash) { } db.TransitionStatePerRoot[root] = db.CurrentTransitionState - fmt.Printf("saved transition state %x\n", root) + fmt.Printf("saved transition state root=%x address=%x\n", root, *db.CurrentTransitionState.CurrentAccountAddress) } func (db *cachingDB) LoadTransitionState(root common.Hash) { @@ -574,6 +574,6 @@ func (db *cachingDB) LoadTransitionState(root common.Hash) { db.CurrentTransitionState = ts.Copy() if db.CurrentTransitionState != nil { - fmt.Println("address", db.CurrentTransitionState.CurrentAccountAddress) + fmt.Println("address", db.CurrentTransitionState.CurrentAccountAddress, crypto.Keccak256Hash(db.CurrentTransitionState.CurrentAccountAddress[:])) } } From a90f682160029d76238de0dc6b75ebd45b11a83d Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Thu, 7 Dec 2023 20:14:04 +0100 Subject: [PATCH 05/12] fix nil pointer panic --- core/state/database.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/state/database.go b/core/state/database.go index eb334e441d5e..d8bc3a317bfb 100644 --- a/core/state/database.go +++ b/core/state/database.go @@ -554,7 +554,10 @@ func (db *cachingDB) SaveTransitionState(root common.Hash) { } db.TransitionStatePerRoot[root] = db.CurrentTransitionState - fmt.Printf("saved transition state root=%x address=%x\n", root, *db.CurrentTransitionState.CurrentAccountAddress) + fmt.Printf("saved transition state root=%x\n", root) + if db.CurrentTransitionState != nil && db.CurrentTransitionState.CurrentAccountAddress != nil { + fmt.Printf("\taddress=%x\n", *db.CurrentTransitionState.CurrentAccountAddress) + } } func (db *cachingDB) LoadTransitionState(root common.Hash) { From 09a088f902c5052948bc6ffe11622e36c29b77a6 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Thu, 7 Dec 2023 20:38:14 +0100 Subject: [PATCH 06/12] remove stacktrace that is no longer useful --- core/state/statedb.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/core/state/statedb.go b/core/state/statedb.go index c5640bd63de1..bdff9451a872 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -1045,13 +1045,6 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash { // s.Database().SetLastMerkleRoot(root) // fmt.Printf("computed root=%x\n", root) // } - _, ismpt := s.trie.(*trie.StateTrie) - _, isvkt := s.trie.(*trie.VerkleTrie) - _, istrn := s.trie.(*trie.TransitionTrie) - fmt.Println("is MPT?", ismpt, isvkt, istrn) - if ismpt { - debug.PrintStack() - } return root } From 9b991f21279af0ac43f582e9e52c04bf468e5c1d Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Thu, 7 Dec 2023 20:41:20 +0100 Subject: [PATCH 07/12] fix a panic --- core/state/database.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/state/database.go b/core/state/database.go index d8bc3a317bfb..e6ea3c75b35c 100644 --- a/core/state/database.go +++ b/core/state/database.go @@ -577,6 +577,10 @@ func (db *cachingDB) LoadTransitionState(root common.Hash) { db.CurrentTransitionState = ts.Copy() if db.CurrentTransitionState != nil { - fmt.Println("address", db.CurrentTransitionState.CurrentAccountAddress, crypto.Keccak256Hash(db.CurrentTransitionState.CurrentAccountAddress[:])) + if db.CurrentTransitionState.CurrentAccountAddress != nil { + fmt.Println("address", db.CurrentTransitionState.CurrentAccountAddress, crypto.Keccak256Hash(db.CurrentTransitionState.CurrentAccountAddress[:])) + } else { + fmt.Println("address", db.CurrentTransitionState.CurrentAccountAddress, "nil") + } } } From f17c76d7f36cc4e8f2f2fff22f0fbb79ba35af89 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Thu, 7 Dec 2023 20:45:03 +0100 Subject: [PATCH 08/12] fix build --- core/state/statedb.go | 1 - 1 file changed, 1 deletion(-) diff --git a/core/state/statedb.go b/core/state/statedb.go index bdff9451a872..088d77be2b6f 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -21,7 +21,6 @@ import ( "errors" "fmt" "math/big" - "runtime/debug" "sort" "time" From 34495e8b7e0cbb78154bac7e2abe082ef8777442 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Fri, 8 Dec 2023 13:27:20 +0100 Subject: [PATCH 09/12] check: copy current account address BEFORE it's saved --- consensus/beacon/consensus.go | 1 + core/state/database.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/consensus/beacon/consensus.go b/consensus/beacon/consensus.go index 7f22d6369a60..110455b91d1a 100644 --- a/consensus/beacon/consensus.go +++ b/consensus/beacon/consensus.go @@ -373,6 +373,7 @@ func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types. if chain.Config().IsPrague(header.Number, header.Time) { fmt.Println("at block", header.Number, "performing transition?", state.Database().InTransition()) parent := chain.GetHeaderByHash(header.ParentHash) + fmt.Println("(in Finalize) parent root=", parent.Root) overlay.OverlayVerkleTransition(state, parent.Root, chain.Config().OverlayStride) } } diff --git a/core/state/database.go b/core/state/database.go index e6ea3c75b35c..745de15fec4a 100644 --- a/core/state/database.go +++ b/core/state/database.go @@ -553,7 +553,7 @@ func (db *cachingDB) SaveTransitionState(root common.Hash) { db.TransitionStatePerRoot = make(map[common.Hash]*TransitionState) } - db.TransitionStatePerRoot[root] = db.CurrentTransitionState + db.TransitionStatePerRoot[root] = db.CurrentTransitionState.Copy() fmt.Printf("saved transition state root=%x\n", root) if db.CurrentTransitionState != nil && db.CurrentTransitionState.CurrentAccountAddress != nil { fmt.Printf("\taddress=%x\n", *db.CurrentTransitionState.CurrentAccountAddress) From d17f36ea87af69485659cfa64235a030db91730a Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Fri, 8 Dec 2023 13:56:23 +0100 Subject: [PATCH 10/12] mandatory panic fix --- core/state/database.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/state/database.go b/core/state/database.go index 745de15fec4a..2151c56057ec 100644 --- a/core/state/database.go +++ b/core/state/database.go @@ -553,10 +553,12 @@ func (db *cachingDB) SaveTransitionState(root common.Hash) { db.TransitionStatePerRoot = make(map[common.Hash]*TransitionState) } - db.TransitionStatePerRoot[root] = db.CurrentTransitionState.Copy() fmt.Printf("saved transition state root=%x\n", root) - if db.CurrentTransitionState != nil && db.CurrentTransitionState.CurrentAccountAddress != nil { - fmt.Printf("\taddress=%x\n", *db.CurrentTransitionState.CurrentAccountAddress) + if db.CurrentTransitionState != nil { + db.TransitionStatePerRoot[root] = db.CurrentTransitionState.Copy() + if db.CurrentTransitionState.CurrentAccountAddress != nil { + fmt.Printf("\taddress=%x\n", *db.CurrentTransitionState.CurrentAccountAddress) + } } } From dd62471ea19091f4fde41acc75091aa7b6240c5d Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Fri, 8 Dec 2023 14:47:56 +0100 Subject: [PATCH 11/12] Remove debug fmt.Println --- consensus/beacon/consensus.go | 1 - core/blockchain.go | 1 - core/state/database.go | 23 ----------------------- core/state/statedb.go | 7 +++---- 4 files changed, 3 insertions(+), 29 deletions(-) diff --git a/consensus/beacon/consensus.go b/consensus/beacon/consensus.go index 110455b91d1a..7f22d6369a60 100644 --- a/consensus/beacon/consensus.go +++ b/consensus/beacon/consensus.go @@ -373,7 +373,6 @@ func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types. if chain.Config().IsPrague(header.Number, header.Time) { fmt.Println("at block", header.Number, "performing transition?", state.Database().InTransition()) parent := chain.GetHeaderByHash(header.ParentHash) - fmt.Println("(in Finalize) parent root=", parent.Root) overlay.OverlayVerkleTransition(state, parent.Root, chain.Config().OverlayStride) } } diff --git a/core/blockchain.go b/core/blockchain.go index 09c730ed397e..ec12f57fc1ee 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1757,7 +1757,6 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error) parent = bc.GetHeader(block.ParentHash(), block.NumberU64()-1) } - fmt.Println("in insertChain is prague?", bc.Config().IsPrague(block.Number(), block.Time())) if bc.Config().IsPrague(block.Number(), block.Time()) { bc.stateCache.LoadTransitionState(parent.Root) diff --git a/core/state/database.go b/core/state/database.go index 2151c56057ec..07891824a4fe 100644 --- a/core/state/database.go +++ b/core/state/database.go @@ -19,7 +19,6 @@ package state import ( "errors" "fmt" - "runtime/debug" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/lru" @@ -210,16 +209,10 @@ func NewDatabaseWithNodeDB(db ethdb.Database, triedb *trie.Database) Database { } func (db *cachingDB) InTransition() bool { - if db.CurrentTransitionState == nil { - fmt.Println("nil transition state in in!") - } return db.CurrentTransitionState != nil && db.CurrentTransitionState.started && !db.CurrentTransitionState.ended } func (db *cachingDB) Transitioned() bool { - if db.CurrentTransitionState == nil { - fmt.Println("nil transition state in ed!") - } return db.CurrentTransitionState != nil && db.CurrentTransitionState.ended } @@ -251,7 +244,6 @@ func (db *cachingDB) ReorgThroughVerkleTransition() { } func (db *cachingDB) InitTransitionStatus(started, ended bool) { - fmt.Println("init-ing status", started, ended) db.CurrentTransitionState = &TransitionState{ ended: ended, started: started, @@ -351,11 +343,9 @@ func (db *cachingDB) OpenTrie(root common.Hash) (Trie, error) { // TODO separate both cases when I can be certain that it won't // find a Verkle trie where is expects a Transitoion trie. if db.InTransition() || db.Transitioned() { - fmt.Printf("opening tree: root=%x\n", root) // NOTE this is a kaustinen-only change, it will break replay vkt, err := db.openVKTrie(root) if err != nil { - fmt.Println("and vkt failed") return nil, err } @@ -369,7 +359,6 @@ func (db *cachingDB) OpenTrie(root common.Hash) (Trie, error) { // trie and an overlay, verkle trie. mpt, err = db.openMPTTrie(db.baseRoot) if err != nil { - fmt.Println("and mpt failed") return nil, err } @@ -553,25 +542,18 @@ func (db *cachingDB) SaveTransitionState(root common.Hash) { db.TransitionStatePerRoot = make(map[common.Hash]*TransitionState) } - fmt.Printf("saved transition state root=%x\n", root) if db.CurrentTransitionState != nil { db.TransitionStatePerRoot[root] = db.CurrentTransitionState.Copy() - if db.CurrentTransitionState.CurrentAccountAddress != nil { - fmt.Printf("\taddress=%x\n", *db.CurrentTransitionState.CurrentAccountAddress) - } } } func (db *cachingDB) LoadTransitionState(root common.Hash) { - fmt.Printf("loading transition state %x %d\n", root, len(db.TransitionStatePerRoot)) if db.TransitionStatePerRoot == nil { db.TransitionStatePerRoot = make(map[common.Hash]*TransitionState) } ts, ok := db.TransitionStatePerRoot[root] if !ok || ts == nil { - debug.PrintStack() - fmt.Println("starting with a fresh state", db.triedb.IsVerkle()) // Start with a fresh state ts = &TransitionState{ended: db.triedb.IsVerkle()} } @@ -579,10 +561,5 @@ func (db *cachingDB) LoadTransitionState(root common.Hash) { db.CurrentTransitionState = ts.Copy() if db.CurrentTransitionState != nil { - if db.CurrentTransitionState.CurrentAccountAddress != nil { - fmt.Println("address", db.CurrentTransitionState.CurrentAccountAddress, crypto.Keccak256Hash(db.CurrentTransitionState.CurrentAccountAddress[:])) - } else { - fmt.Println("address", db.CurrentTransitionState.CurrentAccountAddress, "nil") - } } } diff --git a/core/state/statedb.go b/core/state/statedb.go index 088d77be2b6f..49fa246593ae 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -1040,10 +1040,9 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.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) - // fmt.Printf("computed root=%x\n", root) - // } + if !s.Database().InTransition() && !s.Database().Transitioned() { + s.Database().SetLastMerkleRoot(root) + } return root } From 60d86f5480b3c970857cb392908af34718b05858 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Fri, 8 Dec 2023 14:59:01 +0100 Subject: [PATCH 12/12] more cleanup + comments --- core/state/database.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/state/database.go b/core/state/database.go index 07891824a4fe..21280359794e 100644 --- a/core/state/database.go +++ b/core/state/database.go @@ -543,6 +543,8 @@ func (db *cachingDB) SaveTransitionState(root common.Hash) { } if db.CurrentTransitionState != nil { + // Copy so that the address pointer isn't updated after + // it has been saved. db.TransitionStatePerRoot[root] = db.CurrentTransitionState.Copy() } } @@ -558,8 +560,7 @@ func (db *cachingDB) LoadTransitionState(root common.Hash) { ts = &TransitionState{ended: db.triedb.IsVerkle()} } + // Copy so that the CurrentAddress pointer in the map + // doesn't get overwritten. db.CurrentTransitionState = ts.Copy() - - if db.CurrentTransitionState != nil { - } }