Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: raise_on_revert=False kwarg for allowing failures on calls and transactions #2181

Merged
merged 16 commits into from
Jul 24, 2024

Conversation

antazoey
Copy link
Member

@antazoey antazoey commented Jul 22, 2024

What I did

fixes: #2180
Fixes: Ape-1788

How I did it

How to verify it

Checklist

  • All changes are completed
  • New test cases have been added
  • Documentation has been updated

@antazoey antazoey changed the title feat: allow fail kwarg feat: allow transactions and calls to fail via kwarg Jul 22, 2024
@antazoey
Copy link
Member Author

antazoey commented Jul 22, 2024

  • make work for alls

@antazoey antazoey marked this pull request as draft July 22, 2024 16:17
fubuloubu
fubuloubu previously approved these changes Jul 22, 2024
Copy link
Member

@fubuloubu fubuloubu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, I think I do like raise_on_revert better for the kwarg name, as it shows the python action (e.g. raiseing an error) is tied to the EVM result (e.g. the transaction reverts)

docs/userguides/contracts.md Outdated Show resolved Hide resolved
docs/userguides/contracts.md Outdated Show resolved Hide resolved
src/ape_test/provider.py Outdated Show resolved Hide resolved
docs/userguides/reverts.md Outdated Show resolved Hide resolved
docs/userguides/reverts.md Outdated Show resolved Hide resolved
@antazoey antazoey changed the title feat: allow transactions and calls to fail via kwarg feat: kwargs for avoiding exceptions during reverts on contract method invokes Jul 22, 2024
@antazoey antazoey changed the title feat: kwargs for avoiding exceptions during reverts on contract method invokes feat: kwarg for avoiding exceptions during reverts on contract method invokes Jul 22, 2024
@antazoey
Copy link
Member Author

antazoey commented Jul 22, 2024

@antazoey antazoey marked this pull request as ready for review July 23, 2024 14:12
@antazoey antazoey changed the title feat: kwarg for avoiding exceptions during reverts on contract method invokes feat: raise_on_revert=False kwargs for allowing failures on calls and transactions Jul 23, 2024
@antazoey antazoey changed the title feat: raise_on_revert=False kwargs for allowing failures on calls and transactions feat: raise_on_revert=False kwarg for allowing failures on calls and transactions Jul 23, 2024
@antazoey antazoey requested a review from fubuloubu July 23, 2024 14:37
fubuloubu
fubuloubu previously approved these changes Jul 23, 2024
Copy link
Member

@fubuloubu fubuloubu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great!

One thing I am considering is what happens when partial failure(s) exist in a receipt? (Reverts but handled by upstream logic e.g. SafeTx execution)

This is probably a tracing feature (out or scope for this PR), something like ReceiptAPI.ignored_reverts -> list[ContractLogicError], but might be good to think of how they might work together before merging this

@antazoey
Copy link
Member Author

but might be good to think of how they might work together before merging this

We could put all reverts in a list and have .error refer to the last one?

@antazoey
Copy link
Member Author

tbd im not sure what the experience is like with partially failed txs. Is there a way using local developer networks to simulate this?

@fubuloubu
Copy link
Member

tbd im not sure what the experience is like with partially failed txs. Is there a way using local developer networks to simulate this?

You'd need a contract that does a call to another contract, and then handle the result. In vyper you can do this with raw_call, there is no native exception handling yet. Solidity does allow exception handling with the new custom errors stuff I think using try/catch: https://docs.soliditylang.org/en/v0.8.26/control-structures.html#try-catch

@fubuloubu
Copy link
Member

fubuloubu commented Jul 23, 2024

but might be good to think of how they might work together before merging this

We could put all reverts in a list and have .error refer to the last one?

I think in this scenario if it doesn't revert then .error will be None, but then separately .ignored_reverts may not be empty regardless of whether ultimately the transaction reverted or not (as an error may have been ignored earlier in the trace)

Ultimately seems best to keep these two features separate actually, since they are orthogonal (and likely dependent on the availability of tracing to get)

fubuloubu
fubuloubu previously approved these changes Jul 23, 2024
@antazoey antazoey merged commit 489e059 into ApeWorX:main Jul 24, 2024
15 checks passed
@antazoey antazoey deleted the feat/revert-allow branch July 24, 2024 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: Add option to explicitly ignore reverts
2 participants