From c63a678b8eee19e48b89a1527dde73eb29f6ccc1 Mon Sep 17 00:00:00 2001 From: Filip Krawczyk Date: Tue, 4 Jun 2024 11:32:25 +0200 Subject: [PATCH] Fix invalid u256 handling on L1-L2 messaging --- l1/src/L1MessagesSender.sol | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/l1/src/L1MessagesSender.sol b/l1/src/L1MessagesSender.sol index 9ea525d..1d895b2 100644 --- a/l1/src/L1MessagesSender.sol +++ b/l1/src/L1MessagesSender.sol @@ -70,7 +70,7 @@ contract L1MessagesSender is Ownable { require(mmrSize >= 1, "Invalid tree size"); require(poseidonMMRRoot != bytes32(0), "Invalid root (Poseidon)"); - _sendPoseidonMMRTreeToL2(poseidonMMRRoot, mmrSize, aggregatorId, mmrId); + _sendPoseidonMMRTreeToL2(poseidonMMRRoot, uint128(mmrSize), aggregatorId, mmrId); } function _sendBlockHashToL2( @@ -96,16 +96,20 @@ contract L1MessagesSender is Ownable { function _sendPoseidonMMRTreeToL2( bytes32 poseidonMMRRoot, - uint256 mmrSize, + uint128 mmrSize, uint256 aggregatorId, uint128 mmrId ) internal { - uint256[] memory message = new uint256[](4); + uint128 aggregatorId_low = uint128(aggregatorId); + uint128 aggregatorId_high = uint128(aggregatorId >> 128); + uint256[] memory message = new uint256[](5); + message[0] = uint256(poseidonMMRRoot); message[1] = mmrSize; - message[2] = aggregatorId; - message[3] = mmrId; + message[2] = aggregatorId_low; + message[3] = aggregatorId_high; + message[4] = mmrId; // Pass along msg.value starknetCore.sendMessageToL2{value: msg.value}(