From 2b4f1835ccbc6bd9d7a672fe0afc6bc27059927a Mon Sep 17 00:00:00 2001 From: Rahul Kothari Date: Mon, 22 May 2023 16:26:34 +0000 Subject: [PATCH] change currentVersion to track numberOfVersions to behave like a counter. --- l1-contracts/src/core/messagebridge/Registry.sol | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/l1-contracts/src/core/messagebridge/Registry.sol b/l1-contracts/src/core/messagebridge/Registry.sol index 183deb71d44e..ff94195ff60d 100644 --- a/l1-contracts/src/core/messagebridge/Registry.sol +++ b/l1-contracts/src/core/messagebridge/Registry.sol @@ -14,25 +14,22 @@ import {DataStructures} from "@aztec/core/libraries/DataStructures.sol"; * @notice Keeps track of important information for L1<>L2 communication. */ contract Registry is IRegistry { - // starts with version 1. Incremented on each upgrade. - uint256 public currentVersion; + uint256 public numberOfVersions; DataStructures.RegistrySnapshot internal currentSnapshot; mapping(uint256 version => DataStructures.RegistrySnapshot snapshot) internal snapshots; // todo: this function has to be permissioned. /** * Creates a new snapshot of the registry - * @dev starts with version 1. * @param _rollup - The address of the rollup contract * @param _inbox - The address of the inbox contract * @param _outbox - The address of the outbox contract */ function upgrade(address _rollup, address _inbox, address _outbox) external { - currentVersion++; DataStructures.RegistrySnapshot memory newSnapshot = DataStructures.RegistrySnapshot(_rollup, _inbox, _outbox, block.number); currentSnapshot = newSnapshot; - snapshots[currentVersion] = newSnapshot; + snapshots[numberOfVersions++] = newSnapshot; } /** @@ -61,6 +58,7 @@ contract Registry is IRegistry { /** * Fetches a snapshot of the registry indicated by `version` + * @dev the version is 0 indexed, so the first snapshot is version 0. * @param _version - The version of the rollup to return (i.e. which snapshot) * @return the snapshot */