Skip to content

Commit

Permalink
check chainID range
Browse files Browse the repository at this point in the history
  • Loading branch information
invocamanman committed Feb 16, 2024
1 parent 4f894e5 commit 42bdaef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion contracts/v2/PolygonRollupManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ contract PolygonRollupManager is
/**
* @notice Create a new rollup
* @param rollupTypeID Rollup type to deploy
* @param chainID ChainID of the rollup, must be a new one
* @param chainID ChainID of the rollup, must be a new one, can not have more than 32 bits
* @param admin Admin of the new created rollup
* @param sequencer Sequencer of the new created rollup
* @param gasTokenAddress Indicates the token address that will be used to pay gas fees in the new rollup
Expand Down Expand Up @@ -616,6 +616,12 @@ contract PolygonRollupManager is
revert RollupTypeObsolete();
}

// check chainID max value
// Currently we have this limitation by the circuit, might be removed in a future
if (chainID > type(uint32).max) {
revert ChainIDOutOfRange();
}

// Check chainID nullifier
if (chainIDToRollupID[chainID] != 0) {
revert ChainIDAlreadyExist();
Expand Down
5 changes: 5 additions & 0 deletions contracts/v2/interfaces/IPolygonRollupManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,9 @@ interface IPolygonRollupManager {
* @dev When verifying proof for multiple roolups and they are not ordered by ID
*/
error RollupIDNotAscendingOrder();

/**
* @dev When try to create a new rollup and set a chainID bigger than 32 bits
*/
error ChainIDOutOfRange();
}

0 comments on commit 42bdaef

Please sign in to comment.