Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: adding contract upgrade document #603

Merged
merged 1 commit into from
Apr 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions doc/upgrading-contracts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# How to upgrade contracts

At least initially, we retain the ability to upgrade the nightfall contracts following deployment.
We use the Openzeppelin [Upgrades](https://docs.openzeppelin.com/upgrades-plugins/1.x/) Truffle plugin
to do that. Make sure you have read the details before attempting an upgrade because there are some
specifics around the structure of the contract that need to be addressed.

## The approach

We use `deployer` to upgrade contracts. `deployer` has 4 migrations stored in its migration folder
The first three migrations perform a 'normal' deployment of the polygon-nightfall contract suite. They
do however make sure that all contracts (but not libraries) are deployed with a proxy to enable them to
be upgraded at a later date. The fourth migration is used to upgrade contracts.

In a normal deployment run, `deployer` will only run the first three migrations. If, however, its
`UPGRADE` environment variable is set to <anything at all>, then the first three migrations will be ignored
and the subsequent migrations run. Currently that's only migration 4.

The upgrade migration (4) requires editing to include the contracts that you wish to upgrade (unless they have
the same name as the original contracts). Then, running deployer will result in the contracts being upgraded.

Don't forget that the solidity source code is contained within the `deployer` container. Therefore, it is necessary
to rebuild the container to incorporate any changes to the contract code.

Note that libraries are not proxied. They contain no state, and so we freely re-deploy and re-link them each time.
It may be cheaper to proxy them but this adds significantly to the number of proxy contracts.

## Testing

Please see the README in the ping-pong test directory.