core/state: add createcontract to journal fuzzing

This commit is contained in:
Martin Holst Swende 2024-04-15 10:12:24 +02:00
parent 10482a8fe0
commit c3b8364e60
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0

View file

@ -385,6 +385,27 @@ func newTestAction(addr common.Address, r *rand.Rand) testAction {
} }
}, },
}, },
{
name: "CreateContract",
fn: func(a testAction, s *StateDB) {
if !s.Exist(addr) {
s.CreateAccount(addr)
}
contractHash := s.GetCodeHash(addr)
emptyCode := contractHash == (common.Hash{}) || contractHash == types.EmptyCodeHash
storageRoot := s.GetStorageRoot(addr)
emptyStorage := storageRoot == (common.Hash{}) || storageRoot == types.EmptyRootHash
if s.GetNonce(addr) == 0 && emptyCode && emptyStorage {
s.CreateContract(addr)
// We also set some code here, to prevent the
// CreateContract action from being performed twice in a row,
// which would cause a difference in state when unrolling
// the journal. (CreateContact assumes created was false prior to
// invocation, and the journal rollback sets it to false).
s.SetCode(addr, []byte{1})
}
},
},
{ {
name: "SelfDestruct", name: "SelfDestruct",
fn: func(a testAction, s *StateDB) { fn: func(a testAction, s *StateDB) {