Skip to content

Commit

Permalink
tooling: make client justfile's commands take an optional rollup_conf…
Browse files Browse the repository at this point in the history
…ig_path

Needed to target a devnet which doesnt have a standard chain_id
  • Loading branch information
samlaf committed Dec 11, 2024
1 parent de7c531 commit 983319b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ monorepo/

# Environment Variables
.env

# kona-host data-dir
data/
13 changes: 10 additions & 3 deletions bin/client/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,22 @@ run-client-asterisc block_number l1_rpc l1_beacon_rpc l2_rpc rollup_node_rpc ver
{{verbosity}}

# Run the client program natively with the host program attached.
run-client-native block_number l1_rpc l1_beacon_rpc l2_rpc rollup_node_rpc verbosity='':
run-client-native block_number l1_rpc l1_beacon_rpc l2_rpc rollup_node_rpc rollup_config_path='' verbosity='':
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
L1_NODE_ADDRESS="{{l1_rpc}}"
L1_BEACON_ADDRESS="{{l1_beacon_rpc}}"
L2_NODE_ADDRESS="{{l2_rpc}}"
OP_NODE_ADDRESS="{{rollup_node_rpc}}"

L2_CHAIN_ID=$(cast chain-id --rpc-url $L2_NODE_ADDRESS)
if [ -z "{{rollup_config_path}}" ]; then
CHAIN_ID_OR_ROLLUP_CONFIG_ARG="--l2-chain-id $L2_CHAIN_ID"
else
CHAIN_ID_OR_ROLLUP_CONFIG_ARG="--rollup-config-path $(realpath {{rollup_config_path}})"
fi

CLAIMED_L2_BLOCK_NUMBER={{block_number}}
echo "Fetching configuration for block #$CLAIMED_L2_BLOCK_NUMBER..."

Expand All @@ -82,7 +90,6 @@ run-client-native block_number l1_rpc l1_beacon_rpc l2_rpc rollup_node_rpc verbo
AGREED_L2_HEAD_HASH=$(cast block --rpc-url $L2_NODE_ADDRESS $((CLAIMED_L2_BLOCK_NUMBER - 1)) --json | jq -r .hash)
L1_ORIGIN_NUM=$(cast rpc --rpc-url $OP_NODE_ADDRESS "optimism_outputAtBlock" $(cast 2h $((CLAIMED_L2_BLOCK_NUMBER - 1))) | jq -r .blockRef.l1origin.number)
L1_HEAD=$(cast block --rpc-url $L1_NODE_ADDRESS $((L1_ORIGIN_NUM + 30)) --json | jq -r .hash)
L2_CHAIN_ID=$(cast chain-id --rpc-url $L2_NODE_ADDRESS)

# Move to the workspace root
cd $(git rev-parse --show-toplevel)
Expand All @@ -94,12 +101,12 @@ run-client-native block_number l1_rpc l1_beacon_rpc l2_rpc rollup_node_rpc verbo
--claimed-l2-output-root $CLAIMED_L2_OUTPUT_ROOT \
--agreed-l2-output-root $AGREED_L2_OUTPUT_ROOT \
--claimed-l2-block-number $CLAIMED_L2_BLOCK_NUMBER \
--l2-chain-id $L2_CHAIN_ID \
--l1-node-address $L1_NODE_ADDRESS \
--l1-beacon-address $L1_BEACON_ADDRESS \
--l2-node-address $L2_NODE_ADDRESS \
--native \
--data-dir ./data \
$CHAIN_ID_OR_ROLLUP_CONFIG_ARG \
{{verbosity}}

# Run the client program natively with the host program attached, in offline mode.
Expand Down

0 comments on commit 983319b

Please sign in to comment.