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

[isoltest] Add support for events using call side-effects. #11050

Merged
merged 2 commits into from
May 31, 2021

Conversation

aarlt
Copy link
Member

@aarlt aarlt commented Mar 4, 2021

Fixes #6902.

@aarlt aarlt force-pushed the isoltest-effects-events branch from e26dc56 to 1d14a4d Compare March 4, 2021 12:30
@aarlt aarlt force-pushed the isoltest-effects branch from a1c6550 to ce4fd8d Compare March 4, 2021 19:17
@aarlt aarlt changed the title [isoltest] Add support for events using effects. [isoltest] Add support for events using call-effects. Mar 4, 2021
@aarlt aarlt force-pushed the isoltest-effects-events branch 2 times, most recently from 171cfd0 to 3c35244 Compare March 4, 2021 19:27
@aarlt aarlt force-pushed the isoltest-effects branch from ce4fd8d to efc7805 Compare April 29, 2021 23:25
@aarlt aarlt force-pushed the isoltest-effects-events branch from 3c35244 to f5f8c0a Compare April 29, 2021 23:26
@aarlt aarlt force-pushed the isoltest-effects branch from efc7805 to 7390def Compare April 30, 2021 02:06
@aarlt aarlt force-pushed the isoltest-effects-events branch 2 times, most recently from ed7e535 to ca5a695 Compare April 30, 2021 02:24
@aarlt aarlt force-pushed the isoltest-effects branch from 7390def to d2ee50b Compare April 30, 2021 22:31
@aarlt aarlt force-pushed the isoltest-effects-events branch from ca5a695 to 2f27704 Compare April 30, 2021 22:40
@chriseth
Copy link
Contributor

chriseth commented May 3, 2021

Please try to parse the errors and display them nicely. If this is more than a day's work, then at least try to display the error signature instead of its hash and split the data by chunks of 0x20 bytes and format them as "unknown data".

@aarlt aarlt force-pushed the isoltest-effects branch 5 times, most recently from a4b4748 to fa2a297 Compare May 3, 2021 16:22
@aarlt aarlt force-pushed the isoltest-effects-events branch from 2f27704 to c212b23 Compare May 5, 2021 04:20
@aarlt aarlt force-pushed the isoltest-effects branch 4 times, most recently from 4edfe0f to f493277 Compare May 8, 2021 03:42
@aarlt aarlt force-pushed the isoltest-effects-events branch 3 times, most recently from ecc9c36 to de49d4a Compare May 9, 2021 22:15
@aarlt aarlt force-pushed the isoltest-effects-events branch 3 times, most recently from ecdb3ee to 4acc2b2 Compare May 26, 2021 00:06
@aarlt
Copy link
Member Author

aarlt commented May 26, 2021

@cameel Thanks for your review! I think I covered everything, except the actual parameter decoding. It should not be that complicated, but I will add this tomorrow.

@cameel
Copy link
Member

cameel commented May 26, 2021

OK. I'll take another look today. From what I've seen yesterday, most of the issues I found were cosmetic so this should be quick.

If the decoding turns out to be time-consuming, feel free to just skip it in this PR. It's just nice to have, not anything critical.

@cameel
Copy link
Member

cameel commented May 26, 2021

Reviewed again, including the older comments. All of those older ones seem solved or irrelevant. So the remaining things (apart from some minor tweaks) are:

@aarlt aarlt force-pushed the isoltest-effects-events branch from 4acc2b2 to b67d7eb Compare May 27, 2021 03:54
@aarlt
Copy link
Member Author

aarlt commented May 27, 2021

@cameel I added a very simple parameter decoder. I tried to implement a more advanced decoder, but it would take more time to implement this completely. Right now it only uses the parameter types for indexed/nonIndexed events for simple bool's. By default everything is just decoded as hex, but if the hex data consists of printable ascii characters, the parameter will be decoded as a string. For this none of the provided type information is used. Also the parameters are just decoded in 32 byte chunks.

However, at least we have the parameter type information available, so if needed we could improve the decoding in another PR.

@aarlt
Copy link
Member Author

aarlt commented May 27, 2021

I just saw that chk_spelling fails, because the strings are split into 32 byte chunks. I think it should be easily possible to just merge multiple string literals.

Comment on lines 326 to 327
LogRecord(util::h160 _creator, bytes _data, std::vector<util::h256> _topics)
: creator(_creator), data(std::move(_data)), topics(std::move(_topics)) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
LogRecord(util::h160 _creator, bytes _data, std::vector<util::h256> _topics)
: creator(_creator), data(std::move(_data)), topics(std::move(_topics)) {}
LogRecord(util::h160 _creator, bytes _data, std::vector<util::h256> _topics):
creator(_creator), data(std::move(_data)), topics(std::move(_topics)) {}

Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't you move the creator? Also do you really need a constructor or would {}-constructing be enough?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was also wondering why the constructor is needed, but it seem to be needed.

Copy link
Member

Choose a reason for hiding this comment

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

It's because of the logs.emplace_back() call in ExecutionFramework::recordedLogs(). Apparently it tries to execute LogRecord() rather than LogRecord{} and a struct does not have the former. This is supposed to change in C++20 from what I've read.

So we could leave it as is or do logs.push_back({x, y, z ...}) instead which will allow us to remove the constructor.

Why don't you move the creator?

I wanted to point that out originally but then noticed that creator is h160, which is FixedHash, which is std::array so there's no benefit from moving it. It being const& parameter would make more sense.

@chriseth
Copy link
Contributor

Maybe just change the string in snark.sol, we can think about a better solution later.

@aarlt aarlt force-pushed the isoltest-effects-events branch from b67d7eb to 3755373 Compare May 27, 2021 14:45
cameel
cameel previously approved these changes May 27, 2021
Copy link
Member

@cameel cameel left a comment

Choose a reason for hiding this comment

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

Looks fine now. I have two small suggestions and you need to update gas cost in snark.sol but other than that I think we're done here.

@aarlt aarlt force-pushed the isoltest-effects-events branch from 3755373 to 038c714 Compare May 27, 2021 20:23
@aarlt aarlt force-pushed the isoltest-effects-events branch from 038c714 to 85e3fcb Compare May 28, 2021 04:22
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.

[isoltest] Handle events in isoltest semantics tests.
6 participants