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

Pass raw data with ContractLogicError #2922

Merged
merged 6 commits into from
Apr 27, 2023

Conversation

kclowes
Copy link
Collaborator

@kclowes kclowes commented Apr 17, 2023

What was wrong?

People frequently request the raw data to be sent back with the ContractLogicError.

Closes #2793, #2336

How was it fixed?

This PR sends back the raw data as an attribute on the error class without breaking the existing API.

Todo:

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@kclowes kclowes force-pushed the pass-msg-data-contract-logic-error branch from 1c68bb0 to 4c780d7 Compare April 17, 2023 23:06
@kclowes kclowes force-pushed the pass-msg-data-contract-logic-error branch from 4c780d7 to cd2f9ce Compare April 19, 2023 18:09
@kclowes kclowes marked this pull request as ready for review April 19, 2023 20:02
@kclowes kclowes force-pushed the pass-msg-data-contract-logic-error branch from 3a8121a to 2985a6a Compare April 19, 2023 20:09
@kclowes kclowes force-pushed the pass-msg-data-contract-logic-error branch from 2985a6a to 3629fba Compare April 19, 2023 20:14
@kclowes kclowes requested review from pacrob and fselmo April 19, 2023 20:16
Copy link
Collaborator

@fselmo fselmo left a comment

Choose a reason for hiding this comment

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

Oh I like this approach in general! The more information the better on exceptions 👌🏼.

I think we should be able to add this to the OffchainLookup exception also which would be some nice information to have available.

offchain_lookup_contract.functions.testOffchainLookup(
OFFCHAIN_LOOKUP_TEST_DATA
).call(ccip_read_enabled=False)
assert e.value.data == OFFCHAIN_LOOKUP_RETURN_DATA
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@fselmo this assertion fails if it's run in isolation. the OFFCHAIN_LOOKUP_RETURN_DATA changes, but only fails that way on eth-tester, not with the geth integration tests. Do you have any ideas why the OFFCHAIN_LOOKUP_RETURN_DATA would be different when the whole file is run vs. run in isolation?

Copy link
Collaborator

@fselmo fselmo Apr 20, 2023

Choose a reason for hiding this comment

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

Oh, yeah. The very first value that's in the OffchainLookup revert in the contract is the particular contract's address which will differ between the contract deployed via the geth fixture and the one for eth-tester. You'll just have to change the beginning of the constant value for OFFCHAIN_LOOKUP_RETURN_DATA for the eth-tester tests to match that.

It should only differ in that and I checked that:

>>> e.value.data[:10] + e.value.data[74:] == OFFCHAIN_LOOKUP_RETURN_DATA[:10] + OFFCHAIN_LOOKUP_RETURN_DATA[74:]
True

first 10: "0x" (2 indexes) + 4 byte function selector (8 indexes)
next 64 should be abi-encoded address value (32 bytes * 2 indexes per byte)
[74:] is the rest

so the differing 32 bytes should be indexes [10:74] in the string.

Copy link
Collaborator Author

@kclowes kclowes Apr 21, 2023

Choose a reason for hiding this comment

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

Aha, thank you! I'll update the assertion so that it only asserts on e.value.data[:74] or at least skips the middle address section.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or just update [10:74] to match the address that deploys to the eth-tester fixture

@kclowes kclowes force-pushed the pass-msg-data-contract-logic-error branch from 99a5996 to 7d30587 Compare April 21, 2023 20:40
Copy link
Contributor

@pacrob pacrob left a comment

Choose a reason for hiding this comment

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

lgtm!

@kclowes kclowes force-pushed the pass-msg-data-contract-logic-error branch 4 times, most recently from 825abfc to 5e451db Compare April 26, 2023 20:07
@kclowes kclowes force-pushed the pass-msg-data-contract-logic-error branch from 5e451db to 6049c73 Compare April 26, 2023 20:16
@kclowes kclowes merged commit 9f628c3 into ethereum:main Apr 27, 2023
@kclowes kclowes deleted the pass-msg-data-contract-logic-error branch April 27, 2023 17:00
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.

Add support for custom errors or provide full RPC response if transaction is reverted
3 participants