Rollup local exit trees
The L2 bridge contract manages a special Merkle tree called a local exit tree for each network that participates in bridging and claiming which is updated by the PolygonZkEVMGlobalExitRootL2.sol contract. Data frombridgeAsset() and bridgeMessage() calls on the bridge is stored in leaf nodes on the local exit trees.
Exit tree for rollups
The roots of the L2 local exit trees feed into a single exit tree that manages state from all participating L2 rollups. The state lives in the L1 realm and is accessed at sequencing time. The L2 local exit root is accessible on the rollup manager by calling thegetRollupExitRoot() method.
L1 local exit tree
Every time there is a call tobridgeAsset() and bridgeMessage() on the bridge at the L1 Ethereum level, the data is stored in a leaf node on the L1 local exit tree.
L1 info tree
The L1 info tree is stored in the PolygonZkEVMGlobalExitRootV2.sol contract also known as the global exit root manager. All subtrees exit roots feed into the leaves of the L1 info tree, which contains the global exit root (GER). The GER is the fingerprint of the information stored in all trees, and thus represents the global state of the system.Exit leaves
Two constants define transaction leaf types in the bridge contract.int32 originNetwork: Origin network ID, where the original asset belongs.address originTokenAddress: IfleafType = 0, Origin network token address (0x0000...0000) is reserved for ether. IfleafType = 1,msg.senderof the message.uint32 destinationNetwork: Bridging destination network ID.address destinationAddress: Address that receives the bridged asset in the destination network.uint256 leafAmount: Amount of tokens/ether to bridge.bytes32 keccak256(metadata): Hash of the metadata. This metadata contains information about assets transferred or the message payload.
Updating system state
The system uses a set of exit tree roots to manage system state. Leaves of the trees point to transaction data such as detailed above. Adding a new leaf to the tree triggers an update to the exit tree root which then propagates to an update on the global exit tree root. Using Merkle tree exit roots in this way, referenced by the bridge contracts and accessible to thePolygonRollupManager contract with getters, the bridge contract triggers data synchronization across L1 and L2, including at the sequencer and state db level.
The use of two distinct global exit root manager contracts for L1 and L2, as well as separate logic for the sequencing flow and the bridge contract, allows for extensive network interoperability. Meanwhile, all asset transfers can be validated by any L1 and L2 node due to the accessibility of state data.
The exit roots are modified in two key flows; sequencing and bridging.
Sequencing flow
ThePolygonZkEVMGlobalExitRootV2 contract manages updates to the exit roots on sequencing. The contract calls updateExitRoot(...) on the GlobalExitRootManager during the sequencing flow to add an exit leaf to the relevant exit tree.

- Initiate update:
PolygonZkEVMEtroginitiates the update process by callingupdateExitRootsonPolygonRollupBaseEtrog. - Retrieve current roots:
PolygonRollupBaseEtrogretrieves the current local and global exit roots fromPolygonZkEVMGlobalExitRootL2andPolygonZkEVMGlobalExitRootV2respectively. - Compute new exit root:
PolygonRollupBaseEtrogcomputes the new exit root based on the retrieved local and global exit roots. - Update local exit root:
PolygonRollupBaseEtrogupdates the local exit root inPolygonZkEVMGlobalExitRootL2. - Update global exit root:
PolygonRollupBaseEtrogupdates the global exit root inPolygonZkEVMGlobalExitRootV2. - Verify updated exit root:
PolygonRollupBaseEtrogcallsgetRollupExitRootonPolygonRollupManagerto verify the updated exit root.
Bridging flow
When bridging, the global exit root is updated if theforceUpdateGlobalExitRoot variable is set to true.

- The user interacts with the
PolygonZkEVMBridgeV2contract by calling thebridge()function. PolygonZkEVMBridgeV2callsupdateLocalExitRoot()onPolygonZkEVMGlobalExitRootL2, which updates the local exit root.- If
forceUpdateGlobalExitRootis set to true,PolygonZkEVMBridgeV2callsupdateGlobalExitRoot()onPolygonZkEVMGlobalExitRootV2, which updates the global exit root.