diff --git a/rust/kona/.gitignore b/rust/kona/.gitignore index f6ffc3e47b1..3f6cb754672 100644 --- a/rust/kona/.gitignore +++ b/rust/kona/.gitignore @@ -30,6 +30,7 @@ jwt.hex # FPVM artifacts state.bin.gz +out.bin.gz meta.json out.json diff --git a/rust/kona/bin/client/justfile b/rust/kona/bin/client/justfile index 2e20de632d8..0fb9268bbe2 100644 --- a/rust/kona/bin/client/justfile +++ b/rust/kona/bin/client/justfile @@ -175,6 +175,7 @@ run-client-cannon block_number l1_rpc l1_beacon_rpc l2_rpc rollup_node_rpc rollu HOST_BIN_PATH="{{KONA_CLIENT_ROOT}}/../../../target/release/kona-host" CLIENT_BIN_PATH="{{KONA_CLIENT_ROOT}}/../../../target/mips64-unknown-none/release-client-lto/kona-client" STATE_PATH="{{KONA_CLIENT_ROOT}}/../../state.bin.gz" + FINAL_STATE_PATH="{{KONA_CLIENT_ROOT}}/../../out.bin.gz" L1_NODE_ADDRESS="{{l1_rpc}}" L1_BEACON_ADDRESS="{{l1_beacon_rpc}}" @@ -217,6 +218,7 @@ run-client-cannon block_number l1_rpc l1_beacon_rpc l2_rpc rollup_node_rpc rollu --info-at '%10000000' \ --proof-at never \ --input $STATE_PATH \ + --output $FINAL_STATE_PATH \ -- \ $HOST_BIN_PATH \ single \ @@ -233,6 +235,8 @@ run-client-cannon block_number l1_rpc l1_beacon_rpc l2_rpc rollup_node_rpc rollu --data-dir ./data \ {{verbosity}} + {{KONA_CLIENT_ROOT}}/scripts/require-cannon-success.sh "$FINAL_STATE_PATH" + # Fetch the offline witness tar from chain-test-data and decompress it into # rust/kona/data. Etag caching in `scripts/fetch-witness-tar.sh` keeps repeat # invocations cheap. @@ -251,10 +255,12 @@ prepare-witness-data witness_tar witness_tar_url: # the `witness_tar` / `witness_tar_url` defaults. run-client-cannon-offline block_number l2_claim l2_output_root l2_head l1_head l2_chain_id witness_tar='op-sepolia-47600000-witness.tar.zst' witness_tar_url='https://github.com/ethereum-optimism/chain-test-data/releases/download/kona-2026-08-13-op-sepolia-47600000-v2' verbosity='': (prepare-witness-data witness_tar witness_tar_url) #!/usr/bin/env bash + set -o errexit -o nounset -o pipefail HOST_BIN_PATH="{{KONA_CLIENT_ROOT}}/../../../target/debug/kona-host" CLIENT_BIN_PATH="{{KONA_CLIENT_ROOT}}/../../../target/mips64-unknown-none/release-client-lto/kona-client" STATE_PATH="{{KONA_CLIENT_ROOT}}/../../state.bin.gz" + FINAL_STATE_PATH="{{KONA_CLIENT_ROOT}}/../../out.bin.gz" CLAIMED_L2_BLOCK_NUMBER={{block_number}} CLAIMED_L2_OUTPUT_ROOT={{l2_claim}} @@ -280,6 +286,7 @@ run-client-cannon-offline block_number l2_claim l2_output_root l2_head l1_head l --info-at '%10000000' \ --proof-at never \ --input $STATE_PATH \ + --output $FINAL_STATE_PATH \ -- \ $HOST_BIN_PATH \ single \ @@ -292,3 +299,5 @@ run-client-cannon-offline block_number l2_claim l2_output_root l2_head l1_head l --server \ --data-dir ./data \ {{verbosity}} + + {{KONA_CLIENT_ROOT}}/scripts/require-cannon-success.sh "$FINAL_STATE_PATH" diff --git a/rust/kona/bin/client/scripts/fetch-witness-tar.sh b/rust/kona/bin/client/scripts/fetch-witness-tar.sh index aa8186278bd..3e588aab198 100755 --- a/rust/kona/bin/client/scripts/fetch-witness-tar.sh +++ b/rust/kona/bin/client/scripts/fetch-witness-tar.sh @@ -21,5 +21,10 @@ TAR_PATH="${TESTDATA_DIR}/${TAR_NAME}" ETAG_PATH="${TESTDATA_DIR}/${TAR_NAME}.etag" mkdir -p "${TESTDATA_DIR}" +# An etag without its tar would make the server answer 304 with no body and +# leave no tar to extract. +if [[ ! -f "${TAR_PATH}" ]]; then rm -f "${ETAG_PATH}"; fi +# No --retry-delay: it replaces curl's exponential backoff (1, 2, 4, 8, 16 s) +# with a fixed wait, which a longer release-CDN or redirect failure outlasts. curl --etag-save "${ETAG_PATH}" --etag-compare "${ETAG_PATH}" \ - -L --fail -o "${TAR_PATH}" "${URL}" + -L --fail --retry 5 --retry-all-errors -o "${TAR_PATH}" "${URL}" diff --git a/rust/kona/bin/client/scripts/require-cannon-success.sh b/rust/kona/bin/client/scripts/require-cannon-success.sh new file mode 100755 index 00000000000..31e3fc8f051 --- /dev/null +++ b/rust/kona/bin/client/scripts/require-cannon-success.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# Fail unless the program in a final Cannon state exited with code 0. +# +# `cannon run` exits 0 whatever the program's exit code is. The client rejects +# an invalid claim by exiting non-zero, so that result is visible only in the +# final state. +# +# Usage: require-cannon-success.sh +# +# Requires `cannon` and `jq` on PATH. +set -o errexit -o nounset -o pipefail + +FINAL_STATE="${1?Must specify the final Cannon state written by cannon run --output}" + +STATUS=$(cannon witness --input "${FINAL_STATE}" | jq -r '"\(.exited) \(.exitCode)"') +if [[ "${STATUS}" != "true 0" ]]; then + echo "error: the client did not exit with code 0 in Cannon (exited, exit code: ${STATUS})" >&2 + exit 1 +fi +echo "The client exited with code 0 in Cannon."