From b6a4ac99610328410881a9ad57b4c02361b0056c Mon Sep 17 00:00:00 2001 From: jwasinger Date: Mon, 20 Oct 2025 17:51:29 +0800 Subject: [PATCH] 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. --- core/vm/evm.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/vm/evm.go b/core/vm/evm.go index 88ef1cf121..8975c791c8 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -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 }