From e146ded5b281d5ff55d66197c75e121c0f85211c Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Mon, 23 Sep 2024 10:31:04 +0800 Subject: [PATCH] core/state: commit snapshot only if the base layer exists --- core/state/statedb.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/state/statedb.go b/core/state/statedb.go index 1a12f519a4..b2b4f8fb97 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -1265,7 +1265,7 @@ func (s *StateDB) commitAndFlush(block uint64, deleteEmptyObjects bool) (*stateU } if !ret.empty() { // If snapshotting is enabled, update the snapshot tree with this new version - if snap := s.db.Snapshot(); snap != nil { + if snap := s.db.Snapshot(); snap != nil && snap.Snapshot(ret.originRoot) != nil { start := time.Now() if err := snap.Update(ret.root, ret.originRoot, ret.destructs, ret.accounts, ret.storages); err != nil { log.Warn("Failed to update snapshot tree", "from", ret.originRoot, "to", ret.root, "err", err)