Skip to content

Commit

Permalink
Merge branch 'aaronmgdr/invite-page' of github.com:celo-org/celo-mono…
Browse files Browse the repository at this point in the history
…repo into aaronmgdr/invite-page

* 'aaronmgdr/invite-page' of github.com:celo-org/celo-monorepo: (63 commits)
  Fix compile error during local clean build (#1506)
  Update to RN 61 and AndroidX (#1343)
  Set usage of shuffled round robin in the genesis block (#1464)
  Add spanish backup key for backup key flow (#1500)
  Fix sync tests by pulling genesis block to determine epoch length (#1504)
  [Wallet] fix missing full name error alert (#1496)
  [Wallet + Verification Pool] Add details about generating an app-signature (#1482)
  Deploy celo's image of ethstats (#1421)
  Storing previous randomness values (#1197)
  [Wallet] Fix wei invite bug (#1489)
  Point all packages to latest ganache-cli master (#1488)
  Point end-to-end tests back to master (#1469)
  [Wallet] Migrate app view functions to contractkit (#1381)
  [Wallet] Add script to translate locale strings (#1485)
  [Wallet] Update wallet celo client version and add missing translations for backup flow (#1483)
  [Wallet] Hotfix local currency (#1481)
  [Wallet] Remove QR debouncing to improve responsiveness (#1480)
  [Wallet] Upgrade app version to v1.5.1 (#1463)
  Update governance end-to-end tests to work with changed precompile (#1476)
  Fixes key_placer.sh when encrypting files (#1465)
  ...
  • Loading branch information
aaronmgdr committed Oct 29, 2019
2 parents 4ce51c4 + ad42c0e commit b690e87
Show file tree
Hide file tree
Showing 497 changed files with 23,019 additions and 17,956 deletions.
191 changes: 59 additions & 132 deletions .circleci/config.yml

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,22 @@ CLUSTER_DOMAIN_NAME="celo-networks-dev"
TESTNET_PROJECT_NAME="celo-testnet"

BLOCKSCOUT_DOCKER_IMAGE_REPOSITORY="gcr.io/celo-testnet/blockscout"
BLOCKSCOUT_WEB_DOCKER_IMAGE_TAG="web-f6c3e0888d1d0ef72dc8bf870808702b7fd13730"
BLOCKSCOUT_INDEXER_DOCKER_IMAGE_TAG="indexer-f6c3e0888d1d0ef72dc8bf870808702b7fd13730"
BLOCKSCOUT_DOCKER_IMAGE_TAG="5fba4843b3e78b5ab75d01766214cb24c6a40649"
BLOCKSCOUT_WEB_REPLICAS=3
BLOCKSCOUT_DB_SUFFIX=

ETHSTATS_DOCKER_IMAGE_REPOSITORY="gcr.io/celo-testnet/ethstats"
ETHSTATS_DOCKER_IMAGE_TAG="i0ffe524c625ea59e4492dc92c2e638689c36e4b0"

GETH_NODE_DOCKER_IMAGE_REPOSITORY="us.gcr.io/celo-testnet/geth"
# When upgrading change this to latest commit hash from the master of the geth repo
# `geth $ git show | head -n 1`
GETH_NODE_DOCKER_IMAGE_TAG="7fbd6f3574f1c1c1e657c152fc63fb771adab3af"
GETH_NODE_DOCKER_IMAGE_TAG="ba213df07070433970d9b2cf75bae1d146cbfeda"

GETH_BOOTNODE_DOCKER_IMAGE_REPOSITORY="gcr.io/celo-testnet/geth-all"
# When upgrading change this to latest commit hash from the master of the geth repo
# `geth $ git show | head -n 1`
GETH_BOOTNODE_DOCKER_IMAGE_TAG="7fbd6f3574f1c1c1e657c152fc63fb771adab3af"
GETH_BOOTNODE_DOCKER_IMAGE_TAG="ba213df07070433970d9b2cf75bae1d146cbfeda"

CELOTOOL_DOCKER_IMAGE_REPOSITORY="gcr.io/celo-testnet/celo-monorepo"
CELOTOOL_DOCKER_IMAGE_TAG="celotool-dfdc3e8b26e98aa294b27e2b5621c184488a10db"
Expand Down
3 changes: 1 addition & 2 deletions .env.integration
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ CLUSTER_DOMAIN_NAME="celo-testnet"
TESTNET_PROJECT_NAME="celo-testnet"

BLOCKSCOUT_DOCKER_IMAGE_REPOSITORY="gcr.io/celo-testnet/blockscout"
BLOCKSCOUT_WEB_DOCKER_IMAGE_TAG="web-f6c3e0888d1d0ef72dc8bf870808702b7fd13730"
BLOCKSCOUT_INDEXER_DOCKER_IMAGE_TAG="indexer-f6c3e0888d1d0ef72dc8bf870808702b7fd13730"
BLOCKSCOUT_DOCKER_IMAGE_TAG="ad86714d629c01272e0651dec1fb6a968c3cec71"
BLOCKSCOUT_WEB_REPLICAS=3
BLOCKSCOUT_DB_SUFFIX="25"
BLOCKSCOUT_SUBNETWORK_NAME="Integration"
Expand Down
21 changes: 21 additions & 0 deletions README-dev.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# README GUIDE FOR CELO DEVELOPERS

## Monorepo inter-package dependencies

Many packages depend on other packages within the monorepo. When this happens, follow these rules:

1. All packages must use **master version** of sibling packages.
2. Exception to (1) are packages that represent a GAE/firebase app which must use the last published version.
3. To differentiate published vs unpublished version. Master version (in package.json) must end with suffix `-dev` and should not be published.
4. If a developer want to publish a version; then after publishing it needs to set master version to next `-dev` version and change all package.json that require on it.

To check which pakages need amending, you can run (in the root pkg):

yarn check:packages

A practical example:

- In any given moment, `contractkit/package.json#version` field **must** of the form `x.y.z-dev`
- If current version of contractkit is: `0.1.6-dev` and we want to publish a new version, we should:
- publish version `0.1.6`
- change `package.json#version` to `0.1.7-dev`
- change in other packages within monorepo that were using `0.1.6-dev` to `0.1.7-dev`

## How to publish a new npm package

First checkout the alfajores branch.
Expand Down
2 changes: 1 addition & 1 deletion SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ Install the Android 28 system image and create an Android Virtual Device:

```bash
sdkmanager "system-images;android-28;google_apis;x86"
avdmanager create avd --force --name Nexus_5X_API_28 --device "Nexus 5X" -k "system-images;android-28;google_apis;x86" --abi "google_apis/x86"
avdmanager create avd --force --name Nexus_5X_API_28_x86 --device "Nexus 5X" -k "system-images;android-28;google_apis;x86" --abi "google_apis/x86"
```

Execute the following and add it to your `~/.bash_profile`:
Expand Down
14 changes: 14 additions & 0 deletions dockerfiles/circleci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,18 @@ RUN export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - && \
sudo apt-get update -y && sudo apt-get install google-cloud-sdk -y

RUN sudo wget https://dl.google.com/go/go1.11.5.linux-amd64.tar.gz && \
sudo tar xf go1.11.5.linux-amd64.tar.gz -C /usr/local

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y

ENV PATH="/usr/local/go/bin:/home/circleci/.cargo/bin:${PATH}"

RUN go version

RUN rustup install 1.36.0 && \
rustup default 1.36.0

RUN mkdir ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config

CMD ["/bin/sh"]
6 changes: 3 additions & 3 deletions dockerfiles/cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ RUN npm install @celo/celocli
FROM node:10-alpine as final_image

ARG network_name="alfajores"
ARG network_id="44782"
ARG network_id="44784"

# Without musl-dev, geth will fail with a confusing "No such file or directory" error.
# bash is required for start_geth.sh
Expand All @@ -62,8 +62,8 @@ COPY packages/cli/start_geth.sh /celo/start_geth.sh
COPY --from=geth /usr/local/bin/geth /usr/local/bin/geth
COPY --from=geth /celo/genesis.json /celo
COPY --from=geth /celo/static-nodes.json /celo
COPY --from=node /celo-monorepo/node_modules /celo-monorepo/node_modules
COPY --from=node /celo-monorepo/node_modules /celo-monorepo/node_modules
RUN chmod ugo+x /celo/start_geth.sh && ln -s /celo-monorepo/node_modules/.bin/celocli /usr/local/bin/celocli

EXPOSE 8545 8546 30303 30303/udp
ENTRYPOINT ["/celo/start_geth.sh", "/usr/local/bin/geth", "alfajores", "full", "44782", "/root/.celo", "/celo/genesis.json", "/celo/static-nodes.json"]
ENTRYPOINT ["/celo/start_geth.sh", "/usr/local/bin/geth", "alfajores", "full", "44784", "/root/.celo", "/celo/genesis.json", "/celo/static-nodes.json"]
17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"postinstall": "yarn run lerna run postinstall && patch-package && yarn keys:decrypt",
"preinstall": "bash scripts/create_key_templates.sh",
"keys:decrypt": "bash scripts/key_placer.sh decrypt",
"keys:encrypt": "bash scripts/key_placer.sh encrypt"
"keys:encrypt": "bash scripts/key_placer.sh encrypt",
"check:packages": "node ./scripts/check-packages.js"
},
"husky": {
"hooks": {
Expand All @@ -34,26 +35,28 @@
"packages/*"
],
"nohoist": [
"@celo/verifier/react-native",
"@celo/mobile/react-native",
"@celo/react-components/react-native",
"@celo/web/@timkendrick/monaco-editor",
"@celo/web/@types/react-i18next",
"@celo/web/next-i18next",
"**/openzeppelin-solidity"
]
},
"devDependencies": {
"@types/jest": "^24.0.17",
"@babel/core": "^7.6.2",
"@babel/runtime": "^7.6.2",
"@types/jest": "^24.0.18",
"babel-jest": "^24.9.0",
"husky": "^3.0.0",
"lerna": "^3.16.0",
"patch-package": "^5.1.1",
"prettier": "1.13.5",
"pretty-quick": "^1.11.1",
"solc": "0.5.8",
"tslint": "^5.20.0",
"jest": "^24.8.0",
"ts-jest": "^24.0.2",
"jest": "^24.9.0",
"jest-junit": "^8.0.0",
"jest-snapshot": "^24.9.0",
"ts-jest": "^24.1.0",
"typescript-tslint-plugin": "^0.5.4",
"tsconfig-paths": "^3.8.0",
"ts-node": "^8.3.0",
Expand Down
1 change: 0 additions & 1 deletion packages/attestation-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"yargs": "13.3.0"
},
"devDependencies": {
"@celo/ganache-cli": "git+https://github.com/celo-org/ganache-cli.git#98ad2ba",
"@celo/protocol": "1.0.0",
"@types/dotenv": "4.0.3",
"@types/debug": "^4.1.5",
Expand Down
20 changes: 20 additions & 0 deletions packages/celotool/ci_test_attestations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -euo pipefail

# This test starts a standalone Geth node and runs transactions on it.

# For testing a particular branch of Geth repo (usually, on Circle CI)
# Usage: ci_test_attestations.sh checkout <branch_of_geth_repo_to_test>
# For testing the local Geth dir (usually, for manual testing)
# Usage: ci_test_attestations.sh local <location_of_local_geth_dir>

if [ "${1}" == "checkout" ]; then
# Test master by default.
BRANCH_TO_TEST=${2:-"master"}
echo "Checking out geth at branch ${BRANCH_TO_TEST}..."
../../node_modules/.bin/mocha -r ts-node/register src/e2e-tests/attestations_tests.ts --branch ${BRANCH_TO_TEST}
elif [ "${1}" == "local" ]; then
export GETH_DIR="${2}"
echo "Testing using local geth dir ${GETH_DIR}..."
../../node_modules/.bin/mocha -r ts-node/register src/e2e-tests/attestations_tests.ts --localgeth ${GETH_DIR}
fi
4 changes: 1 addition & 3 deletions packages/celotool/ci_test_sync_with_network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ test_ultralight_sync () {
echo "Testing ultralight sync with '${NETWORK_NAME}' network"
# Run the sync in ultralight mode
geth_tests/network_sync_test.sh ${NETWORK_NAME} ultralight
# Get the epoch size by sourcing this file
source ${CELO_MONOREPO_DIR}/.env.${NETWORK_NAME}
# Verify what happened by reading the logs.
${CELO_MONOREPO_DIR}/node_modules/.bin/mocha -r ts-node/register ${CELO_MONOREPO_DIR}/packages/celotool/src/e2e-tests/verify_ultralight_geth_logs.ts --gethlogfile ${GETH_LOG_FILE} --epoch ${EPOCH}
${CELO_MONOREPO_DIR}/node_modules/.bin/mocha -r ts-node/register ${CELO_MONOREPO_DIR}/packages/celotool/src/e2e-tests/verify_ultralight_geth_logs.ts --network "${NETWORK_NAME}" --gethlogfile ${GETH_LOG_FILE}
}

# Some code in celotool requires this file to contain the MNEMONOIC.
Expand Down
6 changes: 3 additions & 3 deletions packages/celotool/src/cmds/account/verify.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AccountArgv } from '@celo/celotool/src/cmds/account'
import { portForwardAnd } from '@celo/celotool/src/lib/port_forward'
import { CeloContract, newKit } from '@celo/contractkit'
import { newKit } from '@celo/contractkit'
import { AttestationsWrapper } from '@celo/contractkit/lib/wrappers/Attestations'
import { ActionableAttestation, decodeAttestationCode } from '@celo/walletkit'
import prompts from 'prompts'
Expand Down Expand Up @@ -100,10 +100,10 @@ async function requestMoreAttestations(
attestationsRequested: number
) {
await attestations
.approveAttestationFee(CeloContract.StableToken, attestationsRequested)
.approveAttestationFee(attestationsRequested)
.then((txo) => txo.sendAndWaitForReceipt())
await attestations
.request(phoneNumber, attestationsRequested, CeloContract.StableToken)
.request(phoneNumber, attestationsRequested)
.then((txo) => txo.sendAndWaitForReceipt())
}

Expand Down
10 changes: 10 additions & 0 deletions packages/celotool/src/cmds/deploy/initial/blockchain-api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { switchToClusterFromEnv } from 'src/lib/cluster'
import { envVar, fetchEnv } from 'src/lib/env-utils'
import { AccountType, getAddressFromEnv } from 'src/lib/generate_utils'
import { execCmd } from 'src/lib/utils'
import { UpgradeArgv } from '../../deploy/upgrade'

export const command = 'blockchain-api'

export const describe = 'command for upgrading blockchain-api'
Expand All @@ -12,6 +14,14 @@ type BlockchainApiArgv = UpgradeArgv
export const handler = async (argv: BlockchainApiArgv) => {
await switchToClusterFromEnv()
const testnetProjectName = fetchEnv(envVar.TESTNET_PROJECT_NAME)
const newFaucetAddress = getAddressFromEnv(AccountType.VALIDATOR, 0) // We use the 0th validator as the faucet
console.info(`updating blockchain-api yaml file for env ${argv.celoEnv}`)
await execCmd(
`sed -i.bak 's/FAUCET_ADDRESS: .*$/FAUCET_ADDRESS: \"${newFaucetAddress}\"/g' ../blockchain-api/app.${
argv.celoEnv
}.yaml`
)
await execCmd(`rm ../blockchain-api/app.${argv.celoEnv}.yaml.bak`) // Removing temporary bak file
console.info(`deploying blockchain-api for env ${argv.config} to ${testnetProjectName}`)
await execCmd(
`yarn --cwd ../blockchain-api run deploy -p ${testnetProjectName} -n ${argv.celoEnv}`
Expand Down
10 changes: 7 additions & 3 deletions packages/celotool/src/cmds/deploy/initial/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,9 @@ async function makeMetadata(testnet: string, address: string, index: number) {
const fileName = `validator-${testnet}-${address}-metadata.json`
const filePath = `/tmp/${fileName}`

const metadata = new IdentityMetadataWrapper(IdentityMetadataWrapper.emptyData)
const metadata = IdentityMetadataWrapper.fromEmpty()
metadata.addClaim(nameClaim)
metadata.addClaim(attestationServiceClaim)

writeFileSync(filePath, metadata.toString())

await uploadFileToGoogleStorage(
Expand Down Expand Up @@ -114,7 +113,12 @@ export const handler = async (argv: InitialArgv) => {
validatorKeys,
},
stableToken: {
initialAccounts: getAddressesFor(AccountType.FAUCET, mnemonic, 2),
initialBalances: {
addresses: getAddressesFor(AccountType.FAUCET, mnemonic, 2),
values: getAddressesFor(AccountType.FAUCET, mnemonic, 2).map(
() => '60000000000000000000000'
), // 60k Celo Dollars
},
},
})

Expand Down
13 changes: 3 additions & 10 deletions packages/celotool/src/cmds/deploy/upgrade/blockchain-api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { switchToClusterFromEnv } from 'src/lib/cluster'
import { envVar, fetchEnv } from 'src/lib/env-utils'
import { execCmd } from 'src/lib/utils'
import { handler as deployInitialBlockchainApiHandler } from '../../deploy/initial/blockchain-api'
import { UpgradeArgv } from '../../deploy/upgrade'

export const command = 'blockchain-api'

export const describe = 'command for upgrading blockchain-api'
Expand All @@ -10,11 +9,5 @@ export const describe = 'command for upgrading blockchain-api'
type BlockchainApiArgv = UpgradeArgv

export const handler = async (argv: BlockchainApiArgv) => {
await switchToClusterFromEnv()
const testnetProjectName = fetchEnv(envVar.TESTNET_PROJECT_NAME)
console.info(`deploying blockchain-api for env ${argv.config} to ${testnetProjectName}`)
await execCmd(
`yarn --cwd ../blockchain-api run deploy -p ${testnetProjectName} -n ${argv.celoEnv}`
)
console.info(`blockchain-api deploy complete`)
await deployInitialBlockchainApiHandler(argv)
}
63 changes: 63 additions & 0 deletions packages/celotool/src/e2e-tests/attestations_tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { ContractKit, newKit } from '@celo/contractkit'
import { AttestationsWrapper } from '@celo/contractkit/lib/wrappers/Attestations'
import { assert } from 'chai'
import { getContext, GethTestConfig, sleep } from './utils'

const validatorAddress = '0x47e172f6cfb6c7d01c1574fa3e2be7cc73269d95'
const phoneNumber = '+15555555555'

describe('governance tests', () => {
const gethConfig: GethTestConfig = {
migrate: true,
instances: [
{ name: 'validator0', validating: true, syncmode: 'full', port: 30303, rpcport: 8545 },
{ name: 'validator1', validating: true, syncmode: 'full', port: 30305, rpcport: 8547 },
{ name: 'validator2', validating: true, syncmode: 'full', port: 30307, rpcport: 8549 },
{ name: 'validator3', validating: true, syncmode: 'full', port: 30309, rpcport: 8551 },
{ name: 'validator4', validating: true, syncmode: 'full', port: 30311, rpcport: 8553 },
],
}

const context: any = getContext(gethConfig)
let contractKit: ContractKit
let Attestations: AttestationsWrapper

before(async function(this: any) {
this.timeout(0)
await context.hooks.before()
})

after(context.hooks.after)

const restart = async () => {
await context.hooks.restart()
contractKit = newKit('http://localhost:8545')
contractKit.defaultAccount = validatorAddress

// TODO(mcortesi): magic sleep. without it unlockAccount sometimes fails
await sleep(2)
// Assuming empty password
await contractKit.web3.eth.personal.unlockAccount(validatorAddress, '', 1000000)
Attestations = await contractKit.contracts.getAttestations()
}

describe('Attestations', () => {
before(async function() {
this.timeout(0)
await restart()
})

it('requests an attestation', async function(this: any) {
this.timeout(10000)
const approve = await Attestations.approveAttestationFee(2)
await approve.sendAndWaitForReceipt()
const request = await Attestations.request(phoneNumber, 2)
await request.sendAndWaitForReceipt()

const stats = await Attestations.getAttestationStat(phoneNumber, validatorAddress)
assert.equal(stats.total, 2)
const actionable = await Attestations.getActionableAttestations(phoneNumber, validatorAddress)
assert.lengthOf(actionable, 2)
})
})
})
5 changes: 2 additions & 3 deletions packages/celotool/src/e2e-tests/exit_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Web3 from 'web3'
import { getContractAddress, getHooks, sleep } from './utils'
import { getContractAddress, getHooks, GethTestConfig, sleep } from './utils'

const blockchainParametersAbi = [
{
Expand Down Expand Up @@ -29,9 +29,8 @@ const blockchainParametersAbi = [
describe('exit tests', function(this: any) {
this.timeout(0)

const gethConfig = {
const gethConfig: GethTestConfig = {
migrateTo: 15,
migrateGovernance: false,
instances: [
{ name: 'validator', validating: true, syncmode: 'full', port: 30303, rpcport: 8545 },
],
Expand Down
Loading

0 comments on commit b690e87

Please sign in to comment.