Skip to content

Commit ad0ddab

Browse files
committed
fix(fast-inbox): correct portal forge-test index expectations for the flip (A-1384)
The flip switched the inbox message index to a compact cumulative counter (totalMessagesInserted, zero-based), but left the fee-portal and token-portal forge tests asserting the old lag-based tree-geometry index (lag * SIZE). Update depositToAztecPublic and TokenPortal expectations to the compact index; the MessageSent checkpointNumber field and the consume/lag machinery are unchanged at this branch, so only the index expectations move. Without this, cd l1-contracts && forge test failed 4 tests once the lint gate stopped masking it.
1 parent ad26547 commit ad0ddab

2 files changed

Lines changed: 15 additions & 14 deletions

File tree

l1-contracts/test/fee_portal/depositToAztecPublic.t.sol

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,9 @@ contract DepositToAztecPublic is Test {
8282
uint256 amount = 100 ether;
8383

8484
Inbox inbox = Inbox(address(Rollup(address(registry.getCanonicalRollup())).getInbox()));
85-
// The first message goes into tree (INITIAL_CHECKPOINT_NUMBER + LAG) at index 0
86-
// Global index = (inProgress - INITIAL_CHECKPOINT_NUMBER) * SIZE + 0
87-
// = ((INITIAL_CHECKPOINT_NUMBER + LAG) - INITIAL_CHECKPOINT_NUMBER) * SIZE
88-
// = LAG * SIZE
89-
uint256 SIZE = 2 ** Constants.L1_TO_L2_MSG_SUBTREE_HEIGHT;
90-
uint256 expectedIndex = TestConstants.AZTEC_INBOX_LAG * SIZE;
85+
// Compact cumulative index (AZIP-22 Fast Inbox): the first message against a fresh Inbox has index 0
86+
// (equal to the number of messages inserted before it), regardless of the inbox lag.
87+
uint256 expectedIndex = 0;
9188

9289
// The purpose of including the function selector is to make the message unique to that specific call. Note that
9390
// it has nothing to do with calling the function.
@@ -156,16 +153,18 @@ contract DepositToAztecPublic is Test {
156153
"Initial inProgress should be INITIAL_CHECKPOINT_NUMBER + lag"
157154
);
158155
state.initialInProgress = state.testInbox.getInProgress();
159-
state.expectedIndex1 = state.lag * state.SIZE;
160-
state.expectedIndex2 = state.lag * state.SIZE + 1;
156+
// Compact cumulative index (AZIP-22 Fast Inbox): messages are indexed by insertion order from 0,
157+
// independent of the lag-based tree geometry.
158+
state.expectedIndex1 = 0;
159+
state.expectedIndex2 = 1;
161160

162161
vm.prank(state.testToken.owner());
163162
state.testToken.mint(address(this), state.amount * 2);
164163
state.testToken.approve(address(state.testFeeJuicePortal), state.amount * 2);
165164

166165
// Send first message
167166
(, uint256 index1) = state.testFeeJuicePortal.depositToAztecPublic(state.to, state.amount, state.secretHash1);
168-
assertEq(index1, state.expectedIndex1, "First message index should be lag * SIZE");
167+
assertEq(index1, state.expectedIndex1, "First message index should be 0 (compact cumulative)");
169168
assertEq(
170169
state.testInbox.getInProgress(),
171170
state.expectedInProgress,
@@ -175,7 +174,7 @@ contract DepositToAztecPublic is Test {
175174

176175
// Send second message
177176
(, uint256 index2) = state.testFeeJuicePortal.depositToAztecPublic(state.to, state.amount, state.secretHash2);
178-
assertEq(index2, state.expectedIndex2, "Second message index should be lag * SIZE + 1");
177+
assertEq(index2, state.expectedIndex2, "Second message index should be 1 (compact cumulative)");
179178
assertEq(
180179
state.testInbox.getInProgress(),
181180
state.expectedInProgress,

l1-contracts/test/portals/TokenPortal.t.sol

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ contract TokenPortalTest is Test {
118118
testERC20.mint(address(this), mintAmount);
119119
testERC20.approve(address(tokenPortal), mintAmount);
120120

121-
// Check for the expected message
122-
uint256 expectedIndex = (FIRST_REAL_TREE_NUM - 1) * L1_TO_L2_MSG_SUBTREE_SIZE;
121+
// Check for the expected message.
122+
// Compact cumulative index (AZIP-22 Fast Inbox): the first message against a fresh Inbox has index 0.
123+
uint256 expectedIndex = 0;
123124
DataStructures.L1ToL2Msg memory expectedMessage = _createExpectedMintPrivateL1ToL2Message(expectedIndex);
124125

125126
bytes32 expectedLeaf = expectedMessage.sha256ToField();
@@ -146,8 +147,9 @@ contract TokenPortalTest is Test {
146147
testERC20.mint(address(this), mintAmount);
147148
testERC20.approve(address(tokenPortal), mintAmount);
148149

149-
// Check for the expected message
150-
uint256 expectedIndex = (FIRST_REAL_TREE_NUM - 1) * L1_TO_L2_MSG_SUBTREE_SIZE;
150+
// Check for the expected message.
151+
// Compact cumulative index (AZIP-22 Fast Inbox): the first message against a fresh Inbox has index 0.
152+
uint256 expectedIndex = 0;
151153
DataStructures.L1ToL2Msg memory expectedMessage = _createExpectedMintPublicL1ToL2Message(expectedIndex);
152154
bytes32 expectedLeaf = expectedMessage.sha256ToField();
153155
bytes16 expectedHash = bytes16(keccak256(abi.encodePacked(inbox.getState().rollingHash, expectedLeaf)));

0 commit comments

Comments
 (0)