PriorityTree

Git Source

Functions

getFirstUnprocessedPriorityTx

Returns zero if and only if no operations were processed from the tree

function getFirstUnprocessedPriorityTx(Tree storage _tree)
  internal
  view
  returns (uint256);

Returns

NameTypeDescription
<none>uint256Index of the oldest priority operation that wasn't processed yet

getTotalPriorityTxs

function getTotalPriorityTxs(Tree storage _tree)
  internal
  view
  returns (uint256);

Returns

NameTypeDescription
<none>uint256The total number of priority operations that were added to the priority queue, including all processed ones

getSize

function getSize(Tree storage _tree) internal view returns (uint256);

Returns

NameTypeDescription
<none>uint256The total number of unprocessed priority operations in a priority queue

push

Add the priority operation to the end of the priority queue

function push(Tree storage _tree, bytes32 _hash) internal;

setup

Set up the tree

function setup(Tree storage _tree, uint256 _startIndex) internal;

getRoot

function getRoot(Tree storage _tree) internal view returns (bytes32);

Returns

NameTypeDescription
<none>bytes32Returns the tree root.

isHistoricalRoot

function isHistoricalRoot(Tree storage _tree, bytes32 _root)
  internal
  view
  returns (bool);

Parameters

NameTypeDescription
_treeTree
_rootbytes32The root to check.

Returns

NameTypeDescription
<none>boolReturns true if the root is a historical root.

processBatch

Process the priority operations of a batch.

Note, that the function below only checks that a certain segment of items is present in the tree. It does not check that e.g. there are no zero items inside the provided itemHashes, so in theory proofs that include non-existing priority operations could be created. This function relies on the fact that the itemHashes of _priorityOpsData are hashes of valid priority transactions. This fact is ensured by the fact the rolling hash of those is sent to the Executor by the bootloader and so assuming that zero knowledge proofs are correct, so is the structure of the itemHashes.

function processBatch(
  Tree storage _tree,
  PriorityOpsBatchInfo memory _priorityOpsData
) internal;

skipUntil

Allows to skip a certain number of operations.

It is used when the corresponding transactions have been processed by priority queue.

function skipUntil(Tree storage _tree, uint256 _lastUnprocessed) internal;

Parameters

NameTypeDescription
_treeTree
_lastUnprocesseduint256The new expected id of the unprocessed transaction.

initFromCommitment

Initialize a chain from a commitment.

function initFromCommitment(
  Tree storage _tree,
  PriorityTreeCommitment memory _commitment
) internal;

l1Reinit

Reinitialize the tree from a commitment on L1.

function l1Reinit(Tree storage _tree, PriorityTreeCommitment memory _commitment)
  internal;

checkGWReinit

Reinitialize the tree from a commitment on GW.

function checkGWReinit(
  Tree storage _tree,
  PriorityTreeCommitment memory _commitment
) internal view;

getCommitment

Returns the commitment to the priority tree.

function getCommitment(Tree storage _tree)
  internal
  view
  returns (PriorityTreeCommitment memory commitment);

Structs

Tree

struct Tree {
  uint256 startIndex;
  uint256 unprocessedIndex;
  mapping(bytes32 => bool) historicalRoots;
  DynamicIncrementalMerkle.Bytes32PushTree tree;
}