-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Parse tuple arguments from event #2211
Conversation
Thanks @cc7768! I will take a look! |
I have tried implementing the fix and still seeing issues File "/usr/local/lib/python3.9/dist-packages/brownie/_cli/run.py", line 50, in main |
437b45c
to
bf9f60b
Compare
c499b3e
to
a57f532
Compare
- Nested tuples seemed to be broken when parsing event filters. This commit piggy backs off previous work and uses the collapse_if_tuple() method in the _build_argument_filters_from_even_abi() method. From testing, this seemes to have been a missing piece to get these issues resolved and the added test passing. - Remove testing nested tuple method from tests that require the test id enum. These were added in the previous commit. Instead, add a test specific to testing the new method / event for tuples. - Add testing for the new nested tuple function + event in the emitter contract. - closes 1629 - closes 2298
`enable_strict_bytes_type_checking()` appears to be broken with solidity versions `0.5.0` and above. This commit separates a new emitter contract, compiled with solidity `0.8.11`, and the older emitter contract, compiled with solidity `0.4.21`. This way, we can update the tests using the `emitter` pytest modules while the strict bytes test can use the old emitter contract until we can update `enable_strict_bytes_type_checking()` to be compatible with newer solidity versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thank you for getting this one over the line. I think there is at least one other issue we can close with this one! Left a few comments, but nothing blocking.
Thank you @fselmo for getting this across the finish line! I hope I didn't leave you more work than if you had started from scratch 😅 I see that you're based in CO -- Let me know if you're around during ETH Denver so I can treat you to a beer or a coffee! |
Not at all, thanks for getting the ball rolling on this. Yep, the plan is to go to ETH Denver 🤞🏼 |
Thanks for merging! |
What was wrong?
Events that have tuple-valued arguments are currently unable to be parsed.
Related to Issue #1629
How was it fixed?
I used the proposed fix from #1484
I'm struggling a little on incorporating the new test... I think I'm close but haven't quite had it come together yet.
I've done the following:
tests/core/contracts/contract_sources/Emitter.sol
TestTuple
)LogStructArgs
) that usesTestTuple
as an argumentlogStruct
) that emits theLogStructArgs
eventweb3/_utils/module_testing/emitter_contract.py
CONTRACT_EMITTER_CODE
andCONTRACT_EMITTER_RUNTIME
but I ran into errors because I haven't done this before. What's the easiest way to generate these?web3/tests/core/contracts/conftest.py
LogStructArgs
to theLogFunctions
classLogStructArgs
to theLogTopics
classtests/core/contracts/test_extracting_event_data.py
test_event_data_extraction
test_event_rich_log
~Sorry for the lengthy read. I think it's close but I just need a little push to get it across the finish line.
@fselmo, picking up here:
Added a bit more to this PR, thanks @cc7768 for getting this started!
- Added a
NestedTestTuple
struct inside theTestTuple
juuuuuust to be sure- Added a test for the added event and function that was failing
- Added
collapse_if_tuple()
in a few more places that were missing, from the test I added, until it passed- Separated the
emitter
contract into a version compiled with a newer solidity version (0.8.11
) and the original one (compiled with0.4.21
) since the strict bytes check does not seem to work with solidity versions0.5.0
and above. Created an issue here to track that.Todo:
The main TODO item left is to add tests -- The lack of tests is why #1484 was never merged.The only function that is changed isget_event_abi_types_for_decoding
fromweb3/_utils/events.py
. This function itself is only called byget_event_data
fromweb3/_utils/events.py
. Theget_event_data
function is only tested intests/core/contracts/test_extracting_event_data.py
so the TODO items, as far as I can tell, should be:- [x] Ensure old tests continue to work with the update
- [x] Add new test case that incorporates having tuple arguments to an event
- [x] Add entry to the release notes
Cute Animal Picture