From 1ce151ccbd8d28cf866cb28b76fa60a18e371c40 Mon Sep 17 00:00:00 2001 From: diminator Date: Fri, 13 Sep 2019 15:13:25 +0200 Subject: [PATCH 1/8] Solution for build error on Linux 19.04 distro --- packages/cli/README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/cli/README.md b/packages/cli/README.md index 8b6ec8ddf40..8b59e09c35d 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -4,10 +4,27 @@ Tool for interacting with the Celo Protocol. ## Development +### Build + Use `yarn build:sdk ` to build the sdk for the target environment (CLI dependency). Use `yarn build` to compile the CLI. +> I'm getting the follow error: `Cannot find module '@celo/contractkit'`. +> +> What to do? + +A possible solution is to build `contractkit` manually from the monorepo. + +```bash +> cd ../contractkit +> yarn build +> cd ../cli +> yarn build +``` + +### Generate docs + Use `yarn docs` to populate `packages/docs` with generated documentation. Generated files should be checked in, and CI will fail if CLI modifications cause changes in the docs which were not checked in. _See [@celo/dev-cli](https://github.com/celo-org/dev-cli) for how we customize doc generation._ From 461410cf72a30fe3445023bb06cd7f48dbe2149f Mon Sep 17 00:00:00 2001 From: diminator Date: Tue, 17 Sep 2019 14:24:38 +0200 Subject: [PATCH 2/8] solutions to truffle doesnt compile and out of gas in the CLI --- packages/cli/README.md | 53 +++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/packages/cli/README.md b/packages/cli/README.md index 8b59e09c35d..4ba372a5bb6 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -10,21 +10,56 @@ Use `yarn build:sdk ` to build the sdk for the target environment (CLI Use `yarn build` to compile the CLI. +### Generate docs + +Use `yarn docs` to populate `packages/docs` with generated documentation. Generated files should be checked in, and CI will fail if CLI modifications cause changes in the docs which were not checked in. + +_See [@celo/dev-cli](https://github.com/celo-org/dev-cli) for how we customize doc generation._ + +### Known build issues on Linux + > I'm getting the follow error: `Cannot find module '@celo/contractkit'`. -> -> What to do? -A possible solution is to build `contractkit` manually from the monorepo. +A possible solution is to build the monorepo manually. +Go to the `celo-monorepo` root directory and ```bash -> cd ../contractkit -> yarn build -> cd ../cli > yarn build ``` -### Generate docs +If all works well, navigate to `packages/cli`. -Use `yarn docs` to populate `packages/docs` with generated documentation. Generated files should be checked in, and CI will fail if CLI modifications cause changes in the docs which were not checked in. +> I'm getting the follow error during the above build: `lerna ERR! yarn run build exited 1 in '@celo/protocol'`. -_See [@celo/dev-cli](https://github.com/celo-org/dev-cli) for how we customize doc generation._ +This error implies that the `truffle` project is not initialized. +Navigate to `celo-monorepo/packages/protocol` and initialize the truffle project. +Make sure you do NOT overwrite any existing contracts, migrations or tests. + +``` +> truffle init +This directory is non-empty... +? Proceed anyway? Yes +✔ Preparing to download +✔ Downloading +contracts already exists in this directory... +? Overwrite contracts? No +migrations already exists in this directory... +? Overwrite migrations? No +test already exists in this directory... +? Overwrite test? No +✔ Cleaning up temporary files +✔ Setting up box +``` + +After doing this you should be able to continue the build process + +> I've got the cli built successfully but the running the `cli` yields: `Error: Returned values aren't valid, did it run Out of Gas?`. + +When running the `cli` against a full node, this can mean that the contract artifacts are out of date. +Solution: switch to the `alfajores` branch and build the `celo-monorepo`. + +```bash +> git checkout alfajores +> yarn build +> git checkout master +``` From 12d940ec4a8a9e9f8f5a97834401d913fc814a84 Mon Sep 17 00:00:00 2001 From: diminator Date: Tue, 17 Sep 2019 15:01:55 +0200 Subject: [PATCH 3/8] add more info building against alfajores --- packages/cli/README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/cli/README.md b/packages/cli/README.md index 4ba372a5bb6..ff1db78cb6b 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -35,7 +35,8 @@ This error implies that the `truffle` project is not initialized. Navigate to `celo-monorepo/packages/protocol` and initialize the truffle project. Make sure you do NOT overwrite any existing contracts, migrations or tests. -``` +```bash +> npm i -g truffle > truffle init This directory is non-empty... ? Proceed anyway? Yes @@ -58,8 +59,14 @@ After doing this you should be able to continue the build process When running the `cli` against a full node, this can mean that the contract artifacts are out of date. Solution: switch to the `alfajores` branch and build the `celo-monorepo`. +Go to the `celo-monorepo` root directory and + ```bash > git checkout alfajores +> yarn > yarn build > git checkout master +> yarn +> cd packages/cli +> ./bin/run account:balance $CELO_ACCOUNT_ADDRESS ``` From 685077631f435781e339c810fa47c92bb681aca1 Mon Sep 17 00:00:00 2001 From: diminator Date: Tue, 17 Sep 2019 15:30:57 +0200 Subject: [PATCH 4/8] do not switch back to master --- packages/cli/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/cli/README.md b/packages/cli/README.md index ff1db78cb6b..1771e901835 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -65,8 +65,6 @@ Go to the `celo-monorepo` root directory and > git checkout alfajores > yarn > yarn build -> git checkout master -> yarn > cd packages/cli > ./bin/run account:balance $CELO_ACCOUNT_ADDRESS ``` From 73cbfdf568a340570389edcd2307c410e6186de0 Mon Sep 17 00:00:00 2001 From: diminator Date: Fri, 20 Sep 2019 19:06:29 +0200 Subject: [PATCH 5/8] update truffle.js issue --- packages/cli/README.md | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/packages/cli/README.md b/packages/cli/README.md index 1771e901835..27d874a4753 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -29,27 +29,25 @@ Go to the `celo-monorepo` root directory and If all works well, navigate to `packages/cli`. -> I'm getting the follow error during the above build: `lerna ERR! yarn run build exited 1 in '@celo/protocol'`. +> I'm getting the follow output during above build: -This error implies that the `truffle` project is not initialized. -Navigate to `celo-monorepo/packages/protocol` and initialize the truffle project. -Make sure you do NOT overwrite any existing contracts, migrations or tests. +```bash +Compiling +Warning: Both truffle-config.js and truffle.js were found. Using truffle-config.js. + +Compiling your contracts... +=========================== +> Everything is up to date, there is nothing to compile. + +{ Error: ENOENT: no such file or directory, open '../packages/protocol/build/contracts/Proxy.json' +``` + +This error implies that the `truffle` finds (a faulty) `truffle-config.js`. + +Navigate to `celo-monorepo/packages/protocol` and: ```bash -> npm i -g truffle -> truffle init -This directory is non-empty... -? Proceed anyway? Yes -✔ Preparing to download -✔ Downloading -contracts already exists in this directory... -? Overwrite contracts? No -migrations already exists in this directory... -? Overwrite migrations? No -test already exists in this directory... -? Overwrite test? No -✔ Cleaning up temporary files -✔ Setting up box +> cp truffle.js truffle-config.js ``` After doing this you should be able to continue the build process From 37ba262ece4ecbde8b4b48fb8b344731641724b2 Mon Sep 17 00:00:00 2001 From: diminator Date: Thu, 26 Sep 2019 15:49:20 +0200 Subject: [PATCH 6/8] mv truffle.js to truffle-config.js --- packages/protocol/{truffle.js => truffle-config.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/protocol/{truffle.js => truffle-config.js} (100%) diff --git a/packages/protocol/truffle.js b/packages/protocol/truffle-config.js similarity index 100% rename from packages/protocol/truffle.js rename to packages/protocol/truffle-config.js From a07554d2a9d8086c91135702398e7b33b585e71d Mon Sep 17 00:00:00 2001 From: diminator Date: Thu, 26 Sep 2019 15:51:07 +0200 Subject: [PATCH 7/8] delete truffle-config section --- packages/cli/README.md | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/packages/cli/README.md b/packages/cli/README.md index 27d874a4753..8b9a842ae53 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -29,29 +29,6 @@ Go to the `celo-monorepo` root directory and If all works well, navigate to `packages/cli`. -> I'm getting the follow output during above build: - -```bash -Compiling -Warning: Both truffle-config.js and truffle.js were found. Using truffle-config.js. - -Compiling your contracts... -=========================== -> Everything is up to date, there is nothing to compile. - -{ Error: ENOENT: no such file or directory, open '../packages/protocol/build/contracts/Proxy.json' -``` - -This error implies that the `truffle` finds (a faulty) `truffle-config.js`. - -Navigate to `celo-monorepo/packages/protocol` and: - -```bash -> cp truffle.js truffle-config.js -``` - -After doing this you should be able to continue the build process - > I've got the cli built successfully but the running the `cli` yields: `Error: Returned values aren't valid, did it run Out of Gas?`. When running the `cli` against a full node, this can mean that the contract artifacts are out of date. From 8603ec5da1ce1859e955543aa8e2bcc5417420f1 Mon Sep 17 00:00:00 2001 From: diminator Date: Thu, 26 Sep 2019 17:28:10 +0200 Subject: [PATCH 8/8] change truffle.js dependencies to truffle-config.js --- packages/protocol/.solcover.js | 44 ------------------- packages/protocol/README.md | 2 +- packages/protocol/migrations/07_reserve.ts | 2 +- .../protocol/migrations/08_stabletoken.ts | 2 +- packages/protocol/migrations/15_governance.ts | 2 +- packages/protocol/runTests.js | 2 +- .../scripts/bash/set_exchange_rate.sh | 2 +- .../protocol/scripts/truffle/get_balances.ts | 2 +- packages/protocol/scripts/truffle/invite.ts | 2 +- .../protocol/scripts/truffle/network_check.ts | 2 +- packages/protocol/scripts/truffle/revoke.ts | 2 +- .../scripts/truffle/set_exchange_rate.ts | 2 +- packages/protocol/scripts/truffle/transfer.ts | 2 +- 13 files changed, 12 insertions(+), 56 deletions(-) delete mode 100644 packages/protocol/.solcover.js diff --git a/packages/protocol/.solcover.js b/packages/protocol/.solcover.js deleted file mode 100644 index 254f66f6135..00000000000 --- a/packages/protocol/.solcover.js +++ /dev/null @@ -1,44 +0,0 @@ -const mnemonic = require('./truffle.js').networks.development.mnemonic -const datadir = '.datadir' - -module.exports = { - datadir, - copyPackages: ['openzeppelin-solidity'], - testrpcOptions: '-d -m "' + mnemonic + '" -g 0 --db ' + datadir, - port: 8545, - skipFiles: [ - // Need custom precompiles - 'common/GoldToken.sol', - 'identity/Attestations.sol', - - // Proxies - 'common/GasCurrencyWhitelistProxy.sol', - 'common/GoldTokenProxy.sol', - 'common/MultiSigProxy.sol', - 'common/RegistryProxy.sol', - 'common/ValidatorsProxy.sol', - 'governance/LockedGoldProxy.sol', - 'identity/AttestationsProxy.sol', - 'identity/EscrowProxy.sol', - 'stability/ExchangeProxy.sol', - 'stability/MedianatorProxy.sol', - 'stability/OracleProxy.sol', - 'stability/ReserveProxy.sol', - 'stability/StableTokenProxy.sol', - - // Test contracts - 'common/test/GetSetV0.sol', - 'common/test/GetSetV1.sol', - 'common/test/HasInitializer.sol', - 'common/test/MsgSenderCheck.sol', - 'governance/test/MockLockedGold.sol', - 'governance/test/MockElection.sol', - 'governance/test/MockGovernance.sol', - 'governance/test/SortedListTest.sol', - 'stability/test/FractionUtilTest.sol', - 'stability/test/MockGoldToken.sol', - 'stability/test/MockReserve.sol', - 'stability/test/MockStableToken.sol', - 'stability/test/SortedFractionMedianListTest.sol', - ], -} diff --git a/packages/protocol/README.md b/packages/protocol/README.md index 7039b06ec66..ae22fe7f07a 100644 --- a/packages/protocol/README.md +++ b/packages/protocol/README.md @@ -16,7 +16,7 @@ Then, to deploy contracts to a network run: yarn run init-network -n NETWORK ``` -This will deploy the contracts to the network specified in `truffle.js` and save the artifacts to `build/NETWORK`. +This will deploy the contracts to the network specified in `truffle-config.js` and save the artifacts to `build/NETWORK`. If your network was deployed with `helm`, you will probably set `NETWORK` the same as your `NAME` (which sets `NAMESPACE_NAME` and `RELEASE_NAME`). For more clarity on these names, also see the [testnet helm chart README](../helm-charts/testnet/README.md) ### Migrations diff --git a/packages/protocol/migrations/07_reserve.ts b/packages/protocol/migrations/07_reserve.ts index b97f02978da..45ab18b2c59 100644 --- a/packages/protocol/migrations/07_reserve.ts +++ b/packages/protocol/migrations/07_reserve.ts @@ -8,7 +8,7 @@ import { } from '@celo/protocol/lib/web3-utils' import { config } from '@celo/protocol/migrationsConfig' import { RegistryInstance, ReserveInstance } from 'types' -const truffle = require('@celo/protocol/truffle.js') +const truffle = require('@celo/protocol/truffle-config.js') const initializeArgs = async (): Promise<[string, number]> => { const registry: RegistryInstance = await getDeployedProxiedContract( diff --git a/packages/protocol/migrations/08_stabletoken.ts b/packages/protocol/migrations/08_stabletoken.ts index 920b438ae13..5bc02ece37d 100644 --- a/packages/protocol/migrations/08_stabletoken.ts +++ b/packages/protocol/migrations/08_stabletoken.ts @@ -16,7 +16,7 @@ import { StableTokenInstance, } from 'types' -const truffle = require('@celo/protocol/truffle.js') +const truffle = require('@celo/protocol/truffle-config.js') const NULL_ADDRESS = '0x0000000000000000000000000000000000000000' const initializeArgs = async (): Promise => { diff --git a/packages/protocol/migrations/15_governance.ts b/packages/protocol/migrations/15_governance.ts index 5b55ec636d9..eec28590310 100644 --- a/packages/protocol/migrations/15_governance.ts +++ b/packages/protocol/migrations/15_governance.ts @@ -13,7 +13,7 @@ import { config } from '@celo/protocol/migrationsConfig' import { toFixed } from '@celo/utils/lib/fixidity' const initializeArgs = async (networkName: string): Promise => { - const approver = require('@celo/protocol/truffle.js').networks[networkName].from + const approver = require('@celo/protocol/truffle-config.js').networks[networkName].from return [ config.registry.predeployedProxyAddress, diff --git a/packages/protocol/runTests.js b/packages/protocol/runTests.js index 4e92630311d..2704b7c37a1 100644 --- a/packages/protocol/runTests.js +++ b/packages/protocol/runTests.js @@ -4,7 +4,7 @@ const glob = require('glob-fs')({ }) const { exec } = require('./lib/test-utils') const minimist = require('minimist') -const network = require('./truffle.js').networks.development +const network = require('./truffle-config.js').networks.development const sleep = (seconds) => new Promise((resolve) => setTimeout(resolve, 1000 * seconds)) diff --git a/packages/protocol/scripts/bash/set_exchange_rate.sh b/packages/protocol/scripts/bash/set_exchange_rate.sh index eb97a853d73..ec54f5aac2a 100755 --- a/packages/protocol/scripts/bash/set_exchange_rate.sh +++ b/packages/protocol/scripts/bash/set_exchange_rate.sh @@ -7,7 +7,7 @@ set -euo pipefail # # Flags: # -f: Filepath to csv of (timestamp, stableValue, goldValue) tuples -# -n: name of the network defined in truffle.js to set the exchange rate on +# -n: name of the network defined in truffle-config.js to set the exchange rate on # -s: StableToken component of exchange rate # -g: GoldToken component of exchange rate # -c: Override for truffle config diff --git a/packages/protocol/scripts/truffle/get_balances.ts b/packages/protocol/scripts/truffle/get_balances.ts index 44475f2ddb3..c65c266d211 100644 --- a/packages/protocol/scripts/truffle/get_balances.ts +++ b/packages/protocol/scripts/truffle/get_balances.ts @@ -5,7 +5,7 @@ import { GoldTokenInstance, StableTokenInstance } from 'types' * A simple script to check token balances on a testnet. * * Expects the following flags: - * network: name of the network defined in truffle.js to deploy to + * network: name of the network defined in truffle-config.js to deploy to * account: address of the account to transfer tokens to * * Run using truffle exec, e.g.: diff --git a/packages/protocol/scripts/truffle/invite.ts b/packages/protocol/scripts/truffle/invite.ts index bc2c6f47e9e..e4e210c77c6 100644 --- a/packages/protocol/scripts/truffle/invite.ts +++ b/packages/protocol/scripts/truffle/invite.ts @@ -17,7 +17,7 @@ const twilioConfig = require('@celo/protocol/twilio-config') * A simple script to send a payment and invite a user. * * Expects the following flags: - * network: name of the network defined in truffle.js to deploy to + * network: name of the network defined in truffle-config.js to deploy to * stableValue: amount of stable token to transfer * goldValue: amount of gold transfer * phone: phone number of user to invite diff --git a/packages/protocol/scripts/truffle/network_check.ts b/packages/protocol/scripts/truffle/network_check.ts index 05b8db47186..4f81207c363 100644 --- a/packages/protocol/scripts/truffle/network_check.ts +++ b/packages/protocol/scripts/truffle/network_check.ts @@ -25,7 +25,7 @@ const contractMapping: any = {} * A simple script to check contract state invariants. * * Expects the following flags: - * network: name of the network defined in truffle.js to test + * network: name of the network defined in truffle-config.js to test * build_directory: location of the appropriate build artifacts * * Run using truffle exec, e.g.: diff --git a/packages/protocol/scripts/truffle/revoke.ts b/packages/protocol/scripts/truffle/revoke.ts index 33a79992886..bca24d91d29 100644 --- a/packages/protocol/scripts/truffle/revoke.ts +++ b/packages/protocol/scripts/truffle/revoke.ts @@ -8,7 +8,7 @@ import { AttestationsInstance } from 'types' * * Expects the following flags: * phone: the phone number to revoke in E164 format - * network: name of the network defined in truffle.js + * network: name of the network defined in truffle-config.js * * Run using truffle exec, e.g.: * truffle exec identity/scripts/revoke.js --network testnet --phone +18005882300 diff --git a/packages/protocol/scripts/truffle/set_exchange_rate.ts b/packages/protocol/scripts/truffle/set_exchange_rate.ts index b35f10b7e18..699383cce2d 100644 --- a/packages/protocol/scripts/truffle/set_exchange_rate.ts +++ b/packages/protocol/scripts/truffle/set_exchange_rate.ts @@ -67,7 +67,7 @@ const getLesserAndGreater = ( * * Expects the following flags: * csv: Filepath to csv of (timestamp, stableValue, goldValue) tuples - * network: name of the network defined in truffle.js to set the exchange rate on + * network: name of the network defined in truffle-config.js to set the exchange rate on * stableValue: StableToken component of exchange rate * goldValue: GoldToken component of exchange rate * diff --git a/packages/protocol/scripts/truffle/transfer.ts b/packages/protocol/scripts/truffle/transfer.ts index 64d0d2312ee..9f7e9f9c8f5 100644 --- a/packages/protocol/scripts/truffle/transfer.ts +++ b/packages/protocol/scripts/truffle/transfer.ts @@ -9,7 +9,7 @@ import { GoldTokenInstance, StableTokenInstance } from 'types' * A simple script to transfer token balances on a testnet. * * Expects the following flags: - * network: name of the network defined in truffle.js to deploy to + * network: name of the network defined in truffle-config.js to deploy to * to: address of the account to transfer tokens to * stableValue: amount of stable token to transfer * goldValue: amount of gold transfer