Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(client): Add justfile for running client program #283

Merged
merged 1 commit into from
Jun 19, 2024
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
22 changes: 5 additions & 17 deletions bin/host/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ use tokio::sync::RwLock;
mod parser;
pub(crate) use parser::parse_b256;

mod types;
pub(crate) use types::Network;

mod tracing_util;
pub(crate) use tracing_util::init_tracing_subscriber;

Expand All @@ -25,18 +22,6 @@ pub struct HostCli {
/// Verbosity level (0-4)
#[arg(long, short, help = "Verbosity level (0-4)", action = ArgAction::Count)]
pub v: u8,
/// The rollup chain parameters
#[clap(long)]
pub rollup_config: PathBuf,
/// Predefined network selection.
#[clap(long)]
pub network: Network,
/// The Data Directory for preimage data storage. Default uses in-memory storage.
#[clap(long)]
pub data_dir: Option<PathBuf>,
/// Address of L2 JSON-RPC endpoint to use (eth and debug namespace required).
#[clap(long)]
pub l2_node_address: Option<String>,
/// Hash of the L1 head block. Derivation stops after this block is processed.
#[clap(long, value_parser = parse_b256)]
pub l1_head: B256,
Expand All @@ -55,15 +40,18 @@ pub struct HostCli {
/// The L2 chain ID.
#[clap(long)]
pub l2_chain_id: u64,
//// Path to the genesis file.
/// Address of L2 JSON-RPC endpoint to use (eth and debug namespace required).
#[clap(long)]
pub l2_genesis_path: PathBuf,
pub l2_node_address: Option<String>,
/// Address of L1 JSON-RPC endpoint to use (eth namespace required)
#[clap(long)]
pub l1_node_address: Option<String>,
/// Address of the L1 Beacon API endpoint to use.
#[clap(long)]
pub l1_beacon_address: Option<String>,
/// The Data Directory for preimage data storage. Default uses in-memory storage.
#[clap(long)]
pub data_dir: Option<PathBuf>,
/// Run the specified client program as a separate process detached from the host. Default is
/// to run the client program in the host process.
#[clap(long)]
Expand Down
11 changes: 0 additions & 11 deletions bin/host/src/cli/types.rs

This file was deleted.

93 changes: 68 additions & 25 deletions bin/programs/client/justfile
Original file line number Diff line number Diff line change
@@ -1,45 +1,88 @@
set fallback := true

# Alter inputs as needed
L1_HEAD := "0x99a606fd807b1d4de3b0e875e8999eca8b658144e8bf17fc1d5b35a18edad4c5"
L2_HEAD := "0xa88ff85df4148ae174122d7e3637d5044ff08faff4aee1d8295b59df6e752f6b"
L2_OUTPUT_ROOT := "0x436e677d6ead4a915be25462eba837d287efcfa14aab8aa0b7dae49f7ff21f67"
L2_CLAIM := "0xff57b5ecc49aea302259672f8a3ec7634ef4b9970bf54798de4f265768015796"
L2_BLOCK_NUMBER := "121449098"
L2_CHAIN_ID := "10"

# default recipe to display help information
default:
@just --list

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

# TODO: These configuration values are currently mocked. Once they're consumed,
# update this to offer default run or optionally alter by pre-setting them.
ROLLUP_CONFIG_PATH="x"
L2_GENESIS_PATH="x"
L1_HEAD=$(cast 2b 0)
L2_HEAD=$(cast 2b 0)
L2_OUTPUT_ROOT=$(cast 2b 0)
L2_CLAIM=$(cast 2b 0)
L2_BLOCK_NUMBER=0
L2_CHAIN_ID=10
L1_NODE_ADDRESS="{{l1_rpc}}"
L1_BEACON_ADDRESS="{{l1_beacon_rpc}}"
L2_NODE_ADDRESS="{{l2_rpc}}"

HOST_BIN_PATH="./target/release/kona-host"
CLIENT_BIN_PATH="./target/riscv64gc-unknown-none-elf/release-client-lto/kona"
STATE_PATH="./state.json"

# Move to the workspace root
cd $(git rev-parse --show-toplevel)

echo "Building client program for RISC-V target..."
just build-asterisc --bin kona --profile release-client-lto

echo "Loading client program into Asterisc state format..."
asterisc load-elf --path=$CLIENT_BIN_PATH

echo "Building host program for native target..."
cargo build --bin kona-host --release

echo "Running asterisc"
asterisc run \
--info-at '%10000000' \
--proof-at never \
--input $STATE_PATH \
-- \
$HOST_BIN_PATH \
--l1-head {{L1_HEAD}} \
--l2-head {{L2_HEAD}} \
--l2-claim {{L2_CLAIM}} \
--l2-output-root {{L2_OUTPUT_ROOT}} \
--l2-block-number {{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 \
--server \
--data-dir ./data \
--exec "" \
{{verbosity}}

# Run the client program natively with the host program attached.
run-client-native l1_rpc l1_beacon_rpc l2_rpc verbosity:
#!/usr/bin/env bash

L1_NODE_ADDRESS="{{l1_rpc}}"
L1_BEACON_ADDRESS="{{l1_beacon_rpc}}"
L2_NODE_ADDRESS="{{l2_rpc}}"

CLIENT_BIN_PATH="./target/release-client-lto/kona-client"
CLIENT_BIN_PATH="./target/release-client-lto/kona"

# Move to the workspace root
cd $(git rev-parse --show-toplevel)

echo "Building client program..."
cargo build --bin kona-client --profile release-client-lto
cargo build --bin kona --profile release-client-lto --features tracing-subscriber
echo "Running host program with native client program..."
(cd ../../.. && cargo r --bin kona-host --release -- \
--rollup-config $ROLLUP_CONFIG_PATH \
--network optimism \
--l2-genesis-path $L2_GENESIS_PATH \
--l1-head $L1_HEAD \
--l2-head $L2_HEAD \
--l2-claim $L2_CLAIM \
--l2-output-root $L2_OUTPUT_ROOT \
--l2-block-number $L2_BLOCK_NUMBER \
--l2-chain-id $L2_CHAIN_ID \
cargo r --bin kona-host --release -- \
--l1-head {{L1_HEAD}} \
--l2-head {{L2_HEAD}} \
--l2-claim {{L2_CLAIM}} \
--l2-output-root {{L2_OUTPUT_ROOT}} \
--l2-block-number {{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 \
--exec $CLIENT_BIN_PATH \
{{verbosity}})
--data-dir ./data \
{{verbosity}}
Loading