Selaa lähdekoodia

Add documentation for deploying prod contracts

Tom Pointon 3 vuotta sitten
vanhempi
sitoutus
ba7c2cd92b
3 muutettua tiedostoa jossa 38 lisäystä ja 2 poistoa
  1. 8 0
      ethereum/.env.prod.development
  2. 3 2
      ethereum/.env.test
  3. 27 0
      ethereum/Deploying.md

+ 8 - 0
ethereum/.env.prod.development

@@ -0,0 +1,8 @@
+# Migrations Metadata
+MIGRATIONS_DIR=./migrations/prod
+MIGRATIONS_NETWORK=development
+
+#Pyth
+WORMHOME_BRIDGE_ADDRESS=0x68605AD7b15c732a30b1BbC62BE8F2A509D74b4D
+PYTH_TO_WORMHOLE_CHAIN_ID=0x1
+PYTH_TO_WORMHOLE_EMITTER=0x6bb14509a612f01fbbc4cffeebd4bbfb492a86df717ebe92eb6df432a3f00a25

+ 3 - 2
ethereum/.env.test

@@ -14,6 +14,7 @@ BRIDGE_INIT_GOV_CHAIN_ID=0x1
 BRIDGE_INIT_GOV_CONTRACT=0x0000000000000000000000000000000000000000000000000000000000000004
 BRIDGE_INIT_WETH=0xDDb64fE46a91D46ee29420539FC25FD07c5FEa3E
 
-#Pyth Migrations
+#Pyth
+WORMHOME_BRIDGE_ADDRESS=0x68605AD7b15c732a30b1BbC62BE8F2A509D74b4D
 PYTH_TO_WORMHOLE_CHAIN_ID=0x1
-PYTH_TO_WORMHOLE_EMITTER=8fuAZUxHecYLMC76ZNjYzwRybUiDv9LhkRQsAccEykLr
+PYTH_TO_WORMHOLE_EMITTER=0x6bb14509a612f01fbbc4cffeebd4bbfb492a86df717ebe92eb6df432a3f00a25

+ 27 - 0
ethereum/Deploying.md

@@ -0,0 +1,27 @@
+# Deploying Contracts to Production
+
+Running the Truffle migrations in [`migrations/prod`](migrations/prod) will deploy the contracts to production. Truffle stores the address of the deployed contracts in the build artifacts, which can make local development difficult. We use [`truffle-deploy-registry`](https://github.com/MedXProtocol/truffle-deploy-registry) to store the addresses separately from the artifacts, in the [`networks`](networks) directory. When we need to perform operations on the deployed contracts, such as performing additional migrations, we can run `apply-registry -n networks/$NETWORK` to populate the artifacts with the correct addresses.
+
+An example deployment process, for deploying to Binance Smart Chain Testnet:
+
+```bash
+# Load the configuration environment variables for deploying to BSC Testnet.
+rm -f .env && ln -s .env.prod.development .env & set -o allexport && source .env set && set +o allexport
+
+# Ensure that we deploy a fresh build with up-to-date dependencies.
+rm -rf build .openzeppelin node_modules && npm install && npx truffle compile --all
+
+# Merge the network addresses into the artifacts, if some contracts are already deployed.
+npx apply-registry -n networks/$MIGRATIONS_NETWORK
+
+# Perform the migration
+npx run truffle migrate --network $MIGRATIONS_NETWORK
+
+# Running the migration will cause a JSON file to be written to the networks/
+# directory, with a filename like 1648198934288.json (the Truffle network ID).
+# To make it more obvious which network this corresponds to, move this file
+# to networks/$MIGRATIONS_NETWORK.
+mkdir -p networks/$MIGRATIONS_NETWORK && mv networks/NETWORK__ID.json networks/$MIGRATIONS_NETWORK
+```
+
+As a sanity check, it is recommended to deploy the  migrations in `migrations/prod` to the Truffle `development` network first. You can do this by using the configuration values in [`.env.prod.development`](.env.prod.development).