From 0ce5ba5bf7265ea3718e3eed39acf1b995df8405 Mon Sep 17 00:00:00 2001 From: Marek Mahut Date: Fri, 28 Aug 2020 15:32:34 +0200 Subject: [PATCH 1/5] Improved readme clarity --- Dockerfile | 10 ++++++ README.md | 44 ++++++++++++++++++++++++- connectors/erg-usd-connector/Dockerfile | 10 ++++++ docker-compose.yml | 34 +++++++++++++++++++ docker/ergo.conf | 17 ++++++++++ docker/oracle-config.yaml | 1 + 6 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 connectors/erg-usd-connector/Dockerfile create mode 100644 docker-compose.yml create mode 100644 docker/ergo.conf create mode 120000 docker/oracle-config.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..bd6d9f20 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM rust:1.45.2 as builder +WORKDIR /usr/src/ +RUN git clone https://github.com/ergoplatform/oracle-core.git +WORKDIR /usr/src/oracle-core +RUN cargo build --release +RUN cargo install --path . + +FROM rust:1.45.2-slim +COPY --from=builder /usr/local/cargo/bin/oracle-core /usr/local/bin/oracle-core +CMD ["oracle-core"] diff --git a/README.md b/README.md index 60cd7430..7e053b87 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,48 @@ In order for an oracle pool to run, it must be first created/bootstrapped on-cha Check out the [Oracle Pool Bootstrap folder](oracle-pool-bootstrap) for detailed instructions about how to bootstrap an oracle pool using the CLI tool or manually. +# Running An Oracle Using Docker Compose +It's possible to setup an oracle cluster using docker compose. We do not recommend this deployment for production, unless you know what you are doing. + +1. Before bringing the cluster up, we need to update the `apiKeyHash` value inside `docker/ergo.conf`. This key will be used for interaction with the API. + +2. After that is done, we can bring up the cluster. + +``` +docker-compose up -d +``` + +3. It will take a while until our Ergo `node` sync the blockchain. After it is done, we need to restore our wallet using the API key defined in the first step. As you can see, we need to define a wallet password as well. + +``` +$ curl -XPOST -H "api_key: hello" \ + -d '{"pass": "123", "mnemonic": "all all all..."}' \ + -H "accept: application/json" \ + -H "Content-Type: application/json" \ + http://localhost:9053/wallet/restore +"OK" +``` + +4. Now we need to unlock the wallet using the password we defined in the step above. + +``` +$ curl -XPOST -H "api_key: hello" \ + -d '{"pass": "123"}' \ + -H "accept: application/json" \ + -H "Content-Type: application/json" \ + http://localhost:9053/wallet/unlock +"OK" +``` + +5. Verify your wallet is on the tip and has some balance in it. + +``` +$ curl -XGET -H "api_key: hello" \ + -H "accept: application/json" \ + -H "Content-Type: application/json" \ + http://localhost:9053/wallet/balances +``` + # Writing A New Connector If you are looking to create a new Oracle Pool for a new datapoint, you need to write a new Connector. This process has been greatly simplified thanks to [`Connector Lib`](connectors/connector-lib). @@ -68,4 +110,4 @@ Now within 15-20 lines of Rust code, you can easily create your own Connector th If you would like to integrate your pool with the Ergo Explorer we have also created [`Frontend Connector Lib`](connectors/frontend-connector-lib). This library builds off of `Connector Lib` and automatically provides + runs an API server which produces all of the data required for the frontend. -Building a Frontend Connector provides a single endpoint which summarizes the majority of relevant data about your Oracle Pool, and as such can also be useful if you intend to create your own custom website/frontend for showing off what is going on in your pool. \ No newline at end of file +Building a Frontend Connector provides a single endpoint which summarizes the majority of relevant data about your Oracle Pool, and as such can also be useful if you intend to create your own custom website/frontend for showing off what is going on in your pool. diff --git a/connectors/erg-usd-connector/Dockerfile b/connectors/erg-usd-connector/Dockerfile new file mode 100644 index 00000000..ea0972ef --- /dev/null +++ b/connectors/erg-usd-connector/Dockerfile @@ -0,0 +1,10 @@ +FROM rust:1.45.2 as builder +WORKDIR /usr/src/ +RUN git clone https://github.com/ergoplatform/oracle-core.git +WORKDIR /usr/src/oracle-core/connectors/erg-usd-connector +RUN cargo build --release +RUN cargo install --path . + +FROM rust:1.45.2-slim +COPY --from=builder /usr/local/cargo/bin/erg-usd-connector /usr/local/bin/erg-usd-connector +CMD ["erg-usd-connector"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..8300940a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,34 @@ +version: "3" + +volumes: + ergo_node_storage: + +services: + node: + image: ergoplatform/ergo:v3.3.0 + restart: unless-stopped + volumes: + - "ergo_node_storage:/home/ergo/.ergo" + - "${PWD}/docker/ergo.conf:/etc/ergo.conf" + command: --mainnet -c /etc/ergo.conf + ports: + - 9030:9030 + - 9053:9053 + + oracle-core: + build: . + restart: unless-stopped + network_mode: "host" + volumes: + - "${PWD}/docker/oracle-config.yaml:/oracle-config.yaml" + depends_on: + - node + + erg-usd-connector: + build: connectors/erg-usd-connector/ + restart: unless-stopped + network_mode: "host" + volumes: + - "${PWD}/docker/oracle-config.yaml:/oracle-config.yaml" + depends_on: + - oracle-core diff --git a/docker/ergo.conf b/docker/ergo.conf new file mode 100644 index 00000000..6ff3c5ac --- /dev/null +++ b/docker/ergo.conf @@ -0,0 +1,17 @@ +ergo { + directory = ${ergo.directory}"/.ergo" + node { + mining = false + } + wallet.secretStorage.secretDir = ${ergo.directory}"/wallet/keystore" +} + +scorex { + restApi { + # Hex-encoded Blake2b256 hash of an API key. + # Should be 64-chars long Base16 string. + # below is the hash of the string 'hello' + # replace with your actual hash + apiKeyHash = "324dcf027dd4a30a932c441f365a25e86b173defa4b8e58948253471b81b72cf" + } +} diff --git a/docker/oracle-config.yaml b/docker/oracle-config.yaml new file mode 120000 index 00000000..c5949635 --- /dev/null +++ b/docker/oracle-config.yaml @@ -0,0 +1 @@ +../oracle-config.yaml \ No newline at end of file From dac411dd8572950e9a897477b8faa16aca5d1475 Mon Sep 17 00:00:00 2001 From: Robert Kornacki Date: Mon, 17 Aug 2020 15:54:48 -0400 Subject: [PATCH 2/5] Update README.md --- README.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 7e053b87..b9d65021 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ It's possible to setup an oracle cluster using docker compose. We do not recomme docker-compose up -d ``` -3. It will take a while until our Ergo `node` sync the blockchain. After it is done, we need to restore our wallet using the API key defined in the first step. As you can see, we need to define a wallet password as well. +3. While our Ergo `node` syncs the blockchain we can restore our wallet using the API key defined in the first step. As you can see, we need to define a wallet password as well. ``` $ curl -XPOST -H "api_key: hello" \ @@ -93,15 +93,9 @@ $ curl -XPOST -H "api_key: hello" \ "OK" ``` -5. Verify your wallet is on the tip and has some balance in it. - -``` -$ curl -XGET -H "api_key: hello" \ - -H "accept: application/json" \ - -H "Content-Type: application/json" \ - http://localhost:9053/wallet/balances -``` +5. The node will sync over the next couple of hours or so which provides us with a good time frame to setup the oracle core itself and get the required UTXO-set scans registered. +... # Writing A New Connector If you are looking to create a new Oracle Pool for a new datapoint, you need to write a new Connector. This process has been greatly simplified thanks to [`Connector Lib`](connectors/connector-lib). From f4e332eba006b7289d2baa46e58c0621e04233b3 Mon Sep 17 00:00:00 2001 From: Marek Mahut Date: Sat, 22 Aug 2020 12:42:03 +0200 Subject: [PATCH 3/5] Docker: moving to ergo node 3.3.1 --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 8300940a..89b87a12 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ volumes: services: node: - image: ergoplatform/ergo:v3.3.0 + image: ergoplatform/ergo:v3.3.1 restart: unless-stopped volumes: - "ergo_node_storage:/home/ergo/.ergo" From 6d274c816957ecb127df41357d4cc5766b007233 Mon Sep 17 00:00:00 2001 From: Marek Mahut Date: Sat, 22 Aug 2020 13:09:21 +0200 Subject: [PATCH 4/5] Docker: ada-usd-connector init --- connectors/ada-usd-connector/Dockerfile | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 connectors/ada-usd-connector/Dockerfile diff --git a/connectors/ada-usd-connector/Dockerfile b/connectors/ada-usd-connector/Dockerfile new file mode 100644 index 00000000..0cd5f8d5 --- /dev/null +++ b/connectors/ada-usd-connector/Dockerfile @@ -0,0 +1,10 @@ +FROM rust:1.45.2 as builder +WORKDIR /usr/src/ +RUN git clone https://github.com/ergoplatform/oracle-core.git +WORKDIR /usr/src/oracle-core/connectors/ada-usd-connector +RUN cargo build --release +RUN cargo install --path . + +FROM rust:1.45.2-slim +COPY --from=builder /usr/local/cargo/bin/ada-usd-connector /usr/local/bin/ada-usd-connector +CMD ["ada-usd-connector"] From 0acaf24a1a43377a296a53416727d16097349e52 Mon Sep 17 00:00:00 2001 From: Marek Mahut Date: Fri, 28 Aug 2020 15:39:23 +0200 Subject: [PATCH 5/5] Docker compose: adding multiple connectors --- docker-compose.yml | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 89b87a12..d4de3086 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,12 +15,12 @@ services: - 9030:9030 - 9053:9053 - oracle-core: + oracle-core-erg-usd: build: . restart: unless-stopped network_mode: "host" volumes: - - "${PWD}/docker/oracle-config.yaml:/oracle-config.yaml" + - "${PWD}/scripts/erg-usd-oracle/oracle-config.yaml:/oracle-config.yaml" depends_on: - node @@ -29,6 +29,28 @@ services: restart: unless-stopped network_mode: "host" volumes: - - "${PWD}/docker/oracle-config.yaml:/oracle-config.yaml" + - "${PWD}/scripts/erg-usd-oracle/oracle-config.yaml:/oracle-config.yaml" + ports: + - 9092:9092 + depends_on: + - oracle-core-erg-usd + + oracle-core-ada-usd: + build: . + restart: unless-stopped + network_mode: "host" + volumes: + - "${PWD}/scripts/ada-usd-oracle/oracle-config.yaml:/oracle-config.yaml" + depends_on: + - node + + ada-usd-connector: + build: connectors/ada-usd-connector/ + restart: unless-stopped + network_mode: "host" + volumes: + - "${PWD}/scripts/ada-usd-oracle/oracle-config.yaml:/oracle-config.yaml" + ports: + - 9082:9082 depends_on: - - oracle-core + - oracle-core-ada-usd