Skip to content

Conversation

@partylikeits1983
Copy link
Contributor

@partylikeits1983 partylikeits1983 commented Jan 12, 2026

Resolves #2220
Builds on top of: #2238

This PR implements this solidity function in MASM:

function getLeafValue(
    uint8 leafType,
    uint32 originNetwork,
    address originAddress,
    uint32 destinationNetwork,
    address destinationAddress,
    uint256 amount,
    bytes32 metadataHash
) public pure returns (bytes32) {
    return
        keccak256(
            abi.encodePacked(
                leafType,
                originNetwork,
                originAddress,
                destinationNetwork,
                destinationAddress,
                amount,
                metadataHash
            )
        );
}

To quickly test that the masm implementation of get_leaf_value matches the agglayer Solidity implementation, you can expirement by running this basic solidity contract in Remix:

Link to Remix: Remix

Copy and paste this code into remix and run this testtest_keccak_hash_get_leaf_value:

cargo test test_keccak_hash_get_leaf_value --package miden-testing
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract KeccakU256 {
    function getLeafValue(
        uint8 leafType,
        uint32 originNetwork,
        address originAddress,
        uint32 destinationNetwork,
        address destinationAddress,
        uint256 amount,
        bytes32 metadataHash
    ) public pure returns (bytes32) {
        return keccak256(
            abi.encodePacked(
                leafType,
                originNetwork,
                originAddress,
                destinationNetwork,
                destinationAddress,
                amount,
                metadataHash
            )
        );
    }

    function hashFixedLeafHardhat() external pure returns (bytes32) {
        uint8 leafType = 0;
        uint32 originNetwork = 0;
        address tokenAddress = 0x1234567890123456789012345678901234567890;
        uint32 destinationNetwork = 1;
        address destinationAddress = 0x0987654321098765432109876543210987654321;
        uint256 amount = 1;
        bytes32 metadataHash =
            0x2cdc14cacf6fec86a549f0e4d01e83027d3b10f29fa527c1535192c1ca1aac81;

        return getLeafValue(
            leafType,
            originNetwork,
            tokenAddress,
            destinationNetwork,
            destinationAddress,
            amount,
            metadataHash
        );
    }
}

@partylikeits1983 partylikeits1983 changed the base branch from next to agglayer January 12, 2026 16:47
@partylikeits1983 partylikeits1983 added the no changelog This PR does not require an entry in the `CHANGELOG.md` file label Jan 12, 2026
@partylikeits1983 partylikeits1983 changed the base branch from agglayer to ajl-agglayer-asset-conversion January 13, 2026 16:10
@partylikeits1983 partylikeits1983 changed the base branch from ajl-agglayer-asset-conversion to ajl-solidity-type-conversions January 13, 2026 16:10
@partylikeits1983 partylikeits1983 marked this pull request as ready for review January 13, 2026 16:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@mmagician
Copy link
Contributor

mmagician commented Jan 14, 2026

Also, for completeness we should be looking at V2 of the AggLayer contracts. For getLeafValue the logic doesn't change, but it does for its caller _verifyLeafBridge

@partylikeits1983
Copy link
Contributor Author

@mmagician Lets first merge #2238, then will rebase this PR against agglayer branch. Same with #2270

Base automatically changed from ajl-solidity-type-conversions to agglayer January 16, 2026 08:13
Base automatically changed from agglayer to next January 16, 2026 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agglayer no changelog This PR does not require an entry in the `CHANGELOG.md` file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement getLeafValue() in MASM

3 participants