Skip to content
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

Refactor geth-poa-docker setup #34

Merged
21 commits merged into from
Apr 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,35 @@

**E**thereum **D**evelopment **E**nvironment and **N**etwork is a collection of tools and templates to enable app developers to create new prototypes fast and effectively.

**Contents:**
## Contents

* Private “proof-of-work” Blockchain (2x Geth) + EthStats Dashboard + Ether Explorer v2
- Private PoA geth blockchain including bootnode, fullnode, miners, explorers and monitors

* Private “proof-of-authority” Blockchain (6x Parity) + EthStats Dashboard + Ether Explorer v2
- Private PoW geth blockchain including bootstrapping node, scalabe number of nodes, explorers and monitors

* “Toolbox” with Truffle, Oyente and some Utils
- Private PoA parity blockchain including authorities, members, explorers and monitors

- Toolbox with Truffle, Oyente and some development utilities

![Screenshot of the EDEN dashboard](/doc/img/eden_grafik.png)

## Getting Started

* Get a local copy of the repository, master branch is the latest version available:
- Get a local copy of the repository, master branch is the latest version available:

```
git clone https://github.com/MaibornWolff/eden.git
```

* Install [NodeJS](https://nodejs.org)
- Install [NodeJS](https://nodejs.org)

* Install [Docker Desktop](https://www.docker.com/products/docker-desktop)
- Install [Docker Desktop](https://www.docker.com/products/docker-desktop)

* Install [EditorConfig](https://editorconfig.org/#download) plugin for your editor/IDE
- Install [EditorConfig](https://editorconfig.org/#download) plugin for your editor/IDE

### Installing

Refer to the README file of each blockchain. They are in the project subfolders. Have fun! :)
Refer to the README file of each blockchain. They are in the project subfolders.

## Contributing

Expand Down
27 changes: 27 additions & 0 deletions geth-poa-docker/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.PHONY: build build-no-cache clean logs reset restart start start-attached stop

build:
docker-compose build

build-no-cache:
docker-compose build --no-cache

clean:
docker-compose down --rmi all --volumes --remove-orphans

logs:
docker-compose logs -f

reset: stop clean
docker-compose up -d --build --force-recreate --remove-orphans

restart: stop start

start:
docker-compose up -d --remove-orphans

start-attached:
docker-compose up --remove-orphans

stop:
docker-compose down --volumes --remove-orphans
74 changes: 46 additions & 28 deletions geth-poa-docker/README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,59 @@
# 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**
# Local PoA Ethereum Network

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.
A set of Docker images to create a local PoA Ethereum network with one bootnode, two miners, one fullnode, two swarm bee nodes with clef as key management service, three explorers, a monitor and its corresponding dashboard. This was built to understand how local PoA 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.**

## 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 testnet consists of several parts:

## 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.
- 1 bootnode: registers existing nodes on the network, discovery service.
- 2 miners: also called **sealers** within proof-of-authority (PoA). They validate the blocks.
- 1 fullnode: this serves as **transaction relay** and is a fullnode that does not mine, is locked but has RPC exposed.
- 2 swarm bee nodes: these nodes make up the **peer-to-peer CDN**.
- 3 blockchain explorer: 2 lightweight web applications to explore the blockchain and 1 blockscout explorer.
- 1 monitor and its corresponding dashboard: the monitor collects data from the fullnode which is displayed through the dashboard.

## 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.
## Quick start

The RPC Ports of the nodes are mapped to your localhost, the addresses are:
Setting up this network requires you to install Docker and Docker Compose. Clone the repository, and run `docker-compose up` or use Makefile commands from this directory.

```
# Start the network
$ make start
# Restart the network
$ make restart
# Stop the network
$ make stop
```

The network should start and synchronize without any further configuration. The network always uses the latest available version of Ethereum (geth), the network is set up for clique proof-of-authority similar to the Ethereum Rinkeby testnet.

## Topology

### Bootnode

* geth-dev-miner-1 : No RPC exposed
* geth-dev-miner-2: No RPC exposed
* geth-dev-node: [http://localhost:8545](http://localhost:8545)
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.

## 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.
### Miners and fullnode

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 dApp.

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
- geth-dev-miner-1: [http://localhost:8541](http://localhost:8541)
- geth-dev-miner-2: [http://localhost:8543](http://localhost:8543)
- geth-dev-node: [http://localhost:8545](http://localhost:8545)

### Swarm bee / IPFS

Work in progress

### Blockchain explorer

A blockchain explorer fetches the data from `geth-dev-node` through RPC calls. The blockchain explorers can be found at the addresses:

## Whisper (/SHH:/)
Coming soon ...
- geth-explorer: [http://localhost:8080](http://localhost:8080)
- lite-explorer: [http://localhost:8800](http://localhost:8800)
- blockscout-explorer: [http://localhost:8800](http://localhost:4000)

## 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).
### Blockchain monitor and dashboard

## Blockchain Dashboard
The blockchain dashboard is a simple node.js web application being provided by two separate containers: monitor and dashboard. The monitor collects data from the geth nodes and is being displayed through the dashboard. The blockchain dashboard can be found at [http://localhost:8008](http://localhost:8008)
The blockchain dashboard is a simple node.js web application being provided by two separate containers: `monitor` and `dashboard`. The monitor collects data from `geth-dev-node` which is displayed through the dashboard. The blockchain dashboard can be found at [http://localhost:8008](http://localhost:8008).
42 changes: 42 additions & 0 deletions geth-poa-docker/blockscout/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM bitwalker/alpine-elixir-phoenix:1.11.3

RUN apk --no-cache --update add alpine-sdk gmp-dev automake libtool inotify-tools autoconf python3 git

# Get Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

ENV PATH="$HOME/.cargo/bin:${PATH}"
ENV RUSTFLAGS="-C target-feature=-crt-static"

EXPOSE 4000

ENV PORT=4000 \
MIX_ENV="prod" \
SECRET_KEY_BASE="RMgI4C1HSkxsEjdhtGMfwAHfyT6CKWXOgzCboJflfSm4jeAlic52io05KB6mqzc5"

RUN rm -rf /opt/blockscout
RUN git clone https://github.com/blockscout/blockscout.git /opt/blockscout
WORKDIR /opt/blockscout
# BlockScout v3.6.0-beta
RUN git checkout 7d75236

# Cache elixir deps
RUN mix do deps.get, local.rebar --force, deps.compile

ARG COIN
RUN if [ "$COIN" != "" ]; then sed -i s/"POA"/"${COIN}"/g apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po; fi

# Run forderground build and phoenix digest
RUN mix compile

# Add blockscout npm deps
RUN cd apps/block_scout_web/assets/ && \
npm install && \
npm run deploy && \
cd -

RUN cd apps/explorer/ && \
npm install && \
apk update && apk del --force-broken-world alpine-sdk gmp-dev automake libtool inotify-tools autoconf python3

RUN mix phx.digest
4 changes: 2 additions & 2 deletions geth-poa-docker/bootnode/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ RUN apt-get update \
&& apt-get install -y wget software-properties-common \
&& rm -rf /var/lib/apt/lists/*

WORKDIR "/root"
WORKDIR /root

RUN add-apt-repository -y ppa:ethereum/ethereum

Expand All @@ -13,7 +13,7 @@ RUN apt-get update \
&& apt-get install -y ethereum

ENV nodekeyhex=""
CMD exec bootnode -nodekeyhex $nodekeyhex
CMD exec bootnode -nodekeyhex $nodekeyhex -addr $bootnodeIp:30301 -verbosity 4

EXPOSE 30301/udp
EXPOSE 30303/udp
Loading