Skip to content

Commit

Permalink
Save historical roots
Browse files Browse the repository at this point in the history
  • Loading branch information
ly0va committed Jun 17, 2024
1 parent ca4ec9b commit b08fe66
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import {DynamicIncrementalMerkle} from "../../common/libraries/openzeppelin/IncrementalMerkle.sol";
import {Merkle} from "./Merkle.sol";
Expand All @@ -15,6 +18,7 @@ library PriorityTree {
struct Tree {
uint256 startIndex;
uint256 unprocessedIndex; // relative to `startIndex`
mapping(bytes32 => bool) historicalRoots;
DynamicIncrementalMerkle.Bytes32PushTree tree;
}

Expand All @@ -36,7 +40,8 @@ library PriorityTree {

/// @notice Add the priority operation to the end of the priority queue
function push(Tree storage _tree, bytes32 _hash) internal {
_tree.tree.push(_hash);
(, bytes32 newRoot) = _tree.tree.push(_hash);
_tree.historicalRoots[newRoot] = true;
}

function setup(Tree storage _tree, bytes32 _zero, uint256 _startIndex) internal {
Expand All @@ -54,7 +59,7 @@ library PriorityTree {
_tree.unprocessedIndex,
_priorityOpsData.itemHashes
);
require(expectedRoot == _tree.tree.root(), "");
require(_tree.historicalRoots[expectedRoot], "");

Check failure on line 62 in l1-contracts/contracts/state-transition/libraries/PriorityTree.sol

View workflow job for this annotation

GitHub Actions / lint

GC: Use Custom Errors instead of require statements

Check failure on line 62 in l1-contracts/contracts/state-transition/libraries/PriorityTree.sol

View workflow job for this annotation

GitHub Actions / lint

GC: Use Custom Errors instead of require statements

Check failure on line 62 in l1-contracts/contracts/state-transition/libraries/PriorityTree.sol

View workflow job for this annotation

GitHub Actions / lint

GC: Use Custom Errors instead of require statements
_tree.unprocessedIndex += _priorityOpsData.itemHashes.length;
}
}
Expand Down

0 comments on commit b08fe66

Please sign in to comment.