forked from ChainSafe/gossamer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(devnet): Local Gossamer Devnet (ChainSafe#2008)
* wip * revise function, add test * cleanup * more wip * add pubip flag to cli * go mod tidy after upgrading to 1.17 * add config tests * devnet cmd test * fix bob * fix confd command * update dockerfiles * use dev go.mod and go.sum * fix logs * update lint settings * fix linting * add readme * update README * remove symlinking step * Update devnet/README.md Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com> * Update devnet/README.md Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com> * Update devnet/README.md Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com> * Update devnet/alice.Dockerfile Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com> * Update devnet/alice.Dockerfile Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com> * Update devnet/alice.Dockerfile Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com> * Update devnet/alice.Dockerfile Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com> * Update devnet/alice.Dockerfile Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com> * cr feedback, fix metrics on bob * fix go.mod * go mod tidy * Update devnet/cmd/update-dd-agent-confd/main.go Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com> * Update devnet/cmd/update-dd-agent-confd/main.go Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com> * cr feedback * update readme * Update devnet/README.md Co-authored-by: noot <36753753+noot@users.noreply.github.com> * cr feedback * more cr feedback * use embed * add license * trimpath * Update devnet/bob.Dockerfile Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com> Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com> Co-authored-by: noot <36753753+noot@users.noreply.github.com>
- Loading branch information
1 parent
af7725f
commit 23ce39f
Showing
22 changed files
with
1,245 additions
and
15 deletions.
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
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,54 @@ | ||
# Gossamer Devnet | ||
|
||
Docker container and Docker Compose for a Gossamer Devnet currently with three authority nodes running the `gssmr` chain with keys `alice`, `bob` and `charlie`. | ||
|
||
## Requirements | ||
|
||
- [Docker Compose](https://docs.docker.com/compose/install/) | ||
|
||
## Running the Devnet | ||
|
||
From the Gossamer root run the following commands to run the devnet | ||
|
||
```sh | ||
# will rebuild the containers based on the current code | ||
docker-compose up --abort-on-container-exit --build | ||
|
||
# will run the devnet without rebuilding | ||
docker-compose up --abort-on-container-exit | ||
|
||
# destroys the devnet | ||
docker-compose down | ||
``` | ||
|
||
> **_NOTE:_** The devnet is not stateful, so subsequent runs will start from the genesis block. | ||
## Prometheus Datadog Integration | ||
|
||
All Prometheus metrics from the nodes are piped to Datadog. You can setup your own dashboard and add additional tags by modifying the Dockerfiles. Currently the metrics are prefixed with `gossamer.local.devnet` and are tagged (Prometheus label) with a `key` tag for `alice`, `bob`, and `charlie`. | ||
|
||
For metrics to be piped to Datadog, you will require a Datadog API key. Please contact Elizabeth or myself (Tim) for access to datadog if you don't already have it. | ||
|
||
The Datadog API key must be an environment variable on your own machine, which Docker Compose will pick up and inject when building the node images. | ||
|
||
``` | ||
export $DD_API_KEY=YourKey | ||
``` | ||
|
||
## Files | ||
|
||
### Dockerfiles | ||
|
||
There are two Docker files used in the devnet. `alice.Dockerfile` is the lead node and is intiated with the `babe-lead` flag to build the first block. `bob.Dockerfile` is used for both `bob` and `charlie`. | ||
|
||
### cmd/update-dd-agent-confd | ||
|
||
A command line app to create a `confd.yml` file used by the Datadog agent when piping metrics to Datadog. It's used in the both `alice.Dockerfile` and `bob.Dockerfile` to create specific `confd.yml` files. | ||
|
||
### alice.node.key | ||
|
||
This key is injected in `alice.Dockerfile` so it uses the same public key for the `bootnodes` param in `bob.Dockerfile`. | ||
|
||
### docker-compose.yml | ||
|
||
The Docker Compose file. Specifies the IP addresses of all the nodes. |
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,29 @@ | ||
# Copyright 2021 ChainSafe Systems (ON) | ||
# SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
FROM golang:1.17 | ||
|
||
ARG DD_API_KEY=somekey | ||
RUN DD_API_KEY=${DD_API_KEY} DD_AGENT_MAJOR_VERSION=7 DD_INSTALL_ONLY=true DD_SITE="datadoghq.com" bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script.sh)" | ||
|
||
WORKDIR /gossamer | ||
|
||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
COPY . . | ||
|
||
RUN go install -trimpath github.com/ChainSafe/gossamer/cmd/gossamer | ||
|
||
# use modified genesis-spec.json with only 3 authority nodes | ||
RUN cp -f devnet/chain/gssmr/genesis-spec.json chain/gssmr/genesis-spec.json | ||
|
||
RUN gossamer --key=alice init | ||
|
||
# use a hardcoded key for alice, so we can determine what the peerID is for subsequent nodes | ||
RUN cp devnet/alice.node.key ~/.gossamer/gssmr/node.key | ||
|
||
RUN go run devnet/cmd/update-dd-agent-confd/main.go -n=gossamer.local.devnet -t=key:alice > /etc/datadog-agent/conf.d/openmetrics.d/conf.yaml | ||
|
||
ENTRYPOINT service datadog-agent start && gossamer --key=alice --babe-lead --publish-metrics --rpc --rpc-external=true --pubip=10.5.0.2 | ||
EXPOSE 7001/tcp 8545/tcp 8546/tcp 8540/tcp 9876/tcp |
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,35 @@ | ||
# Copyright 2021 ChainSafe Systems (ON) | ||
# SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
FROM golang:1.17 | ||
|
||
ARG DD_API_KEY=somekey | ||
RUN DD_API_KEY=${DD_API_KEY} DD_AGENT_MAJOR_VERSION=7 DD_INSTALL_ONLY=true DD_SITE="datadoghq.com" bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script.sh)" | ||
|
||
WORKDIR /gossamer | ||
|
||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
COPY . . | ||
|
||
RUN go install -trimpath github.com/ChainSafe/gossamer/cmd/gossamer | ||
|
||
# use modified genesis-spec.json with only 3 authority nodes | ||
RUN cp -f devnet/chain/gssmr/genesis-spec.json chain/gssmr/genesis-spec.json | ||
|
||
ARG key | ||
RUN test -n "$key" | ||
ARG pubip | ||
RUN test -n "$pubip" | ||
|
||
ENV key=${key} | ||
ENV pubip=${pubip} | ||
|
||
RUN gossamer --key=${key} init | ||
|
||
RUN go run devnet/cmd/update-dd-agent-confd/main.go -n=gossamer.local.devnet -t=key:${key} > /etc/datadog-agent/conf.d/openmetrics.d/conf.yaml | ||
|
||
ENTRYPOINT service datadog-agent start && gossamer --key=${key} --bootnodes=/ip4/10.5.0.2/tcp/7001/p2p/12D3KooWMER5iow67nScpWeVqEiRRx59PJ3xMMAYPTACYPRQbbWU --publish-metrics --rpc --pubip=${pubip} | ||
|
||
EXPOSE 7001/tcp 8545/tcp 8546/tcp 8540/tcp 9876/tcp |
Oops, something went wrong.