Skip to content

Commit 651565a

Browse files
committed
second
1 parent e492ac1 commit 651565a

File tree

1 file changed

+38
-16
lines changed

1 file changed

+38
-16
lines changed

scripts/make-upgrade-proposal

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ deploy_release_candidate() {
297297
--mode upgrade \
298298
--wasm ./internet_identity.wasm.gz \
299299
--argument-type raw \
300-
--argument-file "$(cat ./dfx_arg.bin)"
300+
--argument "$(cat ./dfx_arg.bin)"
301301
}
302302

303303
test_release_candidate() {
@@ -327,21 +327,45 @@ share_proposal() {
327327
}
328328

329329
confirm_proposal_arguments() {
330-
echo "Confirm that the sha256 of the arg.bin file matches the one in the Proposal.md file"
330+
echo "Confirm that the sha256 of the mainnet_arg.bin file matches the one in the Proposal.md file"
331331
echo ""
332-
echo "You need to execute 'shasum -a 256 ./arg.bin' and compare the output with the command in the proposal.md file"
332+
echo "You need to execute 'shasum -a 256 ./mainnet_arg.bin' and compare the output with the command in the proposal.md file"
333+
}
334+
335+
run_didc_command_for_ii_init() {
336+
local SUBCOMMAND="$1"
337+
shift
338+
local ARGS=("$@")
339+
local OPTS="-d ./src/internet_identity/internet_identity.did -t '(opt InternetIdentityInit)'"
340+
didc "$SUBCOMMAND" $OPTS "${ARGS[@]}"
341+
}
342+
343+
didc_encode_ii_init() {
344+
local ARG_FILE="$1"
345+
local ARG="$(cat "$ARG_FILE")"
346+
run_didc_command_for_ii_init encode "$ARG"
347+
}
348+
349+
didc_assist_ii_init() {
350+
run_didc_command_for_ii_init assist | awk '/\(/ {flag=1} flag {print} /\)/ {flag=0}'
351+
}
352+
353+
compute_sha256sum_for_args() {
354+
local ARG_FILE="$1"
355+
didc_encode_ii_init "$ARG_FILE" | xxd -r -p | sha256sum | cut -f1 -d' '
333356
}
334357

335358
prepare_proposal_argument() {
336359
echo "You need at least the didc from 2024-07-29 https://github.com/dfinity/candid/releases/tag/2024-07-29"
337-
didc assist -d ./src/internet_identity/internet_identity.did -t '(opt InternetIdentityInit)' | awk '/\(/ {flag=1} flag {print} /\)/ {flag=0}' > args.txt
338-
didc encode -d ./src/internet_identity/internet_identity.did -t '(opt InternetIdentityInit)' "$(cat args.txt)" > dfx_arg.bin
339-
cat dfx_arg.bin | xxd -r -p > arg.bin
360+
didc_assist_ii_init > args.txt
361+
didc_encode_ii_init args.txt > dfx_arg.bin
362+
# DFX raw arguments are are encoded differently that ic-admin's --arg values (mainnet_arg.bin).
363+
xxd -r -p dfx_arg.bin > mainnet_arg.bin
340364
}
341365

342366
append_proposal_argument() {
343367
# Get the arguments from the file
344-
ARGUMENTS=$(cat "args.txt")
368+
ARGUMENTS="$(cat args.txt)"
345369

346370
cat >> proposal.md << EOF
347371
@@ -350,7 +374,7 @@ append_proposal_argument() {
350374
Run the following command to verify the upgrade argument hash:
351375
352376
\`\`\`
353-
didc encode '${ARGUMENTS}' | xxd -r -p | sha256sum
377+
didc encode -d ./src/internet_identity/internet_identity.did -t '(opt InternetIdentityInit)' '${ARGUMENTS}' | xxd -r -p | sha256sum
354378
\`\`\`
355379
356380
The output should match the argument hash.
@@ -364,8 +388,7 @@ download_proposal_text() {
364388
dry_run_proposal() {
365389
# Download again the release tag wasm to check the hash along the latest downloaded before.
366390
curl -sSL https://github.com/dfinity/internet-identity/releases/download/$TAG_NAME/internet_identity_production.wasm.gz -o internet_identity-$TAG_NAME.wasm.gz
367-
# Read again the arguments to check the hash along the arg.bin file sent in the proposal.
368-
ARGUMENTS=$(cat "args.txt")
391+
# Read again the arguments to check the hash along the mainnet_arg.bin file sent in the proposal.
369392
ic-admin \
370393
--use-hsm \
371394
--key-id "01" \
@@ -378,8 +401,8 @@ dry_run_proposal() {
378401
--mode upgrade \
379402
--wasm-module-path ./internet_identity.wasm.gz \
380403
--wasm-module-sha256 "$(sha256 internet_identity-$TAG_NAME.wasm.gz)" \
381-
--arg arg.bin \
382-
--arg-sha256 "$(didc encode "$ARGUMENTS" | xxd -r -p | sha256sum | cut -f1 -d' ')" \
404+
--arg mainnet_arg.bin \
405+
--arg-sha256 "$(compute_sha256sum_for_args args.txt)" \
383406
--dry-run \
384407
--summary-file ./proposal.md \
385408
--proposal-title "Upgrade Internet Identity Canister to $(git rev-parse --short HEAD)"
@@ -388,8 +411,7 @@ dry_run_proposal() {
388411
make_proposal() {
389412
# Download again the release tag wasm to check the hash along the latest downloaded before.
390413
curl -sSL https://github.com/dfinity/internet-identity/releases/download/$TAG_NAME/internet_identity_production.wasm.gz -o internet_identity-$TAG_NAME.wasm.gz
391-
# Read again the arguments to check the hash along the arg.bin file sent in the proposal.
392-
ARGUMENTS=$(cat "args.txt")
414+
# Read again the arguments to check the hash along the mainnet_arg.bin file sent in the proposal.
393415
ic-admin \
394416
--use-hsm \
395417
--key-id "01" \
@@ -402,8 +424,8 @@ make_proposal() {
402424
--mode upgrade \
403425
--wasm-module-path ./internet_identity.wasm.gz \
404426
--wasm-module-sha256 "$(sha256 internet_identity-$TAG_NAME.wasm.gz)" \
405-
--arg arg.bin \
406-
--arg-sha256 "$(didc encode "$ARGUMENTS" | xxd -r -p | sha256sum | cut -f1 -d' ')" \
427+
--arg mainnet_arg.bin \
428+
--arg-sha256 "$(compute_sha256sum_for_args args.txt)" \
407429
--summary-file ./proposal.md \
408430
--proposal-title "Upgrade Internet Identity Canister to $(git rev-parse --short HEAD)"
409431
}

0 commit comments

Comments
 (0)