Skip to content

Commit

Permalink
Merge pull request #271 from OffchainLabs/dont-dirty-reset-object
Browse files Browse the repository at this point in the history
Revert "core/state: mark account as dirty when resetObject occurs"
  • Loading branch information
joshuacolvin0 authored Nov 21, 2023
2 parents 65bc346 + f5328d1 commit f4eec6e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions core/state/journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ type (
account *common.Address
}
resetObjectChange struct {
account *common.Address
prev *stateObject
prevdestruct bool
prevAccount []byte
Expand Down Expand Up @@ -181,7 +180,13 @@ func (ch resetObjectChange) revert(s *StateDB) {
}

func (ch resetObjectChange) dirtied() *common.Address {
return ch.account
// Arbitrum: We keep the behavior that existed before go-ethereum v1.12.1 and return nil,
// instead of returning the reset address as upstream go-ethereum v1.12.1 does.
// That's because, unlike for go-ethereum, whether this account is dirty or not is relevant for Arbitrum.
// Arbitrum hooks manipulate the state in some ways that go-ethereum doesn't which cause that relevance,
// e.g. subtracting balance from an account that hasn't been otherwise touched.
// See https://github.com/OffchainLabs/nitro/pull/1976 for details
return nil
}

func (ch selfDestructChange) revert(s *StateDB) {
Expand Down
1 change: 0 additions & 1 deletion core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,6 @@ func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject)
// cache the latest account/storage data.
prevAccount, ok := s.accountsOrigin[prev.address]
s.journal.append(resetObjectChange{
account: &addr,
prev: prev,
prevdestruct: prevdestruct,
prevAccount: s.accounts[prev.addrHash],
Expand Down
2 changes: 2 additions & 0 deletions core/state/statedb_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ func (test *stateTest) verify(root common.Hash, next common.Hash, db *trie.Datab
}

func TestStateChanges(t *testing.T) {
t.Skip("Arbitrum doesn't support some of these operations due to https://github.com/OffchainLabs/go-ethereum/pull/271")

config := &quick.Config{MaxCount: 1000}
err := quick.Check((*stateTest).run, config)
if cerr, ok := err.(*quick.CheckError); ok {
Expand Down

0 comments on commit f4eec6e

Please sign in to comment.