Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Add new token symbol scripts

* Remove old contracts

* Remove old js code

* Contract test code gen

* Try franklin init CI

* Try franklin contract build

* Ignore yarn errors for now

* Clean cache

* Add env check script

* Use drone CI

* Cache in DroneCI

* Cache in CI

* Working CI version one

* Try fix two build per commit

* Fix some scripts

* Fix fmt

* Drone cargo fmt fix

* Contract test CI

* Cache fix

* CI env

* Docker ci

* Fix test builds

* Fix clippy

* Add rust test and clippy to CI

* Rename db update script

* Move contract generation to franklin build-contracts

* Add erc20 token script

* Fix clippy in data restore
  • Loading branch information
dvush authored Oct 22, 2019
1 parent 66076f5 commit daa06fe
Show file tree
Hide file tree
Showing 126 changed files with 553 additions and 16,847 deletions.
117 changes: 117 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
kind: pipeline
type: docker
name: default

steps:
- name: restore-cache
image: drillster/drone-volume-cache
volumes:
- name: cache
path: /cache
settings:
restore: true
mount:
- ./contracts/node_modules
- ./js/client_js/node_modules
- ./js/explorer/node_modules
- ./js/franklin_lib/node_modules
- ./target/cargo

- name: init
image: matterlabs/ci
commands:
- export FRANKLIN_HOME=`pwd`
- export PATH=$FRANKLIN_HOME/bin:$PATH
- export CARGO_HOME=$FRANKLIN_HOME/target/cargo
- franklin env ci
- franklin yarn
- franklin db-wait
- franklin db-setup
depends_on:
- restore-cache

- name: build-contracts
image: matterlabs/ci
commands:
- export FRANKLIN_HOME=`pwd`
- export PATH=$FRANKLIN_HOME/bin:$PATH
- export CARGO_HOME=$FRANKLIN_HOME/target/cargo
- franklin build-contracts
depends_on:
- init

- name: rust-checks
image: matterlabs/ci
commands:
- export FRANKLIN_HOME=`pwd`
- export PATH=$FRANKLIN_HOME/bin:$PATH
- export CARGO_HOME=$FRANKLIN_HOME/target/cargo
- cargo fmt -- --check
- cargo clippy --tests --benches -- -D warnings
depends_on:
- build-contracts

- name: rust-tests
image: matterlabs/ci
commands:
- export FRANKLIN_HOME=`pwd`
- export PATH=$FRANKLIN_HOME/bin:$PATH
- export CARGO_HOME=$FRANKLIN_HOME/target/cargo
- cargo test
depends_on:
- rust-checks

- name: deploy-test
image: matterlabs/ci
commands:
- export FRANKLIN_HOME=`pwd`
- export PATH=$FRANKLIN_HOME/bin:$PATH
- export CARGO_HOME=$FRANKLIN_HOME/target/cargo
- franklin genesis
- franklin redeploy
depends_on:
- rust-tests

- name: contract-test
image: matterlabs/ci
commands:
- export FRANKLIN_HOME=`pwd`
- export PATH=$FRANKLIN_HOME/bin:$PATH
- export CARGO_HOME=$FRANKLIN_HOME/target/cargo
- franklin test-contracts
depends_on:
- build-contracts


- name: rebuild-cache
image: drillster/drone-volume-cache
volumes:
- name: cache
path: /cache
settings:
rebuild: true
mount:
- ./contracts/node_modules
- ./js/client_js/node_modules
- ./js/explorer/node_modules
- ./js/franklin_lib/node_modules
- ./target/cargo
depends_on:
- init
- rust-checks


volumes:
- name: cache
host:
path: /tmp/cache

services:
- name: geth
image: gluk64/franklin:geth
- name: postgres
image: postgres:10.4

trigger:
event:
- pull_request
15 changes: 0 additions & 15 deletions .github/workflows/rust.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Cargo.lock

/etc/env/*
!/etc/env/dev.env.example
!/etc/env/ci.env
/contracts/yarn-error.log
/deploy.log
/test.log
Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ init:
yarn:
@cd js/franklin_lib && yarn
@cd js/client && yarn
@cd js/loadtest && yarn
@cd js/explorer && yarn
@cd contracts && yarn

Expand Down Expand Up @@ -141,11 +140,11 @@ push-image-rust: image-rust
deploy-contracts: confirm_action
@bin/deploy-contracts.sh

test-contracts: confirm_action
@bin/prepare-test-contracts.sh
test-contracts: confirm_action build-contracts
@bin/contracts-test.sh

build-contracts: confirm_action
@bin/prepare-test-contracts.sh
@cd contracts && yarn build

# deploy-contracts: confirm_action
Expand Down Expand Up @@ -227,6 +226,8 @@ endif
ifeq (dev,$(FRANKLIN_ENV))
stop: confirm_action
@docker-compose stop server prover
else ifeq (ci,$(FRANKLIN_ENV))
stop:
else
stop: confirm_action stop-prover stop-server stop-nginx
endif
Expand Down
2 changes: 1 addition & 1 deletion bin/.confirm_action
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

if [ ! "$FRANKLIN_ENV" == "dev" ]
if [ "$FRANKLIN_ENV" != "dev" ] && [ "$FRANKLIN_ENV" != "ci" ]
then
echo -n "Dangerous action. Type environment name ('$FRANKLIN_ENV') to confirm: "
read CONFIRMED
Expand Down
25 changes: 25 additions & 0 deletions bin/check-environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

set -e

check_tool() {
command -v $1 > /dev/null || (echo $1 not found && exit 1)
}

echo Checking environment

check_tool yarn
check_tool node
node --version | grep "v10.*" > /dev/null || (echo "Node version 10 is supported" && exit 1)
check_tool docker
check_tool docker-compose
check_tool envsubst
check_tool cargo
check_tool jq
check_tool psql
check_tool pg_isready
check_tool diesel

( (sed --version | grep GNU) &> /dev/null || (gsed --version | grep GNU) &> /dev/null ) || (echo "sed or gsed should be GNU-sed" && exit 1)

echo Environment is fine
15 changes: 15 additions & 0 deletions bin/db-update-token-symbol.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# Usage: db-update-token-symbol.sh token_address new_token_symbol

. .setup_env

set -e

TOKEN_ADDRESS=$1
SYMBOL=$2

echo Setting token $2 symbol to $1
psql "$DATABASE_URL" -c "UPDATE tokens \
SET symbol = '$SYMBOL' \
WHERE address = '$TOKEN_ADDRESS'"
10 changes: 10 additions & 0 deletions bin/governance-add-erc20.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Usage: governance-add-erc20.sh erc20_token_address
# Adds new ERC20 token to our network
. .setup_env

.confirm_action || exit 1

cd $FRANKLIN_HOME/contracts
f npx ts-node scripts/add-erc20-token.ts $1
2 changes: 2 additions & 0 deletions bin/init
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -e

check-environment.sh

franklin dev-up
franklin env
franklin yarn || true # It can fail.
Expand Down
2 changes: 2 additions & 0 deletions bin/prepare-test-contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

. .setup_env

cd $FRANKLIN_HOME

IN_DIR=./contracts/contracts/
OUT_DIR=./contracts/contracts/generated

Expand Down
6 changes: 3 additions & 3 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
},
"scripts": {
"build": "waffle",
"test": "waffle && mocha -r ts-node/register test/**/*.ts",
"deploy": "waffle && ts-node scripts/testnet-deploy.ts",
"test": "yarn build && mocha -r ts-node/register test/**/*.ts",
"deploy": "yarn build && ts-node scripts/testnet-deploy.ts",
"print-operator-wallet": "ts-node scripts/init-operator-acc.ts",
"submit-proof": "ts-node scripts/submit-proof.ts",
"submit-test-proof": "waffle && ts-node scripts/submit-test-proof.ts",
"submit-test-proof": "yarn build && ts-node scripts/submit-test-proof.ts",
"lint:solidity": "solhint contracts/**/*.sol",
"lint:ts": "tslint -c tslint.json {scripts,test}/**/*.ts",
"lint:ts-fix": "tslint -c tslint.json --fix {scripts,test}/**/*.ts",
Expand Down
19 changes: 19 additions & 0 deletions contracts/scripts/add-erc20-token.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {bigNumberify} from "ethers/utils";
import {Contract, ethers} from "ethers";
import {governanceContractCode} from "../src.ts/deploy";
import {AddressZero} from "ethers/constants";

const provider = new ethers.providers.JsonRpcProvider(process.env.WEB3_URL);
const governorWallet = ethers.Wallet.fromMnemonic(process.env.MNEMONIC, "m/44'/60'/0'/0/1").connect(provider);
const governanceDeployedContract = new Contract(process.env.GOVERNANCE_ADDR, governanceContractCode.interface, governorWallet);

async function main() {
let tokenAddress = process.argv[process.argv.length - 1];
console.log("Adding new ERC20 token to network: ", tokenAddress);
let tx = await governanceDeployedContract.addToken(tokenAddress, {gasLimit: bigNumberify("1000000")});
console.log("tx hash: ",tx.hash);
let receipt = await tx.wait();
console.log("status: ", receipt.status);
}

main();
3 changes: 0 additions & 3 deletions contracts_old/.gitignore

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion contracts_old/bin/contracts_FranklinProxy_sol_Franklin.abi

This file was deleted.

1 change: 0 additions & 1 deletion contracts_old/bin/contracts_FranklinProxy_sol_Franklin.bin

This file was deleted.

1 change: 0 additions & 1 deletion contracts_old/bin/contracts_Migrations_sol_Migrations.abi

This file was deleted.

Loading

0 comments on commit daa06fe

Please sign in to comment.