std: add call_with_default and std::evm::erc20 safe-transfer helpers#1514
Draft
cburgdorf wants to merge 1 commit into
Draft
std: add call_with_default and std::evm::erc20 safe-transfer helpers#1514cburgdorf wants to merge 1 commit into
cburgdorf wants to merge 1 commit into
Conversation
Collaborator
Author
|
I'm not quite sure if we really want the erc20 stuff in the std lib or if that should be in an external ingot. But I think the |
Collaborator
For now I think std should have rich support for all common interfaces. We can optionally kick it out to an external ingot later. |
Typed external calls strictly decode returndata, so a `-> bool` message reverts when a token (USDT-style) executes but returns no data. Add two opt-in layers; the strict `call<M>` path is untouched: - `Call::call_with_default<M>` (+ `Address::call_with_default`): identical to `call<M>` except that a successful call with EMPTY returndata yields a caller-supplied default instead of a decode revert. Reverts still bubble verbatim and non-empty returndata is still decoded strictly. Caveat (as in Vyper's default_return_value): a call to a codeless address yields the default. - `std::evm::erc20` with `safe_transfer` / `safe_transfer_from` / `safe_approve` (OpenZeppelin SafeERC20 semantics): tolerates empty returndata, reverts on a `false` return, and closes the no-code hole with an extcodesize check performed only on the empty-returndata path. Fixture tests cover the full mock matrix for both layers: compliant, reverting (revert data asserted verbatim), no-return, false-returning, malformed (<32 bytes) returndata, and no-code targets, plus a non-bool return type exercising both the empty and non-empty paths.
cburgdorf
force-pushed
the
call_with_default
branch
from
July 16, 2026 15:11
ab8f8a3 to
78a0d92
Compare
Collaborator
Author
|
@sbillig sounds good. Then, this should be ready for human review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Typed external calls strictly decode returndata, so a
-> boolmessage reverts when a token (USDT-style) executes but returns no data. Add two opt-in layers; the strictcall<M>path is untouched:Call::call_with_default<M>(+Address::call_with_default): identical tocall<M>except that a successful call with EMPTY returndata yields a caller-supplied default instead of a decode revert. Reverts still bubble verbatim and non-empty returndata is still decoded strictly. Caveat (as in Vyper's default_return_value): a call to a codeless address yields the default.std::evm::erc20withsafe_transfer/safe_transfer_from/safe_approve(OpenZeppelin SafeERC20 semantics): tolerates empty returndata, reverts on afalsereturn, and closes the no-code hole with an extcodesize check performed only on the empty-returndata path.Fixture tests cover the full mock matrix for both layers: compliant, reverting (revert data asserted verbatim), no-return, false-returning, malformed (<32 bytes) returndata, and no-code targets, plus a non-bool return type exercising both the empty and non-empty paths.