question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Behavior of ERC165Checker when less than 30k gas available

See original GitHub issue

EIP-165 stipulate that supportsInterface can use up to 30,000 gas.

But as you can see in openzeppelin implementation here, the call is executed without making sure 30,000 gas is indeed given to the call. Remember, the gas provided as part of the STATIC_CALL is just a maximum.

And because of EIP-150 behaviour, it is possible for supportsInterface to get less gas than required for it to complete (and thus throw which is interpreted wrongly as non-implementation) while the rest of the transaction continue and complete.

I described the issue in more details here as the issue is also present in the example implementation described at EIP-165.

Various solution are presented here but the best option is EIP-1930 which also solve issue present in other use cases like meta-transactions.

Also find some test case regarding EIP-165 here

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:18 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
nventurocommented, May 15, 2019

…but the whole point of this is what happens when less than 30k are sent? And a post-check will not know how much was actually sent.

1reaction
nventurocommented, May 13, 2019

check for gas (via gasleft()) before the call but need to account for the gas required between the call to gasleft() and the actual call

What is the intent behind this? What should a contract do if it has less than 30k gas available to make the call?

check for gas afterward assuming supportsinterface is not quitting early based on the gas passed in,

30k will be sent if they are available: the only way for the implementer to quit early is if the transaction doesn’t have enough gas, in which case the caller will revert with an out of gas error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · OpenZeppelin/openzeppelin-contracts · GitHub
Behavior of ERC165Checker when less than 30k gas available bug contracts Smart contract code. #1750 opened May 13, 2019 by wighawag v2.4.
Read more >
ERC165Checker; is it required to check support for ERC-165 ...
My contract needs to check whether an external contract supports a standard interface, I want the function to be as cheap as possible, ......
Read more >
EIP-165: Standard Interface Detection
This function must return a bool and use at most 30,000 gas. Implementation note, there are several logical ways to implement this function....
Read more >
Revest Finance: Lock Manager - SnowTrace
unlockValue; } else { // Only mature if current value less than unlock value ... wei to * `recipient`, forwarding all available gas...
Read more >
Address 0xdbd90b3039489cdd4d281035afd95ad22c850a82
Polygon Sponsored slots available. ... require(permissions == address(0x0) || ERC165Checker. ... This function call must use less than 30 000 gas.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found