core/vm: don't call SetCode after contract creation if initcode didn't return anything (#32916)

The code change is a noop here, and the tracing hook shouldn't be
invoked if the account code doesn't actually change.
This commit is contained in:
jwasinger 2025-10-20 17:51:29 +08:00 committed by GitHub
parent cfb311148c
commit b6a4ac9961
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -601,7 +601,9 @@ func (evm *EVM) initNewContract(contract *Contract, address common.Address) ([]b
}
}
evm.StateDB.SetCode(address, ret, tracing.CodeChangeContractCreation)
if len(ret) > 0 {
evm.StateDB.SetCode(address, ret, tracing.CodeChangeContractCreation)
}
return ret, nil
}