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

Support memory arrays in MerkleTree multiproof #3493

Merged
merged 2 commits into from Jun 27, 2022

Conversation

Amxx
Copy link
Collaborator

@Amxx Amxx commented Jun 20, 2022

Fixes #3492

PR Checklist

  • Tests
  • Documentation
  • Changelog entry

@Amxx Amxx added this to the 4.7 rc milestone Jun 20, 2022
@frangio
Copy link
Contributor

frangio commented Jun 23, 2022

Why do we think the leaves are likely to be in memory?

@frangio frangio changed the title Support leaves in memory when checking multiproof Support memory arrays in MerkleTree multiproof Jun 23, 2022
@frangio frangio modified the milestones: 4.7 rc, 4.7 Jun 23, 2022
@Amxx
Copy link
Collaborator Author

Amxx commented Jun 24, 2022

Most of the time, the leaves are a hash produced in by the contract. For example, you want to claim 100 tokens to for user X, you hash that (sometimes with a nonce)

Like shown in this contract of the merkledrop workshop.

Now if you want to claim multiple allocations at once, you would get an array of descriptions (number of tokens, recipient, ...), you would hash each element of the array, and that would be your leaves that need to be verified. It would be an array in memory.
The array in calldata would be the preimages.

You could imagine having the preimage AND the leaves in calldata, hashing all the preimages, and then checking that the hashes match the calldata array, but that doesn't sound right to me.

Copy link
Contributor

@frangio frangio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've checked that the body of memory and calldata functions is the same.

@Amxx Amxx merged commit 2894059 into OpenZeppelin:master Jun 27, 2022
@Amxx Amxx deleted the fix/merkleproof/calldata branch June 27, 2022 11:15
Amxx added a commit that referenced this pull request Jun 27, 2022
(cherry picked from commit 2894059)
Signed-off-by: Hadrien Croubois <hadrien.croubois@gmail.com>
ronhuafeng added a commit to ronhuafeng/openzeppelin-contracts that referenced this pull request Sep 9, 2022
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.

MerkleProof.processMultiProof should be callable with parameters stored in memory
2 participants