---
sip: 151
network: Ethereum
title: Migration Contracts for Upgrades
status: Implemented
author: Justin J Moses (@justinjmoses)
created: 2021-06-21T00:00:00.000Z
type: Governance
---

<!--You can leave these HTML comments in your merged SIP and delete the visible duplicate text guides, they will not appear and may be helpful to refer to if you edit it again. This is the suggested template for new SIPs. Note that an SIP number will be assigned by an editor. When opening a pull request to submit your SIP, please use an abbreviated title in the filename, `sip-draft_title_abbrev.md`. The title should be 44 characters or less.-->

## Simple Summary

The creation and use of solidity contracts to perform smaller upgrades of the protocol atomically.

## Abstract

<!--A short (~200 word) description of the proposed change, the abstract should clearly describe the proposed change. This is what *will* be done if the SIP is implemented, not *why* it should be done or *how* it will be done. If the SIP proposes deploying a new contract, write, "we propose to deploy a new contract that will do x".-->

In order to reduce protocol downtime, this SIP proposes the creation of migration contracts - [for example](https://gist.github.com/justinjmoses/a960c9d2873697a592b781020c2359f6) - which would be given temporary ownership over the requisite contracts to do the protocol upgrade, before relinquishing back to the protocolDAO.

## Motivation

<!--This is the problem statement. This is the *why* of the SIP. It should clearly explain *why* the current state of the protocol is inadequate.  It is critical that you explain *why* the change is needed, if the SIP proposes changing how something is calculated, you must address *why* the current calculation is innaccurate or wrong. This is not the place to describe how the SIP will address the issue!-->

The current architecture of Synthetix is quite intricate. While many newer contracts rely on the `AddressResolver` which can be updated atomically, many older ones still require manual updates each time a core contract is upgraded (`Proxy.setSynthetix` or `TokenState.setAssociatedContract`). In order to prevent data corruption caused by users intereacting with the protocol in between these upgrade steps and potentially losing funds, the protocol suspends the system completely before the upgrade and resumes it once complete. Due to the nature of SNX being locked in place rather than being sent to the protocol, this requires even the suspension of SNX transfers during upgrades - which is very problematic for centralized exchanges such as Coinbase.

In order to bundle these transactions together into a successful migration, once created the migration contract must be given ownership at the beginning of the transaction. While ownership transfers are rudimentary, the potential for loss of the system is very high - if ownership is not relinquished back to the protocolDAO at the end of the transaction, then potentially the system can no longer be upgraded. Thus these migrations must be carefully analyzed by both Protocol Engineers and auditors.

## Specification

<!--The specification should describe the syntax and semantics of any new feature, there are five sections
1. Overview
2. Rationale
3. Technical Specification
4. Test Cases
5. Configurable Values
-->

### Overview

To add a step to the deploy script within Synthetix to auto-generate a migration contract which will upgrade the protocol atomically (in a single transaction).

### Rationale

The deploy script in Synthetix performs deployment of all new contracts and connects the new contracts to the existing ones. This process can be tweaked to generate solidity code to perform all necessary tasks.

### Technical Specification

The deploy script will need a new flag `--generate-solidity` and will need to be tweaked to generate the upgrade as solidity code without actually performing the upgrade itself.

Implementation proposal: https://github.com/Synthetixio/synthetix/pull/1313

### Test Cases

TBD

### Configurable Values (Via SCCP)

N/A

## Copyright

Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).