Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rust/kona/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jwt.hex

# FPVM artifacts
state.bin.gz
out.bin.gz
Comment thread
teddyknox marked this conversation as resolved.
Resolved
meta.json
out.json

Expand Down
9 changes: 9 additions & 0 deletions rust/kona/bin/client/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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}}"
Expand Down Expand Up @@ -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 \
Expand All @@ -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.
Expand All @@ -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}}
Expand All @@ -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 \
Expand All @@ -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"
7 changes: 6 additions & 1 deletion rust/kona/bin/client/scripts/fetch-witness-tar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
20 changes: 20 additions & 0 deletions rust/kona/bin/client/scripts/require-cannon-success.sh
Original file line number Diff line number Diff line change
@@ -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 <final_state.bin.gz>
#
# 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."
Loading