From 53fd7113a153c558d8c82c55e92442344601d01e Mon Sep 17 00:00:00 2001 From: Vansh Sahay Date: Fri, 19 Jun 2026 12:10:23 +0530 Subject: [PATCH] core/vm: implement EIP-8246 preserve balance on selfdestruct-to-self --- core/vm/instructions.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/vm/instructions.go b/core/vm/instructions.go index 209457f670..2ea1f8a8f7 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -916,7 +916,11 @@ func opSelfdestruct6780(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, erro if this != beneficiary { // Skip no-op transfer when self-destructing to self. evm.StateDB.AddBalance(beneficiary, balance, tracing.BalanceIncreaseSelfdestruct) } - evm.StateDB.SubBalance(this, balance, tracing.BalanceDecreaseSelfdestruct) + // EIP-8246: if the beneficiary is the executing account itself and the fork + // is active, the balance remains unchanged instead of being burned. + if !evm.chainRules.IsAmsterdam || this != beneficiary { + evm.StateDB.SubBalance(this, balance, tracing.BalanceDecreaseSelfdestruct) + } evm.StateDB.SelfDestruct(this) } @@ -928,8 +932,6 @@ func opSelfdestruct6780(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, erro if evm.chainRules.IsAmsterdam && !balance.IsZero() { if this != beneficiary { evm.StateDB.AddLog(types.EthTransferLog(this, beneficiary, balance)) - } else if newContract { - evm.StateDB.AddLog(types.EthBurnLog(this, balance)) } }