Skip to content
Volker Strobel edited this page Apr 2, 2019 · 9 revisions

Run in Swarm Mode

  • On the manager machine: docker swarm init

  • On the worker machines: docker swarm join --token SWMTKN-1-5avuzs49fstxwojl4o362xe7vgi7ayxhb9nu1emfk8vs29h6y8-9cpsx3j3247jwzbwp2r8jyelk 164.15.10.115:2377 (display token via docker swarm join-token worker)

  • In folder of the Dockerfile: docker build -t mygeth .

  • Specify that you want to use mygeth in the compose file: image: mygeth:latest

  • Deploy the stack: docker stack deploy -c ./docker-compose.yml ethereum

  • Scale up: docker service scale ethereum_eth=10

  • Finish and clean everything up: docker stack rm ethereum (take care, that is a detached command!)

  • One-liner to run a command on a container created via the scaled service: ** docker exec $(docker ps -q -f name=servicename) ls or ** docker exec -ti ethereum_eth.1.$(docker service ps -f 'name=ethereum_eth.1' stack_myservice -q --no-trunc | head -n1) /bin/bash\n

  • More info about that: https://stackoverflow.com/questions/39362363/execute-a-command-within-docker-swarm-service

Reinitializing the swarm

  • See https://github.com/moby/moby/issues/35337
  • To remove a node from the swarm, use docker node rm; if you're trying to remove a manager node, it needs to be demoted to a worker first; docker node demote, then docker node rm. Removing the last manager from a swarm (i.e.; stop being a swarm) will be problematic in most cases.

Debugging

  • Show all services: docker service ps ethereum_eth
  • Show all containers: docker container ls

Important advice and TODOs

  • Some functions, like addPeer do not work in web3 -> use the command line interface therefore
  • To debug a background container container (e.g., ethereum-docker_eth_1), use: sudo docker logs --tail 50 --follow --timestamps ethereum-docker_eth_1
  • There was a faulty solc version that caused many problems; the right version to install is solc@0.4.25: npm install solc@0.4.25 --unsafe
  • You also need to install web3 via npm; there's a problem installing it from the Dockerfile. The problem is related to the user in docker; I think I had a solution but may have lost it.
  • The Ethereum processes should be started outside of ARGoS: this way we can save time and other simulators can be used in a plug and play way
  • The interface could be written in javascript (node) or bash; the advantage of bash is speed and ease of use; the advantage of javascript is that return values can be directly used;

Other TODOs

  • Check how many ethers robots receive at the beginning of the experiment. Ideally, this should be 0, to convince readers and have an "open" swarm.
  • Also check the mining difficulty, maybe it's too low
  • That also means that I don't have to regenerate the genesis block anymore. -> Should save time
  • Continue with distributeEther (or rather not, not needed anymore)
  • That means, the boolean flag is already included. Now I need to actually remove the part where the robots are preinitialized.

Other

Things to do again:

  • Add SE, mean etc. CHECK

  • Add blockchain size CHECK

  • Add decentralized consensus

  • Add event

  • Search TODOs in all files

  • Questions for Marco: -- What to do if a consensus is reached? Stop, continue to explore?

Clone this wiki locally