mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
fix emition of selfdestruct balance changes for case where target=source
This commit is contained in:
parent
5031b5f15b
commit
9b194ed298
2 changed files with 15 additions and 6 deletions
|
|
@ -251,9 +251,13 @@ func (s *hookedStateDB) SelfDestruct6780(address common.Address) (uint256.Int, b
|
||||||
|
|
||||||
prev, changed := s.inner.SelfDestruct6780(address)
|
prev, changed := s.inner.SelfDestruct6780(address)
|
||||||
|
|
||||||
|
/*
|
||||||
|
// TODO: figure out if this can be removed (it's redundant with the tracing invocations in core/vm/instructions.go already)
|
||||||
|
// it's also incorrect if the target/source are the same account
|
||||||
if s.hooks.OnBalanceChange != nil && !prev.IsZero() {
|
if s.hooks.OnBalanceChange != nil && !prev.IsZero() {
|
||||||
s.hooks.OnBalanceChange(address, prev.ToBig(), new(big.Int), tracing.BalanceDecreaseSelfdestruct)
|
s.hooks.OnBalanceChange(address, prev.ToBig(), new(big.Int), tracing.BalanceDecreaseSelfdestruct)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if changed && len(prevCode) > 0 {
|
if changed && len(prevCode) > 0 {
|
||||||
if s.hooks.OnCodeChangeV2 != nil {
|
if s.hooks.OnCodeChangeV2 != nil {
|
||||||
|
|
|
||||||
|
|
@ -887,7 +887,9 @@ func opSelfdestruct(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
}
|
}
|
||||||
beneficiary := scope.Stack.pop()
|
beneficiary := scope.Stack.pop()
|
||||||
balance := evm.StateDB.GetBalance(scope.Contract.Address())
|
balance := evm.StateDB.GetBalance(scope.Contract.Address())
|
||||||
|
if scope.Contract.Address() != common.BytesToAddress(beneficiary.Bytes()) {
|
||||||
evm.StateDB.AddBalance(beneficiary.Bytes20(), balance, tracing.BalanceIncreaseSelfdestruct)
|
evm.StateDB.AddBalance(beneficiary.Bytes20(), balance, tracing.BalanceIncreaseSelfdestruct)
|
||||||
|
}
|
||||||
evm.StateDB.SelfDestruct(scope.Contract.Address())
|
evm.StateDB.SelfDestruct(scope.Contract.Address())
|
||||||
if tracer := evm.Config.Tracer; tracer != nil {
|
if tracer := evm.Config.Tracer; tracer != nil {
|
||||||
if tracer.OnEnter != nil {
|
if tracer.OnEnter != nil {
|
||||||
|
|
@ -906,8 +908,11 @@ func opSelfdestruct6780(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, erro
|
||||||
}
|
}
|
||||||
beneficiary := scope.Stack.pop()
|
beneficiary := scope.Stack.pop()
|
||||||
balance := evm.StateDB.GetBalance(scope.Contract.Address())
|
balance := evm.StateDB.GetBalance(scope.Contract.Address())
|
||||||
|
if scope.Contract.Address() != common.BytesToAddress(beneficiary.Bytes()) {
|
||||||
evm.StateDB.SubBalance(scope.Contract.Address(), balance, tracing.BalanceDecreaseSelfdestruct)
|
evm.StateDB.SubBalance(scope.Contract.Address(), balance, tracing.BalanceDecreaseSelfdestruct)
|
||||||
evm.StateDB.AddBalance(beneficiary.Bytes20(), balance, tracing.BalanceIncreaseSelfdestruct)
|
evm.StateDB.AddBalance(beneficiary.Bytes20(), balance, tracing.BalanceIncreaseSelfdestruct)
|
||||||
|
}
|
||||||
|
|
||||||
evm.StateDB.SelfDestruct6780(scope.Contract.Address())
|
evm.StateDB.SelfDestruct6780(scope.Contract.Address())
|
||||||
if tracer := evm.Config.Tracer; tracer != nil {
|
if tracer := evm.Config.Tracer; tracer != nil {
|
||||||
if tracer.OnEnter != nil {
|
if tracer.OnEnter != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue