From 4f359dcd11e8fcb02d4c1972eaca087297eb232e Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Mon, 5 Jan 2026 16:21:34 +0900 Subject: [PATCH] small cleanup --- core/vm/instructions.go | 11 +++++------ tests/testdata | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/core/vm/instructions.go b/core/vm/instructions.go index c62bd24891..fa774bc57d 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -898,19 +898,18 @@ func opSelfdestruct6780(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, erro beneficiary := scope.Stack.pop() balance := evm.StateDB.GetBalance(scope.Contract.Address()) createdInTx := !evm.StateDB.ContractExistedBeforeCurTx(scope.Contract.Address()) + targetIsSelf := scope.Contract.Address() == common.BytesToAddress(beneficiary.Bytes()) if createdInTx { // if the contract is not preexisting, the balance is immediately burned on selfdestruct-to-self evm.StateDB.SubBalance(scope.Contract.Address(), balance, tracing.BalanceDecreaseSelfdestruct) - if scope.Contract.Address() != common.BytesToAddress(beneficiary.Bytes()) { + if !targetIsSelf { evm.StateDB.AddBalance(beneficiary.Bytes20(), balance, tracing.BalanceIncreaseSelfdestruct) } - } else { + } else if !targetIsSelf { // if the contract is preexisting, the balance isn't burned on selfdestruct-to-self - if scope.Contract.Address() != common.BytesToAddress(beneficiary.Bytes()) { - evm.StateDB.SubBalance(scope.Contract.Address(), balance, tracing.BalanceDecreaseSelfdestruct) - evm.StateDB.AddBalance(beneficiary.Bytes20(), balance, tracing.BalanceIncreaseSelfdestruct) - } + evm.StateDB.SubBalance(scope.Contract.Address(), balance, tracing.BalanceDecreaseSelfdestruct) + evm.StateDB.AddBalance(beneficiary.Bytes20(), balance, tracing.BalanceIncreaseSelfdestruct) } evm.StateDB.SelfDestruct6780(scope.Contract.Address()) if tracer := evm.Config.Tracer; tracer != nil { diff --git a/tests/testdata b/tests/testdata index 81862e4848..faf33b4714 160000 --- a/tests/testdata +++ b/tests/testdata @@ -1 +1 @@ -Subproject commit 81862e4848585a438d64f911a19b3825f0f4cd95 +Subproject commit faf33b471465d3c6cdc3d04fbd690895f78d33f2