Skip to content

Commit

Permalink
refactor: Simplify Web3 configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Flouse committed May 17, 2022
1 parent 9a4ab45 commit bd65461
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 60 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ plugins/gw-schema/tmp
/docker/layer2/config/rollup-genesis-deployment.json
/docker/layer2/config/godwoken-config.toml
/docker/layer2/config/polyjuice-root-account-id
/docker/layer2/config/web3-config.env
/docker/layer2/config/web3-indexer-config.toml
/docker/manual-artifacts/
/docker/layer2-v0/data/
Expand Down
5 changes: 1 addition & 4 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ services:
RUST_BACKTRACE: full
STORE_PATH: /var/lib/layer2/data
ACCOUNTS_DIR: /accounts
POSTGRES_USER: user
POSTGRES_DB: lumos
POSTGRES_PASSWORD: password
GITHUB_RUN_ID: ${GITHUB_RUN_ID:-""}
volumes:
- ./layer2:/var/lib/layer2
Expand All @@ -111,7 +108,7 @@ services:
condition: service_completed_successfully

web3:
image: nervos/godwoken-web3-prebuilds:v1.1.0-beta
image: ghcr.io/nervosnetwork/godwoken-web3-prebuilds:compatibility-breaking-changes-871b301
healthcheck:
test: curl http://127.0.0.1:8024 || exit 1
start_period: 10s
Expand Down
7 changes: 7 additions & 0 deletions docker/layer2/config/web3-config.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# see: https://github.com/nervosnetwork/godwoken-web3/tree/compatibility-breaking-changes#config-database

DATABASE_URL=postgres://user:password@postgres:5432/lumos
REDIS_URL=redis://redis:6379

GODWOKEN_JSON_RPC=http://godwoken:8119
GODWOKEN_WS_RPC_URL=ws://godwoken:8120
55 changes: 0 additions & 55 deletions docker/layer2/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -180,60 +180,6 @@ function create-polyjuice-root-account() {
log "Generate file \"$CONFIG_DIR/polyjuice-root-account-id\""
}

function generate-web3-config() {
log "Start"
if [ -s "$CONFIG_DIR/web3-config.env" ]; then
log "$CONFIG_DIR/web3-config.env already exists, skip"
return 0
fi

if ! command -v jq &> /dev/null; then
apt-get install -y jq &>/dev/null
fi

creator_account_id=$(cat $CONFIG_DIR/polyjuice-root-account-id)


cat <<EOF > $CONFIG_DIR/web3-config.env
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)
POLYJUICE_VALIDATOR_TYPE_HASH=$(jq -r '.polyjuice_validator.script_type_hash' $CONFIG_DIR/scripts-deployment.json)
L2_SUDT_VALIDATOR_SCRIPT_TYPE_HASH=$(jq -r '.l2_sudt_validator.script_type_hash' $CONFIG_DIR/scripts-deployment.json)
DATABASE_URL=postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@postgres:5432/$POSTGRES_DB
REDIS_URL=redis://redis:6379
GODWOKEN_JSON_RPC=http://godwoken:8119
GODWOKEN_WS_RPC_URL=ws://godwoken:8120
PORT=8024
# The CHAIN_ID is the identifier of our Godwoken devnet, which is defined in
# Godwoken [RollupConfig#chain_id](https://github.com/nervosnetwork/godwoken/blob/a099f2010b212355f5504a8d464b6b70d29640a5/crates/types/schemas/godwoken.mol#L64).
#
# More about chain id:
# * https://eips.ethereum.org/EIPS/eip-1344#specification
CHAIN_ID=$CHAIN_ID
# Polyjuice Root Account
# see: https://github.com/nervosnetwork/godwoken/blob/develop/docs/life_of_a_polyjuice_transaction.md#root-account--deployment
CREATOR_ACCOUNT_ID=$creator_account_id
# When requesting to "executeTransaction" RPC interface, the RawL2Transaction's
# signature can be omit. Therefore we fill the RawL2Transaction.from_id
# with this DEFAULT_FROM_ID (corresponding to DEFAULT_FROM_ADDRESS).
#
# Usually, ID(3) indicates the first deposited Godwoken account.
DEFAULT_FROM_ID=3
DEFAULT_FROM_ADDRESS=0x2e9df163055245bfadd35e3a1f05f06096447c85
# The builtin ETH_ADDRESS_REGISTRY_ACCOUNT_ID is 2.
# see: https://github.com/nervosnetwork/godwoken/blob/6180f04/crates/common/src/builtins.rs#L5
ETH_ADDRESS_REGISTRY_ACCOUNT_ID=2
EOF

log "Generate file \"$CONFIG_DIR/web3-config.env\""
log "Finished"
}

function generate-web3-indexer-config() {
log "Start"
if [ -s "$CONFIG_DIR/web3-indexer-config.toml" ]; then
Expand Down Expand Up @@ -275,7 +221,6 @@ function main() {
# Should make sure that the Polyjuice root account was created and the layer2 block was synced
create-polyjuice-root-account

generate-web3-config
generate-web3-indexer-config

# Godwoken daemon
Expand Down

0 comments on commit bd65461

Please sign in to comment.