Support memory(bytes) in ABI and dispatch#367
Merged
Conversation
axic
commented
May 1, 2026
| } | ||
| } | ||
|
|
||
| // TODO: this is a copy of memory(string) |
Contributor
Author
There was a problem hiding this comment.
No idea how to deduplicate this, beyond having some helper pulled out.
axic
commented
May 1, 2026
| forall reader. reader : WordReader => | ||
| instance ABIDecoder(memory(bytes), reader):ABIDecode(memory(bytes)) | ||
| { | ||
| function decode(ptr:ABIDecoder(memory(bytes), reader), currentHeadOffset:word) -> memory(bytes) { |
Contributor
Author
There was a problem hiding this comment.
This one I'm not sure how to deduplicate.
Collaborator
There was a problem hiding this comment.
How about
forall a ptrtype reader. reader:WordReader =>
function blockDecode(ptr:ABIDecoder(memory(a), reader), currentHeadOffset:word) -> memory(a) {
let tmp:word;
let headRdr = WordReader.advance(ptr, currentHeadOffset);
let tailPtr : word = WordReader.read(headRdr);
let src = WordReader.advance(ptr, tailPtr);
let srcRdr = getReader(src);
let length = WordReader.read(src);
let total = Add.add(length, 32);
let rounded = round_up_to_mul_of_32(total);
let resultPtr : word = allocate_memory(rounded) ;
WordReader.copyToMem(srcRdr, resultPtr, total);
return memory(resultPtr);
}
forall reader. reader : WordReader =>
instance ABIDecoder(memory(bytes), reader):ABIDecode(memory(bytes))
{
function decode(ptr:ABIDecoder(memory(bytes), reader), currentHeadOffset:word) -> memory(bytes) {
return blockDecode(ptr, currentHeadOffset);
}
}
Alanmrc981
approved these changes
May 2, 2026
mbenke
requested changes
May 6, 2026
mbenke
left a comment
Collaborator
There was a problem hiding this comment.
Please add a test, for example by adding to test/examples/dispatch/basic.solc
function idbytes(b:memory(bytes)) -> (memory(bytes)) {
return b;
}
and to basic.json
{
"input": {
"text-calldata": "idbytes(bytes)(bytes)",
"calldata":"0xc886fb8000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004deadbeef00000000000000000000000000000000000000000000000000000000",
"value": "0"
},
"kind": "call",
"output": {
"returndata":"00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004deadbeef00000000000000000000000000000000000000000000000000000000",
"status": "success"
}
},
Contributor
Author
|
@mbenke added tests |
This file contains hidden or 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.
No description provided.