From 9373700e0c844f702aa9cd686b282b76f64ef9a2 Mon Sep 17 00:00:00 2001 From: jwasinger Date: Fri, 8 Mar 2024 06:25:25 -0800 Subject: [PATCH] Update core/state/statedb.go Co-authored-by: Martin HS --- core/state/statedb.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/state/statedb.go b/core/state/statedb.go index 7e326d803d..24236ad590 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -898,10 +898,13 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash { // Perform updates before deletions. This prevents resolution of unnecessary trie nodes // in circumstances similar to the following: // - // Take value nodes 1, 2 who share the same full node parent 3 and have no other siblings. - // 1 self-destructs specifying a non-existing recipient account which would be a child of 3. - // If the deletion of 1 happens before the account-creating balance transfer, 3 will temporarily - // be collapsed to a short node on 2, requiring 2 to be unecessarily resolved. + // Consider nodes `A` and `B` who share the same full node parent `P` and have no other siblings. + // During the execution of a block: + // - `A` self-destructs, + // - `C` is created, and also shares the parent `P`. + // If the self-destruct is handled first, then `P` would be left with only one child, thus collapsed + // into a shortnode. This requires `B` to be resolved from disk. + // Whereas if the created node is handled first, then the collapse is avoided, and `B` is not resolved. var deletedObjects []*stateObject for addr := range s.stateObjectsPending { if obj := s.stateObjects[addr]; !obj.deleted {