Skip to content

Commit

Permalink
Bring doc updates from develop into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jcortejoso committed Jul 29, 2022
1 parent 0e4d669 commit a210152
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 184 deletions.
148 changes: 35 additions & 113 deletions docs/ReleaseProcess.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
---
sidebar_position: 4
---

# Release Process

## Build a new version

We follow the standard Nevermined release pattern:
The steps to build a new version are the following:

- Make sure the versions are up to date: `package.json`, `setup.py`, `pom.xml`
- Create a tag:
```
$ git tag v2.0.0
```
- Push the tag:
```
$ git push origin v2.0.0
```
- Create a new local feature branch, e.g. `git checkout -b release/v0.2.5`
- Use the `bumpversion.sh` script to bump the project version. You can execute the script using {major|minor|patch} as first argument to bump the version accordingly:
- To bump the patch version: `./bumpversion.sh patch`
- To bump the minor version: `./bumpversion.sh minor`
- To bump the major version: `./bumpversion.sh major`
- assuming we are on version `v0.2.4` and the desired version is `v0.2.5` `./bumpversion.sh patch` has to be run.

## Interact with networks

### Roles

We define four roles:
> :warning: wallets.json file is needed if using a MultiSig Wallet for the deployment. Currently none of the Nevermined contract deployments is using Multisig wallets.
We define six roles (check code configuration in [wallets.js](../scripts/deploy/truffle-wrapper/wallets.js)):

- `deployer`: represented as `accounts[0]`
- `upgrader`: represented as `accounts[1]`
- `upgraderWallet`: represented as the `upgrader` from `wallets.json`
- `ownerWallet`: represented as the `owner` from `wallets.json`
- `governorWallet`: represented as the `governor` from `wallets.json`
- `deployer`: represented as `accounts[8]`
- `upgrader`: represented as `accounts[8]`
- `governor`: represented as `accounts[9]`
- `ownerWallet`: represented as the `owner` from `wallets.json` or `accounts[8]`
- `upgraderWallet`: represented as the `upgrader` from `wallets.json` or `accounts[8]`
- `governorWallet`: represented as the `governor` from `wallets.json` or `accounts[9]`

### Flags

Expand All @@ -45,8 +41,8 @@ To see all the available possibilities please see the `INeverminedConfig` interf
During the deployment of Nevermined all of these parameters can be specified allowing a bespoke environment configuration.
This can be done via the definition of the following environment variables:

* `NVM_MARKETPLACE_FEE`. It refers to the fee charged by Nevermined for using the Service Agreements. It uses an integer number representing a 2 decimal number. It means 1450 means 14.50% fee. The value must be beteen 0 and 10000 (100%). See `marketplaceFee` variable.
* `NVM_RECEIVER_FEE`. It refers to the address that will receive the fee charged by Nevermined per transaction. See `feeReceiver` variable
- `NVM_MARKETPLACE_FEE`. It refers to the fee charged by Nevermined for using the Service Agreements. It uses an integer number representing a 4 decimal number. It means 145000 means 14.50% fee. The value must be beteen 0 and 10000 (100%). See `marketplaceFee` variable.
- `NVM_RECEIVER_FEE`. It refers to the address that will receive the fee charged by Nevermined per transaction. See `feeReceiver` variable

#### Deployer

Expand All @@ -66,115 +62,41 @@ One instance of the multi sig wallet, defined as `owner`. This wallet will be as

### Deploy & Upgrade

All deployment configurations are on `hardhat.config.js`.

- run `yarn clean` to clean the work dir.
- run `yarn compile` to compile the contracts.

This step will create `cache/` and `deploy-cache.json` used to resume the deployment in case something fails.

#### Rinkeby (Testnet)

- Copy the wallet file for `rinkeby`
- `cp wallets_rinkeby.json wallets.json`
- run `export MNEMONIC=<your rinkeby mnemonic>`. You will find them in the password manager.

##### Deploy the whole application

> Remove the deploy file related to the network in `.openzeppelin/` for a clean deployment
- To deploy all contracts run `yarn deploy:rinkeby`. If the deployment fails at any point just retry the command and it will make use of the `cache/` to resume the deployment

This step will create a `unknown-<chainId>.json`. Rename this file to `<tag>-<version>-<chainId>.json`

##### Deploy a single contracts

- To deploy a single contract you need to specify the contracts to deploy as a parameter to the deploy script: ie. `yarn deploy:rinkeby -- NeverminedToken Dispenser`will deploy `NeverminedToken` and `Dispenser`.

##### Upgrade the whole application

- To upgrade all contracts run `yarn upgrade:rinkeby`

##### Upgrade a single contract

- To upgrade a single contract run `yarn upgrade:rinkeby -- NeverminedToken`. For upgrading the `NeverminedToken` contract.

##### Persist artifacts

- Commit all changes in `artifacts/*.rinkeby.json`

#### Mumbai (PolygonTestnet)
The following steps shows how to perform contracts deployment for new deployments (check `[Upgrades.md](./Upgrades.md)` for upgrading details)

- Copy the wallet file for `mumbai`
- `cp wallets_mumbai.json wallets.json`
- run `export MNEMONIC=<your mumbai mnemonic>`. You will find them in the password manager.
#### Copy the files and artifacts

##### Deploy the whole application
- Export the `NETWORK_ID` (check in https://chainlist.org/) and contract's tag `TAG`:

- To deploy all contracts run `yarn deploy:mumbai`

##### Deploy a single contracts

- To deploy a single contract you need to specify the contracts to deploy as a parameter to the deploy script: ie. `yarn deploy:mumbai -- NeverminedToken Dispenser`will deploy `NeverminedToken` and `Dispenser`.

##### Upgrade the whole application

- To upgrade all contracts run `yarn upgrade:mumbai`

##### Upgrade a single contract

- To upgrade a single contract run `yarn upgrade:mumbai -- NeverminedToken`. For upgrading the `NeverminedToken` contract.

##### Persist artifacts

- Commit all changes in `artifacts/*.mumbai.json`


#### Kovan (Testnet)

- Copy the wallet file for `kovan` > `cp wallets_kovan.json wallets.json`
- run `export MNEMONIC=<your kovan mnemonic>`. You will find them in the password manager.
- run `export INFURA_TOKEN=<your infura token>`. You will get it from `infura`.

##### Deploy the whole application

- To deploy all the contracts run `yarn deploy:kovan`

##### Deploy a single contracts

- To deploy a single contracts you need to specify the contracts to deploy as a parameter to the deploy script: ie. `yarn deploy:kovan -- NeverminedToken Dispenser` will deploy `NeverminedToken` and `Dispenser`.

##### Upgrade the whole application
```bash
export NETWORK=mumbai
export TAG=common
```

- To upgrade all contracts run `yarn upgrade:kovan`
- run `export MNEMONIC=<deployment's mnemonic>`. You will find them in the password manager.

##### Upgrade a single contract
##### Deploy and initialize the conracts

- To upgrade a single contract run `yarn upgrade:kovan -- NeverminedToken`. For upgrading the `NeverminedToken` contract.
- To deploy and initialize all contracts run `yarn deploy:$NETWORK`

##### Persist artifacts
##### Upload the artifacts to the repository and persist any change in `openzeppelin/` file

- Commit all changes in `artifacts/*.kovan.json`
- To upload the artifacts to the repository run `./scripts/upload_artifacts_s3.sh contracts $NETWORK $TAG`. You need to have access to S3.

#### Approve upgrades
- Copy the openzeppeling file adding the deployment's tag: `cp -rp .openzeppelin/unknown-$NETWORK_ID.json .openzeppelin/unknown-$NETWORK_ID.json.$TAG`

All upgrades of the contracts have to be approved by the `upgrader` wallet configured in the `wallets.json` file.
- Commit all changes in `.openzeppelin/unknown-$NETWORK_ID.json.$TAG` file

- go to https://wallet.gnosis.pm
- Load `upgrader` wallet
- Select an Ethereum Account that is an `owner` of the multi sig wallet, but not the one who issued the upgrade request. This can be done in the following ways:
- Connect to a local Blockchain node that holds the private key.
- Connect to MetaMask and select the owner account from the multi sig wallet.
- Connect a hardware wallet like ledger or trezor.
- Select the transaction you want to confirm (the upgrade script will tell you which transactions have to be approved in which wallets)
- Click Confirm

## Upload the artifacts (abis/contracts) to Contract Repository
## Script for uploading the artifacts (abis/contracts) to Contract Repository

Once the contracts are deployed to a public network or a new contract version whose contract abis has to been uploaded, use `scripts/upload_artifacts_s3.sh` to upload
the contracts or artifacts to repository https://artifacts-nevermined-rocks.s3.amazonaws.com.
the contracts or artifacts to [nevermined repository](https://artifacts-nevermined-rocks.s3.amazonaws.com).

*Your environment has to be configured and authorized to use aws cli to upload files to `artifacts-nevermined-rocks` bucketi*.
*Your environment has to be configured and authorized to use aws cli to upload files to `artifacts-nevermined-rocks` bucket.*.

The script has the next variables:

Expand Down
120 changes: 49 additions & 71 deletions docs/Upgrades.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ sidebar_position: 5
This documents explains in detail how [nevermined-contracts](https://github.com/nevermined-io/contracts) should be
deployed using zeppelinOS and how the contracts can be upgraded. The latest section describes the test procedure.



## Quickstart

The first step to work with `zos` is to install dependencies then initialize the project. Then compile contracts and add contracts to the project.
Expand All @@ -19,22 +21,24 @@ any future deployments/upgrades.

Here we provide more details into each step of the initial deploy and the approach of upgradeability and governance.


## Roles

> :warning: wallets.json file is needed if using a Gnosis MultiSig Wallet for the deployment. Currently none of the Nevermined contract deployments is using Gnosis Multisig wallets.
Before going into more details about the deployment. We should differentiate between different roles in the system which
govern the upgradeability in nevermined-contracts.

Roles are defined as follows:
Roles are defined as follows (check code configuration in [wallets.js](../scripts/deploy/truffle-wrapper/wallets.js)):

```text
deployer: represented as accounts[8]
upgrader: represented as accounts[8]
governor: represented as accounts[9]
ownerWallet: represented as the owner from wallets.json or accounts[8]
upgraderWallet: represented as the upgrader from wallets.json or accounts[8]
governorWallet: represented as the governor from wallets.json or accounts[9]
```
deployer: represented as accounts[0]
upgrader: represented as accounts[1]
governor: represented as accounts[1]
upgraderWallet: represented as the upgrader from wallets.json
ownerWallet: represented as the owner from wallets.json
governorWallet: represented as the owner from wallets.json
```

- **Deployer**: Can be any account. It is used for deploying the initial `proxy contracts` and the `logic contracts`.

- **Upgrader**: Has to be an `owner` of the `upgrader` multi sig wallet. It is used for issuing upgrade requests against the upgrader multi sig wallet.
Expand All @@ -48,6 +52,7 @@ governorWallet: represented as the owner from wallets.json
- **GovernorWallet**: One instance of the multi sig wallet, defined as `governor`. This wallet will be assigned as zos admin and is required to do config updates in a Nevermined deployment.

## Deploy & Upgrade

`zos` does not support migrations, hence all the initial configuration should be performed with
[Nevermined Contract Tools](https://github.com/nevermined-io/contract-tools).
Contract constructors are ignored so the initial setup of the contract should be made in a
Expand Down Expand Up @@ -100,73 +105,66 @@ The following configuration should be an example for `wallets-<NETWORK_NAME>.jso
### 2. Preparation

The following commands clean, install dependencies and compile the contracts:

```console
$ yarn clean #to clean the work dir
$ yarn #install dependencies
$ yarn compile #to compile the contracts
yarn clean #to clean the work dir
yarn #install dependencies
yarn compile #to compile the contracts
```

### 3. Deploy & Upgrade

The following steps shows how to perform contracts deployment and upgrade on `Rinkeby` and `Kovan` networks.
#### Nile

- Copy the wallet file for `rinkeby`
- `cp wallets_rinkeby.json wallets.json`
- run `export MNEMONIC=<your staging mnemonic>`. You will find them in the password manager.

##### Deploy the whole application

- To deploy all contracts run `yarn deploy:rinkeby`

##### Deploy a single contracts
The following steps shows how to perform contracts deployment and upgrade on `Mumbai` and `<Polygon>` networks.

- To deploy a single contract you need to specify the contracts to deploy as a parameter to the deploy script:
ie. `yarn deploy:rinkeby -- NeverminedToken Dispenser`will deploy `NeverminedToken` and `Dispenser`.
#### Copy the files and artifacts

##### Upgrade the whole application
- Export the `NETWORK_ID` (check in https://chainlist.org/) and contract's tag `TAG`, and latest version deployed `VERSION` for this contract release:

- To upgrade all contracts run `yarn upgrade:rinkeby`

##### Upgrade a single contract

- To upgrade a single contract run `yarn upgrade:rinkeby -- NeverminedToken`. For upgrading the `NeverminedToken` contract.
```bash
export NETWORK_ID=80001 # Network_ID for mumbai
export NETWORK=mumbai
export TAG=common
export VERSION='2.0.0'
```

##### Persist artifacts
- Copy the .openzeppelin file for the `<NETWORK_ID>` and `<TAG>`(like `common` or `public`) deployment you want to upgrade:
- `cp .openzeppelin/unknown-$NETWORK_ID.json.$TAG .openzeppelin/unknown-$NETWORK_ID.json`
- Unpack the latest version of the artifacts for the `<NETWORK_ID>` and `<TAG>` in `artifacts`:

- Commit all changes in `artifacts/*.rinkeby.json`
```bash
wget -O artifacts.tar.gz "http://artifacts-nevermined-rocks.s3.amazonaws.com/$NETWORK_ID/$TAG/contracts_v$VERSION.tar.gz"
tar xvzf artifacts.tar.gz -C artifacts/
```

#### Kovan
- run `export MNEMONIC=<deployment's mnemonic>`. You will find them in the password manager.

- Copy the wallet file for `kovan` > `cp wallets_kovan.json wallets.json`
- run `export MNEMONIC=<your kovan mnemonic>`. You will find them in the password manager.
- run `export INFURA_TOKEN=<your infura token>`. You will get it from `infura`.
##### Upgrade already deployed contracts

##### Deploy the whole application
- To upgrade the contracts run `yarn upgrade:$NETWORK`

- To deploy all the contracts run `yarn deploy:kovan`
##### Deploy and initialize any new contract not present in the old deployed version

##### Deploy a single contracts
- To deploy and initialize all contracts run `yarn deploy:$NETWORK`

- To deploy a single contracts you need to specify the contracts to deploy as a parameter to the deploy script: ie. `yarn deploy:kovan -- NeverminedToken Dispenser` will deploy `NeverminedToken` and `Dispenser`.
This process will show multiple errors for the contracts that are being upgraded. You can ignore those messages.

##### Upgrade the whole application
##### Upgrade the plonk verifier contract to the new version

- To upgrade all contracts run `yarn upgrade:kovan`
- To upgrade the plonk verifier contract to the new version run `npx hardhat run ./scripts/deploy/truffle-wrapper/upgradePlonkVerifier.js --network $NETWORK`

##### Upgrade a single contract
##### Upload the artifacts to the repository and persist any change in `openzeppelin/` file

- To upgrade a single contract run `yarn upgrade:kovan -- NeverminedToken`. For upgrading the `NeverminedToken` contract.
- To upload the artifacts to the repository run `./scripts/upload_artifacts_s3.sh contracts $NETWORK $TAG`. You need to have access to S3.

##### Persist artifacts
- Copy the openzeppeling file base on tag: `cp -rp .openzeppelin/unknown-$NETWORK_ID.json .openzeppelin/unknown-$NETWORK_ID.json.$TAG`

- Commit all changes in `artifacts/*.kovan.json`
- Commit all changes in `.openzeppelin/unknown-$NETWORK_ID.json.$TAG` file

### 4. Approve Upgrade(s)
### 4. Approve Upgrade(s) -no applicable for current deployments-

All upgrades of the contracts have to be approved by the `upgrader` wallet configured in the `wallets.json` file.

- go to https://wallet.gnosis.pm
- go to <https://wallet.gnosis.pm>
- Load `upgrader` wallet
- Select an Ethereum Account that is an `owner` of the multi sig wallet, but not the one who issued the upgrade request. This can be done in the following ways:
- Connect to a local Blockchain node that holds the private key.
Expand All @@ -175,8 +173,7 @@ All upgrades of the contracts have to be approved by the `upgrader` wallet confi
- Select the transaction you want to confirm (the upgrade script will tell you which transactions have to be approved in which wallets)
- Click Confirm


### 5. Audit Contracts
### 5. Audit Contracts -no applicable for current deployments-

To check or document that all transactions have been approved in the multi sig wallet you can run `yarn audit:rinkeby` to get a list of all the current transactions and their current status.

Expand All @@ -190,22 +187,3 @@ To check or document that all transactions have been approved in the multi sig w
Confirmed from: 0x7A13E1aD23546c9b804aDFd13e9AcB184EfCAF58
Executed: false
```

### 6. Documentation
- Update the addresses in the `README.md`
- run `node ./scripts/contracts/get-addresses.js <network name>`

It will output the current proxy addresses in the `README` friendly format.

```text
| AccessCondition | v0.9.0 | 0x45DE141F8Efc355F1451a102FB6225F1EDd2921d |
| AgreementStoreManager | v0.9.0 | 0x62f84700b1A0ea6Bfb505aDC3c0286B7944D247C |
| ConditionStoreManager | v0.9.0 | 0x39b0AA775496C5ebf26f3B81C9ed1843f09eE466 |
| DIDRegistry | v0.9.0 | 0x4A0f7F763B1A7937aED21D63b2A78adc89c5Db23 |
| DIDRegistryLibrary | v0.9.0 | 0x3B3504908Db36f5D5f07CD420ee2BBBbDfB674cF |
| Dispenser | v0.9.0 | 0x865396b7ddc58C693db7FCAD1168E3BD95Fe3368 |
....
```

- Copy this to the `README.md`

0 comments on commit a210152

Please sign in to comment.