diff --git a/core/vm/logger.go b/core/vm/logger.go index c5dcd5c368..14104b69be 100644 --- a/core/vm/logger.go +++ b/core/vm/logger.go @@ -31,6 +31,7 @@ import ( "github.com/scroll-tech/go-ethereum/common/hexutil" "github.com/scroll-tech/go-ethereum/common/math" "github.com/scroll-tech/go-ethereum/core/types" + "github.com/scroll-tech/go-ethereum/crypto" "github.com/scroll-tech/go-ethereum/log" "github.com/scroll-tech/go-ethereum/params" ) @@ -275,6 +276,29 @@ func (l *StructLogger) CaptureState(pc uint64, op OpCode, gas, cost uint64, scop extraData.Caller = append(extraData.Caller, getWrappedAccountForAddr(l, scope.Contract.Address())) } + // in reality it is impossible for CREATE to trigger ErrContractAddressCollision + if op == CREATE2 && opErr == nil { + _ = stack.data[stack.len()-1] // value + offset := stack.data[stack.len()-2] + size := stack.data[stack.len()-3] + salt := stack.data[stack.len()-4] + // `CaptureState` is called **before** memory resizing + // So sometimes we need to auto pad 0. + code := getData(scope.Memory.Data(), offset.Uint64(), size.Uint64()) + + codeAndHash := &codeAndHash{code: code} + + address := crypto.CreateAddress2(contract.Address(), salt.Bytes32(), codeAndHash.Hash().Bytes()) + + contractHash := l.env.StateDB.GetKeccakCodeHash(address) + if l.env.StateDB.GetNonce(address) != 0 || (contractHash != (common.Hash{}) && contractHash != emptyKeccakCodeHash) { + extraData := structLog.getOrInitExtraData() + wrappedStatus := getWrappedAccountForAddr(l, address) + extraData.StateList = append(extraData.StateList, wrappedStatus) + l.statesAffected[address] = struct{}{} + } + } + structLog.RefundCounter = l.env.StateDB.GetRefund() l.logs = append(l.logs, structLog) } diff --git a/params/version.go b/params/version.go index 57446f0197..3aec424bca 100644 --- a/params/version.go +++ b/params/version.go @@ -24,7 +24,7 @@ import ( const ( VersionMajor = 4 // Major version component of the current release VersionMinor = 3 // Minor version component of the current release - VersionPatch = 61 // Patch version component of the current release + VersionPatch = 62 // Patch version component of the current release VersionMeta = "sepolia" // Version metadata to append to the version string )