Make sure contract suicides successfully before add balance to other address.

This commit is contained in:
wangsai.silence 2019-08-16 14:21:42 +08:00
parent dbb03fe989
commit bcafff9bcf

View file

@ -878,9 +878,11 @@ func opStop(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory
func opSuicide(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { func opSuicide(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
balance := interpreter.evm.StateDB.GetBalance(contract.Address()) balance := interpreter.evm.StateDB.GetBalance(contract.Address())
interpreter.evm.StateDB.AddBalance(common.BigToAddress(stack.pop()), balance)
interpreter.evm.StateDB.Suicide(contract.Address()) suicided := interpreter.evm.StateDB.Suicide(contract.Address())
if suicided {
interpreter.evm.StateDB.AddBalance(common.BigToAddress(stack.pop()), balance)
}
return nil, nil return nil, nil
} }