Skip to content

Support msg.data in host calls #321

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

Open
clearloop opened this issue Mar 26, 2025 · 0 comments
Open

Support msg.data in host calls #321

clearloop opened this issue Mar 26, 2025 · 0 comments

Comments

@clearloop
Copy link
Member

clearloop commented Mar 26, 2025

in the implementation of #297, we found that reading the complete call data could be complex: CALLDATA -> memory -> stack, for templates of implementing this (with return but not writing it on stack):

// load the complete call data to memory
PUSH0                   // from 0
PUSH0                   // from 0
CALLDATASIZE     // to size
CALDATALOAD     // calldataload(dest_mem_offset: 0, offest: 0, size: size)

// return the selected memory
PUSH0
CALLDATASIZE
RETURN

considering about the memory pointer:

MSIZE // first we get the memory size as the start pointer for the memory allocation
PUSH0 // to get the complete calldata, we start form offset 0
CALLDATASIZE // complete calldata
CALLDATALOAD // load the calldata to memory

// now we return the calldata
MSIZE
CALLDATASIZE
SUB
CALLDATASIZE
RETURN

for the real implementation, we might need to write the calldata on stack, need to do sort of research on it, mb learn from solidity or huff!

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

No branches or pull requests

1 participant