Skip to content

Commit

Permalink
feat: add godwoken readonly node and enable mem-pool p2p sync (godwok…
Browse files Browse the repository at this point in the history
…enrises#276)

* feat: add godwoken readonly node and
enable mem-pool p2p sync

* fix godwoken readonly port
don't conflict with v0

* web3-indexer use readonly node RPC

* web3-indexer depends on godwoken-readonly healthy

* Bump godwoken-prebuilds to refs/pull/721/merge
This image was built by Flouse/godwoken-docker-prebuilds@f03dd56.
Co-authored-by: Flouse <flouse@gmail.com>
  • Loading branch information
Yin Guanhao committed Jun 14, 2022
1 parent 7e1872f commit 0577349
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ plugins/gw-schema/tmp
/docker/layer1/ckb2/data/
/docker/layer1/ckb3/data/
/docker/layer2/data/
/docker/layer2/data-readonly/
/docker/layer2/config/scripts-deployment.json
/docker/layer2/config/rollup-genesis-deployment.json
/docker/layer2/config/godwoken-config.toml
/docker/layer2/config/godwoken-config-readonly.toml
/docker/layer2/config/polyjuice-root-account-id
/docker/layer2/config/web3-indexer-config.toml
/docker/manual-artifacts/
Expand Down
35 changes: 33 additions & 2 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ services:
condition: service_completed_successfully

godwoken:
image: ghcr.io/keroro520/godwoken-prebuilds:v1-godwoken-d3eb41a-202205310512
image: ghcr.io/flouse/godwoken-prebuilds:1.2-gw-pull-721-merge-202206140118
healthcheck:
test: /var/lib/layer2/healthcheck.sh
start_period: 10s
Expand Down Expand Up @@ -106,6 +106,35 @@ services:
check-ckb-started-successfully:
condition: service_completed_successfully

godwoken-readonly:
image: ghcr.io/flouse/godwoken-prebuilds:1.2-gw-pull-721-merge-202206140118
healthcheck:
test: /var/lib/layer2/healthcheck.sh
start_period: 10s
interval: 30s
retries: 600
environment:
RUST_LOG: info,gw_generator=debug
GODWOKEN_MODE: readonly
RUST_BACKTRACE: full
STORE_PATH: /var/lib/layer2/data-readonly
ACCOUNTS_DIR: /accounts
GITHUB_RUN_ID: ${GITHUB_RUN_ID:-""}
volumes:
- ./layer2:/var/lib/layer2
- ../accounts:/accounts:ro
ports:
- 28119:8119 # rpc
- 28120:8120 # err_receipt_ws_listen
entrypoint: "/var/lib/layer2/entrypoint-readonly.sh"
deploy:
restart_policy:
condition: on-failure
max_attempts: 1
depends_on:
godwoken:
condition: service_healthy

web3:
image: nervos/godwoken-web3-prebuilds:v1.1.2-rc1
healthcheck:
Expand All @@ -132,6 +161,8 @@ services:
condition: service_completed_successfully
godwoken:
condition: service_healthy
godwoken-readonly:
condition: service_healthy
postgres:
condition: service_started
redis:
Expand All @@ -154,7 +185,7 @@ services:
depends_on:
web3:
condition: service_healthy
godwoken:
godwoken-readonly:
condition: service_healthy
postgres:
condition: service_started
Expand Down
6 changes: 2 additions & 4 deletions docker/layer2/config/web3-config.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
DATABASE_URL=postgres://user:password@postgres:5432/lumos
REDIS_URL=redis://redis:6379

GODWOKEN_JSON_RPC=http://godwoken:8119
# TODO: add Godwoken readonly node
# GODWOKEN_READONLY_JSON_RPC=<optional, default equals to GODWOKEN_JSON_RPC>

EXTRA_ESTIMATE_GAS=20000
GODWOKEN_JSON_RPC=http://godwoken:8119
GODWOKEN_READONLY_JSON_RPC=http://godwoken-readonly:8119
38 changes: 38 additions & 0 deletions docker/layer2/entrypoint-readonly.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

set -o errexit

WORKSPACE="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
CONFIG_DIR="$WORKSPACE/config"

function generate-godwoken-readonly-config() {
log "start"
if [ -s "$CONFIG_DIR/godwoken-config-readonly.toml" ]; then
log "$CONFIG_DIR/godwoken-config-readonly.toml already exists, skip"
return 0
fi

cp $CONFIG_DIR/godwoken-config.toml $CONFIG_DIR/godwoken-config-readonly.toml

sed -i 's#^node_mode = .*$#node_mode = '"'$GODWOKEN_MODE'"'#' $CONFIG_DIR/godwoken-config-readonly.toml
sed -i 's#^path = .*$#path = '"'$STORE_PATH'"'#' $CONFIG_DIR/godwoken-config-readonly.toml
sed -i 's@listen = "/ip4/.*"@dial = ["/dns4/godwoken/tcp/9999"]@' $CONFIG_DIR/godwoken-config-readonly.toml

log "Generate file \"$CONFIG_DIR/godwoken-config-readonly.toml\""
}

function log() {
echo "[${FUNCNAME[1]}] $1"
}

function main() {
godwoken --version
gw-tools --version

# Setup Godwoken-readonly at the first time
generate-godwoken-readonly-config

exec godwoken run -c $CONFIG_DIR/godwoken-config-readonly.toml
}

main "$@"
7 changes: 6 additions & 1 deletion docker/layer2/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ function generate-godwoken-config() {
if [ ! -z "$STORE_PATH" ]; then
sed -i 's#^path = .*$#path = '"'$STORE_PATH'"'#' $CONFIG_DIR/godwoken-config.toml
fi
cat >> $CONFIG_DIR/godwoken-config.toml <<EOF
[p2p_network_config]
listen = "/ip4/0.0.0.0/tcp/9999"
EOF
sed -i 's#enable_methods = \[\]#err_receipt_ws_listen = '"'0.0.0.0:8120'"'#' $CONFIG_DIR/godwoken-config.toml

log "Generate file \"$CONFIG_DIR/godwoken-config.toml\""
Expand Down Expand Up @@ -204,7 +209,7 @@ polyjuice_type_script_hash="$(jq -r '.polyjuice_validator.script_type_hash' $CON
rollup_type_hash="$(jq -r '.rollup_type_hash' $CONFIG_DIR/rollup-genesis-deployment.json)"
eth_account_lock_hash="$(jq -r '.eth_account_lock.script_type_hash' $CONFIG_DIR/scripts-deployment.json)"
godwoken_rpc_url="http://godwoken:8119"
godwoken_rpc_url="http://godwoken-readonly:8119"
ws_rpc_url="ws://godwoken:8120"
pg_url="postgres://user:password@postgres:5432/lumos"
Expand Down
4 changes: 4 additions & 0 deletions docker/manual-godwoken.compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ services:
volumes:
- ./manual-artifacts/godwoken:/usr/bin/godwoken
- ./manual-artifacts/gw-tools:/usr/bin/gw-tools
godwoken-readonly:
volumes:
- ./manual-artifacts/godwoken:/usr/bin/godwoken
- ./manual-artifacts/gw-tools:/usr/bin/gw-tools
20 changes: 3 additions & 17 deletions kicker
Original file line number Diff line number Diff line change
Expand Up @@ -173,31 +173,17 @@ function clean() {
exit 1
fi

echo "rm -rf docker/layer2-v0/data/"
echo "rm -f docker/layer2-v0/config/scripts-deployment.json"
echo "rm -f docker/layer2-v0/config/rollup-genesis-deployment.json"
echo "rm -f docker/layer2-v0/config/godwoken-config.toml"
echo "rm -rf docker/layer2/data/"
echo "rm -f docker/layer2/config/scripts-deployment.json"
echo "rm -f docker/layer2/config/rollup-genesis-deployment.json"
echo "rm -f docker/layer2/config/godwoken-config.toml"
echo "rm -f docker/layer2/config/polyjuice-root-account-id"
echo "rm -f docker/layer2/config/web3-indexer-config.toml"
echo "rm -rf docker/ckb-indexer/"
echo "rm -rf docker/layer1/ckb/data/"
echo "rm -rf docker/layer1/ckb2/data/"
echo "rm -rf docker/layer1/ckb3/data/"
echo "rm -rf docker/postgres/data"
echo "rm -rf docker/redis/data"
echo "rm -rf docker/manual-artifacts"
set -x
rm -rf docker/layer2-v0/data/
rm -f docker/layer2-v0/config/scripts-deployment.json
rm -f docker/layer2-v0/config/rollup-genesis-deployment.json
rm -f docker/layer2-v0/config/godwoken-config.toml
rm -rf docker/layer2/data/
rm -rf docker/layer2/data-readonly/
rm -f docker/layer2/config/scripts-deployment.json
rm -f docker/layer2/config/rollup-genesis-deployment.json
rm -f docker/layer2/config/godwoken-config.toml
rm -f docker/layer2/config/godwoken-config-readonly.toml
rm -f docker/layer2/config/polyjuice-root-account-id
rm -f docker/layer2/config/web3-indexer-config.toml
rm -rf docker/ckb-indexer/
Expand Down

0 comments on commit 0577349

Please sign in to comment.