Skip to content

Commit

Permalink
banana fork cold storage handling for create calls (#973)
Browse files Browse the repository at this point in the history
  • Loading branch information
hexoscott authored Aug 19, 2024
1 parent 2e6a30b commit 0e1b963
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions core/vm/evm_zkevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ func (evm *EVM) createZkEvm(caller ContractRef, codeAndHash *codeAndHash, gas ui
evm.intraBlockState.SetNonce(caller.Address(), nonce+1)
}

if evm.chainConfig.IsForkID12Banana(evm.context.BlockNumber) {
// add the address to the access list before taking a snapshot so that it will stay
// in warm storage even if the create call fails
if evm.chainRules.IsBerlin {
evm.intraBlockState.AddAddressToAccessList(address)
}
}

// Ensure there's no existing contract already at the designated address
contractHash := evm.intraBlockState.GetCodeHash(address)
if evm.intraBlockState.GetNonce(address) != 0 || (contractHash != (libcommon.Hash{}) && contractHash != emptyCodeHash) {
Expand All @@ -122,8 +130,12 @@ func (evm *EVM) createZkEvm(caller ContractRef, codeAndHash *codeAndHash, gas ui
// Create a new account on the state
snapshot := evm.intraBlockState.Snapshot()

if evm.chainRules.IsBerlin {
evm.intraBlockState.AddAddressToAccessList(address)
if !evm.chainConfig.IsForkID12Banana(evm.context.BlockNumber) {
// if we aren't at fork 12 then we haven't already added this address to the list so we
// need to add it now. If the create call fails it will be removed from warm storage
if evm.chainRules.IsBerlin {
evm.intraBlockState.AddAddressToAccessList(address)
}
}

evm.intraBlockState.CreateAccount(address, true)
Expand Down

0 comments on commit 0e1b963

Please sign in to comment.