Skip to content

Commit

Permalink
Initial commit for project with submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
mboben committed Apr 8, 2024
0 parents commit cb99f7b
Show file tree
Hide file tree
Showing 11 changed files with 523 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/build-binary.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: binaries


on:
workflow_dispatch:
push:
branches:
tags:

env:
go_version: 1.18.5

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.go_version }}


- run: echo "IMAGE_TAG=dev" >> $GITHUB_ENV
if: ${{ github.ref_name }} == 'main'
- run: echo "IMAGE_TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/v')

- run: sudo apt-get update -y && sudo apt-get install -y rsync
- name: build
id: build
run: |
cd avalanchego
./scripts/build.sh
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: dist-bin
path: |
avalanchego/build
47 changes: 47 additions & 0 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: container-images


on:
push:
branches: [ "main" ]
tags: [ "v*" ]

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1

- run: echo "IMAGE_TAG=dev" >> $GITHUB_ENV
if: github.ref_name == 'main'
- run: echo "IMAGE_TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/v')

- name: Login to ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to docker.io
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_UID }}
password: ${{ secrets.DOCKER_HUB_PAT }}

- name: Build and push default image
uses: docker/build-push-action@v3.2.0
with:
context: . # Because GH actions are for kids and put protection on everything; https://stackoverflow.com/a/71159809/11276254
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
${{ secrets.DOCKER_HUB_REPO }}:${{ env.IMAGE_TAG }}
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "avalanchego"]
path = avalanchego
url = git@github.com:mboben/avalanchego.git
[submodule "coreth"]
path = coreth
url = git@github.com:mboben/coreth.git
57 changes: 57 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FROM golang:1.18 AS build

RUN apt-get update -y && \
apt-get install -y rsync

WORKDIR /app/

COPY ./.git /app/.git
COPY ./avalanchego /app/avalanchego
COPY ./config /app/config
COPY ./coreth /app/coreth

WORKDIR /app/avalanchego/

RUN /app/avalanchego/scripts/build.sh

FROM ubuntu@sha256:b25ef49a40b7797937d0d23eca3b0a41701af6757afca23d504d50826f0b37ce

WORKDIR /app

ENV HTTP_HOST=0.0.0.0 \
HTTP_PORT=9650 \
STAKING_PORT=9651 \
PUBLIC_IP= \
DB_DIR=/app/db \
DB_TYPE=leveldb \
BOOTSTRAP_IPS= \
BOOTSTRAP_IDS= \
CHAIN_CONFIG_DIR=/app/conf \
LOG_DIR=/app/logs \
LOG_LEVEL=info \
NETWORK_ID=costwo \
AUTOCONFIGURE_PUBLIC_IP=1 \
AUTOCONFIGURE_BOOTSTRAP=1 \
AUTOCONFIGURE_BOOTSTRAP_ENDPOINT=https://coston2.flare.network/ext/info \
EXTRA_ARGUMENTS="" \
BOOTSTRAP_BEACON_CONNECTION_TIMEOUT="1m"

RUN apt-get update -y && \
apt-get install -y curl jq

RUN mkdir -p /app/conf/coston /app/conf/C /app/logs /app/db

COPY --from=build /app/avalanchego/build /app/build
COPY entrypoint.sh /app/entrypoint.sh

EXPOSE ${STAKING_PORT}
EXPOSE ${HTTP_PORT}

VOLUME [ "${DB_DIR}" ]
VOLUME [ "${LOG_DIR}" ]
VOLUME [ "${CHAIN_CONFIG_DIR}" ]

HEALTHCHECK CMD curl --fail http://localhost:${HTTP_PORT}/ext/health || exit 1

ENTRYPOINT [ "/usr/bin/bash" ]
CMD [ "/app/entrypoint.sh" ]
139 changes: 139 additions & 0 deletions README-docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Flare & Coston2

Docker image for the Flare & Coston2 node implementation found on [github](https://github.com/flare-foundation/go-flare).

## Quickstart

```sh
docker run -d \
-p 9650-9651:9650-9651 \
flarefoundation/flare:latest
```

<b>Currently the default network is `costwo` but you can change that by providing a `NETWORK_ID` environment variable (i.e. `NETWORK_ID=flare`).</b>

## Mounting storage

The three points of interest for mounting are:

| Name | Default location |
|---|:--|
| Database | `/app/db` |
| Logging | `/app/logs` |
| Configuration | `/app/conf` |

<b>All of these may be changed using the environment variables.</b>

```sh
docker run -d \
-v /tmp/db:/app/db \
-v /tmp/conf:/app/conf \
-p 9650:9650 \
-e AUTOCONFIGURE_BOOTSTRAP=1 \
flarefoundation/go-flare:latest
```

## Container Configuration

These are the environment variables you can edit and their default values:

| Name | Default | Description |
|:--|:--|:--|
| `HTTP_HOST` | `0.0.0.0` | The bind address of the service |
| `HTTP_PORT` | `9650` | The port on which the API is served |
| `STAKING_PORT` | `9651` | The staking port for bootstrapping nodes |
| `PUBLIC_IP` | _(empty)_ | The public IP of the service |
| `DB_DIR` | `/app/db` | The database directory location |
| `DB_TYPE` | `leveldb` | The database type to be used |
| `BOOTSTRAP_IPS` | _(empty)_ | A list of bootstrap server ips; ref [--bootstrap-ips-string](https://docs.avax.network/nodes/maintain/avalanchego-config-flags#--bootstrap-ips-string) |
| `BOOTSTRAP_IDS` | _(empty)_ | A list of bootstrap server ids; ref [--bootstrap-ids-string](https://docs.avax.network/nodes/maintain/avalanchego-config-flags#--bootstrap-ids-string) |
| `CHAIN_CONFIG_DIR` | `/app/conf` | Configuration directory |
| `LOG_DIR` | `/app/logs` | Logging directory |
| `LOG_LEVEL` | `info` | Logging level set with AvalancheGo flag [`--log-level`](https://docs.avax.network/nodes/maintain/avalanchego-config-flags#--log-level-string-verbo-debug-trace-info-warn-error-fatal-off). |
| `NETWORK_ID` | `costwo` | The network id. The common ids are `flare \| costwo` |
| `AUTOCONFIGURE_PUBLIC_IP` | `0` | Set to `1` to autoconfigure `PUBLIC_IP`, skipped if PUBLIC_IP is set |
| `AUTOCONFIGURE_BOOTSTRAP` | `0` | Set to `1` to autoconfigure `BOOTSTRAP_IPS` and `BOOTSTRAP_IDS` |
| `AUTOCONFIGURE_BOOTSTRAP_ENDPOINT` | `https://coston2.flare.network/ext/info` | Endpoint used for [bootstrapping](https://docs.avax.network/nodes/maintain/avalanchego-config-flags#bootstrapping) when `AUTOCONFIGURE_BOOTSTRAP` is enabled. Possible values are `https://coston2.flare.network/ext/info` or `https://flare.flare.network/ext/info`. |
| `AUTOCONFIGURE_FALLBACK_ENDPOINTS` | _(empty)_ | Comma-divided fallback bootstrap endpoints, used if `AUTOCONFIGURE_BOOTSTRAP_ENDPOINT` is not valid (not whitelisted / unreachable / etc), tested from first-to-last until one is valid |
| `BOOTSTRAP_BEACON_CONNECTION_TIMEOUT` | `1m` | Set the duration value (eg. `45s` / `5m` / `1h`) for [--bootstrap-beacon-connection-timeout](https://docs.avax.network/nodes/maintain/avalanchego-config-flags#--bootstrap-beacon-connection-timeout-duration) AvalancheGo flag. |
| `EXTRA_ARGUMENTS` | | Extra arguments passed to flare binary |


## Node Configuration

The flare node can be configured by specifying your own configuration for the different chains but mainly the C (aka. Contract) chain. The specified configuration determines which capabilities the node has and it affects how the node has to be set up. We mainly distinguish between the three standard configurations described below.

### External API configuration

The external API configuration is set to only respond to API calls so it offloads the other internal nodes. What makes it external is the relatively small set of functions that it exposes which are meant for public use. The node with this configuration exposes the HTTP port (default: 9650) and does not need any publicly open ports to work. The images tagged with the suffix `api` have this configuration preloaded by default.

```sh
{
"snowman-api-enabled": false,
"coreth-admin-api-enabled": false,
"coreth-admin-api-dir": "",
"eth-apis": [
"public-eth",
"public-eth-filter",
"net",
"web3",
"internal-public-eth",
"internal-public-blockchain",
"internal-public-transaction-pool"
],
}
```

### Internal API configuration

Similarly to the external API configuration, this one also responds to API calls but has additional calls exposed that help with longer running tasks, debugging, etc. It is therefore <b>NOT</b> meant for public use and it should <b>NOT</b> be publicly accessible. The node with this configuration exposes the HTTP port (default: 9650) and does not need any publicly open ports to work.

```sh
{
"snowman-api-enabled": false,
"coreth-admin-api-enabled": false,
"coreth-admin-api-dir": "",
"eth-apis": [
"public-eth",
"public-eth-filter",
"private-admin",
"public-debug",
"private-debug",
"net",
"debug-tracer",
"web3",
"internal-public-eth",
"internal-public-blockchain",
"internal-public-transaction-pool",
"internal-public-tx-pool",
"internal-public-debug",
"internal-private-debug",
"internal-public-account",
"internal-private-personal"
],
}
```

### Bootstrap configuration

The bootstrap configuration is meant for nodes that will accept and help provision new nodes that want to connect to the network. They need to be publicly accessible and need the staking port (default: 9651) port-forwarded while the http port may remain inaccessible from the public but is needed to initialise the bootstrapping process of a new node.

```sh
{
"snowman-api-enabled": false,
"coreth-admin-api-enabled": false,
"coreth-admin-api-dir": "",
"eth-apis": [
"web3"
],
}
```

### Additional information

Here's a list of helpful links for additional information about configuration:

* [Chain types and configuration](https://docs.avax.network/nodes/maintain/chain-config-flags)
* [Staking](https://docs.avax.network/nodes/validate/staking)
* [Bootstrapping](https://docs.avax.network/nodes/maintain/avalanchego-config-flags#bootstrapping)
* [API calls](https://docs.avax.network/apis/avalanchego/apis)
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# go-flare

go-flare is a modified version of [avalanchego@v1.7.18](https://github.com/ava-labs/avalanchego/releases/tag/v1.7.18) + [coreth@v0.8.16](https://github.com/ava-labs/coreth/releases/tag/v0.8.16) that incorporates the Flare Time Series Oracle (FTSO) and State Connector.

## System Requirements
- go version 1.18.5
- gcc, g++ and jq
- CPU: Equivalent of 8 AWS vCPU
- RAM: 16 GiB
- Storage: 1TB
- OS: Ubuntu 18.04/20.04 or macOS >= 10.15 (Catalina)

## Compilation

After cloning this repository, run:

```sh
cd go-flare/avalanchego && ./scripts/build.sh
```

## Deploy a Validation Node

These servers fulfill a critical role in securing the network:

- They check that all received transactions are valid.
- They run a consensus algorithm so that all validators in the network agree on the transactions to add to the blockchain.
- Finally, they add the agreed-upon transactions to their copy of the ledger.

This guide explains how to deploy your own validator node so you can participate in the consensus and collect the rewards that the network provides to those who help secure it: https://docs.flare.network/infra/validation/deploying/

## Deploy an Observation Node

Observation nodes enable anyone to observe the network and submit transactions. Unlike validator nodes, which provide state consensus and add blocks, observation nodes remain outside the network and have no effect on consensus or blocks.

This guide explains how to deploy your own observation node: https://docs.flare.network/infra/observation/deploying/

## Tests

See `tests/README.md` for testing details

## Container image

Public container images are hosted on [Docker HUB](https://hub.docker.com/r/flarefoundation/go-flare) and [Github Packages](https://github.com/orgs/flare-foundation/packages?repo_name=go-flare);
```
docker.io/flarefoundation/go-flare
hgcr.io/flare-foundation/go-flare
```

### Container builds in CI

CI builds on each:
- push on `main` branch, pushes image tagged as "dev"
- creation of a tag, pushes images tagged as the tag itself

Builds: \
two images, `go-flare:<TAG>` one with `leveldb`
1 change: 1 addition & 0 deletions avalanchego
Submodule avalanchego added at 00d4e0
Loading

0 comments on commit cb99f7b

Please sign in to comment.