Changes v0.3.0 --> v0.3.1
Motivation
The motivation behind these changes is to enable the upgrade of a zkEVM rollup to a pessimistic consensus rollup (PP).
Our goal has been to introduce this functionality with minimal modifications across all system components. To support this transition, we designed a migration mechanism that integrates smoothly into the current rollup architecture.
Specifically, we added a new function to initiate the migration process, and structured the system so that the migration is automatically finalized upon the successful verification of the first proof following the upgrade. This ensures consistency and security during the transition while maintaining alignment with existing rollup lifecycle flows.
Sources
- New TAG
- Git diff PR
- Git diff v10.1.0-rc.5 - v11.0.0-rc.2
Contract Updates for Migration to Pessimistic Proof (PP)
This update introduces a new version (al-v0.3.1
) of the PolygonRollupManager
contract, focusing on enabling rollup migrations from a state transition system to a pessimistic proof (PP) system. The following core updates were implemented:
This update (version al-v0.3.1
) of the PolygonRollupManager contract includes extended functionality to support the migration of rollups from a standard state transition mechanism (ZK) to a pessimistic proof (PP) system. The following components and logic were added or updated to enable this capability:
Flow migration
The migration flow can be found explained in this section: flow migration.
PolygonRollupManager
New Mapping and Events:
-
isRollupMigrating
: A new mapping has been added to keep track of rollups that are in the process of migrating. -
InitMigration
andCompletedMigration
: Two events are emitted to signal the start and completion of the migration flow, respectively.
/**
* @dev Emitted when `initMigration` is called
* @param rollupID Rollup ID that is being migrated
* @param newRollupTypeID New rollup type ID that the rollup will be migrated to
*/
event InitMigration(uint32 indexed rollupID, uint32 newRollupTypeID);
/**
* @dev Emitted when a rollup completes the migration to Pessimistic or ALGateway, just after proving bootstrapped batch
* @param rollupID Rollup ID that completed the migration
*/
event CompletedMigration(uint32 indexed rollupID);
New Error Conditions
NewRollupTypeMustBePessimisticOrALGateway
: Thrown when trying to migrate a rollup to a non pessimistic or ALGateway rollup type withinitMigration
function.InvalidNewLocalExitRoot
: Thrown when trying to finish a migration of a rollup to a pessimistic rollup type withverifyPessimisticTrustedAggregator
function and the proposed new local exit root does not match the expected new local exit root.
Remedations audit
- Comment localExitRoot: add new comment
- Renamed legacy vars function rollupIDToRollupDataDeserialized
- Unifying logic sequenced batches check
PolygonZkEVMBridgeV2
Check global index
It has been detected that a new check is necessary for the globalIndex
to ensure that unused bits are set to 0.
Commit with new check for global index in internal function _verifyLeaf
:
- If
globalIndex & _GLOBAL_INDEX_MAINNET_FLAG != 0
check all unused bits are 0 with:require( _GLOBAL_INDEX_MAINNET_FLAG + uint256(leafIndex) == globalIndex, InvalidGlobalIndex() );
- Else, check all unused bits bits are 0 with:
require( (uint256(indexRollup) << uint256(32)) + uint256(leafIndex) == globalIndex, InvalidGlobalIndex() );
- Add new error for this check:
/** * @dev Thrown when the global index has any unused bits set to 1 */ error InvalidGlobalIndex();
Push Claim Event
Commit with fix for reentrancy call: Now, the event will occur before the call. This way, there won’t be an ordering error if there is reentrancy.
- Before:
- call function - SC call reentrancy - ClaimEvent
- Now:
- call function - ClaimEvent - SC call reentrancy
Internal audit fixes
Commit with follow changes:
IPolygonRollupManager
: Typo in commentPolygonRollupManagerNotUpgraded
: Updatereinitializer(4)
->reinitializer(5)