-
Notifications
You must be signed in to change notification settings - Fork 336
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 tuple encoding in precompiles return position #2068
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nanocryk
added
A0-pleasereview
Pull request needs code review.
B7-runtimenoteworthy
Changes should be noted in any runtime-upgrade release notes
D5-nicetohaveaudit⚠️
PR contains trivial changes to logic that should be properly reviewed.
not-breaking
Does not need to be mentioned in breaking changes
labels
Jan 27, 2023
notlesh
reviewed
Jan 27, 2023
notlesh
reviewed
Jan 27, 2023
min_support: UnboundedBytes, | ||
} | ||
|
||
impl EvmData for TrackInfo { |
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.
Could this be done as a derive macro?
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.
We can add an EvmData derive macro in a follow up PR yes :)
crystalin
approved these changes
Feb 7, 2023
crystalin
added
D9-needsaudit👮
PR contains changes to fund-managing logic that should be properly reviewed and externally audited
and removed
D5-nicetohaveaudit⚠️
PR contains trivial changes to logic that should be properly reviewed.
labels
Feb 7, 2023
notlesh
added
D1-audited👍
PR contains changes to fund-managing logic that has been properly reviewed and externally audited
and removed
D9-needsaudit👮
PR contains changes to fund-managing logic that should be properly reviewed and externally audited
labels
Feb 14, 2023
crystalin
changed the title
Fix tuple encoding in return position
Fix tuple encoding in precompiles return position
Feb 22, 2023
imstar15
pushed a commit
to AvaProtocol/moonbeam
that referenced
this pull request
May 16, 2023
…#2068) * fix returns tuple encoding * use struct in Referanda precompile to keep same encoding * fix typos
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A0-pleasereview
Pull request needs code review.
B7-runtimenoteworthy
Changes should be noted in any runtime-upgrade release notes
D1-audited👍
PR contains changes to fund-managing logic that has been properly reviewed and externally audited
not-breaking
Does not need to be mentioned in breaking changes
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does it do?
In Solidity tuple encoding depends on if the content has static size or not. Dynamic size tuples are encoded with an offset to the tuple data, while static size tuples the fields are encoded inlined.
Function returning multiple values look like they are returning tuples, however they are always encoded inline regardless of if the size is dynamic or not. Note that while structs are usually encoded like tuples, using a struct as return will be encoded differently if the struct is dynamic sized or not.
This PR makes the following changes:
encode_as_function_return_value
that performs the correct encoding. It relies on a new function inEvmData
trait calledis_explicit_tuple
that should only returntrue
for tuples (it has a default implementation tofalse
so that implementing the trait on other types don't require to think about it). In the case that the data being provided toencode_as_function_return_value
returns true foris_explicit_tuple
and false tohas_static_size
, the first 32 bytes (the offset) is stripped.What important points reviewers should know?
Is there something left for follow-up PRs?
EvmData
derive macroWhat alternative implementations were considered?
Are there relevant PRs or issues in other repositories (Substrate, Polkadot, Frontier, Cumulus)?
What value does it bring to the blockchain users?