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

feat: update to v3.1.1 celestia-app, v0.20.4 celestia-node, celestia-types 0.9.0, celestia-rpc 0.8.0 #2

Merged
merged 5 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 3 additions & 3 deletions ci/Dockerfile.bridge
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# A dockerfile for the celestia bridge node in DA layer
# Based on:
# https://github.com/celestiaorg/celestia-node/blob/main/Dockerfile
FROM docker.io/alpine:3.19.1
FROM docker.io/alpine:3.21.0

ENV CELESTIA_HOME=/root

RUN apk update && apk add --no-cache bash jq

# Copy in the binary
COPY --from=ghcr.io/celestiaorg/celestia-node:v0.15.0 /bin/celestia /bin/celestia
COPY --from=ghcr.io/celestiaorg/celestia-node:v0.15.0 /bin/cel-key /bin/cel-key
COPY --from=ghcr.io/celestiaorg/celestia-node:v0.20.4 /bin/celestia /bin/celestia
COPY --from=ghcr.io/celestiaorg/celestia-node:v0.20.4 /bin/cel-key /bin/cel-key

COPY ./run-bridge.sh /opt/entrypoint.sh

Expand Down
6 changes: 3 additions & 3 deletions ci/Dockerfile.lightnode
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# A dockerfile for the celestia bridge node in DA layer
# Based on:
# https://github.com/celestiaorg/celestia-node/blob/main/Dockerfile
FROM docker.io/alpine:3.19.1
FROM docker.io/alpine:3.21.0

ENV CELESTIA_HOME=/root

RUN apk update && apk add --no-cache bash jq

# Copy in the binary
COPY --from=ghcr.io/celestiaorg/celestia-node:v0.15.0 /bin/celestia /bin/celestia
COPY --from=ghcr.io/celestiaorg/celestia-node:v0.15.0 /bin/cel-key /bin/cel-key
COPY --from=ghcr.io/celestiaorg/celestia-node:v0.20.4 /bin/celestia /bin/celestia
COPY --from=ghcr.io/celestiaorg/celestia-node:v0.20.4 /bin/cel-key /bin/cel-key

COPY ./run-lightnode.sh /opt/entrypoint.sh

Expand Down
4 changes: 2 additions & 2 deletions ci/Dockerfile.validator
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# A dockerfile for the celestia validator in consensus layer
# Based on:
# https://github.com/celestiaorg/celestia-app/blob/main/Dockerfile
FROM docker.io/alpine:3.19.1
FROM docker.io/alpine:3.21.0

ENV CELESTIA_HOME=/root

RUN apk update && apk add --no-cache bash jq

# Copy in the binary
COPY --from=ghcr.io/celestiaorg/celestia-app:v2.0.0 /bin/celestia-appd /bin/celestia-appd
COPY --from=ghcr.io/celestiaorg/celestia-app:v3.0.2 /bin/celestia-appd /bin/celestia-appd

COPY ./run-validator.sh /opt/entrypoint.sh

Expand Down
43 changes: 18 additions & 25 deletions ci/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
- LIGHT_COUNT=1
volumes:
- credentials:/credentials
- genesis:/genesis
- shared:/shared

bridge-0:
image: bridge
Expand All @@ -23,12 +23,16 @@ services:
# provide an id for the bridge node (default: 0)
# each node should have a next natural number starting from 0
- NODE_ID=0
# setting SKIP_AUTH to true disables the use of JWT for authentication
- SKIP_AUTH=true
# this must match the service name in the docker-compose.yml file
# used for the trusted peers string for the light node
- CONTAINER_NAME=bridge-0
ports:
- 26658:26658
volumes:
- credentials:/credentials
- genesis:/genesis
- shared:/shared

bridge-1:
image: bridge
Expand All @@ -42,11 +46,14 @@ services:
- NODE_ID=1
# setting SKIP_AUTH to true disables the use of JWT for authentication
- SKIP_AUTH=true
# this must match the service name in the docker-compose.yml file
# used for the trusted peers string for the light node
- CONTAINER_NAME=bridge-1
ports:
- 36658:26658
volumes:
- credentials:/credentials
- genesis:/genesis
- shared:/shared

light-0:
image: light
Expand All @@ -55,33 +62,19 @@ services:
context: .
dockerfile: Dockerfile.lightnode
environment:
# provide an id for the bridge node (default: 0)
# provide an id for the light node (default: 0)
# each node should have a next natural number starting from 0
- NODE_ID=0
# setting SKIP_AUTH to true disables the use of JWT for authentication
- SKIP_AUTH=true
# depending on the number of bridge nodes, provide the count
# is used for the trusted peers string for the light node
- BRIDGE_COUNT=2
ports:
- 46658:26658
volumes:
- credentials:/credentials
- genesis:/genesis

# Uncomment for another bridge node
# remember to adjust services.validator.command
# bridge-1:
# image: bridge
# platform: "linux/amd64"
# build:
# context: .
# dockerfile: Dockerfile.bridge
# environment:
# # provide an id for the bridge node (default: 0)
# # each node should have a next natural number starting from 0
# - NODE_ID=1
# ports:
# - 36658:26658
# volumes:
# - credentials:/credentials
# - genesis:/genesis
- shared:/shared

volumes:
# local volume where node's credentials can persist
Expand All @@ -91,8 +84,8 @@ volumes:
type: "none"
o: "bind"
device: "./credentials"
# a temporary fs where the genesis hash is announced
genesis:
# a temporary fs where the nodes share data
shared:
driver_opts:
type: tmpfs
device: tmpfs
58 changes: 54 additions & 4 deletions ci/run-bridge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@ set -euo pipefail
# Name for this node or `bridge-0` if not provided
NODE_ID="${NODE_ID:-0}"
SKIP_AUTH="${SKIP_AUTH:-false}"
CONTAINER_NAME="${CONTAINER_NAME:-bridge-$NODE_ID}"
NODE_NAME="bridge-$NODE_ID"
# a private local network
P2P_NETWORK="private"
# a bridge node configuration directory
CONFIG_DIR="$CELESTIA_HOME/.celestia-bridge-$P2P_NETWORK"
CONFIG_DIR="$CELESTIA_HOME"
# directory and the files shared with the validator node
CREDENTIALS_DIR="/credentials"
# node credentials
NODE_KEY_FILE="$CREDENTIALS_DIR/$NODE_NAME.key"
NODE_JWT_FILE="$CREDENTIALS_DIR/$NODE_NAME.jwt"
# directory where validator will write the genesis hash
GENESIS_DIR="/genesis"
GENESIS_HASH_FILE="$GENESIS_DIR/genesis_hash"
# directory where validator will write the genesis hash and the bridge node their peers addresses
SHARED_DIR="/shared"
GENESIS_HASH_FILE="$SHARED_DIR/genesis_hash"
TRUSTED_PEERS_FILE="$SHARED_DIR/trusted_peers"

# Wait for the validator to set up and provision us via shared dir
wait_for_provision() {
Expand Down Expand Up @@ -53,6 +55,52 @@ write_jwt_token() {
celestia bridge auth admin --p2p.network "$P2P_NETWORK" > "$NODE_JWT_FILE"
}

append_trusted_peers() {
peer_id=""
start_time=$(date +%s)
timeout=30

while [[ -z "$peer_id" ]]; do
peer_id=$(celestia p2p info | jq -r '.result.id' || echo "")
if [[ -z "$peer_id" ]]; then
echo "Node is not running yet. Retrying..."
sleep 1
fi

current_time=$(date +%s)
elapsed=$((current_time - start_time))
if [[ $elapsed -ge $timeout ]]; then
echo "Failed to retrieve Peer ID after $timeout seconds. Exiting."
exit 1
fi
done

#multiaddr: /dns/$CONTAINER_NAME/tcp/$RPC_PORT/p2p/$peer_id
multiaddr="/dns/$CONTAINER_NAME/tcp/2121/p2p/$peer_id"
echo "Appending trusted peer: $multiaddr"

# Lock the file to prevent race conditions
exec 9>"$TRUSTED_PEERS_FILE.lock"
flock -x 9

# Read existing peers into a variable
existing_peers=""
if [[ -s "$TRUSTED_PEERS_FILE" ]]; then
existing_peers=$(cat "$TRUSTED_PEERS_FILE")
fi

# Append the new multiaddr to the existing peers
if [[ -n "$existing_peers" ]]; then
echo "$existing_peers,$multiaddr" > "$TRUSTED_PEERS_FILE"
else
echo "$multiaddr" > "$TRUSTED_PEERS_FILE"
fi

# Unlock the file
flock -u 9
exec 9>&-
}
jcstein marked this conversation as resolved.
Show resolved Hide resolved

main() {
# Initialize the bridge node
celestia bridge init --p2p.network "$P2P_NETWORK"
Expand All @@ -64,6 +112,8 @@ main() {
add_trusted_genesis
# Update the JWT token
write_jwt_token
# Append the peer multiaddr to the trusted peers (run in background, as the node needs to be running)
append_trusted_peers &
jcstein marked this conversation as resolved.
Show resolved Hide resolved
# give validator some time to set up
sleep 4
# Start the bridge node
Expand Down
54 changes: 49 additions & 5 deletions ci/run-lightnode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,62 @@ set -euo pipefail
# Name for this node or `light-0` if not provided
NODE_ID="${NODE_ID:-0}"
SKIP_AUTH="${SKIP_AUTH:-false}"
BRIDGE_COUNT="${BRIDGE_COUNT}"
jcstein marked this conversation as resolved.
Show resolved Hide resolved
NODE_NAME="light-$NODE_ID"
# a private local network
P2P_NETWORK="private"
# a light node configuration directory
CONFIG_DIR="$CELESTIA_HOME/.celestia-light-$P2P_NETWORK"
CONFIG_DIR="$CELESTIA_HOME"
# directory and the files shared with the validator node
CREDENTIALS_DIR="/credentials"
# node credentials
NODE_KEY_FILE="$CREDENTIALS_DIR/$NODE_NAME.key"
NODE_JWT_FILE="$CREDENTIALS_DIR/$NODE_NAME.jwt"
# directory where validator will write the genesis hash
GENESIS_DIR="/genesis"
GENESIS_HASH_FILE="$GENESIS_DIR/genesis_hash"
# directory where validator will write the genesis hash and the bridge node their peers addresses
SHARED_DIR="/shared"
GENESIS_HASH_FILE="$SHARED_DIR/genesis_hash"
TRUSTED_PEERS_FILE="$SHARED_DIR/trusted_peers"

# Wait for the validator to set up and provision us via shared dir
wait_for_provision() {
echo "Waiting for the validator node to start"
while [[ ! ( -e "$GENESIS_HASH_FILE" && -e "$NODE_KEY_FILE" ) ]]; do
sleep 0.1
done

echo "Validator is ready"

echo "Waiting for $BRIDGE_COUNT bridge nodes to start"
start_time=$(date +%s)
timeout=30

while true; do
if [[ -e "$TRUSTED_PEERS_FILE" ]]; then

echo "Trusted peers file exists"

trusted_peers="$(cat "$TRUSTED_PEERS_FILE")"
echo "Trusted peers: $trusted_peers"
peer_count=$(echo "$trusted_peers" | tr ',' '\n' | wc -l)
echo "Peer count: $peer_count"
if [[ $peer_count -eq $BRIDGE_COUNT ]]; then
echo "$BRIDGE_COUNT bridge nodes are ready"
break
else
echo "Trusted peers file does not contain the expected number of commas. Retrying..."
fi
else
echo "Trusted peers file does not exist yet. Retrying..."
fi

current_time=$(date +%s)
elapsed=$((current_time - start_time))
if [[ $elapsed -ge $timeout ]]; then
echo "Timeout reached. Exiting."
exit 1
fi

sleep 1
done
}

# Import the test account key shared by the validator
Expand All @@ -43,11 +77,19 @@ add_trusted_genesis() {

# Read the hash of the genesis block
genesis_hash="$(cat "$GENESIS_HASH_FILE")"
trusted_peers="$(cat "$TRUSTED_PEERS_FILE")"
# and make it trusted in the node's config
echo "Trusting a genesis: $genesis_hash"
sed -i'.bak' "s/TrustedHash = .*/TrustedHash = $genesis_hash/" "$CONFIG_DIR/config.toml"
}

add_trusted_peers() {
local trusted_peers="$(cat "$TRUSTED_PEERS_FILE")"
local formatted_peers=$(echo "$trusted_peers" | sed 's/\([^,]*\)/"\1"/g')
echo "Trusting peers: $formatted_peers"
sed -i'.bak' "s|TrustedPeers = .*|TrustedPeers = [$formatted_peers]|" "$CONFIG_DIR/config.toml"
}

write_jwt_token() {
echo "Saving jwt token to $NODE_JWT_FILE"
celestia light auth admin --p2p.network "$P2P_NETWORK" > "$NODE_JWT_FILE"
Expand All @@ -62,6 +104,8 @@ main() {
import_shared_key
# Trust the private blockchain
add_trusted_genesis
# Trust the bridge nodes
add_trusted_peers
# Update the JWT token
write_jwt_token
# give validator some time to set up
Expand Down
14 changes: 6 additions & 8 deletions ci/run-validator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ BRIDGE_COINS="200000000000000utia"
VALIDATOR_COINS="1000000000000000utia"
# a directory and the files shared with the bridge nodes
CREDENTIALS_DIR="/credentials"
# directory where validator will write the genesis hash
GENESIS_DIR="/genesis"
GENESIS_HASH_FILE="$GENESIS_DIR/genesis_hash"
# directory where validator will write the genesis hash and the bridge node their peers addresses
SHARED_DIR="/shared"
GENESIS_HASH_FILE="$SHARED_DIR/genesis_hash"
jcstein marked this conversation as resolved.
Show resolved Hide resolved

# Get the address of the node of given name
node_address() {
Expand Down Expand Up @@ -191,14 +191,12 @@ setup_private_validator() {
# If you encounter: `sed: -I or -i may not be used with stdin` on MacOS you can mitigate by installing gnu-sed
# https://gist.github.com/andre3k1/e3a1a7133fded5de5a9ee99c87c6fa0d?permalink_comment_id=3082272#gistcomment-3082272
sed -i'.bak' 's|"tcp://127.0.0.1:26657"|"tcp://0.0.0.0:26657"|g' "$CONFIG_DIR/config/config.toml"
sed -i'.bak' 's|"null"|"kv"|g' "$CONFIG_DIR/config/config.toml"
# enable transaction indexing
sed -i'.bak' 's|indexer = .*|indexer = "kv"|g' "$CONFIG_DIR/config/config.toml"

# reduce the time of commiting the proposed block
# bringing this value too low results in errors
sed -i'.bak' 's|^timeout_commit.*|timeout_commit = "1s"|g' "$CONFIG_DIR/config/config.toml"

# Set app version to 1
sed -i'.bak' 's|"app_version": "2"|"app_version": "1"|g' "$CONFIG_DIR/config/genesis.json"
}

main() {
Expand All @@ -208,7 +206,7 @@ main() {
provision_light_nodes &
# Start the celestia-app
echo "Configuration finished. Running a validator node..."
celestia-appd start --api.enable --grpc.enable
celestia-appd start --api.enable --grpc.enable --force-no-bbr
jcstein marked this conversation as resolved.
Show resolved Hide resolved
}

main
Loading