Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix selfdestruct balance tracking by expecting balance burn #50

Merged
merged 7 commits into from
Feb 15, 2022
Prev Previous commit
Next Next commit
Always call AddBalance
  • Loading branch information
PlasmaPower committed Feb 1, 2022
commit 6cdef3a4b6dc4282b7b304a5155a45ab2d80e1b6
5 changes: 2 additions & 3 deletions core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -799,13 +799,12 @@ func opStop(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byt
func opSuicide(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
beneficiary := scope.Stack.pop()
balance := interpreter.evm.StateDB.GetBalance(scope.Contract.Address())
interpreter.evm.StateDB.AddBalance(beneficiary.Bytes20(), balance)
interpreter.evm.StateDB.Suicide(scope.Contract.Address())
if beneficiary.Bytes20() == scope.Contract.Address() {
// Arbitrum: calling selfdestruct(this) burns the balance
interpreter.evm.StateDB.ExpectBalanceBurn(balance)
} else {
interpreter.evm.StateDB.AddBalance(beneficiary.Bytes20(), balance)
}
interpreter.evm.StateDB.Suicide(scope.Contract.Address())
if interpreter.cfg.Debug {
interpreter.cfg.Tracer.CaptureEnter(SELFDESTRUCT, scope.Contract.Address(), beneficiary.Bytes20(), []byte{}, 0, balance)
interpreter.cfg.Tracer.CaptureExit([]byte{}, 0, nil)
Expand Down