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

Adapt for tools update #345

Merged
merged 3 commits into from
Mar 2, 2023
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ plugins/gw-schema/tmp
/docker/layer2/config/godwoken-config-readonly.toml
/docker/layer2/config/polyjuice-root-account-id
/docker/layer2/config/web3-indexer-config.toml
/docker/layer2/config/withdrawal-to-v1.toml
/docker/manual-artifacts/
/docker/layer2-v0/data/
/docker/layer2-v0/config/scripts-deployment.json
Expand Down
2 changes: 0 additions & 2 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ services:
retries: 3
environment:
RUST_LOG: info,gw_generator=debug
GODWOKEN_MODE: fullnode
RUST_BACKTRACE: full
STORE_PATH: /var/lib/layer2/data
ACCOUNTS_DIR: /accounts
Expand Down Expand Up @@ -118,7 +117,6 @@ services:
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
Expand Down
14 changes: 7 additions & 7 deletions docker/layer1/ckb/specs/dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ genesis_epoch_length = 10
permanent_difficulty_in_dummy = true

[params.hardfork]
rfc_0028 = 10
rfc_0029 = 10
rfc_0030 = 10
rfc_0031 = 10
rfc_0032 = 10
rfc_0036 = 10
rfc_0038 = 10
rfc_0028 = 0
rfc_0029 = 0
rfc_0030 = 0
rfc_0031 = 0
rfc_0032 = 0
rfc_0036 = 0
rfc_0038 = 0

[pow]
func = "Dummy"
14 changes: 7 additions & 7 deletions docker/layer1/ckb2/specs/dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ genesis_epoch_length = 10
permanent_difficulty_in_dummy = true

[params.hardfork]
rfc_0028 = 10
rfc_0029 = 10
rfc_0030 = 10
rfc_0031 = 10
rfc_0032 = 10
rfc_0036 = 10
rfc_0038 = 10
rfc_0028 = 0
rfc_0029 = 0
rfc_0030 = 0
rfc_0031 = 0
rfc_0032 = 0
rfc_0036 = 0
rfc_0038 = 0

[pow]
func = "Dummy"
14 changes: 7 additions & 7 deletions docker/layer1/ckb3/specs/dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ genesis_epoch_length = 10
permanent_difficulty_in_dummy = true

[params.hardfork]
rfc_0028 = 10
rfc_0029 = 10
rfc_0030 = 10
rfc_0031 = 10
rfc_0032 = 10
rfc_0036 = 10
rfc_0038 = 10
rfc_0028 = 0
rfc_0029 = 0
rfc_0030 = 0
rfc_0031 = 0
rfc_0032 = 0
rfc_0036 = 0
rfc_0038 = 0

[pow]
func = "Dummy"
18 changes: 5 additions & 13 deletions docker/layer2-v0/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ WORKSPACE="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
CONFIG_DIR="$WORKSPACE/config"
ACCOUNTS_DIR="${ACCOUNTS_DIR:-"ACCOUNTS_DIR is required"}"
V1_CONFIG_DIR="$WORKSPACE/v1config"
V1_GODWOKEN_CONFIG="$WORKSPACE/v1config/godwoken-config.toml"
WITHDRAWAL_TO_V1_CONFIG=$V1_CONFIG_DIR/withdrawal-to-v1.toml

function log() {
echo "[${FUNCNAME[1]}] $1"
Expand Down Expand Up @@ -51,26 +51,18 @@ function deploy_rollup_genesis() {
log "Generate file \"$CONFIG_DIR/rollup-genesis-deployment.json\""
}

function generate_withdrawal_to_v1_config() {
v1_rollup_type_hash=$(cat ${V1_GODWOKEN_CONFIG} | grep rollup_type_hash | awk '{print $3}')
v1_deposit_lock_code_hash=$(cat ${V1_GODWOKEN_CONFIG} | grep deposit_script_type_hash | awk '{print $3}')
v1_eth_lock_code_hash=$(cat ${V1_GODWOKEN_CONFIG} | grep -C 1 'type_ = "eth"' | awk '{print $3}' | grep '0x')

echo "\n[withdrawal_to_v1_config]\nv1_rollup_type_hash = ${v1_rollup_type_hash}\nv1_deposit_lock_code_hash = ${v1_deposit_lock_code_hash}\nv1_eth_lock_code_hash = ${v1_eth_lock_code_hash}\nv1_deposit_minimal_cancel_timeout_msecs = 604800000"
}

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

log "check godwoken v1 config file exists"
log "check withdrawal-to-v1.toml exists"
start_time=$(date +%s)
while true; do
sleep 1
if [ -f "${V1_GODWOKEN_CONFIG}" ]; then
if [ -f $WITHDRAWAL_TO_V1_CONFIG ]; then
break
fi
elapsed=$(( $(date +%s) - start_time ))
Expand Down Expand Up @@ -100,7 +92,7 @@ function generate_godwoken_config() {
fi
sed -i 's#enable_methods = \[\]#err_receipt_ws_listen = '"'0.0.0.0:8120'"'#' $CONFIG_DIR/godwoken-config.toml

printf "$(generate_withdrawal_to_v1_config)" >> $CONFIG_DIR/godwoken-config.toml
cat $WITHDRAWAL_TO_V1_CONFIG >> $CONFIG_DIR/godwoken-config.toml

log "Generate file \"$CONFIG_DIR/godwoken-config.toml\""
}
Expand Down Expand Up @@ -169,7 +161,7 @@ function main() {
deploy_scripts
deploy_rollup_genesis
generate_godwoken_config

start_godwoken_at_background

deposit_for_test_accounts
Expand Down
3 changes: 2 additions & 1 deletion docker/layer2/config/scripts-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"tron_account_lock" : "/scripts/godwoken-scripts/tron-account-lock",
"withdrawal_lock" : "/scripts/godwoken-scripts/withdrawal-lock",
"eth_addr_reg_validator": "/scripts/godwoken-scripts/eth-addr-reg-validator",
"omni_lock": "/scripts/godwoken-scripts/omni_lock"
"omni_lock": "/scripts/godwoken-scripts/omni_lock",
"delegate_cell_lock": "/scripts/godwoken-scripts/delegate-cell-lock"
}
}
18 changes: 12 additions & 6 deletions docker/layer2/entrypoint-readonly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ function generate_godwoken_readonly_config() {
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
sed -i '/^\[block_producer.wallet_config\]/,+7d' $CONFIG_DIR/godwoken-config-readonly.toml
RUST_BACKTRACE=full gw-tools generate-config \
--ckb-rpc http://ckb:8114 \
--ckb-indexer-rpc http://ckb-indexer:8116 \
--node-mode "readonly" \
--store-path $STORE_PATH \
-c $CONFIG_DIR/scripts-config.json \
--scripts-deployment-path $CONFIG_DIR/scripts-deployment.json \
-g $CONFIG_DIR/rollup-genesis-deployment.json \
--rollup-config $CONFIG_DIR/rollup-config.json \
-o $CONFIG_DIR/godwoken-config-readonly.toml \
--rpc-server-url 0.0.0.0:8119 \
--p2p-dial /dns4/godwoken/tcp/9999

log "Generate file \"$CONFIG_DIR/godwoken-config-readonly.toml\""
}
Expand Down
31 changes: 11 additions & 20 deletions docker/layer2/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ function deploy_scripts() {
start_ckb_miner_at_background
RUST_BACKTRACE=full gw-tools deploy-scripts \
--ckb-rpc http://ckb:8114 \
--ckb-indexer-rpc http://ckb-indexer:8116 \
-i $CONFIG_DIR/scripts-config.json \
-o $CONFIG_DIR/scripts-deployment.json \
-k $ACCOUNTS_DIR/rollup-scripts-deployer.key
Expand All @@ -100,8 +101,8 @@ function deploy_rollup_genesis() {
start_ckb_miner_at_background
RUST_BACKTRACE=full gw-tools deploy-genesis \
--ckb-rpc http://ckb:8114 \
--ckb-indexer-rpc http://ckb-indexer:8116 \
--scripts-deployment-path $CONFIG_DIR/scripts-deployment.json \
--omni-lock-config-path $CONFIG_DIR/scripts-deployment.json \
--rollup-config $CONFIG_DIR/rollup-config.json \
-o $CONFIG_DIR/rollup-genesis-deployment.json \
-k $ACCOUNTS_DIR/godwoken-block-producer.key
Expand All @@ -121,28 +122,19 @@ function generate_godwoken_config() {
RUST_BACKTRACE=full gw-tools generate-config \
--ckb-rpc http://ckb:8114 \
--ckb-indexer-rpc http://ckb-indexer:8116 \
--node-mode fullnode \
--store-path $STORE_PATH \
-c $CONFIG_DIR/scripts-config.json \
--scripts-deployment-path $CONFIG_DIR/scripts-deployment.json \
--omni-lock-config-path $CONFIG_DIR/scripts-deployment.json \
-g $CONFIG_DIR/rollup-genesis-deployment.json \
--rollup-config $CONFIG_DIR/rollup-config.json \
-o $CONFIG_DIR/godwoken-config.toml \
--rpc-server-url 0.0.0.0:8119 \
--privkey-path $ACCOUNTS_DIR/godwoken-block-producer.key \
--block-producer-address 0x2e9df163055245bfadd35e3a1f05f06096447c85
--block-producer-address 0x2e9df163055245bfadd35e3a1f05f06096447c85 \
--p2p-listen /ip4/0.0.0.0/tcp/9999 \
--output-withdrawal-to-v1-config $CONFIG_DIR/withdrawal-to-v1.toml

# some dirty modification
if [ ! -z "$GODWOKEN_MODE" ]; then
sed -i 's#^node_mode = .*$#node_mode = '"'$GODWOKEN_MODE'"'#' $CONFIG_DIR/godwoken-config.toml
fi
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
log "Generate file \"$CONFIG_DIR/godwoken-config.toml\""
}

Expand All @@ -157,16 +149,15 @@ function create_polyjuice_root_account() {

# Deposit for block_producer
#
# Here we deposit from ckb-miner-and-faucet.key instead of
# godwoken-block-producer.key to avoid double spending cells locked by the
# latter -- godwoken has already started and may spend them too for block
# submission etc.
# Use rollup-scripts-deployer so that this transaction isn't in conflict
# with submission txs or v0 deployment/submission txs.
log "Deposit for block_producer"
RUST_BACKTRACE=full gw-tools deposit-ckb \
--privkey-path $ACCOUNTS_DIR/ckb-miner-and-faucet.key \
--privkey-path $ACCOUNTS_DIR/rollup-scripts-deployer.key \
--eth-address 0x2e9df163055245bfadd35e3a1f05f06096447c85 \
--godwoken-rpc-url http://127.0.0.1:8119 \
--ckb-rpc http://ckb:8114 \
--ckb-indexer-rpc http://ckb-indexer:8116 \
--scripts-deployment-path $CONFIG_DIR/scripts-deployment.json \
--config-path $CONFIG_DIR/godwoken-config.toml \
--capacity 2000
Expand Down
9 changes: 6 additions & 3 deletions kicker
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ function clean() {
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 -f docker/layer2/config/withdrawal-to-v1.toml
rm -rf docker/ckb-indexer/
rm -rf docker/layer1/ckb/data/
rm -rf docker/layer1/ckb2/data/
Expand Down Expand Up @@ -214,7 +215,8 @@ function deposit() {
ethaddr=${1:?"\"$EXECUTABLE deposit\" requires eth address as 1st argument"}
amount=${2:?"\"$EXECUTABLE deposit\" requires amount as 2nd argument"}

pkpath=${PRIVATE_KEY_PATH:-"$WORKSPACE/accounts/ckb-miner-and-faucet.key"}
# Use rollup-scripts-deployer to avoid conflict with v0/v1 block submission.
pkpath=${PRIVATE_KEY_PATH:-"$WORKSPACE/accounts/rollup-scripts-deployer.key"}
if [ ! -f $pkpath ]; then
error "$pkpath: No such file or directory"
exit 1
Expand All @@ -229,6 +231,7 @@ function deposit() {
--entrypoint "gw-tools deposit-ckb \
--godwoken-rpc-url http://godwoken:8119 \
--ckb-rpc http://ckb:8114 \
--ckb-indexer-rpc http://ckb-indexer:8116 \
--scripts-deployment-path /config/scripts-deployment.json \
--config-path /config/godwoken-config.toml \
--privkey-path /privkey-path \
Expand Down Expand Up @@ -303,7 +306,7 @@ function to_script_hash() {
function deposit_v0() {
amount=${1:?"\"$EXECUTABLE deposit\" requires amount as 1nd argument"}

pkpath=${PRIVATE_KEY_PATH:-"$WORKSPACE/accounts/ckb-miner-and-faucet.key"}
pkpath=${PRIVATE_KEY_PATH:-"$WORKSPACE/accounts/rollup-scripts-deployer.key"}
if [ ! -f $pkpath ]; then
error "$pkpath: No such file or directory"
exit 1
Expand Down Expand Up @@ -331,7 +334,7 @@ function withdraw_v0_to_v1() {
ethaddr=${1:?"\"$EXECUTABLE withdraw-v0-to-v1\" requires eth address as 1st argument"}
amount=${2:?"\"$EXECUTABLE withdraw-v0-to-v1\" requires amount as 2nd argument"}

pkpath=${PRIVATE_KEY_PATH:-"$WORKSPACE/accounts/ckb-miner-and-faucet.key"}
pkpath=${PRIVATE_KEY_PATH:-"$WORKSPACE/accounts/rollup-scripts-deployer.key"}
if [ ! -f $pkpath ]; then
error "$pkpath: No such file or directory"
exit 1
Expand Down