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

Get leaves from memory in processMultiProofCalldata #5140

Conversation

Amxx
Copy link
Collaborator

@Amxx Amxx commented Aug 2, 2024

Following the audit discussion.

Note that is reverting a (undocumented breaking) change that we introduced in #4887
5.0 does use memory for leaves in the calldata variants:

Edit: I also took this opportunity to fix some missing {suffix} in the code generation.

@Amxx Amxx added this to the 5.1-after-freeze milestone Aug 2, 2024
@Amxx Amxx requested review from ernestognw and cairoeth August 2, 2024 21:05
Copy link

changeset-bot bot commented Aug 2, 2024

⚠️ No Changeset found

Latest commit: 250325d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Member

@ernestognw ernestognw left a comment

Choose a reason for hiding this comment

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

Looks good, but I'm wondering whether it's still useful to have the following two versions:

function multiProofVerifyCalldata(
    bytes32[] calldata proof,
    bool[] calldata proofFlags,
    bytes32 root,
    bytes32[] calldata leaves,
    function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool) {
    return processMultiProofCalldata(proof, proofFlags, leaves, hasher) == root;
}

function multiProofVerifyCalldata(
    bytes32[] calldata proof,
    bool[] calldata proofFlags,
    bytes32 root,
    bytes32[] calldata leaves
) internal pure returns (bool) {
    return processMultiProofCalldata(proof, proofFlags, leaves) == root;
}

They seem rather unnecessary given that we're copying leaves to memory when using the underlying processMultiProof

@Amxx
Copy link
Collaborator Author

Amxx commented Aug 2, 2024

Right, I forgot about the leaves location in multiProofVerifyCalldata. Fixed.

Copy link
Member

@ernestognw ernestognw left a comment

Choose a reason for hiding this comment

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

Thanks @Amxx

@Amxx Amxx merged commit 24a641d into OpenZeppelin:master Aug 2, 2024
19 checks passed
@Amxx Amxx deleted the refactor/crypto/merkle-proof/mutliproof-leaves-from-memory branch August 2, 2024 22:00
Amxx added a commit to Amxx/openzeppelin-contracts that referenced this pull request Aug 2, 2024
Signed-off-by: Hadrien Croubois <hadrien.croubois@gmail.com>
Amxx added a commit to Amxx/openzeppelin-contracts that referenced this pull request Aug 2, 2024
Signed-off-by: Hadrien Croubois <hadrien.croubois@gmail.com>
Amxx added a commit that referenced this pull request Oct 2, 2024
Signed-off-by: Hadrien Croubois <hadrien.croubois@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants