diff --git a/.env b/.env index 8fa94d0..faa6ee2 100644 --- a/.env +++ b/.env @@ -1,11 +1,13 @@ # Must be set to true for the first run, change it to "false" to avoid migrating the smart contracts on each run. -DEPLOY_CONTRACTS=true +KEEPER_DEPLOY_CONTRACTS=true + +# Specify which ethereum client to run or connect to: kovan, ganache, or ocean_poa_net_local +KEEPER_NETWORK_NAME=development +KEEPER_ARTIFACTS_FOLDER=~/.ocean/keeper-contracts/artifacts + # Ganache specific option, these two options have no effect when not running ganache-cli GANACHE_DATABASE_PATH=. -REUSE_DATABASE=false -# Specify which ethereum client to run or connect to: kovan, ganache, or ocean_poa_net_local -KEEPER_NETWORK_NAME=ganache -ARTIFACTS_FOLDER=~/.ocean/keeper-contracts/artifacts +GANACHE_REUSE_DATABASE=false + # Specify which ocean version use: stable, latests, ... OCEAN_VERSION=stable -COMPOSE_FILE=docker-compose.yml diff --git a/brizo.env b/brizo.env index 2f64e90..bb3d2f9 100755 --- a/brizo.env +++ b/brizo.env @@ -1,17 +1,12 @@ # Use this file to set the env vars required for Brizo. -KEEPER_URL=http://parity-node:8545 -LOCAL_CONTRACTS=true -KEEPER_NETWORK_NAME=ocean_poa_net_local - -SECRET_STORE_URL=http://secret-store:12001 -PARITY_URL=http://parity-node:8545 # Set a valid parity address and password to have seamless interaction with the `keeper` PARITY_ADDRESS=0x00bd138abd70e2f00903268f3db08f2d25677c9e PARITY_PASSWORD=node0 AQUARIUS_URL=http://aquarius:5000 -BRIZO_URL=http://brizo:8030 +SECRET_STORE_URL=http://secret-store:12001 +RPC_URL=http://keeper-node:8545 AZURE_ACCOUNT_NAME= AZURE_ACCOUNT_KEY= diff --git a/compose-files/aquarius.yml b/compose-files/aquarius.yml index 6daeb4c..f0aab6f 100644 --- a/compose-files/aquarius.yml +++ b/compose-files/aquarius.yml @@ -11,3 +11,10 @@ services: - mongodb environment: DB_HOSTNAME: mongodb + + mongodb: + image: mongo:3.6 + command: mongod + networks: + backend: + ipv4_address: 172.15.0.11 diff --git a/compose-files/brizo.yml b/compose-files/brizo.yml index 0c2fa4f..06fa6a6 100644 --- a/compose-files/brizo.yml +++ b/compose-files/brizo.yml @@ -8,10 +8,10 @@ services: backend: ipv4_address: 172.15.0.17 depends_on: - - keeper-contracts + - keeper-node env_file: - ${BRIZO_ENV_FILE} environment: - KEEPER_URL: http://${RPC_URL}:8545 + KEEPER_URL: ${KEEPER_RPC_URL} volumes: - - ${ARTIFACTS_FOLDER}:/usr/local/keeper-contracts/:ro + - ${KEEPER_ARTIFACTS_FOLDER}:/usr/local/keeper-contracts/:ro diff --git a/compose-files/keeper_contracts.yml b/compose-files/keeper_contracts.yml index 0c4dd5b..5462e5c 100644 --- a/compose-files/keeper_contracts.yml +++ b/compose-files/keeper_contracts.yml @@ -2,18 +2,18 @@ version: '2.1' services: keeper-contracts: image: oceanprotocol/keeper-contracts:${OCEAN_VERSION:-stable} - ports: - - "${KEEPER_PORT}:8545" networks: backend: ipv4_address: 172.15.0.14 environment: - LOCAL_CONTRACTS: "true" - DEPLOY_CONTRACTS: ${DEPLOY_CONTRACTS} + DEPLOY_CONTRACTS: ${KEEPER_DEPLOY_CONTRACTS} + REUSE_DATABASE: ${GANACHE_REUSE_DATABASE} DATABASE_PATH: "/ganache-db" - REUSE_DATABASE: ${REUSE_DATABASE} NETWORK_NAME: ${KEEPER_NETWORK_NAME} - POA_HOST: "parity-node" + KEEPER_RPC_HOST: ${KEEPER_RPC_HOST} + KEEPER_RPC_PORT: ${KEEPER_RPC_PORT} + KEEPER_RPC_URL: ${KEEPER_RPC_URL} + depends_on: + - keeper-node volumes: - - ${ARTIFACTS_FOLDER}:/keeper-contracts/artifacts/ - - ${GANACHE_DATABASE_PATH}/ganache-db:/ganache-db + - ${KEEPER_ARTIFACTS_FOLDER}:/keeper-contracts/artifacts/ diff --git a/compose-files/mongo.yml b/compose-files/mongo.yml deleted file mode 100644 index 0a5751a..0000000 --- a/compose-files/mongo.yml +++ /dev/null @@ -1,8 +0,0 @@ -version: '2.1' -services: - mongodb: - image: mongo:3.6 - command: mongod - networks: - backend: - ipv4_address: 172.15.0.11 diff --git a/compose-files/network_volumes.yml b/compose-files/network_volumes.yml index c83814b..14bf031 100644 --- a/compose-files/network_volumes.yml +++ b/compose-files/network_volumes.yml @@ -10,5 +10,5 @@ networks: gateway: 172.15.0.1 volumes: - parity-node: + keeper-node: secret-store: diff --git a/compose-files/nodes/ganache_node.yml b/compose-files/nodes/ganache_node.yml new file mode 100644 index 0000000..23404be --- /dev/null +++ b/compose-files/nodes/ganache_node.yml @@ -0,0 +1,9 @@ +version: '2.1' +services: + keeper-node: + image: trufflesuite/ganache-cli:latest + ports: + - 8545:8545 + networks: + backend: + ipv4_address: 172.15.0.12 diff --git a/compose-files/nodes/kovan_node.yml b/compose-files/nodes/kovan_node.yml new file mode 100644 index 0000000..eb4c8dc --- /dev/null +++ b/compose-files/nodes/kovan_node.yml @@ -0,0 +1,19 @@ +version: '2.1' +services: + keeper-node: + image: oceanprotocol/parity-ethereum:beta + entrypoint: /opt/parity/parity + command: + --chain kovan + --light + --ws-interface all + --jsonrpc-cors all + --jsonrpc-interface all + --jsonrpc-hosts all + --jsonrpc-apis all + --unsafe-expose + ports: + - 8545:8545 + networks: + backend: + ipv4_address: 172.15.0.12 diff --git a/compose-files/parity_client.yml b/compose-files/nodes/pond_node.yml similarity index 93% rename from compose-files/parity_client.yml rename to compose-files/nodes/pond_node.yml index 1b8fe97..0d74921 100644 --- a/compose-files/parity_client.yml +++ b/compose-files/nodes/pond_node.yml @@ -1,6 +1,6 @@ version: '2.1' services: - parity-node: + keeper-node: image: oceanprotocol/parity-ethereum:beta entrypoint: /opt/parity/parity command: @@ -18,7 +18,7 @@ services: --unlock 0x00bd138abd70e2f00903268f3db08f2d25677c9e volumes: - ../parity/parity/config:/home/parity/parity/config - - parity-node:/home/parity/.local/share/io.parity.ethereum/ + - keeper-node:/home/parity/.local/share/io.parity.ethereum/ - ../parity/parity/authorities/validator0.json:/home/parity/.local/share/io.parity.ethereum/keys/ocean-network/validator.json - ../parity/parity/keys:/home/parity/.local/share/io.parity.ethereum/keys/ocean-network - ../parity/parity/authorities/validator0.pwd:/home/parity/parity/validator.pwd diff --git a/compose-files/pleuston.yml b/compose-files/pleuston.yml index 095062d..e56bb07 100644 --- a/compose-files/pleuston.yml +++ b/compose-files/pleuston.yml @@ -4,16 +4,17 @@ services: image: oceanprotocol/pleuston:${OCEAN_VERSION:-stable} networks: backend: - ipv4_address: 172.15.0.18 + ipv4_address: 172.15.0.19 ports: - 3000:3000 depends_on: + - keeper-node - aquarius - brizo environment: # Need browser to connect to exposed ports KEEPER_HOST: localhost AQUARIUS_HOST: localhost - LOCAL_CONTRACTS: 'true' + LOCAL_CONTRACTS: ${KEEPER_DEPLOY_CONTRACTS} volumes: - - ${ARTIFACTS_FOLDER}:/pleuston/node_modules/@oceanprotocol/keeper-contracts/artifacts/:ro + - ${KEEPER_ARTIFACTS_FOLDER}:/pleuston/node_modules/@oceanprotocol/keeper-contracts/artifacts/:ro diff --git a/compose-files/secret_store.yml b/compose-files/secret_store.yml index 748d7db..68233fa 100644 --- a/compose-files/secret_store.yml +++ b/compose-files/secret_store.yml @@ -7,12 +7,12 @@ services: command: --config /etc/parity/secretstore/config.toml --jsonrpc-cors all --jsonrpc-interface all --jsonrpc-hosts all --jsonrpc-apis all volumes: - - ../parity/secret_store/config/:/etc/parity/secretstore/ - - secret-store:/parity_data/ - - ../parity/secret_store/keys/:/parity_data/keys/ocean-network/ + - ../parity/secret_store/config/:/etc/parity/secretstore/ + - secret-store:/parity_data/ + - ../parity/secret_store/keys/:/parity_data/keys/ocean-network/ ports: - - 12000:12000 - - 12001 + - 12000:12000 + - 12001 networks: backend: ipv4_address: 172.15.0.13 @@ -29,3 +29,21 @@ services: backend: ipv4_address: 172.15.0.16 command: nginx -g 'daemon off;' + + secret-store-signing-node: + image: oceanprotocol/parity-ethereum:master + entrypoint: /opt/parity/parity + command: + --chain dev + --light + --jsonrpc-interface all + --jsonrpc-apis secretstore + --jsonrpc-cors all + --keys-path /home/parity/.local/keys + ports: + - 9545:8545 + volumes: + - ../parity/parity/keys:/home/parity/.local/keys/DevelopmentChain:ro + networks: + backend: + ipv4_address: 172.15.0.18 \ No newline at end of file diff --git a/parity/docker-compose.yml b/parity/docker-compose.yml index 1c658cc..9e6f2b8 100644 --- a/parity/docker-compose.yml +++ b/parity/docker-compose.yml @@ -14,8 +14,8 @@ services: volumes: - ./parity/config:/parity/config:ro - validator0:/root/.local/share/io.parity.ethereum/ - - ./parity/authorities/validator0.json:/root/.local/share/io.parity.ethereum/keys/${NETWORK_NAME}/validator.json:ro - - ./parity/keys:/root/.local/share/io.parity.ethereum/keys/${NETWORK_NAME} + - ./parity/authorities/validator0.json:/root/.local/share/io.parity.ethereum/keys/${KEEPER_NETWORK_NAME}/validator.json:ro + - ./parity/keys:/root/.local/share/io.parity.ethereum/keys/${KEEPER_NETWORK_NAME} - ./parity/authorities/validator0.pwd:/parity/validator.pwd:ro - ./parity/node0.network.key:/root/.local/share/io.parity.ethereum/network/key:ro ports: @@ -32,7 +32,7 @@ services: volumes: - ./parity/config:/parity/config:ro - validator1:/root/.local/share/io.parity.ethereum/ - - ./parity/authorities/validator1.json:/root/.local/share/io.parity.ethereum/keys/${NETWORK_NAME}/validator.json:ro + - ./parity/authorities/validator1.json:/root/.local/share/io.parity.ethereum/keys/${KEEPER_NETWORK_NAME}/validator.json:ro - ./parity/authorities/validator1.pwd:/parity/validator.pwd:ro - ./parity/node1.network.key:/root/.local/share/io.parity.ethereum/network/key:ro networks: @@ -47,7 +47,7 @@ services: volumes: - ./parity/config:/parity/config:ro - validator2:/root/.local/share/io.parity.ethereum/ - - ./parity/authorities/validator2.json:/root/.local/share/io.parity.ethereum/keys/${NETWORK_NAME}/validator.json:ro + - ./parity/authorities/validator2.json:/root/.local/share/io.parity.ethereum/keys/${KEEPER_NETWORK_NAME}/validator.json:ro - ./parity/authorities/validator2.pwd:/parity/validator.pwd:ro - ./parity/node2.network.key:/root/.local/share/io.parity.ethereum/network/key:ro networks: @@ -64,7 +64,7 @@ services: --unsafe-expose volumes: - ./parity/config:/parity/config:ro - - ./parity/keys:/root/.local/share/io.parity.ethereum/keys/${NETWORK_NAME} + - ./parity/keys:/root/.local/share/io.parity.ethereum/keys/${KEEPER_NETWORK_NAME} ports: - 8180:8180 - 8546:8546 diff --git a/start_ocean.sh b/start_ocean.sh index 8220dfd..76af9a2 100755 --- a/start_ocean.sh +++ b/start_ocean.sh @@ -2,20 +2,25 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" COMPOSE_DIR="${DIR}/compose-files" -# Must be set to true for the first run, change it to "false" to avoid migrating the smart contracts on each run. -export DEPLOY_CONTRACTS="true" + +export PROJECT_NAME="ocean" + +# keeper options +export KEEPER_DEPLOY_CONTRACTS="true" +export KEEPER_ARTIFACTS_FOLDER=$HOME/.ocean/keeper-contracts/artifacts +# Specify which ethereum client to run or connect to: development, kovan, or ocean_poa_net_local +export KEEPER_NETWORK_NAME="ocean_poa_net_local" + # Ganache specific option, these two options have no effect when not running ganache-cli export GANACHE_DATABASE_PATH="${DIR}" -export REUSE_DATABASE="false" -# Specify which ethereum client to run or connect to: kovan, ganache, or ocean_poa_net_local -export KEEPER_NETWORK_NAME="ganache" -export ARTIFACTS_FOLDER=$HOME/.ocean/keeper-contracts/artifacts -export BRIZO_ENV_FILE=$DIR/brizo.env -export PROJECT_NAME="ocean" -# Specify the ethereum default RPC container provider -export RPC_URL='keeper-contracts' -export KEEPER_PORT='8545' +export GANACHE_REUSE_DATABASE="false" +export BRIZO_ENV_FILE=$DIR/brizo.env + +# Specify the ethereum default RPC container provider +export KEEPER_RPC_HOST='keeper-node' +export KEEPER_RPC_PORT='8545' +export KEEPER_RPC_URL="http://"${KEEPER_RPC_HOST}:${KEEPER_RPC_PORT} # colors COLOR_R="\033[0;31m" # red @@ -38,47 +43,82 @@ show_banner # default to latest versions export OCEAN_VERSION=latest +export NODE_FILE=${COMPOSE_DIR}/nodes/pond_node.yml COMPOSE_FILES="" COMPOSE_FILES+=" -f ${COMPOSE_DIR}/network_volumes.yml" -COMPOSE_FILES+=" -f ${COMPOSE_DIR}/mongo.yml" -COMPOSE_FILES+=" -f ${COMPOSE_DIR}/keeper_contracts.yml" COMPOSE_FILES+=" -f ${COMPOSE_DIR}/pleuston.yml" COMPOSE_FILES+=" -f ${COMPOSE_DIR}/aquarius.yml" COMPOSE_FILES+=" -f ${COMPOSE_DIR}/brizo.yml" +COMPOSE_FILES+=" -f ${COMPOSE_DIR}/secret_store.yml" while :; do case $1 in + ################################################# + # Version switches + ################################################# --latest) export OCEAN_VERSION=latest printf $COLOR_Y'Switched to latest components...\n\n'$COLOR_RESET ;; - --reuse-database) - export REUSE_DATABASE="true" - printf $COLOR_Y'Starting and reusing the database ...\n\n'$COLOR_RESET - ;; + ################################################# + # Exclude switches + ################################################# --no-pleuston) COMPOSE_FILES=${COMPOSE_FILES/ -f ${COMPOSE_DIR}\/pleuston.yml/} printf $COLOR_Y'Starting without Pleuston...\n\n'$COLOR_RESET ;; - --local-parity-node) - COMPOSE_FILES+=" -f ${COMPOSE_DIR}/parity_client.yml" - COMPOSE_FILES+=" -f ${COMPOSE_DIR}/secret_store.yml" - export RPC_URL='parity-node' - export KEEPER_NETWORK_NAME="ocean_poa_net_local" - export KEEPER_PORT='8546' - printf $COLOR_Y'Starting with local Parity node...\n\n'$COLOR_RESET + ################################################# + # Contract/Storage switches + ################################################# + --reuse-ganache-database) + export GANACHE_REUSE_DATABASE="true" + printf $COLOR_Y'Starting and reusing the database ...\n\n'$COLOR_RESET ;; + ################################################# + # Node type switches + ################################################# + # connects you to kovan + --local-kovan-node) + export NODE_FILE=${COMPOSE_DIR}/nodes/kovan_node.yml + export KEEPER_NETWORK_NAME="kovan" + printf $COLOR_Y'Starting with local Kovan node...\n\n'$COLOR_RESET + ;; + # spins up a new ganache blockchain + --local-ganache-node) + COMPOSE_FILES+=" -f ${COMPOSE_DIR}/keeper_contracts.yml" + export NODE_FILE=${COMPOSE_DIR}/nodes/ganache_node.yml + export KEEPER_NETWORK_NAME="development" + export KEEPER_DEPLOY_CONTRACTS="true" + printf $COLOR_Y'Starting with local Ganache node...\n\n'$COLOR_RESET + ;; + # connects you to ocean testnet + --local-lake-node) + export NODE_FILE=${COMPOSE_DIR}/nodes/lake_node.yml + export KEEPER_NETWORK_NAME="ocean_poa_aws" + printf $COLOR_Y'Starting with local Lake node...\n\n'$COLOR_RESET + ;; + # spins up pond local testnet + --local-pond-node) + COMPOSE_FILES+=" -f ${COMPOSE_DIR}/keeper_contracts.yml" + export NODE_FILE=${COMPOSE_DIR}/nodes/pond_node.yml + export KEEPER_NETWORK_NAME="ocean_poa_net_local" + export KEEPER_DEPLOY_CONTRACTS="true" + printf $COLOR_Y'Starting with local Pond node...\n\n'$COLOR_RESET + ;; + ################################################# + # Cleaning switches + ################################################# --purge) - docker network rm $PROJECT_NAME_backend || true - docker network rm $PROJECT_NAME_default || true - docker volume rm $PROJECT_NAME_parity-node || true - docker volume rm $PROJECT_NAME_secret-store || true - read -p "Are you sure you want to delete $ARTIFACTS_FOLDER? " -n 1 -r + docker network rm ${PROJECT_NAME}_backend || true + docker network rm ${PROJECT_NAME}_default || true + docker volume rm ${PROJECT_NAME}_keeper-node || true + docker volume rm ${PROJECT_NAME}_secret-store || true + read -p "Are you sure you want to delete $KEEPER_ARTIFACTS_FOLDER? " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]] then - rm -rf $ARTIFACTS_FOLDER + rm -rf ${KEEPER_ARTIFACTS_FOLDER} fi ;; --) # End of all options. @@ -91,7 +131,7 @@ while :; do ;; *) printf $COLOR_Y'Starting Ocean...\n\n'$COLOR_RESET - docker-compose --project-name=$PROJECT_NAME $COMPOSE_FILES up + docker-compose --project-name=$PROJECT_NAME $COMPOSE_FILES -f ${NODE_FILE} up break esac shift