Skip to content

Commit e60f42e

Browse files
committed
core/state: make createcontract not emit dirtied account, unskip tests
1 parent 27cc483 commit e60f42e

File tree

4 files changed

+9
-23
lines changed

4 files changed

+9
-23
lines changed

core/state/journal.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ type (
106106
account *common.Address
107107
}
108108

109+
// createContractChange represents an account becoming a contract-account.
110+
// This event happens prior to executing initcode. The journal-event simply
111+
// manages the created-flag, in order to allow same-tx destruction.
109112
createContractChange struct {
110113
account common.Address
111114
}
@@ -169,7 +172,7 @@ func (ch createObjectChange) revert(s *StateDB) {
169172
}
170173

171174
func (ch createObjectChange) dirtied() *common.Address {
172-
return ch.account
175+
return nil
173176
}
174177

175178
func (ch createObjectChange) copy() journalEntry {

core/state/state_object.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ func (s *stateObject) empty() bool {
7777

7878
// newObject creates a state object.
7979
func newObject(db *StateDB, address common.Address, acct *types.StateAccount) *stateObject {
80-
var (
81-
origin = acct
82-
created = acct == nil // true if the account was not existent
83-
)
80+
origin := acct
8481
if acct == nil {
8582
acct = types.NewEmptyStateAccount()
8683
}
@@ -93,7 +90,6 @@ func newObject(db *StateDB, address common.Address, acct *types.StateAccount) *s
9390
originStorage: make(Storage),
9491
pendingStorage: make(Storage),
9592
dirtyStorage: make(Storage),
96-
created: created,
9793
}
9894
}
9995

core/vm/evm.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,10 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
462462
if !evm.StateDB.Exist(address) {
463463
evm.StateDB.CreateAccount(address)
464464
}
465-
// CreateContract means that regardless of whether the acccount existed
466-
// in the state trie or not, previously, it _now_ becomes created as a
467-
// _contract_ account. This is performed _prior_ to executing the initcode,
468-
// since the initcode acts inside that account.
465+
// CreateContract means that regardless of whether the account previously existed
466+
// in the state trie or not, it _now_ becomes created as a _contract_ account.
467+
// This is performed _prior_ to executing the initcode, since the initcode
468+
// acts inside that account.
469469
evm.StateDB.CreateContract(address)
470470

471471
if evm.chainRules.IsEIP158 {

tests/block_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ func TestBlockchain(t *testing.T) {
4949
// using 4.6 TGas
5050
bt.skipLoad(`.*randomStatetest94.json.*`)
5151

52-
// The tests under Pyspecs are the ones that are published as execution-spect tests.
53-
// We run these tests separately, no need to _also_ run them as part of the
54-
// reference tests.
55-
bt.skipLoad(`^Pyspecs/`)
56-
5752
bt.walk(t, blockTestDir, func(t *testing.T, name string, test *BlockTest) {
5853
execBlockTest(t, bt, test)
5954
})
@@ -69,14 +64,6 @@ func TestExecutionSpecBlocktests(t *testing.T) {
6964
}
7065
bt := new(testMatcher)
7166

72-
// These tests fail as of https://github.com/ethereum/go-ethereum/pull/28666, since we
73-
// no longer delete "leftover storage" when deploying a contract.
74-
bt.skipLoad(`^cancun/eip6780_selfdestruct/selfdestruct/self_destructing_initcode_create_tx.json`)
75-
bt.skipLoad(`^cancun/eip6780_selfdestruct/selfdestruct/self_destructing_initcode.json`)
76-
bt.skipLoad(`^cancun/eip6780_selfdestruct/selfdestruct/recreate_self_destructed_contract_different_txs.json`)
77-
bt.skipLoad(`^cancun/eip6780_selfdestruct/selfdestruct/delegatecall_from_new_contract_to_pre_existing_contract.json`)
78-
bt.skipLoad(`^cancun/eip6780_selfdestruct/selfdestruct/create_selfdestruct_same_tx.json`)
79-
8067
bt.walk(t, executionSpecBlockchainTestDir, func(t *testing.T, name string, test *BlockTest) {
8168
execBlockTest(t, bt, test)
8269
})

0 commit comments

Comments
 (0)