Skip to content

Commit

Permalink
final touches
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Mar 6, 2024
1 parent 3e974f9 commit 66e219c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@ contract FrontierMerkle is IFrontier {
}

function insertLeaf(bytes32 _leaf) external override(IFrontier) returns (uint256) {
uint256 level = _computeLevel(nextIndex);
uint256 index = nextIndex;
uint256 level = _computeLevel(index);
bytes32 right = _leaf;
for (uint256 i = 0; i < level; i++) {
right = sha256(bytes.concat(frontier[i], right));
}
frontier[level] = right;

return nextIndex++;
nextIndex++;

return index;
}

function root() external view override(IFrontier) returns (bytes32) {
Expand Down
5 changes: 2 additions & 3 deletions l1-contracts/test/harnesses/NewInboxHarness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import {Constants} from "../../src/core/libraries/ConstantsGen.sol";

// TODO: rename to InboxHarness once all the pieces of the new message model are in place.
contract NewInboxHarness is NewInbox {
uint256 public constant FIRST_REAL_TREE_NUM = Constants.INITIAL_L2_BLOCK_NUM + 1;

constructor(address _rollup, uint256 _height) NewInbox(_rollup, _height) {}

function getSize() external view returns (uint256) {
Expand Down Expand Up @@ -42,6 +40,7 @@ contract NewInboxHarness is NewInbox {
}

function getNumTrees() external view returns (uint256) {
return inProgress - 1; // -1 because tree number 1 is not real
// -INITIAL_L2_BLOCK_NUM because tree number INITIAL_L2_BLOCK_NUM is not real
return inProgress - Constants.INITIAL_L2_BLOCK_NUM;
}
}

0 comments on commit 66e219c

Please sign in to comment.