New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrap master node in docker container #296
Merged
Merged
Changes from all commits
Commits
Show all changes
88 commits
Select commit
Hold shift + click to select a range
e4b682f
MasterNodeIntegrationSpec draft
DmiSergeev f8ce558
test asserts
DmiSergeev 59f3b35
paths and resources updated
DmiSergeev 0a86aec
minor
DmiSergeev 982d222
node path changed
DmiSergeev dc44086
paths changes
DmiSergeev 1f32b7f
cp/rm in containers
DmiSergeev b048da7
IPs changed
DmiSergeev 946e7ca
increased wait time
DmiSergeev 559bca3
IPs changed
DmiSergeev 7f1d329
host temporarily changed to localhost
DmiSergeev 48f34a5
minor
DmiSergeev 0d99eaa
tracing net_info
DmiSergeev 72f87b7
tracing os name
DmiSergeev 5dc3c9a
checking another ports
DmiSergeev be8cfd1
docker host detection
DmiSergeev 079388a
minor
DmiSergeev c020f9e
minor
DmiSergeev 05f8d95
minor
DmiSergeev 60cc112
running docker with API
DmiSergeev 10d305f
commented code removed
DmiSergeev 9eb664f
fix vm code path lookup in sbt runMain
folex da2ea23
Remove Thread.sleep
folex 2fe82ff
Refactor eventually a bit
folex e789f62
refactor IP check
folex 326ab35
Increase timeout
folex 16ee197
Add ipv6 to checkIp
folex f498785
Remove redundant type check
folex 00da66c
Increase timeouts further
folex ad934ee
Increase timeouts to 60 + 60 seconds
folex 2f1b92b
Pull solver image before tests
folex 46261ce
Timeouts = 30 + 30
folex 4ac765a
timeouts = 60 + 60
folex 1edadd7
Increase timeouts to 120 + 30. Add TODOs -_-
folex b2cd4bc
Fix error message
folex bd93831
Merge branch 'master' into network/integration-test
folex 12be2cd
rename dir
folex dccd87b
Specify current user on tendermint init
folex 837f3c2
Remove --user nonsense, create /tendermint directory before running s…
folex 35df513
Try -> IO::attempt
folex 4ed358b
IO -> F[_] in KeysPath, DockerParams.!! -> DockerIO, don't copy files…
folex e6aafc8
IO -> F[_]
folex 83295f5
F[_] -> IO (funfunfun)
folex d9bfc78
Specify uid
folex 8cf5dea
fix
folex 12d4f21
Thread -> Concurrent[IO]
folex 592b3f6
Refactor pipes
folex 59305f0
WIP: Add assembly & docker plugin to node
folex c56ceee
Merge branch 'master' into network/node-docker
folex 254b196
Wrap master in docker
folex 6726890
a -> the
folex b2166cc
Merge branch 'master' into network/node-docker
folex 86fb706
Generate application.conf in entrypoint.sh
folex dca16b7
Copy configs & code to solvers (and it works!)
folex dc680f3
Refactor run.sh
folex b1ad969
Refactor directory structure & add some comments
folex b2c7335
Fix import, add $PORTS
folex c4c5316
Move configuration logic from MasterNodeApp, add comments
folex 960e538
Add implicit
folex fa0566f
Healthcheck
folex 00adfa1
Comment MasterNodeIntegrationSpec
folex 696c512
Fix integration test, add comments in entrypoint.sh
folex 5445d66
Remove old code from CodeManager, fix exception hanlding in Configura…
folex f0719fc
fix compilation
folex 646ebad
fix ip parsing
folex c20fd5e
fix typo
folex ced64d9
Rename master -> node
folex d5a007e
ubuntu -> alpine, use 2018-dec-demo tag in tests AND code
folex 8634ced
use tag 2018-dec-demo in travis.yml
folex b9d02b9
Try to accumulate strings
folex 6a0e198
Move docker image names to constants
folex 3d923cd
remove println
folex a145610
Enable logs
folex baaa785
Ethereum IP
folex c201f6b
Read swarm ip from env
folex cefe105
Quote strings in config generated in entrypoint.sh
folex 365d0d4
Ganache listen on 0.0.0.0
folex 572b883
Merge branch 'master' into network/node-docker
folex 92cc4c5
increase timeout
folex c4b74aa
Remove implicit
folex dedf8a3
Add comment
folex facfef4
minor pr fixes
folex b4af656
Move docker image to config
folex 5348a81
Increase gas limit in publisher
folex 529abae
Add docker-compose
folex 27980d0
Add README.md
folex a12f754
add npm run getEthAccount
folex ffb9980
Update bootstrap/README.me
folex File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ target/ | |
# IntelliJ | ||
.idea | ||
.vscode | ||
*.iml | ||
|
||
# MacOS folder metadata | ||
.DS_Store | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
## How to run ganache | ||
In order to run master node, you need to have any Ethereum RPC node. In this example we will use Ganache for that purpose. To run Ganache and deploy Fluence contract there, run | ||
``` | ||
cd fluence/bootstrap | ||
|
||
npm install | ||
npm run ganache | ||
npm run migrate | ||
``` | ||
|
||
You will see address of the Deployer contract in your private Ganache blockchain: | ||
``` | ||
Deployer: 0x9995882876ae612bfd829498ccd73dd962ec950a | ||
``` | ||
|
||
Ganache is run in deterministic mode with predefined mnemonic, so this address will always be the same and there is no need to save it. | ||
|
||
## How to run master node | ||
Go to `fluence/tools/node` and run `docker-compose`: | ||
``` | ||
cd fluence/tools/node | ||
|
||
docker-compose -f single-master.yml up -dV | ||
``` | ||
|
||
`single-master.yml` runs one Swarm container and one master node container with solver ports 25000-25003. | ||
|
||
## How to run solvers | ||
|
||
After having run master node, you need to upload and publish your WASM code to Swarm. In this example we will use `llamadb` that can be found at `fluence/node/src/main/resources/docker/vmcode/vmcode-llamadb/llama_db.wasm`. You can use Fluence `cli` to upload and publish it: | ||
``` | ||
cd fluence/cli | ||
|
||
cargo build --release | ||
|
||
target/release/fluence publish ../node/src/main/resources/docker/vmcode/vmcode-llamadb/llama_db.wasm 0x9995882876ae612bfd829498ccd73dd962ec950a 0x4180fc65d613ba7e1a385181a219f1dbfe7bf11d --cluster_size 1 | ||
``` | ||
|
||
You can take a look at `target/release/fluence publish --help` to get the idea of how it works. I will describe parameters briefly: | ||
|
||
- `target/release/fluence` is a `cli` binary we compiled by running `cargo build --release` | ||
- `publish` is a command that uploads code to Swarm and sends it to Ethereum contract (running on Ganache) | ||
- `../node/src/main/resources/docker/vmcode/vmcode-llamadb/llama_db.wasm` is a path to llamadb compiled to WASM | ||
- `0x9995882876ae612bfd829498ccd73dd962ec950a` is a Deployer contract address that was deployed by `npm run migrate` | ||
- `0x4180fc65d613ba7e1a385181a219f1dbfe7bf11d` is an Ethereum account address that's used for publishing code | ||
- `--cluster_size 1` specifies number of nodes required to run this code. We ran single master node, so we specify 1 here. | ||
|
||
## How to check solver is running fine | ||
You can check solver's logs by issuing `docker logs 01_node0` (you may need to replace `01_node0` with the name of the solver container, see `docker ps`). Look for `Commit: processTime=23 height=2`, `processTime` could be anything, you're looking for `height=2`. It can appear after some time, usually 10-60 seconds, depending on your hardware. | ||
|
||
## Cleaning up | ||
- To clean up ALL docker containers, including volumes: `docker ps -a | awk '{print $1}' | xargs docker rm -f ; docker volume prune -f` | ||
- To clean up docker-compose state: `docker-compose -f single-master.yml kill` | ||
- To stop ganache: `pkill -f ganache` | ||
|
||
## Troubleshooting | ||
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Copyright 2018 Fluence Labs Limited | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
#!/usr/bin/env bash -e | ||
folex marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### | ||
# This script is an entrypoint of the Master docker container. | ||
# It first checks that $TENDERMINT_IP and $PORTS are defined, | ||
# if /var/run/docker.sock is passed as a volume, and | ||
# then if running master-node.jar, generate application.conf, | ||
# and run whatever command is passed as arguments (usually it's CMD from Dockerfile). | ||
### | ||
|
||
# set to fail fast | ||
set -e | ||
|
||
if [ -z "$TENDERMINT_IP" ]; then | ||
cat >&2 <<EOF | ||
error: \`-e "TENDERMINT_IP=your_external_ip"\` was not specified. | ||
It is required so Tendermint instance can advertise its address to cluster participants | ||
EOF | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$PORTS" ]; then | ||
cat >&2 <<EOF | ||
error: \`-e "PORTS=start:stop"\` was not specified. | ||
TODO: add more helpful explanation | ||
EOF | ||
exit 1 | ||
fi | ||
|
||
if [ ! -S /var/run/docker.sock ]; then | ||
cat >&2 <<EOF | ||
error: '/var/run/docker.sock' not found in container or is not a socket. | ||
Please, pass it as a volume when running the container: \`-v /var/run/docker.sock:/var/run/docker.sock\` | ||
EOF | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$ETHEREUM_IP" ]; then | ||
ETHEREUM_IP=$TENDERMINT_IP | ||
fi | ||
|
||
SWARM_ENABLED="true" | ||
if [ -z "$SWARM_IP" ]; then | ||
SWARM_ENABLED="false" | ||
fi | ||
|
||
# Running master-node.jar, that means running default CMD | ||
if [ "$3" = "/master-node.jar" ]; then | ||
CONTAINER_ID=$(cat /proc/1/cpuset) | ||
cat > "/master/application.conf" <<EOF | ||
endpoints { | ||
ip = "$TENDERMINT_IP" | ||
min-port = ${PORTS%:*} | ||
max-port = ${PORTS#*:} | ||
} | ||
ethereum { | ||
host = "$ETHEREUM_IP" | ||
} | ||
swarm { | ||
host = "$SWARM_IP" | ||
enabled = "$SWARM_ENABLED" | ||
} | ||
tendermint-path = "/master" | ||
master-container-id = "${CONTAINER_ID#"/docker/"}" | ||
EOF | ||
fi | ||
|
||
# Execute whatever command is passed as arguments. Usually it's CMD from Dockerfile. | ||
exec "$@" |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,36 @@ | ||
// a path to a working directory, where all keys, configurations and codes files will be stored | ||
tendermint-path = "target/.tendermint" | ||
|
||
solver { | ||
image = "fluencelabs/solver" | ||
tag = "2018-dec-demo" | ||
} | ||
|
||
endpoints { | ||
// IP address for all endpoints that will be used for solvers | ||
ip = "127.0.0.1" | ||
// ports that will be selected by the deployer smart contract | ||
min-port = 20000 | ||
max-port = 20100 | ||
} | ||
|
||
ethereum { | ||
// ethereum RPC protocol | ||
protocol = "http" | ||
|
||
// ethereum RPC address | ||
ip = "127.0.0.1" | ||
|
||
// ethereum RPC port | ||
port = 8545 | ||
} | ||
|
||
// use the Swarm or run local precompiled code | ||
use-swarm: true, | ||
use-swarm: false, | ||
swarm { | ||
// the address to the Swarm gateway | ||
host = "http://localhost:8500" | ||
protocol = "http" | ||
host = "localhost" | ||
port = 8500 | ||
enabled = false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,9 +37,7 @@ object ConfigOps { | |
) | ||
) | ||
) | ||
|
||
} | ||
|
||
} | ||
|
||
implicit val inetAddressConvert: ConfigConvert[InetAddress] = | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be merged to master?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There problem is that I can't really release new docker images before I merge this PR to master, and tests in the PR won't pass before I release new docker images.
So this is a workaround, I will create the next pull request after I release new docker images as 'latest', where I will change images to latest everywhere.