diff --git a/README.md b/README.md index 5779b026c..5154ae2d3 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@
-

Rainbow Bridge

+

Rainbow Bridge CLI

- Ethereum to Near trustless, fully decentralized, bidirectional bridge + OPS tool to Rainbow Bridge, an Ethereum to Near trustless, fully decentralized, bidirectional bridge

@@ -11,13 +11,13 @@ npm

- Installation + Installation | - Usage + Usage | - Documentation + Documentation | - Examples + Examples

@@ -28,6 +28,11 @@ need CLI only for the token transfer you need to install all testing dependencie - Install golang, [see](https://golang.org/dl/). - Make sure you are using Node with version <=13. We recommend using [nvm](https://github.com/nvm-sh/nvm) for installing node and npm, if you already don't have one. This constraint will be removed soon; +- yarn +- docker, for deterministic compile rust contracts + +### If you want to test with a local near node: + - You would also need to install resources needed to compile nearcore (in the future this will only be required for the testing CLI): ```bash @@ -38,34 +43,27 @@ rustup target add wasm32-unknown-unknown ``` - Then install dependencies needed for the compilation of nearcore, [see](https://docs.near.org/docs/local-setup/running-testnet#compiling-and-running-official-node-without-docker). - -## Prerequisite - -- linux or mac -- nodejs 12 or 13 -- npm -- yarn -- golang 1.13 or above (For ethashproof util) -- docker (For deterministic compile rust contracts) - -If you want to test with a local near node: - -- rust, and necessary library to build nearcore (For compile and run a local near node) -- python 3.6 or above (For nearup) +- python3, for nearup ## Usage You can install `rainbow-bridge-cli` from npm +``` npm i -g rainbow-bridge-cli +``` To learn the commands that you can use with the rainbow bridge run - rainbow-bridge --help +``` + rainbow --help +``` -Alternatively, clone this repo, `cd environment && yarn install && cd ..`, then you can see what commands you can use with: +Alternatively, clone this repo, `yarn install`, then you can see what commands you can use with: +``` ./index.js --help +``` Parameters of each command can be specified through environment variables, command line arguments, entries in the `~/.rainbow/config.json` config file, or the default value will be used -- in that priority. If argument is not provided and there is no default value the program will not execute. @@ -120,8 +118,7 @@ Let's set them up: Prepare CLI: ```bash -git clone https://github.com/near/rainbow-bridge/ -cd rainbow-bridge/environment +git clone https://github.com/near/rainbow-bridge-cli/ yarn node index.js clean node index.js prepare @@ -305,6 +302,27 @@ node index.js transfer-eth-erc20-from-near --amount 1 --near-sender-account rain You should observe the change of the ERC20 balance as reported by the CLI. +## Contract Development Workflow + +Above steps are ways to run a local bridge and development workflows you need if make any changes to rainbow-bridge-cli. If you want to update any of solidity or rust contracts, they're not in this repo now and workflow is as following. + +- Install dependencies: +```bash +node index.js clean +node index.js prepare +``` +- Start local NEAR network and Ganache +```bash +node start near-node +node start ganache +``` +- If you want to modify solidity contracts, go to `node_modules/rainbow-bridge-sol`, make changes there and run `./build_all.sh` to recompile solidity contracts. +- If you want to modify rust contracts, go to `node_modules/ranbow-bridge-rs`, make changes there and run `./build_all.sh` to recompile rust contracts. +- If you want to modify rainbow bridge lib, go to `node_modules/rainbow-bridge-lib` and make changes there +- Follow instructions above to init eth contracts and near contracts, start services and start testing with bridge +- For changes to Solidity contract, Rust contract, and rainbow-bridge-lib, please submit PRs to: https://github.com/near/rainbow-bridge-sol , https://github.com/near/rainbow-bridge-rs , and https://github.com/near/rainbow-bridge-lib respectively. +- After PR merged in contract repos and rainbow-bridge-lib repo, we will periodically publish them as new version of npm packages. And rainbow-bridge-cli will adopt new version of them. + # Docker: ## Currently we have the following docker options: diff --git a/ci/patch_contract_version.js b/ci/patch_contract_version.js index e491b4e77..0ea3a19a2 100755 --- a/ci/patch_contract_version.js +++ b/ci/patch_contract_version.js @@ -15,6 +15,11 @@ async function main() { 'rainbow-bridge-rs' ] = `near/rainbow-bridge-rs#${process.env.PATCH_RAINBOW_BRIDGE_RS}` } + if (process.env.PATCH_RAINBOW_BRIDGE_LIB) { + packageJson.dependencies[ + 'rainbow-bridge-lib' + ] = `near/rainbow-bridge-lib#${process.env.PATCH_RAINBOW_BRIDGE_LIB}` + } console.log('Contract versions:') console.log( `rainbow-bridge-sol: ${packageJson.dependencies['rainbow-bridge-sol']}` @@ -22,9 +27,13 @@ async function main() { console.log( `rainbow-bridge-rs: ${packageJson.dependencies['rainbow-bridge-rs']}` ) + console.log( + `rainbow-bridge-lib: ${packageJson.dependencies['rainbow-bridge-lib']}` + ) if ( !process.env.PATCH_RAINBOW_BRIDGE_SOL && - !process.env.PATCH_RAINBOW_BRIDGE_RS + !process.env.PATCH_RAINBOW_BRIDGE_RS && + !process.env.PATCH_RAINBOW_BRIDGE_LIB ) { process.exit() } diff --git a/ci/test_verify_eth_headers.sh b/ci/test_verify_eth_headers.sh deleted file mode 100755 index e0d32e9da..000000000 --- a/ci/test_verify_eth_headers.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -set -euo pipefail - -CI_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -ROOT_DIR=$CI_DIR/.. - -mkdir -p $ROOT_DIR/testdata -cd $ROOT_DIR/testdata -curl https://s3-us-west-1.amazonaws.com/rainbow-bridge.nearprotocol.com/test-data/eth-headers.tar.gz -o eth-headers.tar.gz -tar zxf eth-headers.tar.gz - -cd $ROOT_DIR/libs-rs/eth-client -ETH_HEADER_DIR=$ROOT_DIR/testdata/headers cargo test --package eth-client --features expensive_tests --lib -- tests::predumped_block_can_be_added --exact --nocapture diff --git a/ci/test_verify_eth_proofs.sh b/ci/test_verify_eth_proofs.sh deleted file mode 100755 index c81c65d2c..000000000 --- a/ci/test_verify_eth_proofs.sh +++ /dev/null @@ -1,14 +0,0 @@ - #!/bin/bash -set -euo pipefail - -CI_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -ROOT_DIR=$CI_DIR/.. - - -mkdir -p $ROOT_DIR/testdata -cd $ROOT_DIR/testdata -curl https://s3-us-west-1.amazonaws.com/rainbow-bridge.nearprotocol.com/test-data/eth-proofs.tar.gz -o eth-proofs.tar.gz -tar zxf eth-proofs.tar.gz - -cd $ROOT_DIR/libs-rs/eth-prover -ETH_PROOF_DIR=$ROOT_DIR/testdata/eth-proofs cargo test --package eth-prover --features expensive_tests --lib -- tests::verify_dumped_log_entries --exact --nocapture \ No newline at end of file diff --git a/ci/test_verify_near_headers.sh b/ci/test_verify_near_headers.sh deleted file mode 100755 index 0941ecabe..000000000 --- a/ci/test_verify_near_headers.sh +++ /dev/null @@ -1,17 +0,0 @@ - #!/bin/bash -set -euo pipefail - -CI_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -ROOT_DIR=$CI_DIR/.. - -mkdir -p $ROOT_DIR/testdata -cd $ROOT_DIR/testdata -curl https://s3-us-west-1.amazonaws.com/rainbow-bridge.nearprotocol.com/test-data/near-headers.tar.gz -o near-headers.tar.gz -tar zxf near-headers.tar.gz - -cd $ROOT_DIR -yarn - -cd $ROOT_DIR/node_modules/rainbow-bridge-sol/nearbridge -yarn -NEAR_HEADERS_DIR=$ROOT_DIR/testdata/near-headers yarn test diff --git a/ci/test_verify_near_proofs.sh b/ci/test_verify_near_proofs.sh deleted file mode 100755 index 75f32974a..000000000 --- a/ci/test_verify_near_proofs.sh +++ /dev/null @@ -1,17 +0,0 @@ - #!/bin/bash -set -euo pipefail - -CI_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -ROOT_DIR=$CI_DIR/.. - -mkdir -p $ROOT_DIR/testdata -cd $ROOT_DIR/testdata -curl https://s3-us-west-1.amazonaws.com/rainbow-bridge.nearprotocol.com/test-data/near-proofs.tar.gz -o near-proofs.tar.gz -tar zxf near-proofs.tar.gz - -cd $ROOT_DIR -yarn - -cd $ROOT_DIR/node_modules/rainbow-bridge-sol/nearprover -yarn -NEAR_PROOFS_DIR=$ROOT_DIR/testdata/near-proofs yarn test diff --git a/index.js b/index.js index 85d66bb39..e9dfd9796 100755 --- a/index.js +++ b/index.js @@ -36,7 +36,7 @@ const { InitEthProver, } = require('rainbow-bridge-lib/init') -// source dir of environment dir or where rainbow is installed (when install with npm) +// source dir or where rainbow cli is installed (when install with npm) const BRIDGE_SRC_DIR = __dirname const LIBS_SOL_SRC_DIR = path.join( BRIDGE_SRC_DIR, diff --git a/scripts/prepare.sh b/scripts/prepare.sh index 10e63d83d..9c4e858d5 100644 --- a/scripts/prepare.sh +++ b/scripts/prepare.sh @@ -59,7 +59,7 @@ cd $BRIDGE_SRC git submodule update --init --recursive yarn -echo "Installed environment dependencies" +echo "Installed CLI dependencies" cd $BRIDGE_SRC/vendor/ganache yarn