Skip to content

Commit

Permalink
Get number of SNSes from SNS-WASM canister (#382)
Browse files Browse the repository at this point in the history
# Motivation

When creating a snapshot, before killing the replica and archiving the
snapshot, we wait for the aggregator to scrap all SNSes.
Currently we specify to the aggregator how many SNSes it should expect.
This is not necessary because we can get this information from the
SNS-WASM canister.
And it can lead to unnecessary delays when the number is wrong.

# Changes

Instead of passing the number of expected SNSes to the
`dfx-sns-aggregator-wait` let the script determine the expected number
for itself by calling the SNS-WASM canister.

# Tested

CI passes and correctly detects 12 SNSes:

https://github.com/dfinity/snsdemo/actions/runs/10057983124/job/27800205191?pr=382
<img width="427" alt="image"
src="https://github.com/user-attachments/assets/6108d32e-f416-4ab0-845d-4876ea9c152a">
  • Loading branch information
dskloetd authored Jul 23, 2024
1 parent 2499bf6 commit f479e62
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bin/dfx-snapshot-stock-make
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dfx-stock-deploy --ic_commit "$DFX_IC_COMMIT" --ic_dir "$IC_REPO_DIR" --parallel

: "Wait for aggregator to get all SNSs"
# 2 SNSes were created by dfx-sns-demo.
dfx-sns-aggregator-wait --num_sns "$((2 + PARALLEL_SNS_COUNT))"
dfx-sns-aggregator-wait

: "Wait for a checkpoint"
dfx-network-wait-for-checkpoint --timeout 600
Expand Down
3 changes: 2 additions & 1 deletion bin/dfx-sns-aggregator-wait
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ print_help() {
# Source the clap.bash file ---------------------------------------------------
source "$SOURCE_DIR/clap.bash"
# Define options
clap.define short=n long=num_sns desc="The number of SNSs to wait for" variable=EXPECTED_NUM_SNS default="1"
# There are no custom options but we use clap for --help.
# Source the output file ----------------------------------------------------------
source "$(clap.build)"

Expand Down Expand Up @@ -75,6 +75,7 @@ get_sns_count() {
}

wait_for_sns_count() {
EXPECTED_NUM_SNS="$(dfx canister call nns-sns-wasm list_deployed_snses '(record{})' | idl2json | jq '.instances | length')"
echo "Waiting for $EXPECTED_NUM_SNS SNSs"
page_size=10
required_page_count=$(((EXPECTED_NUM_SNS + page_size - 1) / page_size))
Expand Down

0 comments on commit f479e62

Please sign in to comment.