-
Notifications
You must be signed in to change notification settings - Fork 9
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
[WIP] Calldata generation for bytes, bytes[] parameters #303
Closed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
WIP.
Depends on the KEVM PR: runtimeverification/evm-semantics#2265.
Alternative to the manual approach taken in #223 (where assumptions for a specific OP proofs are being added manually).
To assist automated generation of calldata for functions with
bytes
,bytes[]
parameters, as well as structs with such elements, this PR adds the following tosolc_to_k
:where
@custom:length
is used to specify the length (10) of arraybytes[] _withdrawalProof
, and@custom:element-length
is used to specify the length ofbytes
elements in_withdrawalProof
(600). Please use,
as a delimiter between comments — otherwise, two comments starting from/// @custom:length
will get merged into/// @custom:length _withdrawalProof: 10amount: 20
.These values are being added to
Input
aslength
andelement_length
fields, which are then used during syntactic sugar rules generation for a respective function.To make NatSpec comments accessible in compilation artifacts,
forge build
command is adjusted to be called with--extra-output devdoc
. These comments are function-level, so they're initially parsed as part of Method instantiation.This functionality can be tested using the
CallDataTest
contract provided in the kontrol-calldata repository:bytes[] a
array lengths and the length of its elements is then used to generate the rule used to generate calldata; this rule, for abytes[] a
array w/size10
adds 10 elements (V0_V0_a_0: bytes
,V0_V0_a_1: bytes
, ...) to LHS (function signature) and RHS (#abiCallData ( ... )
) expression, e.g., forthe rule looks as follows
bytes
length fromuint128
touint64
, reflecting the check inserted by the compiler.Remaining work: this PR does not include support for other array types, e.g.,
uint256[]
ortuple[]
, as well as nested arrays.