From f1f469f55faf107033aed69cb60a5e56b04a1882 Mon Sep 17 00:00:00 2001 From: Killian Delarue Date: Wed, 30 Oct 2024 14:13:47 +0100 Subject: [PATCH 1/6] Scripts: Remove useless functions from [octez-init-sandbox-client] --- src/bin_client/octez-init-sandboxed-client.sh | 43 ------------------- 1 file changed, 43 deletions(-) diff --git a/src/bin_client/octez-init-sandboxed-client.sh b/src/bin_client/octez-init-sandboxed-client.sh index 8698b4945b01..7d9b1156aa6c 100755 --- a/src/bin_client/octez-init-sandboxed-client.sh +++ b/src/bin_client/octez-init-sandboxed-client.sh @@ -36,35 +36,6 @@ init_sandboxed_client() { fi } -cleanup_clients() { - rm -rf "${client_dirs[@]}" -} - -## Waiter ################################################################## - -wait_for_the_node_to_be_ready() { - local count=0 - if $client rpc get /chains/main/blocks/head/hash > /dev/null 2>&1; then return; fi - printf "Waiting for the node to initialize..." - sleep 1 - while ! $client rpc get /chains/main/blocks/head/hash > /dev/null 2>&1; do - count=$((count + 1)) - if [ "$count" -ge 30 ]; then - echo " timeout." - exit 2 - fi - printf "." - sleep 1 - done - echo " done." -} - -wait_for_the_node_to_be_bootstrapped() { - wait_for_the_node_to_be_ready - echo "Waiting for the node to synchronize with the network..." - $client bootstrapped -} - ## Sandboxed client ######################################################## # key pairs from $src_dir/test/sandbox.json @@ -108,20 +79,6 @@ add_liquidity_baking_default_file() { } -activate_alpha() { - - # Calling `date` with 'AAA+1' is a small tweak to speed-up - # the block baking process. Having a one-hour back timestamp - # avoids having to wait for at least [time_between_block] to - # produce new blocks. - ${client} \ - -block genesis \ - activate protocol ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK \ - with fitness 1 \ - and key activator \ - and parameters "${parameters_file}" -} - usage() { echo "Small script to initialize a client to a local and closed test network with a maximum of 9 nodes." echo -- GitLab From 313d97c8ef1a5b86c3df5ea20303f74b79b03dde Mon Sep 17 00:00:00 2001 From: Killian Delarue Date: Wed, 30 Oct 2024 15:21:08 +0100 Subject: [PATCH 2/6] Scripts: Refactor client initialisation in [octez-init-sandboxed-client] --- src/bin_client/octez-init-sandboxed-client.sh | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/bin_client/octez-init-sandboxed-client.sh b/src/bin_client/octez-init-sandboxed-client.sh index 7d9b1156aa6c..0c3263936834 100755 --- a/src/bin_client/octez-init-sandboxed-client.sh +++ b/src/bin_client/octez-init-sandboxed-client.sh @@ -13,27 +13,24 @@ init_sandboxed_client() { rpc=$((18730 + id)) client_dir="$(mktemp -d -t tezos-tmp-client.XXXXXXXX)" client_dirs+=("$client_dir") + + # Options if [ -n "$SCORU_DATA_DIR" ]; then rollup_node_dir="$SCORU_DATA_DIR" else rollup_node_dir="$(mktemp -d -t tezos-smart-rollup-node.XXXXXXXX)" fi - signer="$local_signer -d $client_dir" if [ -n "$USE_TLS" ]; then - client="$local_client -base-dir $client_dir -endpoint https://$host:$rpc" - admin_client="$local_admin_client -base-dir $client_dir -endpoint https://$host:$rpc" - alpha_baker="$local_alpha_baker -base-dir $client_dir -endpoint https://$host:$rpc" - alpha_accuser="$local_alpha_accuser -base-dir $client_dir -endpoint https://$host:$rpc" - alpha_sc_rollup_node="$local_alpha_sc_rollup_node -base-dir $client_dir -endpoint https://$host:$rpc" - compiler="$local_compiler" + endpoint="https://$host:$rpc" else - client="$local_client -base-dir $client_dir -endpoint http://$host:$rpc" - admin_client="$local_admin_client -base-dir $client_dir -endpoint http://$host:$rpc" - alpha_baker="$local_alpha_baker -base-dir $client_dir -endpoint http://$host:$rpc" - alpha_accuser="$local_alpha_accuser -base-dir $client_dir -endpoint http://$host:$rpc" - alpha_sc_rollup_node="$local_alpha_sc_rollup_node -base-dir $client_dir -endpoint http://$host:$rpc" - compiler="$local_compiler" + endpoint="http://$host:$rpc" fi + + # Binaries + signer="$local_signer -d $client_dir" + client="$local_client -base-dir $client_dir -endpoint $endpoint" + admin_client="$local_admin_client -base-dir $client_dir -endpoint $endpoint" + compiler="$local_compiler" } ## Sandboxed client ######################################################## @@ -135,15 +132,15 @@ main() { local_sc_rollup_node="$bin_dir/../../_build/default/src/proto_$protocol_underscore/bin_sc_rollup_node/main_sc_rollup_node_$protocol_underscore.exe" if [ -n "$USE_TLS" ]; then - baker="$local_baker -base-dir $client_dir -endpoint https://$host:$rpc" - accuser="$local_accuser -base-dir $client_dir -endpoint https://$host:$rpc" - sc_rollup_node="$local_sc_rollup_node -base-dir $client_dir -endpoint https://$host:$rpc" + endpoint="https://$host:$rpc" else - baker="$local_baker -base-dir $client_dir -endpoint http://$host:$rpc" - accuser="$local_accuser -base-dir $client_dir -endpoint http://$host:$rpc" - sc_rollup_node="$local_sc_rollup_node -base-dir $client_dir -endpoint http://$host:$rpc" + endpoint="http://$host:$rpc" fi + baker="$local_baker -base-dir $client_dir -endpoint $endpoint" + accuser="$local_accuser -base-dir $client_dir -endpoint $endpoint" + sc_rollup_node="$local_sc_rollup_node -base-dir $client_dir -endpoint $endpoint" + echo '#!/bin/sh' > $client_dir/bin/octez-baker-$protocol_without_number echo "exec $baker \"\$@\"" >> $client_dir/bin/octez-baker-$protocol_without_number chmod +x $client_dir/bin/octez-baker-$protocol_without_number -- GitLab From 05f085941281d0b86d23ab2950b215dc59418eb6 Mon Sep 17 00:00:00 2001 From: Killian Delarue Date: Thu, 31 Oct 2024 16:33:08 +0100 Subject: [PATCH 3/6] Scripts, Sandbox-client: Comment useless bootstrap variables We comment instead of removing so that it can be used for debugging, and so that we keep the information about the bootstrap accounts --- src/bin_client/octez-init-sandboxed-client.sh | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/bin_client/octez-init-sandboxed-client.sh b/src/bin_client/octez-init-sandboxed-client.sh index 0c3263936834..da45107fe13c 100755 --- a/src/bin_client/octez-init-sandboxed-client.sh +++ b/src/bin_client/octez-init-sandboxed-client.sh @@ -37,24 +37,24 @@ init_sandboxed_client() { # key pairs from $src_dir/test/sandbox.json -BOOTSTRAP1_IDENTITY="tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" -BOOTSTRAP1_PUBLIC="edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav" +#BOOTSTRAP1_IDENTITY="tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" +#BOOTSTRAP1_PUBLIC="edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav" BOOTSTRAP1_SECRET="unencrypted:edsk3gUfUPyBSfrS9CCgmCiQsTCHGkviBDusMxDJstFtojtc1zcpsh" -BOOTSTRAP2_IDENTITY="tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" -BOOTSTRAP2_PUBLIC="edpktzNbDAUjUk697W7gYg2CRuBQjyPxbEg8dLccYYwKSKvkPvjtV9" +#BOOTSTRAP2_IDENTITY="tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" +#BOOTSTRAP2_PUBLIC="edpktzNbDAUjUk697W7gYg2CRuBQjyPxbEg8dLccYYwKSKvkPvjtV9" BOOTSTRAP2_SECRET="unencrypted:edsk39qAm1fiMjgmPkw1EgQYkMzkJezLNewd7PLNHTkr6w9XA2zdfo" -BOOTSTRAP3_IDENTITY="tz1faswCTDciRzE4oJ9jn2Vm2dvjeyA9fUzU" -BOOTSTRAP3_PUBLIC="edpkuTXkJDGcFd5nh6VvMz8phXxU3Bi7h6hqgywNFi1vZTfQNnS1RV" +#BOOTSTRAP3_IDENTITY="tz1faswCTDciRzE4oJ9jn2Vm2dvjeyA9fUzU" +#BOOTSTRAP3_PUBLIC="edpkuTXkJDGcFd5nh6VvMz8phXxU3Bi7h6hqgywNFi1vZTfQNnS1RV" BOOTSTRAP3_SECRET="unencrypted:edsk4ArLQgBTLWG5FJmnGnT689VKoqhXwmDPBuGx3z4cvwU9MmrPZZ" -BOOTSTRAP4_IDENTITY="tz1b7tUupMgCNw2cCLpKTkSD1NZzB5TkP2sv" -BOOTSTRAP4_PUBLIC="edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU" +#BOOTSTRAP4_IDENTITY="tz1b7tUupMgCNw2cCLpKTkSD1NZzB5TkP2sv" +#BOOTSTRAP4_PUBLIC="edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU" BOOTSTRAP4_SECRET="unencrypted:edsk2uqQB9AY4FvioK2YMdfmyMrer5R8mGFyuaLLFfSRo8EoyNdht3" -BOOTSTRAP5_IDENTITY="tz1ddb9NMYHZi5UzPdzTZMYQQZoMub195zgv" -BOOTSTRAP5_PUBLIC="edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n" +#BOOTSTRAP5_IDENTITY="tz1ddb9NMYHZi5UzPdzTZMYQQZoMub195zgv" +#BOOTSTRAP5_PUBLIC="edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n" BOOTSTRAP5_SECRET="unencrypted:edsk4QLrcijEffxV31gGdN2HU7UpyJjA8drFoNcmnB28n89YjPNRFm" ACTIVATOR_SECRET="unencrypted:edsk31vznjHSSpGExDMHYASz45VZqXN4DPxvsa4hAyY8dHM28cZzp6" -- GitLab From 824023714ae6bf96483b800e4bd51b5c2bc6b2b0 Mon Sep 17 00:00:00 2001 From: Killian Delarue Date: Thu, 31 Oct 2024 16:35:29 +0100 Subject: [PATCH 4/6] Scripts, Sandbox-client: Add [octez-protocol-compiler] to binaries --- src/bin_client/octez-init-sandboxed-client.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bin_client/octez-init-sandboxed-client.sh b/src/bin_client/octez-init-sandboxed-client.sh index da45107fe13c..bf08f1f606c1 100755 --- a/src/bin_client/octez-init-sandboxed-client.sh +++ b/src/bin_client/octez-init-sandboxed-client.sh @@ -158,6 +158,10 @@ main() { echo "exec $signer \"\$@\"" >> $client_dir/bin/octez-signer chmod +x $client_dir/bin/octez-signer + echo '#!/bin/sh' > "$client_dir"/bin/octez-protocol-compiler + echo "exec $compiler \"\$@\"" >> "$client_dir"/bin/octez-protocol-compiler + chmod +x "$client_dir"/bin/octez-protocol-compiler + cat << EOF if type octez-client-reset >/dev/null 2>&1 ; then octez-client-reset; fi ; PATH="$client_dir/bin:\$PATH" ; export PATH ; -- GitLab From b839b3d11d624f68d9a292519011e997e6b65119 Mon Sep 17 00:00:00 2001 From: Killian Delarue Date: Wed, 30 Oct 2024 16:12:23 +0100 Subject: [PATCH 5/6] Script, Sandbox-client: Fix linting issues --- src/bin_client/octez-init-sandboxed-client.sh | 59 ++++++++++--------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/src/bin_client/octez-init-sandboxed-client.sh b/src/bin_client/octez-init-sandboxed-client.sh index bf08f1f606c1..4ddab088c0d0 100755 --- a/src/bin_client/octez-init-sandboxed-client.sh +++ b/src/bin_client/octez-init-sandboxed-client.sh @@ -72,7 +72,7 @@ add_sandboxed_bootstrap_identities() { add_liquidity_baking_default_file() { - echo '{ "liquidity_baking_toggle_vote": "pass" }' > ${client_dir}/per_block_votes.json + echo '{ "liquidity_baking_toggle_vote": "pass" }' > "${client_dir}"/per_block_votes.json } @@ -85,8 +85,9 @@ usage() { main() { - local bin_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)")" - if [ $(basename "$bin_dir") = "bin_client" ]; then + local bin_dir + bin_dir="$(cd "$(dirname "$0")" && pwd -P)" + if [ "$(basename "$bin_dir")" = "bin_client" ]; then local_client="${local_client:-$bin_dir/../../_build/default/src/bin_client/main_client.exe}" local_admin_client="${local_admin_client:-$bin_dir/../../_build/default/src/bin_client/main_admin.exe}" local_signer="${local_signer:-$bin_dir/../../_build/default/src/bin_signer/main_signer.exe}" @@ -114,19 +115,23 @@ main() { add_liquidity_baking_default_file - mkdir -p $client_dir/bin + mkdir -p "$client_dir"/bin - echo '#!/bin/sh' > $client_dir/bin/octez-client - echo "exec $client \"\$@\"" >> $client_dir/bin/octez-client - chmod +x $client_dir/bin/octez-client + echo '#!/bin/sh' > "$client_dir"/bin/octez-client + echo "exec $client \"\$@\"" >> "$client_dir"/bin/octez-client + chmod +x "$client_dir"/bin/octez-client - echo '#!/bin/sh' > $client_dir/bin/octez-admin-client - echo "exec $admin_client \"\$@\"" >> $client_dir/bin/octez-admin-client - chmod +x $client_dir/bin/octez-admin-client + echo '#!/bin/sh' > "$client_dir"/bin/octez-admin-client + echo "exec $admin_client \"\$@\"" >> "$client_dir"/bin/octez-admin-client + chmod +x "$client_dir"/bin/octez-admin-client - for protocol in $(cat $bin_dir/../../script-inputs/active_protocol_versions); do - protocol_underscore=$(echo $protocol | tr -- - _) - protocol_without_number=$(echo $protocol | tr -d "\-[0-9]") + echo '#!/bin/sh' > "$client_dir"/bin/octez-protocol-compiler + echo "exec $compiler \"\$@\"" >> "$client_dir"/bin/octez-protocol-compiler + chmod +x "$client_dir"/bin/octez-protocol-compiler + + while IFS= read -r protocol; do + protocol_underscore=$(echo "$protocol" | tr -- - _) + protocol_without_number=$(echo "$protocol" | tr -d "\-[0-9]") local_baker="$bin_dir/../../_build/default/src/proto_$protocol_underscore/bin_baker/main_baker_$protocol_underscore.exe" local_accuser="$bin_dir/../../_build/default/src/proto_$protocol_underscore/bin_accuser/main_accuser_$protocol_underscore.exe" local_sc_rollup_node="$bin_dir/../../_build/default/src/proto_$protocol_underscore/bin_sc_rollup_node/main_sc_rollup_node_$protocol_underscore.exe" @@ -141,22 +146,22 @@ main() { accuser="$local_accuser -base-dir $client_dir -endpoint $endpoint" sc_rollup_node="$local_sc_rollup_node -base-dir $client_dir -endpoint $endpoint" - echo '#!/bin/sh' > $client_dir/bin/octez-baker-$protocol_without_number - echo "exec $baker \"\$@\"" >> $client_dir/bin/octez-baker-$protocol_without_number - chmod +x $client_dir/bin/octez-baker-$protocol_without_number + echo '#!/bin/sh' > "$client_dir"/bin/octez-baker-"$protocol_without_number" + echo "exec $baker \"\$@\"" >> "$client_dir"/bin/octez-baker-"$protocol_without_number" + chmod +x "$client_dir"/bin/octez-baker-"$protocol_without_number" - echo '#!/bin/sh' > $client_dir/bin/octez-smart-rollup-node-$protocol_without_number - echo "exec $sc_rollup_node \"\$@\" -data-dir $rollup_node_dir" >> $client_dir/bin/octez-smart-rollup-node-$protocol_without_number - chmod +x $client_dir/bin/octez-smart-rollup-node-$protocol_without_number + echo '#!/bin/sh' > "$client_dir"/bin/octez-smart-rollup-node-"$protocol_without_number" + echo "exec $sc_rollup_node \"\$@\" -data-dir $rollup_node_dir" >> "$client_dir"/bin/octez-smart-rollup-node-"$protocol_without_number" + chmod +x "$client_dir"/bin/octez-smart-rollup-node-"$protocol_without_number" - echo '#!/bin/sh' > $client_dir/bin/octez-accuser-$protocol_without_number - echo "exec $accuser \"\$@\"" >> $client_dir/bin/octez-accuser-$protocol_without_number - chmod +x $client_dir/bin/octez-accuser-$protocol_without_number - done + echo '#!/bin/sh' > "$client_dir"/bin/octez-accuser-"$protocol_without_number" + echo "exec $accuser \"\$@\"" >> "$client_dir"/bin/octez-accuser-"$protocol_without_number" + chmod +x "$client_dir"/bin/octez-accuser-"$protocol_without_number" + done < "$bin_dir"/../../script-inputs/active_protocol_versions - echo '#!/bin/sh' > $client_dir/bin/octez-signer - echo "exec $signer \"\$@\"" >> $client_dir/bin/octez-signer - chmod +x $client_dir/bin/octez-signer + echo '#!/bin/sh' > "$client_dir"/bin/octez-signer + echo "exec $signer \"\$@\"" >> "$client_dir"/bin/octez-signer + chmod +x "$client_dir"/bin/octez-signer echo '#!/bin/sh' > "$client_dir"/bin/octez-protocol-compiler echo "exec $compiler \"\$@\"" >> "$client_dir"/bin/octez-protocol-compiler @@ -199,6 +204,6 @@ EOF } -if [ "$0" == "$BASH_SOURCE" ]; then +if [ "$0" == "${BASH_SOURCE[0]}" ]; then main "$@" fi -- GitLab From 0f925daebe2e98e444028423e2ec79dc2c5544a9 Mon Sep 17 00:00:00 2001 From: Killian Delarue Date: Wed, 30 Oct 2024 16:36:53 +0100 Subject: [PATCH 6/6] Scripts, Lint: [octez-init-sandbox-client.sh] is not skipped anymore --- scripts/shellcheck_skips | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/shellcheck_skips b/scripts/shellcheck_skips index 2a74c933032e..2e91db8837f0 100644 --- a/scripts/shellcheck_skips +++ b/scripts/shellcheck_skips @@ -1,5 +1,4 @@ src/bin_snoop/bash-completion.sh -src/bin_client/octez-init-sandboxed-client.sh src/lib_bls12_381/libblst/build.sh src/lib_bls12_381/libblst/build/refresh.sh scripts/pkg-common/install_opam.sh -- GitLab