From f669216565a9e03053d10aa2798a652b36e55742 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Mon, 29 Jan 2024 12:55:25 +0100 Subject: [PATCH] core/state: do not journal preimages We do not strictly need to journal preimages: preimages are stored and served for the benefit of remote RPC users, e.g. for debugging solidity storage. There is no 'consensus requirement' for these keys to be reverted in case of reverted scopes. --- core/state/journal.go | 16 ---------------- core/state/statedb.go | 1 - 2 files changed, 17 deletions(-) diff --git a/core/state/journal.go b/core/state/journal.go index 733acef05ab5..c5cdc6288dd8 100644 --- a/core/state/journal.go +++ b/core/state/journal.go @@ -132,10 +132,6 @@ func (j *journal) JournalLog(txHash common.Hash) { j.append(addLogChange{txhash: txHash}) } -func (j *journal) JournalAddPreimage(hash common.Hash) { - j.append(addPreimageChange{hash: hash}) -} - func (j *journal) JournalRefund(prev uint64) { j.append(refundChange{prev: prev}) } @@ -207,7 +203,6 @@ func (j *journal) JournalReset(address common.Address, prevAccountOriginExist bool, prevAccountOrigin []byte, prevStorageOrigin map[common.Hash][]byte) { - j.append(resetObjectChange{ account: &address, prev: prev, @@ -264,9 +259,6 @@ type ( addLogChange struct { txhash common.Hash } - addPreimageChange struct { - hash common.Hash - } touchChange struct { account *common.Address } @@ -399,14 +391,6 @@ func (ch addLogChange) dirtied() *common.Address { return nil } -func (ch addPreimageChange) revert(s *StateDB) { - delete(s.preimages, ch.hash) -} - -func (ch addPreimageChange) dirtied() *common.Address { - return nil -} - func (ch accessListAddAccountChange) revert(s *StateDB) { /* One important invariant here, is that whenever a (addr, slot) is added, if the diff --git a/core/state/statedb.go b/core/state/statedb.go index b299538be039..3bc17938f33c 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -230,7 +230,6 @@ func (s *StateDB) Logs() []*types.Log { // AddPreimage records a SHA3 preimage seen by the VM. func (s *StateDB) AddPreimage(hash common.Hash, preimage []byte) { if _, ok := s.preimages[hash]; !ok { - s.journal.JournalAddPreimage(hash) pi := make([]byte, len(preimage)) copy(pi, preimage) s.preimages[hash] = pi