7

If my contract calls suicide() referencing a contract as the recipient of funds, and that recipient contract default function calls back into my contract, will the call succeed?

contract A {
  function die(address _recipient) external {
    suicide(_recipient);
  }
}

contract B {
  A a;
  function () {
    a.die(this);
  }
}

More importantly, does it matter? Won't all the remaining ETH have been sent as part of the call into B?

Follow-up:

The yellow paper shows that balances are manipulated directly, and not through a call. (pg 29 under the SUICIDE instruction)

The core/vm/instructions.go file in the master branch of the Go client defines the opSuicide() method which looks like it's the one called during execution, and it looks like it doesn't even transfer the balance. It just adds it to the recipient and deletes the calling contract.

func opSuicide(instr instruction, pc *uint64, env Environment, contract *Contract, memory *Memory, stack *stack) {
    balance := env.Db().GetBalance(contract.Address())
    env.Db().AddBalance(common.BigToAddress(stack.pop()), balance)

    env.Db().Delete(contract.Address())
}

Can anyone confirm their understanding of this?

  • I'm actually wondering now if that call even happens. The mathspeak in the yellow paper under the SUICIDE instruction makes it look like the balance is simply added to the recipient account without a call being made. ?? – Jamie Hale Jun 23 '16 at 13:00
5

No, there are no contract invocations with a selfdestruct (suicide), so there is no possibility of reentrancy.

There are no CALLs as you've noted and the Geth code you've quoted is correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.