Skip to content

Commit

Permalink
Create wallet canisters sequentially (#419)
Browse files Browse the repository at this point in the history
# Motivation

Since `dfx` 0.24.1, creating the snapshot results in creating only 11 or
10 SNSes instead of 12 almost every time.
For example:
https://github.com/dfinity/snsdemo/actions/runs/11659664378/job/32460602932?pr=418

After debugging, I found out that creating wallet canisters as part of
the parallel SNS creation started occasionally failing with.
```
Error: Failed to setup wallet caller.
Caused by: Failed to create wallet
Caused by: Failed to load wallet configuration
Caused by: failed to parse contents of /home/runner/work/snsdemo/snsdemo/users/snsdemo_1/.local/share/dfx/network/local/wallets.json as json
Caused by: EOF while parsing a value at line 1 column 0
```

I'm not sure why but it might not work well anymore to create many
wallet canisters simultaneously.

Also, while I was debugging this it appears that MacOS-12 stopped being
supported on GitHub.

# Changes

1. Move the creating the snsdemo identities (which includes wallet
canister creation) outside the parallel process so that it is done
sequentially.
2. Check that we have the expected number of SNSes after SNS creation is
done.
3. Use MacOS 14 instead of MacOS 12.

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
dskloetd and github-actions[bot] authored Nov 4, 2024
1 parent 3208dcf commit 80c1f4f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
# strategy:
# fail-fast: false
# matrix:
# os: [ macos-12, ubuntu-22.04 ]
# os: [ macos-14, ubuntu-22.04 ]
# steps:
# - name: Checkout
# uses: actions/checkout@v3
Expand All @@ -23,7 +23,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-12, ubuntu-22.04]
os: [macos-14, ubuntu-22.04]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -32,7 +32,7 @@ jobs:
echo "$HOME/.local/bin" >> $GITHUB_PATH
echo "$PWD/bin" >> $GITHUB_PATH
- name: Unbork mac
if: matrix.os == 'macos-12'
if: matrix.os == 'macos-14'
run: |
brew install bash
echo "/usr/local/bin" >> $GITHUB_PATH
Expand All @@ -49,11 +49,11 @@ jobs:
./bin/dfx-sns-sale-buy
./bin/dfx-sns-sale-finalize
- name: Create lots of SNS
if: matrix.os != 'macos-12'
if: matrix.os != 'macos-14'
run: |
./bin/dfx-sns-demo-mksns-parallel -s 10 --config_index_offset 2 -m snsdemo8
- name: Save state
if: matrix.os != 'macos-12'
if: matrix.os != 'macos-14'
run: |
# Stop the replica to let it persist all its state before we save the state.
dfx stop
Expand All @@ -69,7 +69,7 @@ jobs:
echo "Saving state"
bin/dfx-snapshot-save --verbose --snapshot state.tar.xz
- name: Upload state
if: matrix.os != 'macos-12'
if: matrix.os != 'macos-14'
uses: actions/upload-artifact@v3
with:
name: snsdemo
Expand All @@ -81,7 +81,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-12, ubuntu-22.04]
os: [macos-14, ubuntu-22.04]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -90,7 +90,7 @@ jobs:
echo "$HOME/.local/bin" >> $GITHUB_PATH
echo "$PWD/bin" >> $GITHUB_PATH
- name: Unbork mac
if: matrix.os == 'macos-12'
if: matrix.os == 'macos-14'
run: |
brew install bash
echo "/usr/local/bin" >> $GITHUB_PATH
Expand All @@ -115,6 +115,6 @@ jobs:
./bin/dfx-sns-sale-buy
./bin/dfx-sns-sale-finalize
- name: Create lots of SNS
if: matrix.os != 'macos-12'
if: matrix.os != 'macos-14'
run: |
./bin/dfx-sns-demo-mksns-parallel -s 10 --config_index_offset 2 -m snsdemo8
6 changes: 5 additions & 1 deletion bin/dfx-sns-demo-mksns-parallel
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,14 @@ create_all_sns() {
PROCESSES=()
echo "I am $$"
for ((i = 0; i < NUM_SNS_TO_MAKE; i++)); do
# Creating wallet canisters in parallel started occasionally failing with
# 0.24.1. When creating 10 in parallel, almost always at least 1 would fail.
# So we create the users outside the background process.
DEMO_USER="snsdemo_$i"
make_user "$DEMO_USER"
(
echo "Starting $BASHPID"
DEMO_USER="snsdemo_$i"
make_user "$DEMO_USER"
become_user "$DEMO_USER"

./bin/dfx-sns-demo-mksns-config --config_index $((CONFIG_INDEX_OFFSET + i)) --unique_logo "$UNIQUE_LOGO"
Expand Down
7 changes: 7 additions & 0 deletions bin/dfx-stock-deploy
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ if [ "${PARALLEL_SNS_COUNT:-0}" -gt 0 ]; then
dfx-sns-demo-mksns-parallel --network "$DFX_NETWORK" --num_sns "$PARALLEL_SNS_COUNT" --majority snsdemo8 --config_index_offset 2 --unique_logo "$UNIQUE_LOGO"
fi

SNS_COUNT="$(dfx canister call nns-sns-wasm list_deployed_snses '(record{})' | idl2json | jq -r '.instances | length')"
EXPECTED_SNS_COUNT="$((2 + PARALLEL_SNS_COUNT))"
if [[ "$SNS_COUNT" != "$EXPECTED_SNS_COUNT" ]]; then
echo "❌ Expected $EXPECTED_SNS_COUNT SNSes. Found $SNS_COUNT"
exit 1
fi

: Set up ckbtc canisters
dfx-ckbtc-import --prefix ckbtc_
dfx-ckbtc-deploy --prefix ckbtc_ --network "$DFX_NETWORK" --yes
Expand Down

0 comments on commit 80c1f4f

Please sign in to comment.