0

According to the Solidity documentation:

A require-style exception is generated in the following situations:

...

If you call a function via a message call but it does not finish properly (i.e. it runs out of gas, has no matching function, or throws an exception itself)

...

Internally, Solidity performs a revert operation (instruction 0xfd) for a require-style exception and executes an invalid operation (instruction 0xfe) to throw an assert-style exception.

However in this transaction an 0xfe opcode is performed (see step 1394) which is used for assert-style exceptions.

Is the documentation incorrect or the compiler doesn't follow the documentation?

1 Answer 1

0

If you look at the source code of the function withdrawTokens

function withdrawToken(address token, uint amount) {
  if (token==0) throw;
  if (tokens[token][msg.sender] < amount) throw;
  tokens[token][msg.sender] = safeSub(tokens[token][msg.sender], amount);
  if (!Token(token).transfer(msg.sender, amount)) throw;
  Withdraw(token, msg.sender, amount, tokens[token][msg.sender]);
}

It explicitely have a throw, and throw will generate 0xfe.

The contract was compiled with version v0.4.9, and require and assert are only available from v0.4.10.

5
  • Does it mean that Token(token).transfer() returns false on out of gas? Commented Oct 28, 2017 at 21:26
  • You are right, if a call to a subcontract runs out of gas, it will cause an exception, and it will propagate to the caller.
    – Ismael
    Commented Oct 28, 2017 at 21:48
  • So in this case it has nothing to do with the throw statement? Commented Oct 28, 2017 at 22:09
  • Yes, you are right again. The trace shows depth=2, meaning it is inside de transfer function. It tries to execute SSTORE with 435 gas remaining, but it needs 5000, this causes out of gas exception. Transfer doesn't return false because it is a direct call instead it will propagate the exception.
    – Ismael
    Commented Oct 29, 2017 at 0:34
  • I guess the culprit is the compiler version. Apparently in earlier versions it used 0xfe for out of gas? Commented Oct 29, 2017 at 2:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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