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

Initial implementation of multi-target CCIP read #28

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

clowestab
Copy link
Contributor

This is my initial implementation of multi-target CCIP read.
I've had a play with a few APIs/architectures and settled on this one.

The crux new API additions being:

  • setTarget which allows you to target a new contract for the value lookups that follow
  • setTargetRef which allows you to reference a value returned from a previous target value lookup. It is a naive API in that it assumes that the value returned and referenced is a valid 20 (padded to 32) byte address.

Added tests to demonstrate functionality in the context of two contracts deployed on L1.

Open to feedback, suggestions, and discussion.

@Arachnid
Copy link
Member

This is a straightforward way to implement multi-target fetches, but I wonder if there's a tidier option that works by extending the VM; something like this:

  • Add a 'slice' opcode that reads a constant and uses the value as offset and length into the top stack element (eg, if the top of the stack is 0x00000000000000001234567890123456789012345678901234567890), then slice20(16, 20) returns 0x1234567890123456789012345678901234567890. This can be used to extract an address from abi-encoded data.
  • Add a setaddr opcode that pops the top stack element and uses it as the address for subsequent fetches.
  • At the start, and whenever a setaddr is encountered, append an account proof to the list of proofs to be returned. Modify the proof format so that we verify these inline rather than specifying them separately.

WDYT?

@clowestab
Copy link
Contributor Author

I'm not averse to that option and its a good opportunity for my to keep playing with low-level code.
I have some bandwidth so I'll have a play and report back

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.

2 participants