diff --git a/.IMGNAME b/.IMGNAME deleted file mode 100644 index 5bc4812..0000000 --- a/.IMGNAME +++ /dev/null @@ -1,4 +0,0 @@ -vertigo/ethereum -# -# first line holds image name (no tag) -# diff --git a/.IMGVERSION b/.IMGVERSION deleted file mode 100644 index 02da816..0000000 --- a/.IMGVERSION +++ /dev/null @@ -1,9 +0,0 @@ -latest -# -# Only the first line of this file is used to determine image tag. -# -# Older tags: -# -v1.6.7 -latest - diff --git a/.gitignore b/.gitignore index 26d4f42..d553ea3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,5 @@ .ethash .bootnode setenv.sh -genesis.json - +config/genesis.json +keystore \ No newline at end of file diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 6f28a9e..0000000 --- a/Dockerfile +++ /dev/null @@ -1,49 +0,0 @@ -# Ethereum playground for private networks -# Playground Ethereum para redes privadas - -# Why not the official image? -# Until 1.7.2 the public image does NOT contain tools beyond geth, -# so we build a new just like the original Dockerfile suggests. -# It seems that future image releases will carry these binaries. - -FROM ubuntu:latest - -LABEL maintainer="andre@vertigo.com.br" - -ARG GETH_URL=https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-amd64-1.7.2-1db4ecdc.tar.gz -ARG GETH_MD5=c17c164d2d59d3972a2e6ecf922d2093 -ARG DEBIAN_FRONTEND=noninteractive - -RUN apt update && \ - apt install wget -y && \ - cd /tmp && \ - wget "$GETH_URL" -q -O /tmp/geth-alltools-linux-amd64.tar.gz && \ - echo "$GETH_MD5 geth-alltools-linux-amd64.tar.gz" > /tmp/geth-alltools-linux-amd64.tar.gz.md5 && \ - md5sum -c /tmp/geth-alltools-linux-amd64.tar.gz.md5 && \ - tar -xzf /tmp/geth-alltools-linux-amd64.tar.gz -C /usr/local/bin/ --strip-components=1 && \ - rm -f /usr/local/bin/COPYING && \ - rm -f /tmp/geth-alltools-* - -ENV GEN_NONCE="0xeddeadbabeeddead" \ - DATA_DIR="/root/.ethereum" \ - CHAIN_TYPE="private" \ - RUN_BOOTNODE=false \ - GEN_CHAIN_ID=1981 \ - BOOTNODE_URL="" - -WORKDIR /opt - -# like ethereum/client-go -EXPOSE 30303 -EXPOSE 8545 - -# bootnode port -EXPOSE 30301 -EXPOSE 30301/udp - -ADD src/* /opt/ -RUN chmod +x /opt/*.sh - -#CMD ["/opt/startgeth.sh"] -ENTRYPOINT ["/opt/startgeth.sh"] - diff --git a/Dockerfile.old b/Dockerfile.old deleted file mode 100644 index 38258a7..0000000 --- a/Dockerfile.old +++ /dev/null @@ -1,28 +0,0 @@ -# Ethereum playground for private networks -# -FROM ethereum/go-ethereum:v1.7.2 - -LABEL maintainer="andre@vertigo.com.br" - -ENV GEN_NONCE="0xeddeadbabeeddead" \ - DATA_DIR="/root/.ethereum" \ - CHAIN_TYPE="private" \ - RUN_BOOTNODE=false \ - GEN_CHAIN_ID=1981 \ - BOOTNODE_URL="" - -WORKDIR /opt - -# inherited from ethereum/client-go -# EXPOSE 30303 -# EXPOSE 8545 - -# bootnode port -EXPOSE 30301 -EXPOSE 30301/udp - -ADD src/* /opt/ -RUN chmod +x /opt/*.sh - -ENTRYPOINT ["/opt/startgeth.sh"] - diff --git a/LEIAME.md b/LEIAME.md deleted file mode 100644 index 80cc733..0000000 --- a/LEIAME.md +++ /dev/null @@ -1,107 +0,0 @@ -Ethereum playground -========== - -Esta imagem é derivada (indiretamente) da imagem oficial "ethereum/go-client", mas ligeiramente modificada para aceitar argumentos que simplifiquem a criação de uma rede Ethereum privada com múltiplos nós. Esta imagem está publicada no Docker Hub como "vertigo/ethereum". - -Alguns scripts no projeto agilizam o uso desta imagem ou mesmo permitem sua construção local. Há um artigo publicado que descreve com mais acuidade estes passos. - -## Definição de Rede Ethereum Privada - -Para isolar uma rede blockchain Ethereum das redes públicas conhecidas não é necessário de forma alguma construir uma rede isolada. Os nós de uma rede privada podem ainda residir na Internet mas, pela natureza do próprio blockchain, estarão implementado uma rede fechada e privada, composta apenas por nós que compartilhem o mesmo bloco gênese. - -Com esta imagem - e scripts associados - o usuário pode fornecer argumentos que irão gerar um bloco gênese previsível, criando um nói em um container Docker de um mesmo blockchain Ethereum privado em qualquer host na Internet (ou rede local, ou mesmo em localhost). - -As variáveis de ambiente passadas como argumentos pelos scripts aos containers são: - -* GEN_NONCE: any value your nodes agree upon, the default is "0xeddeadbabeeddead" -* NET_ID: any integer value your nodes agree upon, the default is 1981 - -The GEN_NONCE variable is used during the start script to create the "genesis.json" used when initializing the blockchain. Similarly, the NET_ID variable defines the "network_id" of the network. All members of the private network must have the same genesis block and network_id, so all you'll have to do is run the containers with the same "-e" arguments for these variables (the provided scripts do it). - -## Bootnode - -A bootnode is a "dumb" node in the network that aids other nodes on P2P discovery. - -There are several valid strategies to enable node discovery (including a static topology with disabled discovery). Having one or more bootnodes seems to be the best one, for it creates no obstacles for a dynamic network. - -As a dumb node, the bootnode is a cheap and effective solution to aid the network self-discovery. It fits container-land perfectly, because any swarm can ressurect such a node almost instantly. The main Ethereum network itself is served by a set of bootnodes whose addresses are hard-coded in the "geth" client code. - -The `bootnode.sh` script runs a specialized bootnode container named "ethereum-bootnode". You can check its dynamically generated URL checking its log: - -```sh -docker logs ethereum-bootnode -... -I0908 14:46:45.899423 p2p/discover/udp.go:217] Listening, enode://52f4bf370b6f407a6b3bca149b2fe24fc54ce6ac19ffe0926ad41d9bfc86ccf9bd8703fa5a4961ab28bba2a81eacba183652f744d3ff02602ecb63b7ccd3643f@172.17.0.4:30301 -``` - -There is another useful script that parses the "enode" URL from this very same log (it is used in other scripts to find the bootnode URL automatically): - -```sh -./getbootnodeurl.sh -enode://76e50d0dd4ae583d2653d414f9acd1df4e7a75f4bab53c7cafedc6433696ba9596c6dc84626423e629760b3ab2af9f97220dfee73961cb5be1a8ce1fa40a0bff@172.17.0.4:30301 -``` - -## Volumes - -The provided utility scripts are meant for local development use and rely on local volumes to persist data. For example, the script `runnode.sh ` creates a local volume ".ether-" at the current folder. When using this container in production you should try another strategy to guarantee the node portability. - -The folders created bu each script are: - -* bootnode.sh: volume ".bootnode" -* runnode.sh: volume ".ether-" (ex: "./runnode node1" creates the volume ".ether-node1") -* runminer.sh: volume ".ether-" (id.) - -Note: if ran without arguments the scripts `runnode.sh` and `runminer.sh` assume the argument "node1" and "miner1", respectively. - -## Your first node - -The script `runnode.sh` runs the first node in your private Ethereum network (a container named "ethereum-node1"). It is important to notice that it looks for and connects to the bootnode, but since it is alone in the world it won't find any peer (yet) - the bootnode is a dumb node that doesn't count as a peer. - -```sh -./runnode.sh -``` - -## Your second node - -The same script `runnode.sh` can be used to run as many other nodes you want, all you need is to supply a node name as its argument. A container named "ethereum-" will be created and started, looking for the bootnode and eventually finding the first node (and the others you ran) as its peer. - -```sh -./runnode.sh node2 -``` - -## Checking the nodes' peers - -Self-discovery can take a few seconds, but it is easy to check it with the script `showpeers.sh`. The command below shows the peers of container "ethereum-node": - -```sh -./showpeers.sh -``` - -An optional argument can specify another node container to be checked: - -```sh -./showpeers.sh ethereum-node2 -``` - -## Running a miner node - -The nodes "ethereum-node1" e "ethereum-node2" are non-mining nodes - they served the purpose of testeing the ability to create a private Ethereum network capable of self-discovery. Another script `runminer.sh` is similar to the `runnode.sh`, but it starts mining nodes (it assumes "miner1" if ran without arguments): - -```sh -./runminer.sh [node_name] -``` - -To check if it discovered its peers "node1" and "node2": - -```sh -./showpeers.sh ethereum-miner1 -``` - -Mining can take quite a long time to run for the first time. Onde again, to check the node work and status you can always go for the container log: - -```sh -docker logs -f ethereum-miner1 -``` - - - diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3da42fe --- /dev/null +++ b/Makefile @@ -0,0 +1,57 @@ +.DEFAULT_GOAL := help +BLUE := $(shell tput setaf 4) +RESET := $(shell tput sgr0) +help: + @printf "\n# Help \n\n" + @grep -E '^[^ .]+: .*?## .*$$' $(MAKEFILE_LIST) \ + | awk '\ + BEGIN { FS = ": .*##" };\ + { gsub(";", "\n\t\t ") }; \ + { printf "%-20s$(RESET) %s\n", $$1, $$2 }' + @printf "\n" + +init: ## init the genesis.json file + @./bin/genesis.sh + @echo "generated file config/genesis.json" + +start_nodes: ## start 2 nodes + ./bootnode.sh + RPC_PORT=8545 ./runnode.sh node1 + ./runnode.sh node2 + +start_miner: ## start 1 miner + ./runminer.sh miner1 + +seal: ## run sealer + ./runsealer.sh + +stop: ## stop everything + ./bin/killall.sh + +clean: ## reset everything; + ./bin/wipeall.sh + sudo rm -Rf .ether-* + sudo rm -Rf .ethash + sudo rm -Rf .bootnode + +bash: ## launch a bash with 'ethereum/client-go:alltools' + ./bin/runbash.sh +ps: ## see all docker containers; + docker ps + +show_node: ## show node peers + ./bin/showpeers.sh node1 +show_miner: ## show miner peers; + ./bin/showpeers.sh miner1 + +attach_miner: ## attach to miner 1 + ./bin/runattach.sh ethereum-miner1 +attach_node1: ## attach to node 1 + ./bin/runattach.sh ethereum-node1 +attach_node2: ## attach to node 2; + ./bin/runattach.sh ethereum-node2 + +copy_keystore: ## copy keystore + sudo cp ./keystore/* .ether-node1/keystore + sudo cp ./keystore/* .ether-node1/keystore + sudo cp ./keystore/* .ether-miner1/keystore \ No newline at end of file diff --git a/README.md b/README.md index f16c274..2858d90 100644 --- a/README.md +++ b/README.md @@ -1,122 +1,138 @@ -Ethereum playground +Ethereum Private Network ========== -This works is based on the official "ethereum/go-client" docker image, without modifications. A few scripts in this project simplify playing with this image. +Scripts to use the official "ethereum/go-client" docker image. -## Quick start +# Get Started -Assuming you have Docker up and running: +### `make init` -* Run a bootnode -* Run a common node -* Run a miner node -* Check a node's peers +To generate a `genesis.json` file. -```sh -./bootnode.sh -./runnode.sh -./runminer.sh -./showpeers.sh -``` +### `make start_nodes` -## Network definition +Boots up a new block chain. Peek at the containers by running `make ps`. -To isolate your private Ethereum network from the main public one it does not require an isolated physical network at all. Its nodes can still reside on the Internet and yet implement a closed private Ethereum network. - -This 'genesis.sh' allows the user to define environment variables that will reflect on a particular (and predictable) genesis block, therefore creating an Ethereum network that cannot interact with another one. This is done when the script generates a 'genesis.json' file that is mounted on each node's container. - -Those variables are: +``` +$ make ps -* GEN_NONCE: any value your nodes agree upon, the default is "0xeddeadbabeeddead" -* GEN_CHAIN_ID: any integer value your nodes agree upon, the default is 1981 -* GEN_ALLOC: pre-funded accounts +CONTAINER ID IMAGE +xxxxxxx ethereum/client-go:v1.8.12 ethereum-node2 +xxxxxxx ethereum/client-go:v1.8.12 ethereum-node1 +xxxxxxx ethereum/client-go:alltools-v1.8.12 ethereum-bootnode +``` -The 'runnode.sh' scripts checks if the node database has already been initilized and runs 'geth init genesis.json' when needed. Similarly, the GEN_CHAIN_ID variable defines the "network_id" of the network. All members of the private network will use the same genesis file. +### `make attach_node1` -## Bootnode +To create initial accounts -A bootnode is a "dumb" node in the network that aids other nodes on P2P discovery. +``` +adam = personal.newAccount("pwd") +"0x0000000000000000000000000000000000000001" -There are several valid strategies to enable node discovery (including a static topology with disabled discovery). Having one or more bootnodes seems to be the best one, for it creates no obstacles for a dynamic network. +eve = personal.newAccount("pwd") +"0x0000000000000000000000000000000000000002" +``` -As a dumb node, the bootnode is a cheap and effective solution to aid the network self-discovery. It fits container-land perfectly, because any swarm can ressurect such a node almost instantly. The main Ethereum network itself is served by a set of bootnodes whose addresses are hard-coded in the "geth" client code. +### Start a miner -The `bootnode.sh` script runs a specialized bootnode container named "ethereum-bootnode". You can check its dynamically generated URL checking its log: +Take the id of an account you created and use it to start your miner -```sh -docker logs ethereum-bootnode -... -INFO [12-05|02:30:08] UDP listener up self=enode://c409a84245a91384a6743e800c4f45df31915d9c6a30c1352a4442d18e443b184107696231d714f3c3015f13263a416ec019d637fb567aea5455114f1cf161d2@[::]:30301 +``` +ETHERBASE=0x0000000000000000000000000000000000000001 make start_miner ``` -There is another useful script that parses the "enode" URL from this very same log (it is used in other scripts to find the bootnode URL automatically): +And that will start a container where all mined coins are credited to that account. -```sh -./getbootnodeurl.sh -enode://76e50d0dd4ae583d2653d414f9acd1df4e7a75f4bab53c7cafedc6433696ba9596c6dc84626423e629760b3ab2af9f97220dfee73961cb5be1a8ce1fa40a0bff@172.17.0.4:30301 -``` +## Transfer funds -## Volumes +Wait a long while for some coin to get created then transfer funds -The provided utility scripts are meant for local development use and rely on local volumes to persist data. For example, the script `runnode.sh ` creates a local volume ".ether-" at the current folder. When using this container in production you should try another strategy to guarantee the node portability. +``` +$ make attach_node1 -The folders created bu each script are: +adam = eth.accounts[0] +eve = eth.accounts[1] -* bootnode.sh: volume ".bootnode" -* runnode.sh: volume ".ether-" (ex: "./runnode node1" creates the volume ".ether-node1") -* runminer.sh: volume ".ether-" (id.) +personal.unlockAccount(adam,'pwd',0) +personal.unlockAccount(eve,'pwd',0) -Note: if ran without arguments the scripts `runnode.sh` and `runminer.sh` assume the argument "node1" and "miner1", respectively. +eth.sendTransaction({from: adam, to: eve, value: web3.toWei(4, "ether")}) +``` -## Your first node +## Check balance -The script `runnode.sh` runs the first node in your private Ethereum network (a container named "ethereum-node1"). It is important to notice that it looks for and connects to the bootnode, but since it is alone in the world it won't find any peer (yet) - the bootnode is a dumb node that doesn't count as a peer. +A miner must be running to verify the transaction and it takes a bit for the transfer to go through. -```sh -./runnode.sh +``` +adam = eth.accounts[0] +web3.fromWei(eth.getBalance(adam), "ether"); ``` -## Your second node +## Other Helpful Scripts -The same script `runnode.sh` can be used to run as many other nodes you want, all you need is to supply a node name as its argument. A container named "ethereum-" will be created and started, looking for the bootnode and eventually finding the first node (and the others you ran) as its peer. +We have scripted a number of common tasks. Run `make` to see list of commands: -```sh -./runnode.sh node2 +``` +$ make + +# Help + +init init the genesis.json file +start_nodes start 2 nodes +start_miner start 1 miner +seal run sealer +stop stop everything +clean reset everything + +bash launch a bash with 'ethereum/client-go:alltools' +ps see all docker containers + +show_node show node peers +show_miner show miner peers + +attach_miner attach to miner 1 +attach_node1 attach to node 1 +attach_node2 attach to node 2 + +list_accounts list all ethereum accounts +copy_keystore copy keystore ``` -## Checking the nodes' peers +## Good Reads -Self-discovery can take a few seconds, but it is easy to check it with the script `showpeers.sh`. The command below shows the peers of container "ethereum-node": +* https://medium.com/@kacharlabhargav21/connecting-geth-to-metamask-fc2b2c89d9f9 +* https://web3js.readthedocs.io/en/v1.2.11/web3-eth.html#eth-sendtransaction +* https://geth.ethereum.org/docs/interface/managing-your-accounts -```sh -./showpeers.sh -``` -An optional argument can specify another node container to be checked: +# Advanced Details -```sh -./showpeers.sh node2 -``` +## Network definition -## Running a miner node +To isolate your private Ethereum network from the main public one it does not require an isolated physical network at all. Its nodes can still reside on the Internet and yet implement a closed private Ethereum network. -The nodes "ethereum-node1" e "ethereum-node2" are non-mining nodes - they served the purpose of testeing the ability to create a private Ethereum network capable of self-discovery. Another script `runminer.sh` is similar to the `runnode.sh`, but it starts mining nodes (it assumes "miner1" if ran without arguments): +This 'genesis.sh' allows the user to define environment variables that will reflect on a particular (and predictable) genesis block, therefore creating an Ethereum network that cannot interact with another one. This is done when the script generates a 'genesis.json' file that is mounted on each node's container. -```sh -./runminer.sh [node_name] -``` +Those variables are: -To check if it discovered its peers "node1" and "node2": +* GEN_NONCE: any value your nodes agree upon, the default is "0xeddeadbabeeddead" +* GEN_CHAIN_ID: any integer value your nodes agree upon, the default is 1981 -```sh -./showpeers.sh ethereum-miner1 -``` +## Containers -Mining can take quite a long time to run for the first time. Onde again, to check the node work and status you can always go for the container log: +A bootnode is a "dumb" node in the network that aids other nodes on P2P discovery and does not count as a peer. -```sh -docker logs -f ethereum-miner1 -``` +The nodes are peers and maintain the blockchain +The miner works the blockchain and gets paid for it. + +## Volumes + +The provided utility scripts are meant for local development use and rely on local volumes to persist data. For example, the script `runnode.sh ` creates a local volume ".ether-" at the current folder. When using this container in production you should try another strategy to guarantee the node portability. +The folders art +* .bootnode +* .ether- +* .ether- diff --git a/azure/azuredeploy.parameters.json b/azure/azuredeploy.parameters.json deleted file mode 100644 index 42026cd..0000000 --- a/azure/azuredeploy.parameters.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "dnsNamePrefix": { - "value": "ethereum-playground" - }, - "agentCount": { - "value": 3 - }, - "agentVMSize" : { - "value": "Standard_A2" - }, - "linuxAdminUsername": { - "value": "etheruser" - }, - "orchestratorType": { - "value": "Swarm" - }, - "masterCount": { - "value": 1 - }, - "sshRSAPublicKey": { - "value": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCm5YGmSyX6wABwZnWZS+fE3ECa8h8061wsV08hjQh4SRn6zPAfQHQQNdTug7zehBXXXeMyYI76DG+8qdKaEqY94mrVHAoKoGASrOZUoAdeK5vh4Gm9qbJAvPWkmJ9u85c7KL1a8YmlfNAlxfpCzLnNSGuJqC6usPhCz+O6VYNw9M+pvPtKiqgoHztrJOvbKKoDIktD4eS/+66HefqEqsHtXKRrg9vmA6589/m7ajYWcvSwwQM0IxDRp1kuOVjmWK6YxS5+q4l3VoP2T0my/Lu80IC+4RGNNvd5RryVZbLHTtfwLOjrm+ONF/6xdgdJNzGMl9Q+WV6sZsPimb7/lLhExNuuiJaYNiAKahyMN65ZWqu3RiwkfNvANo/dL11rZfuVjxiSTChsKyuEVJvLmWGcTrXDs4L+5olt2x3ugr0QMDurZwa5M1FilLZqYn0eVkxBgsS/U5JYI7lwQoldZba7Y3BlXPtsg8Dl3iLH0xrK7pGVmPmTLkWXh5oQrZcN2bGWZRwMCudLFgst0V5nFBtdGMrTTsRDu9SSAyQQJ+nDF3Ihdf3W0vKxaIHHhwVMeYqRNyMFy6oqGaPbzVn5C0zpU8PjVwecF+nxeCG8iaEPRRi2CZQARCOvPl/iq57D/AD7Umi5OldSZlrunv8mYQMp06TGOWM4R/AQzmX3C5Sgbw== goroh@hotmail.com.br" - } - } -} diff --git a/azure/azuredeploy.parameters.json.template b/azure/azuredeploy.parameters.json.template deleted file mode 100644 index 9f91093..0000000 --- a/azure/azuredeploy.parameters.json.template +++ /dev/null @@ -1,27 +0,0 @@ -{ - "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "dnsNamePrefix": { - "value": "$AZURE_DNS_PREFIX" - }, - "agentCount": { - "value": 3 - }, - "agentVMSize" : { - "value": "Standard_A2" - }, - "linuxAdminUsername": { - "value": "etheruser" - }, - "orchestratorType": { - "value": "Swarm" - }, - "masterCount": { - "value": 1 - }, - "sshRSAPublicKey": { - "value": "$AZURE_PUB_KEY" - } - } -} diff --git a/azure/install-azure-driver.sh b/azure/install-azure-driver.sh deleted file mode 100644 index eafbec6..0000000 --- a/azure/install-azure-driver.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -sudo apt-get install -y cifs-utils -sudo wget https://github.com/Azure/azurefile-dockervolumedriver/releases/download/v0.5.0/azurefile-dockervolumedriver -q -O /usr/bin/azurefile-dockervolumedriver -sudo wget https://raw.githubusercontent.com/Azure/azurefile-dockervolumedriver/master/contrib/init/upstart/azurefile-dockervolumedriver.conf -q -O /etc/init/azurefile-dockervolumedriver.conf -sudo wget https://raw.githubusercontent.com/Azure/azurefile-dockervolumedriver/master/contrib/init/upstart/azurefile-dockervolumedriver.default -q -O /etc/default/azurefile-dockervolumedriver -sudo initctl reload-configuration -sudo initctl start azurefile-dockervolumedriver - - diff --git a/countpeers.sh b/bin/countpeers.sh similarity index 100% rename from countpeers.sh rename to bin/countpeers.sh diff --git a/bin/genesis.sh b/bin/genesis.sh new file mode 100755 index 0000000..5b75d08 --- /dev/null +++ b/bin/genesis.sh @@ -0,0 +1,4 @@ +#!/bin/bash +GEN_NONCE="0xeddeadbabeeddead" +GEN_CHAIN_ID=1981 +sed "s/\${GEN_NONCE}/$GEN_NONCE/g" config/genesis.json.template | sed "s/\${GEN_CHAIN_ID}/$GEN_CHAIN_ID/g" > config/genesis.json diff --git a/getbootnodeurl.sh b/bin/getbootnodeurl.sh similarity index 100% rename from getbootnodeurl.sh rename to bin/getbootnodeurl.sh diff --git a/killall.sh b/bin/killall.sh similarity index 100% rename from killall.sh rename to bin/killall.sh diff --git a/killnode.sh b/bin/killnode.sh similarity index 100% rename from killnode.sh rename to bin/killnode.sh diff --git a/runattach.sh b/bin/runattach.sh similarity index 100% rename from runattach.sh rename to bin/runattach.sh diff --git a/runbash.sh b/bin/runbash.sh similarity index 100% rename from runbash.sh rename to bin/runbash.sh diff --git a/showpeers.sh b/bin/showpeers.sh similarity index 100% rename from showpeers.sh rename to bin/showpeers.sh diff --git a/wipeall.sh b/bin/wipeall.sh similarity index 71% rename from wipeall.sh rename to bin/wipeall.sh index c95330b..cee1a99 100755 --- a/wipeall.sh +++ b/bin/wipeall.sh @@ -4,6 +4,3 @@ echo "Removing containers..." docker stop $(docker ps -q -f name=ethereum) docker rm $(docker ps -aq -f name=ethereum) echo "Removing volumes in $DATA_ROOT..." -rm -Rf $DATA_ROOT/.ether-* -rm -Rf $DATA_ROOT/.ethash -rm -Rf $DATA_ROOT/.bootnode diff --git a/build.sh b/build.sh deleted file mode 100755 index e05ad85..0000000 --- a/build.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -IMGVERSION=$(head -n 1 .IMGVERSION) -IMGVERSION=${IMGVERSION:-"latest"} -IMGNAME=$(head -n 1 .IMGNAME) -ARGPROXY= -[[ ! -z "$http_proxy" ]] && ARGPROXY="--build-arg http_proxy=$http_proxy" -[[ ! -z "$https_proxy" ]] && ARGPROXY="$ARGPROXY --build-arg https_proxy=$https_proxy" -[[ ! -z "$no_proxy" ]] && ARGPROXY="$ARGPROXY --build-arg no_proxy=$no_proxy" -echo "Building $IMGNAME:latest" -[[ ! -z "$ARGPROXY" ]] && echo "ARGPROXY=$ARGPROXY" -docker build $ARGPROXY \ - -t "$IMGNAME:$IMGVERSION" . -echo "Done!" diff --git a/src/genesis.json.template b/config/genesis.json.template similarity index 91% rename from src/genesis.json.template rename to config/genesis.json.template index b1db09d..9d2c531 100644 --- a/src/genesis.json.template +++ b/config/genesis.json.template @@ -5,9 +5,7 @@ "eip155Block": 0, "eip158Block": 0 }, - "alloc" : { - ${GEN_ALLOC} - }, + "alloc" : {}, "coinbase" : "0x0000000000000000000000000000000000000000", "difficulty" : "0x1", "extraData" : "", diff --git a/genesis.sh b/genesis.sh deleted file mode 100755 index f4824f3..0000000 --- a/genesis.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -GEN_NONCE="0xeddeadbabeeddead" -GEN_CHAIN_ID=1981 -GEN_ALLOC='"0x0000000000000000000000000000000000000001": {"balance": "100000"}' -sed "s/\${GEN_NONCE}/$GEN_NONCE/g" src/genesis.json.template | sed "s/\${GEN_ALLOC}/$GEN_ALLOC/g" | sed "s/\${GEN_CHAIN_ID}/$GEN_CHAIN_ID/g" > genesis.json diff --git a/runminer.sh b/runminer.sh index 29315fe..b5e2e72 100755 --- a/runminer.sh +++ b/runminer.sh @@ -2,4 +2,5 @@ NODE_NAME=$1 NODE_NAME=${NODE_NAME:-"miner1"} ETHERBASE=${ETHERBASE:-"0x0000000000000000000000000000000000000001"} +echo "Proceeds sent to: $ETHERBASE" ./runnode.sh $NODE_NAME --mine --minerthreads=1 --etherbase="$ETHERBASE" diff --git a/runnode.sh b/runnode.sh index aa4fd81..e88219c 100755 --- a/runnode.sh +++ b/runnode.sh @@ -9,15 +9,18 @@ DATA_HASH=${DATA_HASH:-"$(pwd)/.ethash"} echo "Destroying old container $CONTAINER_NAME..." docker stop $CONTAINER_NAME docker rm $CONTAINER_NAME +GENESIS_FILEPATH=$(pwd)/config/genesis.json RPC_PORTMAP= RPC_ARG= + +# RPC_PORT - environment variable set by caller (optional) if [[ ! -z $RPC_PORT ]]; then -# RPC_ARG='--ws --wsaddr=0.0.0.0 --wsport 8546 --wsapi=db,eth,net,web3,personal --wsorigins "*" --rpc --rpcaddr=0.0.0.0 --rpcport 8545 --rpcapi=db,eth,net,web3,personal --rpccorsdomain "*"' + #RPC_ARG='--ws --wsaddr=0.0.0.0 --wsport 8546 --wsapi=db,eth,net,web3,personal --wsorigins "*" --rpc --rpcaddr=0.0.0.0 --rpcport 8545 --rpcapi=db,eth,net,web3,personal --rpccorsdomain "*"' RPC_ARG='--rpc --rpcaddr=0.0.0.0 --rpcport 8545 --rpcapi=db,eth,net,web3,personal --rpccorsdomain "*"' RPC_PORTMAP="-p $RPC_PORT:8545" fi -BOOTNODE_URL=${BOOTNODE_URL:-$(./getbootnodeurl.sh)} -if [ ! -f $(pwd)/genesis.json ]; then +BOOTNODE_URL=${BOOTNODE_URL:-$(./bin/getbootnodeurl.sh)} +if [ ! -f $GENESIS_FILEPATH ]; then echo "No genesis.json file found, please run 'genesis.sh'. Aborting." exit fi @@ -25,8 +28,9 @@ if [ ! -d $DATA_ROOT/keystore ]; then echo "$DATA_ROOT/keystore not found, running 'geth init'..." docker run --rm \ -v $DATA_ROOT:/root/.ethereum \ - -v $(pwd)/genesis.json:/opt/genesis.json \ + -v $GENESIS_FILEPATH:/opt/genesis.json \ $IMGNAME init /opt/genesis.json + sudo cp $(pwd)/keystore/* $DATA_ROOT/keystore echo "...done!" fi echo "Running new container $CONTAINER_NAME..." @@ -34,6 +38,6 @@ docker run $DETACH_FLAG --name $CONTAINER_NAME \ --network ethereum \ -v $DATA_ROOT:/root/.ethereum \ -v $DATA_HASH:/root/.ethash \ - -v $(pwd)/genesis.json:/opt/genesis.json \ + -v $GENESIS_FILEPATH:/opt/genesis.json \ $RPC_PORTMAP \ $IMGNAME --bootnodes=$BOOTNODE_URL $RPC_ARG --cache=512 --verbosity=4 --maxpeers=3 ${@:2} diff --git a/runsealer.sh b/runsealer.sh index 784dd2b..d6f77dd 100755 --- a/runsealer.sh +++ b/runsealer.sh @@ -1,5 +1,5 @@ #!/bin/bash NODE_NAME=$1 -NODE_NAME=${NODE_NAME:-"miner1"} +NODE_NAME=${NODE_NAME:-"sealer1"} ETHERBASE=${ETHERBASE:-"0x0000000000000000000000000000000000000001"} ./runnode.sh $NODE_NAME --mine --minerthreads=1 --unlock="$ETHERBASE" diff --git a/setenv.sh.template b/setenv.sh.template deleted file mode 100644 index f15328b..0000000 --- a/setenv.sh.template +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -# UNCOMMENT AND COMPLETE FOR DIGITAL OCEAN -export DIGITALOCEAN_ACCESS_TOKEN= - -# UNCOMMENT BELOW AND COMPLETE FOR AZURE CLI -export AZURE_TEMPLATE_URL=https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-acs-swarm/azuredeploy.json -export AZURE_RESOURCE_GROUP="EthereumPlayground" -export AZURE_DEPLOYMENT_NAME="EthereumSwarm" -export AZURE_LOCATION=eastus -export AZURE_DNS_PREFIX=ethereum-playground -export AZURE_DEPLOY_JSON=`cat ./azure/azuredeploy.parameters.json` -# UNCOMMENT TO READ PUBLIC KEY INTO VAR AND SUBST IN PARAMETER FILE -export AZURE_PUB_KEY=`cat ~/.ssh/id_rsa.pub` -sed "s%\$AZURE_PUB_KEY%$AZURE_PUB_KEY%" azure/azuredeploy.parameters.json.template | \ - sed "s%\$AZURE_DNS_PREFIX%$AZURE_DNS_PREFIX%" > azure/azuredeploy.parameters.json - -# UNCOMMENT BELOW AND COMPLETE FOR AZURE ON DOCKER-MACHINE -export AZUREDM_LOCATION=eastus -export AZUREDM_RESOURCE_GROUP="EthereumDMPlayground" -export AZUREDM_SUBSCRIPTION_ID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - -# UNCOMMENT BELOW AND COMPLETE FOR AMAZON ECS OR AMAZON AWS (docker-machine) -export AWS_ACCESS_KEY_ID=xxxxxxxxxxxxxxxxxxxx -export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -export AWS_REGION=us-east-1 -export AWS_SUBNET=b -export AWS_CLUSTER=ethereum-playground diff --git a/src/genesis.json b/src/genesis.json deleted file mode 100644 index 3bb25a3..0000000 --- a/src/genesis.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "config": { - "chainId": ${GEN_CHAIN_ID}, - "homesteadBlock": 0, - "eip155Block": 0, - "eip158Block": 0 - }, - "alloc" : { - ${GEN_ALLOC} - }, - "coinbase" : "0x0000000000000000000000000000000000000000", - "difficulty" : "0x20000", - "extraData" : "", - "gasLimit" : "0x2fefd8", - "nonce" : "${GEN_NONCE}", - "mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000", - "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", - "timestamp" : "0x00" -} diff --git a/src/startgeth.sh b/src/startgeth.sh deleted file mode 100755 index 2874c06..0000000 --- a/src/startgeth.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh - -#MY_IP=$(ip addr show eth0 | grep -Po 'inet \K[\d.]+') -MY_IP=$(ifconfig eth0 | awk '/inet addr/{print substr($2,6)}') -GEN_ARGS= - -if [ "$1" == "bash" ]; then - echo "Running bash console..." - exec /bin/bash -fi - -# replace vars -if [[ ! -z $GEN_NONCE ]]; then - echo "Generating genesis.nonce from arguments..." - sed "s/\${GEN_NONCE}/$GEN_NONCE/g" -i /opt/genesis.json -fi -echo "Generating genesis.alloc from arguments..." -sed "s/\${GEN_ALLOC}/$GEN_ALLOC/g" -i /opt/genesis.json - -echo "Generating genesis.chainid from arguments..." -sed "s/\${GEN_CHAIN_ID}/$GEN_CHAIN_ID/g" -i /opt/genesis.json - -echo "Running ethereum node with CHAIN_TYPE=$CHAIN_TYPE" -if [ "$CHAIN_TYPE" == "private" ]; then - # empty datadir -> geth init - DATA_DIR=${DATA_DIR:-"/root/.ethereum"} - echo "DATA_DIR=$DATA_DIR, contents:" - ls -la $DATA_DIR - if [ ! -d "$DATA_DIR" ] || [ -d "ls -A $DATA_DIR" ]; then - echo "DATA_DIR '$DATA_DIR' non existant or empty. Initializing DATA_DIR..." - geth --datadir "$DATA_DIR" init /opt/genesis.json - fi - GEN_ARGS="--datadir $DATA_DIR" -# [[ ! -z $NET_ID ]] && GEN_ARGS="$GEN_ARGS --networkid=$NET_ID" -# [[ ! -z $MY_IP ]] && GEN_ARGS="$GEN_ARGS --nat=extip:$MY_IP" - GEN_ARGS="$GEN_ARGS --nat=any" - [[ ! -z $BOOTNODE_URL ]] && GEN_ARGS="--bootnodes=$BOOTNODE_URL $GEN_ARGS" -fi - -if [ "$RUN_BOOTNODE" == "true" ]; then - echo "Running bootnode..." - KEY_FILE="/opt/bootnode/boot.key" - mkdir -p /opt/bootnode - if [ ! -f "$KEY_FILE" ]; then - echo "(creating $KEY_FILE)" - bootnode --genkey="$KEY_FILE" - fi - [[ -z $BOOTNODE_SERVICE ]] && BOOTNODE_SERVICE=$MY_IP - echo "Running bootnode with arguments '--nodekey=$KEY_FILE --addr $BOOTNODE_SERVICE:30301 $@'" - exec /usr/local/bin/bootnode --nodekey="$KEY_FILE" --addr "$BOOTNODE_SERVICE:30301" "$@" -# exec /usr/local/bin/bootnode --nodekey="$KEY_FILE" "$@" -fi - -echo "Running geth with arguments $GEN_ARGS $@" -exec /usr/local/bin/geth $GEN_ARGS "$@" -