From e26a4e88d29a293d42d106657b6384d7609f1a46 Mon Sep 17 00:00:00 2001 From: invocamanman Date: Fri, 16 Feb 2024 12:15:15 +0100 Subject: [PATCH] check chainID range --- contracts/v2/PolygonRollupManager.sol | 8 +++++++- contracts/v2/interfaces/IPolygonRollupManager.sol | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/contracts/v2/PolygonRollupManager.sol b/contracts/v2/PolygonRollupManager.sol index 76f3902ab..f394746a8 100644 --- a/contracts/v2/PolygonRollupManager.sol +++ b/contracts/v2/PolygonRollupManager.sol @@ -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 @@ -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(); diff --git a/contracts/v2/interfaces/IPolygonRollupManager.sol b/contracts/v2/interfaces/IPolygonRollupManager.sol index da86f2b9c..a3c26408b 100644 --- a/contracts/v2/interfaces/IPolygonRollupManager.sol +++ b/contracts/v2/interfaces/IPolygonRollupManager.sol @@ -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(); }