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

add avail setup/template for chess #82

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
57 changes: 57 additions & 0 deletions chess/.env.avail-localhost
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
START_BLOCKHEIGHT="1"

SELF_SIGNING_ENABLED="true"
SELF_SIGNING_API_KEY="XX"

## Middleware
# Note: This is the URL which your middleware will use to interact with your game node webserver
# Example: "http://localhost:3333"
BACKEND_URI="http://localhost:3333"

## MISC
# Note: This is the port your game node webserver will use
# Example: "3333"
WEBSERVER_PORT="3333"
# Note: This enables running your game node with just the webserver running, meaning no new blocks will be synced.
# This is primarily useful for development, devops, or testing other edge cases where you want to interact with
# the game node but not have the game state progress forward.
SERVER_ONLY_MODE="false"

## DATABASE
DB_HOST="localhost"
DB_PORT="5432"
DB_NAME="postgres"
DB_USER="postgres"
DB_PW="postgres"

## Batcher setup
# BATCHER DB connection:
BATCHER_DB_HOST="localhost"
BATCHER_DB_PORT="54321"
BATCHER_DB_NAME="postgres"
BATCHER_DB_USER="postgres"
BATCHER_DB_PW="postgres"

# Batcher Contract:
DEFAULT_FEE="10000000000000000"

# Batcher Webserver:
BATCHER_PORT="3340"

BATCHER_URI="http://localhost:3340"

# Batcher Validation parameters:
GAME_NODE_URI="http://localhost:3333"
DEFAULT_VALIDATION_ACTIVE="false"
GAME_INPUT_VALIDATOR_PERIOD="1000"
BATCHED_TRANSACTION_POSTER_PERIOD="3000"
BATCHED_MESSAGE_SIZE_LIMIT="100000"
MAX_USER_INPUTS_PER_MINUTE="10"
MAX_USER_INPUTS_PER_DAY="500"

# Batcher Avail settings
BATCHER_NETWORK='avail'
BATCHER_PRIVATE_KEY='bottom drive obey lake curtain smoke basket hold race lonely fit walk//Alice'
BATCHER_AVAIL_LIGHT_CLIENT="http://localhost:7007"
CHAIN_URI="ws://127.0.0.1:9944"
SECURITY_NAMESPACE="sp1"
46 changes: 46 additions & 0 deletions chess/avail/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
FROM rust:1.75 AS base

RUN apt update -y && apt install protobuf-compiler -y

FROM base AS node_builder

RUN git clone https://github.com/availproject/avail
WORKDIR "/avail"

# This builds the binary. Important to note here is the fast-runtime feature to have 8 seconds between blocks.
RUN cargo build --locked --release --features fast-runtime
RUN cp target/release/avail-node /bin/
RUN which curl

FROM debian:bookworm-slim AS node
COPY --from=node_builder /bin/avail-node /bin
ADD ./health_check.sh bin
RUN apt update -y && apt install curl net-tools vim -y
CMD ["/bin/avail-node", "--dev", "--name=LocalAvailNode", "-d=/output/data", "--rpc-methods=unsafe", "--unsafe-rpc-external", "--rpc-cors=all", "--enable-kate-rpc", "--state-pruning=archive-canonical"]

## light client

FROM rust:1.75 AS light_builder

RUN apt update -y && apt install clang -y

RUN git clone https://github.com/availproject/avail-light.git
WORKDIR "/avail-light"

RUN cargo build --locked --release --bin avail-light
RUN cp target/release/avail-light /bin/

RUN cargo build --locked --release -p avail-light-bootstrap
RUN cp target/release/avail-light-bootstrap /bin/

FROM debian:bookworm-slim AS light
COPY --from=light_builder /bin/avail-light /bin

ADD ./avail-light-config.yaml .
ADD ./identity.toml .

CMD ["/bin/avail-light", "--config", "avail-light-config.yaml"]

FROM debian:bookworm-slim AS bootstrap
COPY --from=light_builder /bin/avail-light-bootstrap /bin
CMD ["/bin/avail-light-bootstrap"]
14 changes: 14 additions & 0 deletions chess/avail/avail-light-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
log_level = "info"
http_server_host = "0.0.0.0"
http_server_port = 7007

secret_key = { seed = "avail" }
port = 37000

full_node_ws = ["ws://node:9944"]
app_id = 1
confidence = 92.0
block_processing_delay = 0
sync_start_block = 0

bootstraps = ["/dns4/lightbootstrap/tcp/39000/p2p/12D3KooWStAKPADXqJ7cngPYXd2mSANpdgh1xQ34aouufHA2xShz"]
35 changes: 35 additions & 0 deletions chess/avail/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
services:
node:
build:
dockerfile: Dockerfile
target: node
ports:
- 30333:30333
- "9944:9944"
- "9933:9933"
healthcheck:
test: ["CMD", "sh", "/bin/health_check.sh"]
interval: 2s
timeout: 60s
retries: 30

lightbootstrap:
build:
dockerfile: Dockerfile
target: bootstrap
ports:
- "7700:7700"
- "39000:39000"

light:
build:
dockerfile: Dockerfile
target: light
depends_on:
node:
condition: service_healthy
lightbootstrap:
condition: service_started
ports:
- "7007:7007"
restart: on-failure:5
6 changes: 6 additions & 0 deletions chess/avail/health_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

curl -X POST \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":"1","method":"system_health","params":[]}' \
http://localhost:9944 || exit 1
1 change: 1 addition & 0 deletions chess/avail/identity.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
avail_secret_uri = 'bottom drive obey lake curtain smoke basket hold race lonely fit walk//Alice'
7 changes: 7 additions & 0 deletions chess/config.avail-localhost.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
avail-main:
type: avail-main
lightClient: 'http://localhost:7007'
rpc: ws://127.0.0.1:9944
delay: 0
confirmationDepth: 0
genesisHash: "0xdd60847daa1119ecc9bdd006b140087737ac03d260ce110ecd7cb33cf721be35"