mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 13:21:37 +00:00
core/vm: implement EIP-8246 preserve balance on selfdestruct-to-self
This commit is contained in:
parent
7c9032dff6
commit
53fd7113a1
1 changed files with 5 additions and 3 deletions
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue