Commit 221ba589 authored by Marius Momeu's avatar Marius Momeu

[eth] Add initial Ethereum configuration files

parent 537bd858
ethereum-private-network/truffle-code
......@@ -7,9 +7,26 @@
**Note**: If you get a `connection timeout error` while executing `startFabric.sh`, please set the environment variable `FABRIC_START_TIMEOUT=30`, or to a larger value, if it still fails
# Ethereum
* TODO
We are going to build a docker-based private local Ethereum network with the following nodes:
* 1 bootnode for bootstrapping the ethereum private network
* 2 miner nodes for mining transaction blocks
* 1 dev node that exposes RPC services for interacting with the blockchain
* 2 swarm nodes for storing and distribute blockchain code and data
* 1 truffle node for developing & deploying smart contracts
* 1 explorer node for analyzing the state of the blockchain network
In order to configure the network, execute the following commands:
```
cd ./ethereum-private-network
docker-compose up -d
```
# IPFS
......@@ -18,7 +35,6 @@
* https://blog.ipfs.io/1-run-ipfs-on-docker/
# BigchainDB
Go through the following tutorial to run an BCDB node in a docker container:
......
This diff is collapsed.
# Local Ethereum Network
A set of Docker images to create a local Ethereum network with three nodes and a monitor. This was built to understand how local Ethereum networks have to be set up and to provide a local test environment. **Never use this in a productive environment, as the docker-compose.yml contains hardcoded passwords and private keys for convenience**
The testnet consists out of multiple parts :
* 1 Bootnode - registers existing nodes on the network, discovery service.
* 2 Miners - Also called **sealers** with proof-of-authority. They validate the blocks. No RPC is exposed as they are required to be unlocked.
* 1 Node - This serves as **transaction relay** and is a fullnode that does not mine, is locked but has RPC exposed
* 2 Swarm nodes - These nodes make up the **peer-to-peer CDN**
* 1 Blockchain explorer - Lightweight web application to explore the blockchain through web application.
## Usage
Setting up this networks requires you to install Docker. Clone the repository, and run `docker-compose up` from the repository root. The network should start and synchronize without any further configuration. The networks always uses the latest available versions of Ethereum and Swarm, the network is set up for clique proof-of-authority similar to the Ethereum Rinkeby testnet. For more information on clique POA see https://github.com/ethereum/EIPs/issues/225 .
## The bootnode
The nodes in the network are connecting with the bootnode. This is a special ethereum node, designed to provide a register of the existing nodes in the network. The parameter `nodekeyhex`in the `docker-compose.yml` is needed to derive the `enodeID` which is later passed to the other nodes. The IP needs to be fixed, as the other nodes need to know where to find the bootnode, and DNS is not supported. The bootnode does not participate in synchronization of state or mining.
## Miners / Geth Nodes
There are three nodes that participate in the network. The state is synchronized between them and they are trying to create blocks with mining. Initially they connect to the bootnode with the information derived from the fixed IP and the nodekeyhex. If you want to interact with the network, you need to connect via RPC. You can attach a geth instance, connect Remix IDE or connect your browser with web3 and build a ÐApp.
The RPC Ports of the nodes are mapped to your localhost, the addresses are:
* geth-dev-miner-1 : No RPC exposed
* geth-dev-miner-2: No RPC exposed
* geth-dev-node: [http://localhost:8545](http://localhost:8545)
## Swarm (/BZZ:/)
Swarm is a distributed storage platform and content distribution service, a native base layer service of the ethereum web3 stack. The primary objective of Swarm is to provide a sufficiently decentralized and redundant store of Ethereum’s public record, in particular to store and distribute dapp code and data as well as blockchain data. From an economic point of view, it allows participants to efficiently pool their storage and bandwidth resources in order to provide these services to all participants of the network, all while being incentivised by Ethereum. Files on Swarm are represented by their KECCAK256 Checksum.
The RPC Ports of the nodes are mapped to your localhost, the addresses are:
* [http://localhost:8500](http://localhost:8500) - geth-swarm-1
* [http://localhost:8501](http://localhost:8501) - geth-swarm-2
## Whisper (/SHH:/)
Coming soon ...
## Blockchain Explorer
The blockchain explorer is a simple node.js web application being provided by a seperate container: geth-explorer. The application uses the web3 javascript API to fetch the data from `geth-dev-node` through RPC calls. The blockchain explorer can be found at [http://localhost:8080](http://localhost:8080).
FROM ubuntu:xenial
RUN apt-get update \
&& apt-get install -y wget software-properties-common \
&& rm -rf /var/lib/apt/lists/*
WORKDIR "/root"
RUN add-apt-repository -y ppa:ethereum/ethereum
RUN apt-get update \
&& apt-get install -y ethereum
ENV nodekeyhex=""
CMD exec bootnode -nodekeyhex $nodekeyhex
EXPOSE 30301/udp
EXPOSE 30303/udp
version: "3"
services:
geth-bootnode:
hostname: geth-bootnode
environment:
- nodekeyhex=08f0e1dee5c1b4645f3331a566009e41a4514b6cd28656d63d0449ecf812812b #Needs to be fix, so that the miners know the resulting enode id
build:
context: ./bootnode
ports:
- 30301:30301/udp
networks:
chainnet:
ipv4_address: 172.25.0.101 # The miners need to know the IP address later on
geth-dev-miner-1:
hostname: geth-dev-miner-1
depends_on:
- geth-bootnode
environment:
- address=0x8cc5a1a0802db41db826c2fcb72423744338dcb0 #derived from the private key which is passed in the args
- bootnodeId=76a8171707eca17647a47ca99ffd348927dfa60102792ea349a25d5192e61855be83b786e376276a306afcceea4ffd1c9c77e4370b417efc39f328a0d068004c #derived from the nodekeyhex of the bootnode
- bootnodeIp=172.25.0.101
build:
context: ./miner
args:
privatekey: df504d175ae63abf209bad9dda965310d99559620550e74521a6798a41215f46 # Please don't do something like this in production, okay?
password: pass
container_name: geth-miner-1
volumes:
- eth-data-1:/root/.ethash
networks:
chainnet:
ipv4_address: 172.25.0.102 # The monitor needs to know this address
geth-dev-miner-2:
hostname: geth-dev-miner-2
depends_on:
- geth-bootnode
environment:
- address=0x3590aca93338b0721966a8d0c96ebf2c4c87c544 #derived from the private key which is passed in the args
- bootnodeId=76a8171707eca17647a47ca99ffd348927dfa60102792ea349a25d5192e61855be83b786e376276a306afcceea4ffd1c9c77e4370b417efc39f328a0d068004c #derived from the nodekeyhex of the bootnode
- bootnodeIp=172.25.0.101
build:
context: ./miner
args:
privatekey: bc5b578e0dcb2dbf98dd6e5fe62cb5a28b84a55e15fc112d4ca88e1f62bd7c35
password: word
container_name: geth-miner-2
volumes:
- eth-data-2:/root/.ethash
networks:
chainnet:
ipv4_address: 172.25.0.104
geth-dev-node:
hostname: geth-dev-node
depends_on:
- geth-dev-miner-2
environment:
- address=0x3590aca93338b0721966a8d0c96ebf2c4c87c544 #derived from the private key which is passed in the args
- bootnodeId=76a8171707eca17647a47ca99ffd348927dfa60102792ea349a25d5192e61855be83b786e376276a306afcceea4ffd1c9c77e4370b417efc39f328a0d068004c #derived from the nodekeyhex of the bootnode
- bootnodeIp=172.25.0.101
build:
context: ./node
args:
privatekey: bc5b578e0dcb2dbf98dd6e5fe62cb5a28b84a55e15fc112d4ca88e1f62bd7c35
password: word
container_name: geth-node
ports:
- 8545:8545
healthcheck:
test: wget http://localhost:8545
interval: 2s
timeout: 5s
retries: 30
volumes:
- eth-data-3:/root/.ethash
networks:
chainnet:
ipv4_address: 172.25.0.110
geth-dev-swarm-1:
hostname: geth-dev-swarm-1
depends_on:
- geth-dev-node
environment:
- address=8cc5a1a0802db41db826c2fcb72423744338dcb0 #derived from the private key which is passed in the args
- bootnodeId=76a8171707eca17647a47ca99ffd348927dfa60102792ea349a25d5192e61855be83b786e376276a306afcceea4ffd1c9c77e4370b417efc39f328a0d068004c #derived from the nodekeyhex of the bootnode
- bootnodeIp=172.25.0.101
build:
context: ./swarm
args:
privatekey: df504d175ae63abf209bad9dda965310d99559620550e74521a6798a41215f46
password: pass
container_name: geth-swarm-1
ports:
- 8500:8500
- 30399:30399/udp
volumes:
- eth-data-4:/root/.ethash
networks:
chainnet:
ipv4_address: 172.25.0.111
geth-dev-swarm-2:
hostname: geth-dev-miner-3
depends_on:
- geth-dev-node
environment:
- address=3590aca93338b0721966a8d0c96ebf2c4c87c544 #derived from the private key which is passed in the args
- bootnodeId=76a8171707eca17647a47ca99ffd348927dfa60102792ea349a25d5192e61855be83b786e376276a306afcceea4ffd1c9c77e4370b417efc39f328a0d068004c #derived from the nodekeyhex of the bootnode
- bootnodeIp=172.25.0.101
build:
context: ./swarm
args:
privatekey: bc5b578e0dcb2dbf98dd6e5fe62cb5a28b84a55e15fc112d4ca88e1f62bd7c35
password: pass
container_name: geth-swarm-2
ports:
- 8501:8500
- 30340:30399/udp
volumes:
- eth-data-5:/root/.ethash
networks:
chainnet:
ipv4_address: 172.25.0.112
geth-explorer:
hostname: geth-explorer
depends_on:
- geth-dev-node
ports:
- 8080:8080
build:
context: ./explorer
container_name: geth-explorer
networks:
chainnet:
ipv4_address: 172.25.0.125
truffle-dev:
hostname: truffle-dev
depends_on:
- geth-dev-node
build:
context: ./truffle
command: bash
stdin_open: true
tty: true
container_name: truffle-dev
volumes:
- ./truffle-code:/root/code
networks:
chainnet:
ipv4_address: 172.25.0.126
networks:
chainnet:
driver: bridge
ipam:
config:
- subnet: 172.25.0.0/24
volumes:
eth-data-1:
eth-data-2:
eth-data-3:
eth-data-4:
eth-data-5:
eth-data-6:
FROM node:6.11-alpine
WORKDIR "/opt"
RUN apk add --update git make g++ && \
git clone https://bitbucket.org/designisdead/blockchain-explorer.git
WORKDIR "/opt/blockchain-explorer"
RUN git checkout c6e12f1
RUN npm install
CMD npm run start
EXPOSE 8080
FROM ubuntu:xenial
RUN apt-get update \
&& apt-get install -y wget software-properties-common \
&& rm -rf /var/lib/apt/lists/*
WORKDIR "/root"
RUN add-apt-repository -y ppa:ethereum/ethereum
ARG binary
RUN apt-get update \
&& apt-get install -y ethereum
ARG password
ARG privatekey
RUN echo $password > ~/.accountpassword
RUN echo $privatekey > ~/.privatekey
ADD ./genesis.json ./genesis.json
RUN geth init genesis.json
RUN geth account import --password ~/.accountpassword ~/.privatekey
ENV address=""
ENV bootnodeId=""
ENV bootnodeIp=""
CMD exec geth --bootnodes "enode://$bootnodeId@$bootnodeIp:30301" --networkid "6660001" --verbosity=4 --syncmode=full --mine --gasprice "0" --etherbase $address --unlock $address --password ~/.accountpassword
{
"config": {
"chainId": 6660001,
"homesteadBlock": 1,
"eip150Block": 2,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 3,
"eip158Block": 3,
"byzantiumBlock": 4,
"clique": {
"period": 5,
"epoch": 30000
}
},
"nonce": "0x0",
"timestamp": "0x5a8efd25",
"extraData": "0x00000000000000000000000000000000000000000000000000000000000000003590aca93338b0721966a8d0c96ebf2c4c87c5448cc5a1a0802db41db826c2fcb72423744338dcb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0xf42400",
"difficulty": "0x1",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"3590aca93338b0721966a8d0c96ebf2c4c87c544": {
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
},
"8cc5a1a0802db41db826c2fcb72423744338dcb0": {
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
FROM ubuntu:xenial
RUN apt-get update \
&& apt-get install -y wget software-properties-common \
&& rm -rf /var/lib/apt/lists/*
WORKDIR "/root"
RUN add-apt-repository -y ppa:ethereum/ethereum
ARG binary
RUN apt-get update \
&& apt-get install -y ethereum
ARG password
ARG privatekey
RUN echo $password > ~/.accountpassword
RUN echo $privatekey > ~/.privatekey
ADD ./genesis.json ./genesis.json
RUN geth init genesis.json
RUN geth account import --password ~/.accountpassword ~/.privatekey
ENV address=""
ENV bootnodeId=""
ENV bootnodeIp=""
CMD exec geth --bootnodes "enode://$bootnodeId@$bootnodeIp:30301" --networkid "6660001" --verbosity=4 --rpc --rpcaddr "0.0.0.0" --rpcapi "eth,web3,net,admin,debug,db" --rpccorsdomain "*" --syncmode="full"
EXPOSE 8545
EXPOSE 30303
{
"config": {
"chainId": 6660001,
"homesteadBlock": 1,
"eip150Block": 2,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 3,
"eip158Block": 3,
"byzantiumBlock": 4,
"clique": {
"period": 5,
"epoch": 30000
}
},
"nonce": "0x0",
"timestamp": "0x5a8efd25",
"extraData": "0x00000000000000000000000000000000000000000000000000000000000000003590aca93338b0721966a8d0c96ebf2c4c87c5448cc5a1a0802db41db826c2fcb72423744338dcb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0xf42400",
"difficulty": "0x1",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"3590aca93338b0721966a8d0c96ebf2c4c87c544": {
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
},
"8cc5a1a0802db41db826c2fcb72423744338dcb0": {
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
FROM ubuntu:xenial
RUN apt-get update \
&& apt-get install -y wget software-properties-common \
&& rm -rf /var/lib/apt/lists/*
WORKDIR "/root"
RUN add-apt-repository -y ppa:ethereum/ethereum
ARG binary
RUN apt-get update \
&& apt-get install -y geth ethereum-swarm
ARG password
ARG privatekey
RUN echo $password > ~/.accountpassword
RUN echo $privatekey > ~/.privatekey
RUN geth account import --password ~/.accountpassword ~/.privatekey
ENV address=""
ENV bootnodeId=""
ENV bootnodeIp=""
CMD exec swarm --bootnodes "enode://$bootnodeId@$bootnodeIp:30399" --password ~/.accountpassword --bzzaccount $address --datadir .ethereum --keystore .ethereum/keystore --bzzapi "0.0.0.0" -corsdomain "*" -httpaddr "0.0.0.0"
EXPOSE 8500
EXPOSE 33099
# Node image
FROM node:latest
# Create code directory
RUN mkdir /root/code
# Set working directory
WORKDIR /root/code
# Install Truffle
RUN npm install -g truffle
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment