Skip to content

Commit 09d2813

Browse files
authored
chore(client): Add justfile for running client program (#283)
1 parent 4c400d0 commit 09d2813

File tree

3 files changed

+73
-53
lines changed

3 files changed

+73
-53
lines changed

bin/host/src/cli/mod.rs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ use tokio::sync::RwLock;
1313
mod parser;
1414
pub(crate) use parser::parse_b256;
1515

16-
mod types;
17-
pub(crate) use types::Network;
18-
1916
mod tracing_util;
2017
pub(crate) use tracing_util::init_tracing_subscriber;
2118

@@ -25,18 +22,6 @@ pub struct HostCli {
2522
/// Verbosity level (0-4)
2623
#[arg(long, short, help = "Verbosity level (0-4)", action = ArgAction::Count)]
2724
pub v: u8,
28-
/// The rollup chain parameters
29-
#[clap(long)]
30-
pub rollup_config: PathBuf,
31-
/// Predefined network selection.
32-
#[clap(long)]
33-
pub network: Network,
34-
/// The Data Directory for preimage data storage. Default uses in-memory storage.
35-
#[clap(long)]
36-
pub data_dir: Option<PathBuf>,
37-
/// Address of L2 JSON-RPC endpoint to use (eth and debug namespace required).
38-
#[clap(long)]
39-
pub l2_node_address: Option<String>,
4025
/// Hash of the L1 head block. Derivation stops after this block is processed.
4126
#[clap(long, value_parser = parse_b256)]
4227
pub l1_head: B256,
@@ -55,15 +40,18 @@ pub struct HostCli {
5540
/// The L2 chain ID.
5641
#[clap(long)]
5742
pub l2_chain_id: u64,
58-
//// Path to the genesis file.
43+
/// Address of L2 JSON-RPC endpoint to use (eth and debug namespace required).
5944
#[clap(long)]
60-
pub l2_genesis_path: PathBuf,
45+
pub l2_node_address: Option<String>,
6146
/// Address of L1 JSON-RPC endpoint to use (eth namespace required)
6247
#[clap(long)]
6348
pub l1_node_address: Option<String>,
6449
/// Address of the L1 Beacon API endpoint to use.
6550
#[clap(long)]
6651
pub l1_beacon_address: Option<String>,
52+
/// The Data Directory for preimage data storage. Default uses in-memory storage.
53+
#[clap(long)]
54+
pub data_dir: Option<PathBuf>,
6755
/// Run the specified client program as a separate process detached from the host. Default is
6856
/// to run the client program in the host process.
6957
#[clap(long)]

bin/host/src/cli/types.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.

bin/programs/client/justfile

Lines changed: 68 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,88 @@
11
set fallback := true
22

3+
# Alter inputs as needed
4+
L1_HEAD := "0x99a606fd807b1d4de3b0e875e8999eca8b658144e8bf17fc1d5b35a18edad4c5"
5+
L2_HEAD := "0xa88ff85df4148ae174122d7e3637d5044ff08faff4aee1d8295b59df6e752f6b"
6+
L2_OUTPUT_ROOT := "0x436e677d6ead4a915be25462eba837d287efcfa14aab8aa0b7dae49f7ff21f67"
7+
L2_CLAIM := "0xff57b5ecc49aea302259672f8a3ec7634ef4b9970bf54798de4f265768015796"
8+
L2_BLOCK_NUMBER := "121449098"
9+
L2_CHAIN_ID := "10"
10+
311
# default recipe to display help information
412
default:
513
@just --list
614

7-
# Run the client program natively with the hos
8-
run-client-native l1_rpc l1_beacon_rpc l2_rpc verbosity:
15+
# Run the client program on asterisc with the host in detached server mode.
16+
run-client-asterisc l1_rpc l1_beacon_rpc l2_rpc verbosity:
917
#!/usr/bin/env bash
1018

11-
# TODO: These configuration values are currently mocked. Once they're consumed,
12-
# update this to offer default run or optionally alter by pre-setting them.
13-
ROLLUP_CONFIG_PATH="x"
14-
L2_GENESIS_PATH="x"
15-
L1_HEAD=$(cast 2b 0)
16-
L2_HEAD=$(cast 2b 0)
17-
L2_OUTPUT_ROOT=$(cast 2b 0)
18-
L2_CLAIM=$(cast 2b 0)
19-
L2_BLOCK_NUMBER=0
20-
L2_CHAIN_ID=10
19+
L1_NODE_ADDRESS="{{l1_rpc}}"
20+
L1_BEACON_ADDRESS="{{l1_beacon_rpc}}"
21+
L2_NODE_ADDRESS="{{l2_rpc}}"
22+
23+
HOST_BIN_PATH="./target/release/kona-host"
24+
CLIENT_BIN_PATH="./target/riscv64gc-unknown-none-elf/release-client-lto/kona"
25+
STATE_PATH="./state.json"
26+
27+
# Move to the workspace root
28+
cd $(git rev-parse --show-toplevel)
29+
30+
echo "Building client program for RISC-V target..."
31+
just build-asterisc --bin kona --profile release-client-lto
32+
33+
echo "Loading client program into Asterisc state format..."
34+
asterisc load-elf --path=$CLIENT_BIN_PATH
35+
36+
echo "Building host program for native target..."
37+
cargo build --bin kona-host --release
38+
39+
echo "Running asterisc"
40+
asterisc run \
41+
--info-at '%10000000' \
42+
--proof-at never \
43+
--input $STATE_PATH \
44+
-- \
45+
$HOST_BIN_PATH \
46+
--l1-head {{L1_HEAD}} \
47+
--l2-head {{L2_HEAD}} \
48+
--l2-claim {{L2_CLAIM}} \
49+
--l2-output-root {{L2_OUTPUT_ROOT}} \
50+
--l2-block-number {{L2_BLOCK_NUMBER}} \
51+
--l2-chain-id {{L2_CHAIN_ID}} \
52+
--l1-node-address $L1_NODE_ADDRESS \
53+
--l1-beacon-address $L1_BEACON_ADDRESS \
54+
--l2-node-address $L2_NODE_ADDRESS \
55+
--server \
56+
--data-dir ./data \
57+
--exec "" \
58+
{{verbosity}}
59+
60+
# Run the client program natively with the host program attached.
61+
run-client-native l1_rpc l1_beacon_rpc l2_rpc verbosity:
62+
#!/usr/bin/env bash
2163

2264
L1_NODE_ADDRESS="{{l1_rpc}}"
2365
L1_BEACON_ADDRESS="{{l1_beacon_rpc}}"
2466
L2_NODE_ADDRESS="{{l2_rpc}}"
2567

26-
CLIENT_BIN_PATH="./target/release-client-lto/kona-client"
68+
CLIENT_BIN_PATH="./target/release-client-lto/kona"
69+
70+
# Move to the workspace root
71+
cd $(git rev-parse --show-toplevel)
2772

2873
echo "Building client program..."
29-
cargo build --bin kona-client --profile release-client-lto
74+
cargo build --bin kona --profile release-client-lto --features tracing-subscriber
3075
echo "Running host program with native client program..."
31-
(cd ../../.. && cargo r --bin kona-host --release -- \
32-
--rollup-config $ROLLUP_CONFIG_PATH \
33-
--network optimism \
34-
--l2-genesis-path $L2_GENESIS_PATH \
35-
--l1-head $L1_HEAD \
36-
--l2-head $L2_HEAD \
37-
--l2-claim $L2_CLAIM \
38-
--l2-output-root $L2_OUTPUT_ROOT \
39-
--l2-block-number $L2_BLOCK_NUMBER \
40-
--l2-chain-id $L2_CHAIN_ID \
76+
cargo r --bin kona-host --release -- \
77+
--l1-head {{L1_HEAD}} \
78+
--l2-head {{L2_HEAD}} \
79+
--l2-claim {{L2_CLAIM}} \
80+
--l2-output-root {{L2_OUTPUT_ROOT}} \
81+
--l2-block-number {{L2_BLOCK_NUMBER}} \
82+
--l2-chain-id {{L2_CHAIN_ID}} \
4183
--l1-node-address $L1_NODE_ADDRESS \
4284
--l1-beacon-address $L1_BEACON_ADDRESS \
4385
--l2-node-address $L2_NODE_ADDRESS \
4486
--exec $CLIENT_BIN_PATH \
45-
{{verbosity}})
87+
--data-dir ./data \
88+
{{verbosity}}

0 commit comments

Comments
 (0)