MezzMigrator
Inherits: ReentrancyGuardUpgradeable, HubOwnableUUPSUpgradeable, IMezzMigrator
Author: Daniel Yamagata & Naveen Ailawadi
The Mezz Migrator is responsible for upgrading core contracts to newer versions, resetting the latest versions to patched implementations, and providing the address of the latest version of an implementation
The data used for a reinitialization function is validated such that a team cannot manage its owners, modules, or guard during an upgrade
State Variables
MezzMigratorStorageLocation
bytes32 private constant MezzMigratorStorageLocation =
0x14b40c2177fe6203daba99a4176ffdb237b2208d924b24ad9173fc87b13b6a00;
Functions
_getMezzMigratorStorage
function _getMezzMigratorStorage() internal pure returns (MezzMigratorStorage storage $);
constructor
constructor(address _mezzHub) HubOwnableUUPSUpgradeable(_mezzHub);
init
Initializer for the Mezz Migrator. Sets up the V1 implementations for the given Core IDs. Only callabe by the owner of the Mezz Hub
Even though Mezz Migrator is not UUPSUpgradeable, an initializer is used to set up the V1 implementations This is due to the fact that implementations need to be aware of the Mezz Migrator upon construction Therefore, the Mezz Migrator is unable to use them in its own construction
function init(bytes32[] memory coreIds, address[] memory implementations) external initializer onlyHubOwner;
Parameters
coreIds
bytes32[]
The coreIds of the implementations
implementations
address[]
The addresses of the implementations
__MezzMigrator_init
function __MezzMigrator_init(bytes32[] memory coreIds, address[] memory implementations) internal onlyInitializing;
setNewCoreVersion
Sets a 'newImplementation' for the latest version of 'coreId'. Only callable by the Mezz Hub Owner
function setNewCoreVersion(bytes32 coreId, address newImplementation) external onlyHubOwner;
Parameters
coreId
bytes32
The coreId of the implementation
newImplementation
address
The address of the new implementation
resetLatestCoreVersion
Resets the latest version associated with the Core ID back to the prior version. Only callable by the Mezz Hub Owner
Does not change the latest core version. Only resets the latest version's implementation for a given core ID
function resetLatestCoreVersion(bytes32 coreId, address newImplementation) external onlyHubOwner;
Parameters
coreId
bytes32
The core ID to reset the latest version for
newImplementation
address
The new implementation to set the latest version to
upgradeToNewerVersion
Upgrades the caller, who is assumed to be a contract, to a newer version
This function is not access controlled
function upgradeToNewerVersion(uint256 newVersion, bytes memory data) external pausable nonReentrant;
resetToPatchedLatestVersion
Resets the caller's contract to the latest version, which should be patched beforehand. Only callabe if the protocol state is paused or frozen
The caller must be the latest version to be able to reset the latest patched version
function resetToPatchedLatestVersion(bytes memory data) external nonReentrant;
Parameters
data
bytes
Data used for the initialization
getLatestVersion
Returns the latest version for a given core implementation
function getLatestVersion(bytes32 coreId) external view returns (uint256);
Returns
<none>
uint256
The latest version as a uint256
getLatestCoreImplementation
Returns the latest implementation for a given core ID
function getLatestCoreImplementation(bytes32 coreId) external view returns (address);
getCoreImplementationByVersion
Returns the implementation for a given core ID and version
function getCoreImplementationByVersion(bytes32 coreId, uint256 version) external view returns (address);
_setUpV1CoreIds
Validates and sets the initial core IDs and implementations in the constructor
function _setUpV1CoreIds(bytes32[] memory coreIds, address[] memory implementations) internal;
_validateImplementationSupportsCredentialedInterface
Validates that the implementation supports the 'ICredentialed' interface
function _validateImplementationSupportsCredentialedInterface(address implementation) internal view;
_validateLatestVersion
Reverts if the latest version is zero
function _validateLatestVersion(uint256 latestVersion, bytes32 coreId) internal pure;
_validateVersion
Reverts if 'version is zero or greater than 'latestVersion'
function _validateVersion(uint256 version, uint256 latestVersion) internal pure;
_validateImplementationVersion
Validates that the implementation version is equal to the 'expectedVersion'
function _validateImplementationVersion(uint256 expectedVersion, address implementation) internal pure;
_validateImplementationCoreId
Validates that the implementation core ID is equal to the passed in core ID
function _validateImplementationCoreId(bytes32 coreId, address implementation) internal pure;
Structs
MezzMigratorStorage
struct MezzMigratorStorage {
mapping(bytes32 => mapping(uint256 => address)) _implementationByCoreIdByVersion;
mapping(bytes32 => uint256) _implementationVersion;
}