Skip to content

Commit

Permalink
Merge pull request #327 from 0xPolygonHermez/feature/rename-index
Browse files Browse the repository at this point in the history
rename indexL1 to leafCount
  • Loading branch information
invocamanman committed Sep 13, 2024
2 parents 922d548 + d0ec0b0 commit 0b27044
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 60 deletions.
12 changes: 6 additions & 6 deletions contracts/v2/consensus/validium/PolygonValidiumEtrog.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ contract PolygonValidiumEtrog is PolygonRollupBaseEtrog, IPolygonValidium {
/**
* @notice Allows a sequencer to send multiple batches
* @param batches Struct array which holds the necessary data to append new batches to the sequence
* @param indexL1InfoRoot Index of the L1InfoRoot that will be used in this sequence
* @param l1InfoTreeLeafCount leaf count of the L1InfoRoot that will be used in this sequence
* @param maxSequenceTimestamp Max timestamp of the sequence. This timestamp must be inside a safety range (actual + 36 seconds).
* This timestamp should be equal or higher of the last block inside the sequence, otherwise this batch will be invalidated by circuit.
* @param expectedFinalAccInputHash This parameter must match the acc input hash after hash all the batch data
Expand All @@ -90,7 +90,7 @@ contract PolygonValidiumEtrog is PolygonRollupBaseEtrog, IPolygonValidium {
*/
function sequenceBatchesValidium(
ValidiumBatchData[] calldata batches,
uint32 indexL1InfoRoot,
uint32 l1InfoTreeLeafCount,
uint64 maxSequenceTimestamp,
bytes32 expectedFinalAccInputHash,
address l2Coinbase,
Expand All @@ -117,7 +117,7 @@ contract PolygonValidiumEtrog is PolygonRollupBaseEtrog, IPolygonValidium {

// Get global batch variables
bytes32 l1InfoRoot = globalExitRootManager.l1InfoRootMap(
indexL1InfoRoot
l1InfoTreeLeafCount
);

if (l1InfoRoot == bytes32(0)) {
Expand Down Expand Up @@ -247,7 +247,7 @@ contract PolygonValidiumEtrog is PolygonRollupBaseEtrog, IPolygonValidium {
/**
* @notice Allows a sequencer to send multiple batches
* @param batches Struct array which holds the necessary data to append new batches to the sequence
* @param indexL1InfoRoot Index of the L1InfoRoot that will be used in this sequence
* @param l1InfoTreeLeafCount Index of the L1InfoRoot that will be used in this sequence
* @param maxSequenceTimestamp Max timestamp of the sequence. This timestamp must be inside a safety range (actual + 36 seconds).
* This timestamp should be equal or higher of the last block inside the sequence, otherwise this batch will be invalidated by circuit.
* @param expectedFinalAccInputHash This parameter must match the acc input hash after hash all the batch data
Expand All @@ -257,7 +257,7 @@ contract PolygonValidiumEtrog is PolygonRollupBaseEtrog, IPolygonValidium {
*/
function sequenceBatches(
BatchData[] calldata batches,
uint32 indexL1InfoRoot,
uint32 l1InfoTreeLeafCount,
uint64 maxSequenceTimestamp,
bytes32 expectedFinalAccInputHash,
address l2Coinbase
Expand All @@ -267,7 +267,7 @@ contract PolygonValidiumEtrog is PolygonRollupBaseEtrog, IPolygonValidium {
}
super.sequenceBatches(
batches,
indexL1InfoRoot,
l1InfoTreeLeafCount,
maxSequenceTimestamp,
expectedFinalAccInputHash,
l2Coinbase
Expand Down
6 changes: 3 additions & 3 deletions contracts/v2/lib/PolygonRollupBaseEtrog.sol
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ abstract contract PolygonRollupBaseEtrog is
/**
* @notice Allows a sequencer to send multiple batches
* @param batches Struct array which holds the necessary data to append new batches to the sequence
* @param indexL1InfoRoot Index of the L1InfoRoot that will be used in this sequence
* @param l1InfoTreeLeafCount Index of the L1InfoRoot that will be used in this sequence
* @param maxSequenceTimestamp Max timestamp of the sequence. This timestamp must be inside a safety range (actual + 36 seconds).
* This timestamp should be equal or higher of the last block inside the sequence, otherwise this batch will be invalidated by circuit.
* @param expectedFinalAccInputHash This parameter must match the acc input hash after hash all the batch data
Expand All @@ -412,7 +412,7 @@ abstract contract PolygonRollupBaseEtrog is
*/
function sequenceBatches(
BatchData[] calldata batches,
uint32 indexL1InfoRoot,
uint32 l1InfoTreeLeafCount,
uint64 maxSequenceTimestamp,
bytes32 expectedFinalAccInputHash,
address l2Coinbase
Expand All @@ -438,7 +438,7 @@ abstract contract PolygonRollupBaseEtrog is

// Get global batch variables
bytes32 l1InfoRoot = globalExitRootManager.l1InfoRootMap(
indexL1InfoRoot
l1InfoTreeLeafCount
);

if (l1InfoRoot == bytes32(0)) {
Expand Down
30 changes: 18 additions & 12 deletions test/contractsv2/PolygonRollupManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ describe("Polygon Rollup Manager", () => {
// Sequence Batches
const currentTime = Number((await ethers.provider.getBlock("latest"))?.timestamp);
let currentLastBatchSequenced = 1;
const indexL1infoRoot = 0;
const l1InfoTreeLeafCount = 0;

const height = 32;
const merkleTreeGLobalExitRoot = new MerkleTreeBridge(height);
Expand All @@ -580,7 +580,7 @@ describe("Polygon Rollup Manager", () => {
.connect(trustedSequencer)
.sequenceBatches(
[sequence],
indexL1infoRoot,
l1InfoTreeLeafCount,
currentTime,
expectedAccInputHash2,
trustedSequencer.address
Expand Down Expand Up @@ -921,7 +921,7 @@ describe("Polygon Rollup Manager", () => {
.connect(trustedSequencer)
.sequenceBatches(
[sequenceForced],
indexL1infoRoot,
l1InfoTreeLeafCount,
currentTime,
expectedAccInputHash3,
trustedSequencer.address
Expand Down Expand Up @@ -1360,19 +1360,25 @@ describe("Polygon Rollup Manager", () => {
);

const currentTime = Number((await ethers.provider.getBlock("latest"))?.timestamp);
const indexL1InfoRoot = 0;
const l1InfoTreeLeafCount = 0;
const expectedAccInputHash1 = calculateAccInputHashetrog(
await newZkEVMContract.lastAccInputHash(),
ethers.keccak256(l2txData),
await polygonZkEVMGlobalExitRoot.l1InfoRootMap(indexL1InfoRoot),
await polygonZkEVMGlobalExitRoot.l1InfoRootMap(l1InfoTreeLeafCount),
currentTime,
trustedSequencer.address,
ethers.ZeroHash
);
// Sequence Batches
const txSequenceBatches = await newZkEVMContract
.connect(trustedSequencer)
.sequenceBatches([sequence], indexL1InfoRoot, currentTime, expectedAccInputHash1, trustedSequencer.address);
.sequenceBatches(
[sequence],
l1InfoTreeLeafCount,
currentTime,
expectedAccInputHash1,
trustedSequencer.address
);

const receipt = await txSequenceBatches.wait();
const logs = receipt.logs;
Expand Down Expand Up @@ -1971,7 +1977,7 @@ describe("Polygon Rollup Manager", () => {

// Sequence Batches
const currentTime = Number((await ethers.provider.getBlock("latest"))?.timestamp);
const indexL1InfoRoot = 0;
const l1InfoTreeLeafCount = 0;

const lastBlock = await ethers.provider.getBlock("latest");

Expand All @@ -1991,7 +1997,7 @@ describe("Polygon Rollup Manager", () => {
.connect(trustedSequencer)
.sequenceBatches(
[sequence],
indexL1InfoRoot,
l1InfoTreeLeafCount,
currentTime,
expectedAccInputHash2,
trustedSequencer.address
Expand Down Expand Up @@ -2650,7 +2656,7 @@ describe("Polygon Rollup Manager", () => {

expect(await newZkEVMContract.dataAvailabilityProtocol()).to.be.equal(PolygonDataCommitee.target);
await PolygonDataCommitee.setupCommittee(0, [], "0x");
const indexL1InfoRoot = 0;
const l1InfoTreeLeafCount = 0;
const lastBlock = await ethers.provider.getBlock("latest");

const rootSC = await polygonZkEVMGlobalExitRoot.getRoot();
Expand All @@ -2667,7 +2673,7 @@ describe("Polygon Rollup Manager", () => {
.connect(trustedSequencer)
.sequenceBatchesValidium(
[sequence],
indexL1InfoRoot,
l1InfoTreeLeafCount,
currentTime,
expectedAccInputHash2,
trustedSequencer.address,
Expand Down Expand Up @@ -2922,7 +2928,7 @@ describe("Polygon Rollup Manager", () => {

// Sequence Batches
const currentTime = Number((await ethers.provider.getBlock("latest"))?.timestamp);
const indexL1InfoRoot = 0;
const l1InfoTreeLeafCount = 0;
const expectedAccInputHash = calculateAccInputHashetrog(
await PolygonZKEVMV2Contract.lastAccInputHash(),
ethers.keccak256(l2txData),
Expand All @@ -2934,7 +2940,7 @@ describe("Polygon Rollup Manager", () => {
await expect(
PolygonZKEVMV2Contract.connect(trustedSequencer).sequenceBatches(
[sequence],
indexL1InfoRoot,
l1InfoTreeLeafCount,
currentTime,
expectedAccInputHash,
trustedSequencer.address
Expand Down
10 changes: 5 additions & 5 deletions test/contractsv2/PolygonRollupManagerUpgrade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ describe("Polygon Rollup manager upgraded", () => {
// Sequence Batches
const currentTime = Number((await ethers.provider.getBlock("latest"))?.timestamp);
let currentLastBatchSequenced = 1;
const indexL1infoRoot = 0;
const l1InfoTreeLeafCount = 0;

const height = 32;
const merkleTreeGLobalExitRoot = new MerkleTreeBridge(height);
Expand All @@ -658,7 +658,7 @@ describe("Polygon Rollup manager upgraded", () => {
.connect(trustedSequencer)
.sequenceBatches(
[sequence],
indexL1infoRoot,
l1InfoTreeLeafCount,
currentTime,
expectedAccInputHash2,
trustedSequencer.address
Expand Down Expand Up @@ -994,7 +994,7 @@ describe("Polygon Rollup manager upgraded", () => {
.connect(trustedSequencer)
.sequenceBatches(
[sequenceForced],
indexL1infoRoot,
l1InfoTreeLeafCount,
currentTime,
expectedAccInputHash3,
trustedSequencer.address
Expand Down Expand Up @@ -1360,7 +1360,7 @@ describe("Polygon Rollup manager upgraded", () => {

const rootSC = await polygonZkEVMGlobalExitRoot.getRoot();
const rootJS = merkleTreeGLobalExitRoot.getRoot();
const indexL1infoRoot = 0;
const l1InfoTreeLeafCount = 0;

expect(rootSC).to.be.equal(rootJS);

Expand All @@ -1378,7 +1378,7 @@ describe("Polygon Rollup manager upgraded", () => {
.connect(trustedSequencer)
.sequenceBatches(
[sequence],
indexL1infoRoot,
l1InfoTreeLeafCount,
currentTime,
expectedAccInputHash2,
trustedSequencer.address
Expand Down
Loading

0 comments on commit 0b27044

Please sign in to comment.