Skip to content

Commit

Permalink
Merge pull request #220 from oceanprotocol/feature/ocean-contracts
Browse files Browse the repository at this point in the history
Feature/ocean contracts
  • Loading branch information
alexcos20 committed Sep 17, 2020
2 parents 5e164c2 + 5e215d6 commit 5f894dc
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 21 deletions.
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,15 @@ The startup script comes with a set of options for customizing various things.

The default versions are always a combination of component versions which are considered stable.

| Aquarius | Provider | Ganache |
| -------- | -------- | -------- |
| `vx.x.x` | `vx.x.x` | `latest` |
| Aquarius | Provider | Ganache | ocean-contracts |
| -------- | -------- | -------- | --------------- |
| `vx.x.x` | `vx.x.x` | `latest` | `test`

You can override the Docker image tag used for a particular component by setting its associated environment variable before calling `start_ocean.sh`:

- `AQUARIUS_VERSION`
- `PROVIDER_VERSION`
- `CONTRACTS_VERSION`

For example:

Expand Down Expand Up @@ -116,7 +117,17 @@ This Building Block can be disabled by setting the `--no-aquarius` flag.
| ----------- | ------------- | --------------------- | --------------------- | --------------------------------------------------- |
| `ganache` | `8545` | http://ganache:9000 | http://localhost:8545 | |

The accounts can be access with this seed phrase:
### ocean-contracts
* Deploy all smart contracts from the ocean-contracts repo
* Export artifacts files (.json) to default shared folder between all containers
* Create address file (address.json) that has the address of each deployed
smart contract that is required by the ocean library. This file is saved to the same folder with the artifacts files

| Hostname | External Port | Internal URL | Local URL | Description |
| ------------------- | ------------- | --------------------- | --------------------- | ------------------------------------------- |
| `ocean-contracts` | | | | |

The accounts can be accessed with this seed phrase:

```
taxi music thumb unique chat sand crew more leg another off lamp
Expand Down
14 changes: 14 additions & 0 deletions compose-files/aquarius.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ services:
networks:
backend:
ipv4_address: 172.15.0.5
depends_on:
- ocean-contracts
environment:
DB_MODULE: ${DB_MODULE}
DB_HOSTNAME: ${DB_HOSTNAME}
Expand All @@ -18,3 +20,15 @@ services:
DB_CA_CERTS: ${DB_CA_CERTS}
DB_CLIENT_KEY: ${DB_CLIENT_KEY}
DB_CLIENT_CERT: ${DB_CLIENT_CERT}
LOG_LEVEL: DEBUG
EVENTS_ECIES_PRIVATE_KEY: "0x5d75837394b078ce97bc289fa8d75e21000573520bfa7784a9d28ccaae602bf8"
ARTIFACTS_PATH: "/ocean-contracts/artifacts"
ADDRESS_FILE: ${OCEAN_ADDRESS_FILE:-/ocean-contracts/artifacts/address.json}
DEPLOY_CONTRACTS: ${DEPLOY_CONTRACTS}
NETWORK_NAME: ${CONTRACTS_NETWORK_NAME}
EVENTS_RPC: "http://172.15.0.3:8545"
EVENTS_ALLOW: "0"
RUN_EVENTS_MONITOR: "1"

volumes:
- ${OCEAN_ARTIFACTS_FOLDER}:/ocean-contracts/artifacts/
8 changes: 7 additions & 1 deletion compose-files/aquarius_elasticsearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ services:
ipv4_address: 172.15.0.5
depends_on:
- elasticsearch
- ocean-contracts
environment:
DB_MODULE: ${DB_MODULE}
DB_HOSTNAME: ${DB_HOSTNAME}
Expand All @@ -32,7 +33,12 @@ services:
DB_CLIENT_CERT: ${DB_CLIENT_CERT}
LOG_LEVEL: DEBUG
EVENTS_ECIES_PRIVATE_KEY: "0x5d75837394b078ce97bc289fa8d75e21000573520bfa7784a9d28ccaae602bf8"
EVENTS_CONTRACT_ADDRESS: ${DDO_CONTRACT_ADDRESS}
ARTIFACTS_PATH: "/ocean-contracts/artifacts"
ADDRESS_FILE: ${OCEAN_ADDRESS_FILE:-/ocean-contracts/artifacts/address.json}
DEPLOY_CONTRACTS: ${DEPLOY_CONTRACTS}
NETWORK_NAME: ${CONTRACTS_NETWORK_NAME}
EVENTS_RPC: "http://172.15.0.3:8545"
EVENTS_ALLOW: "0"
RUN_EVENTS_MONITOR: "1"
volumes:
- ${OCEAN_ARTIFACTS_FOLDER}:/ocean-contracts/artifacts/
2 changes: 1 addition & 1 deletion compose-files/ganache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ services:
networks:
backend:
ipv4_address: 172.15.0.3
entrypoint: ["node", "/app/ganache-core.docker.cli.js", "--blockTime", "2", "--db", "./ganache_cache", "--networkId","0x2324","--gasLimit","10000000000","--gasPrice","1","---hardfork","istanbul","--mnemonic","${GANACHE_MNEMONIC}"]
entrypoint: ["node", "/app/ganache-core.docker.cli.js", "--db", "./ganache_cache", "--networkId","0x2324","--gasLimit","10000000000","--gasPrice","1","---hardfork","istanbul","--mnemonic","${GANACHE_MNEMONIC}"]
24 changes: 24 additions & 0 deletions compose-files/ocean_contracts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3'
services:
ocean-contracts:
image: oceanprotocol/ocean-contracts:$CONTRACTS_VERSION
networks:
backend:
ipv4_address: 172.15.0.14
environment:
MNEMONIC: ${GANACHE_MNEMONIC}
OWNER_ROLE_ADDRESS: ${CONTRACTS_OWNER_ROLE_ADDRESS}
DEPLOY_CONTRACTS: ${DEPLOY_CONTRACTS}
LOCAL_CONTRACTS: ${DEPLOY_CONTRACTS}
REUSE_DATABASE: ${GANACHE_REUSE_DATABASE}
DATABASE_PATH: "/ganache-db"
NETWORK_NAME: ${CONTRACTS_NETWORK_NAME}
NETWORK_RPC_HOST: ${NETWORK_RPC_HOST}
NETWORK_RPC_PORT: ${NETWORK_RPC_PORT}
NETWORK_RPC_URL: ${NETWORK_RPC_URL}
LOCAL_USER_ID: ${LOCAL_USER_ID}
LOCAL_GROUP_ID: ${LOCAL_GROUP_ID}
depends_on:
- ganache
volumes:
- ${OCEAN_ARTIFACTS_FOLDER}:/ocean-contracts/artifacts/
7 changes: 6 additions & 1 deletion compose-files/provider.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ services:
networks:
backend:
ipv4_address: 172.15.0.4
depends_on:
- ocean-contracts
environment:
ARTIFACTS_PATH: ${OCEAN_ARTIFACTS_FOLDER:-/ocean-provider/artifacts}
ARTIFACTS_PATH: "/ocean-contracts/artifacts"
NETWORK_URL: ${NETWORK_RPC_URL}
PARITY_URL: ${NETWORK_RPC_URL}
PROVIDER_KEY: ${PROVIDER_PRIVATE_KEY}
PROVIDER_PRIVATE_KEY: ${PROVIDER_PRIVATE_KEY}
PROVIDER_ADDRESS: ${PROVIDER_ADDRESS}
PROVIDER_PASSWORD: ${PROVIDER_PASSWORD}
Expand All @@ -21,3 +24,5 @@ services:
IPFS_GATEWAY: ${PROVIDER_IPFS_GATEWAY}
OCEAN_PROVIDER_TIMEOUT: '9000'
OPERATOR_SERVICE_URL: ${OPERATOR_SERVICE_URL}
volumes:
- ${OCEAN_ARTIFACTS_FOLDER}:/ocean-contracts/artifacts/
41 changes: 27 additions & 14 deletions start_ocean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ DIR="${DIR/ /\\ }"
COMPOSE_DIR="${DIR}/compose-files"

# Default versions of Aquarius, Provider
export AQUARIUS_VERSION=${AQUARIUS_VERSION:-v3}
export PROVIDER_VERSION=${PROVIDER_VERSION:-v0.1.0}

export AQUARIUS_VERSION=${AQUARIUS_VERSION:v3}
export PROVIDER_VERSION=${PROVIDER_VERSION:latest}
export CONTRACTS_VERSION=${CONTRACTS_VERSION:-test}
export PROJECT_NAME="ocean"
export FORCEPULL="false"

# Export User UID and GID
export LOCAL_USER_ID=$(id -u)
export LOCAL_GROUP_ID=$(id -g)


# Specify the ethereum default RPC container provider
if [ ${IP} = "localhost" ]; then
Expand All @@ -42,9 +47,18 @@ else
fi
export NETWORK_RPC_PORT="8545"
export NETWORK_RPC_URL="http://"${NETWORK_RPC_HOST}:${NETWORK_RPC_PORT}
# Use this seed only on Spree! (Spree is the default.)
# Use this seed on ganache to always create the same wallets
export GANACHE_MNEMONIC=${GANACHE_MNEMONIC:-"taxi music thumb unique chat sand crew more leg another off lamp"}

# Ocean contracts
export OCEAN_HOME="${HOME}/.ocean"
export CONTRACTS_OWNER_ROLE_ADDRESS="${CONTRACTS_OWNER_ROLE_ADDRESS}"
export DEPLOY_CONTRACTS="true"
export OCEAN_ARTIFACTS_FOLDER="${OCEAN_HOME}/ocean-contracts/artifacts"
export ADDRESS_FILE="${OCEAN_ARTIFACTS_FOLDER}/address.json"
echo "export ADDRESS_FILE=${ADDRESS_FILE}"
# Specify which ethereum client to run or connect to: development
export CONTRACTS_NETWORK_NAME="ganache"

# Default Aquarius parameters: use Elasticsearch
export DB_MODULE="elasticsearch"
Expand All @@ -64,12 +78,7 @@ CHECK_ELASTIC_VM_COUNT=true
export PROVIDER_LOG_LEVEL=INFO
export PROVIDER_WORKERS=1
export PROVIDER_IPFS_GATEWAY=https://ipfs.oceanprotocol.com
export PROVIDER_PRIVATE_KEY=0x9bf5d7e4978ed5206f760e6daded34d657572bd49fa5b3fe885679329fb16b16
export PROVIDER_ENCRYPTED_KEY=''
export PROVIDER_ADDRESS=''
export PROVIDER_PASSWORD=''
export PROVIDER_KEYFILE="/accounts/provider.json"
export DDO_CONTRACT_ADDRESS=''
export PROVIDER_PRIVATE_KEY=0xfd5c1ccea015b6d663618850824154a3b3fb2882c46cefb05b9a93fea8c3d215

if [ ${IP} = "localhost" ]; then
export AQUARIUS_URI=http://172.15.0.5:5000
Expand All @@ -81,11 +90,6 @@ fi
export OPERATOR_SERVICE_URL=https://operator-api.operator.dev-ocean.com


# Export User UID and GID
export LOCAL_USER_ID=$(id -u)
export LOCAL_GROUP_ID=$(id -g)


#add aquarius to /etc/hosts

if [ ${IP} = "localhost" ]; then
Expand Down Expand Up @@ -141,6 +145,11 @@ function check_max_map_count {
fi
}

function clean_local_contracts {
rm -f "${OCEAN_ARTIFACTS_FOLDER}/ready"
rm -f "${OCEAN_ARTIFACTS_FOLDER}/*.json"
}

check_if_owned_by_root
show_banner

Expand All @@ -150,6 +159,8 @@ COMPOSE_FILES+=" -f ${COMPOSE_DIR}/dashboard.yml"
COMPOSE_FILES+=" -f ${COMPOSE_DIR}/aquarius_elasticsearch.yml"
COMPOSE_FILES+=" -f ${COMPOSE_DIR}/provider.yml"
COMPOSE_FILES+=" -f ${COMPOSE_DIR}/ganache.yml"
COMPOSE_FILES+=" -f ${COMPOSE_DIR}/ocean_contracts.yml"

DOCKER_COMPOSE_EXTRA_OPTS="${DOCKER_COMPOSE_EXTRA_OPTS:-}"

while :; do
Expand All @@ -176,6 +187,7 @@ while :; do
;;
--no-ganache)
COMPOSE_FILES="${COMPOSE_FILES/ -f ${COMPOSE_DIR}\/ganache.yml/}"
COMPOSE_FILES="${COMPOSE_FILES/ -f ${COMPOSE_DIR}\/ocean_contracts.yml/}"
printf $COLOR_Y'Starting without Ganache...\n\n'$COLOR_RESET
;;
--no-aquarius)
Expand Down Expand Up @@ -218,6 +230,7 @@ while :; do
*)
[ ${CHECK_ELASTIC_VM_COUNT} = "true" ] && check_max_map_count
printf $COLOR_Y'Starting Ocean V3...\n\n'$COLOR_RESET
[ ${DEPLOY_CONTRACTS} = "true" ] && clean_local_contracts
[ ${FORCEPULL} = "true" ] && eval docker-compose "$DOCKER_COMPOSE_EXTRA_OPTS" --project-name=$PROJECT_NAME "$COMPOSE_FILES" pull
eval docker-compose "$DOCKER_COMPOSE_EXTRA_OPTS" --project-name=$PROJECT_NAME "$COMPOSE_FILES" up --remove-orphans
break
Expand Down

0 comments on commit 5f894dc

Please sign in to comment.