Skip to content

Commit

Permalink
core/state: do not journal preimages
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
holiman committed Jan 29, 2024
1 parent 0379c92 commit f669216
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 17 deletions.
16 changes: 0 additions & 16 deletions core/state/journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -264,9 +259,6 @@ type (
addLogChange struct {
txhash common.Hash
}
addPreimageChange struct {
hash common.Hash
}
touchChange struct {
account *common.Address
}
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f669216

Please sign in to comment.