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?

bumped to the homepage by Community yesterday

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

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.

  • Does it mean that Token(token).transfer() returns false on out of gas? – medvedev1088 Oct 28 '17 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 Oct 28 '17 at 21:48
  • So in this case it has nothing to do with the throw statement? – medvedev1088 Oct 28 '17 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 Oct 29 '17 at 0:34
  • I guess the culprit is the compiler version. Apparently in earlier versions it used 0xfe for out of gas? – medvedev1088 Oct 29 '17 at 2:45

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.