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

fix: issue when contracts w/o source IDs would not enrich #2047

Merged
merged 11 commits into from
May 3, 2024

Conversation

antazoey
Copy link
Member

@antazoey antazoey commented May 1, 2024

What I did

fixes: #2035

Enrichment was skipped for contracts missing source IDs. This adds it.

bonuses that are not needed but were still part of the fun:

TODO: Refactor CompilerAPI plugins to use new helper method (instead of re-implementing n-places) compiler_manager.get_custom_error()

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 requested a review from fubuloubu May 1, 2024 22:18
fubuloubu
fubuloubu previously approved these changes May 1, 2024
@banteg
Copy link
Contributor

banteg commented May 2, 2024

so in my initial tests it shows the correct error at the end

image

but in the trace it's still reverted without message

image

moreover, if an error encodes some additional details, it doesn't get caught at all. here is an updated test.

def test_custom_error_2(accounts):
    universal_router = Contract("0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD")
    for value in [10**18, 0]:
        receipt = universal_router.execute(
            "0x0b00",
            [
                "0x0000000000000000000000003fc91a3afd70395cd496c647d5a6cc9d4b2b7fad0000000000000000000000000000000000000000000000000de0b6b3a7640000",
                "0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20001f4a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000",
            ],
            sender=accounts[0],
            value=value,
        )
        receipt.show_trace()

expected AllowanceExpired(uint256) that encodes 0

actual

E   ape.exceptions.ContractLogicError: 0xd81b2f2e0000000000000000000000000000000000000000000000000000000000000000

@antazoey
Copy link
Member Author

antazoey commented May 2, 2024

inputs should work!

but it looks like it is struggling to find the AllowanceExpired ABI - it is not on the contract for some reason.

In [3]: contr = Contract("0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD")

In [4]: [err.name for err in contr.contract_type.errors]
Out[4]: 
['BalanceTooLow',
 'BuyPunkFailed',
 'ContractLocked',
 'ETHNotAccepted',
 'ExecutionFailed',
 'FromAddressIsNotOwner',
 'InsufficientETH',
 'InsufficientToken',
 'InvalidBips',
 'InvalidCommandType',
 'InvalidOwnerERC1155',
 'InvalidOwnerERC721',
 'InvalidPath',
 'InvalidReserves',
 'InvalidSpender',
 'LengthMismatch',
 'SliceOutOfBounds',
 'TransactionDeadlinePassed',
 'UnableToClaim',
 'UnsafeCast',
 'V2InvalidPath',
 'V2TooLittleReceived',
 'V2TooMuchRequested',
 'V3InvalidAmountOut',
 'V3InvalidCaller',
 'V3InvalidSwap',
 'V3TooLittleReceived',
 'V3TooMuchRequested']

In [5]:

EDIT: fixed! Had to search from the back 95d5d39

fubuloubu
fubuloubu previously approved these changes May 2, 2024
@antazoey antazoey force-pushed the fix/enrich-err branch 2 times, most recently from 7eee9c6 to ac25fa4 Compare May 2, 2024 15:54
@antazoey
Copy link
Member Author

antazoey commented May 2, 2024

  • add more tests
  • fix test breakage

@antazoey antazoey requested a review from fubuloubu May 2, 2024 20:56
fubuloubu
fubuloubu previously approved these changes May 2, 2024
@antazoey antazoey force-pushed the fix/enrich-err branch 2 times, most recently from daa4dee to b9f26da Compare May 3, 2024 13:14
@antazoey antazoey merged commit aec6abb into ApeWorX:main May 3, 2024
17 checks passed
@antazoey antazoey deleted the fix/enrich-err branch May 3, 2024 13:50
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.

Catch and re-throw w/ CustomError if ErrorABI match detected
3 participants