Skip to content

Commit

Permalink
feat(ci): Run Host + Client natively in offline mode
Browse files Browse the repository at this point in the history
Adds a few jobs to CI to run the host + client program against known
witness data in offline mode, over both the Ecotone and Fjord hardfork.
  • Loading branch information
clabby committed Jul 1, 2024
1 parent 8915dcd commit 58e5bb6
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 26 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/client_host.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Client + Host
on:
push:
branches: [main]
merge_group:
pull_request:
env:
CARGO_TERM_COLOR: always
jobs:
host-client-offline-runs:
name: ${{ matrix.name }}
strategy:
matrix:
name:
[
"OP Mainnet (Ecotone) - Block #122093770",
"OP Sepolia (Fjord) - Block #13992475",
]
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout sources
uses: actions/checkout@v4
- uses: taiki-e/install-action@just
- name: Install Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Set environment
run: |
if [[ ${{ contains(matrix.name, 122093770) }} == true ]]; then
BLOCK_NUMBER=122093770
echo "BLOCK_NUMBER=$BLOCK_NUMBER" >> $GITHUB_ENV
echo "L2_CLAIM=0xf31619aa7cdf03e6e51bb5eda528309eff0354172c4a64186622929c76bd58a9" >> $GITHUB_ENV
echo "L2_OUTPUT_ROOT=0xec52f62123ab0404c1729fbb34716046cffaba6c47836b353184e231e290c560" >> $GITHUB_ENV
echo "L2_HEAD=0xd20e2cad399a964c7bb656c8d32a6e5356a831167cc58a00e60285abf7e94df6" >> $GITHUB_ENV
echo "L1_HEAD=0xed32f3f6cdf80c1d755851ad065f4436ff17ff35b7910262f0d22c1e0919a315" >> $GITHUB_ENV
echo "L2_CHAIN_ID=10" >> $GITHUB_ENV
echo "WITNESS_TAR_NAME=ecotone-op-mainnet-$BLOCK_NUMBER-witness.tar.zst" >> $GITHUB_ENV
elif [[ ${{ contains(matrix.name, 13992475) }} == true ]]; then
BLOCK_NUMBER=13992475
echo "BLOCK_NUMBER=$BLOCK_NUMBER" >> $GITHUB_ENV
echo "L2_CLAIM=0xba854e0a3e1e65f8e4b05f39a5ad28c13eac0d5444c7c336b6f7ebabb0f20229" >> $GITHUB_ENV
echo "L2_OUTPUT_ROOT=0x59cfca741f06a0e5607e3526e4f9931b8a6a2313b48d8bd0c2242bace6d930f1" >> $GITHUB_ENV
echo "L2_HEAD=0x90ec80845a776021ce56b3e87072e8e30d2931c9c67ccaf2a305bd08268178ee" >> $GITHUB_ENV
echo "L1_HEAD=0x607b4a4d2bd7e7bced989e4bc471a5ce61335b63881c624c8522f63113a5af86" >> $GITHUB_ENV
echo "L2_CHAIN_ID=11155420" >> $GITHUB_ENV
echo "WITNESS_TAR_NAME=fjord-op-sepolia-$BLOCK_NUMBER-witness.tar.zst" >> $GITHUB_ENV
fi
- name: Decompress witness data directory
working-directory: .
run: |
tar --zstd -xvf ./bin/client/testdata/$WITNESS_TAR_NAME -C .
- name: Run host + client offline
working-directory: ./bin/client
run: |
just run-client-native-offline \
$BLOCK_NUMBER \
$L2_CLAIM \
$L2_OUTPUT_ROOT \
$L2_HEAD \
$L1_HEAD \
$L2_CHAIN_ID \
-vv
30 changes: 30 additions & 0 deletions bin/client/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,33 @@ run-client-native block_number l1_rpc l1_beacon_rpc l2_rpc rollup_node_rpc verbo
--exec $CLIENT_BIN_PATH \
--data-dir ./data \
{{verbosity}}

# Run the client program natively with the host program attached, in offline mode.
run-client-native-offline block_number l2_claim l2_output_root l2_head l1_head l2_chain_id verbosity:
#!/usr/bin/env bash
CLIENT_BIN_PATH="./target/release-client-lto/kona"

L2_BLOCK_NUMBER={{block_number}}
L2_CLAIM={{l2_claim}}
L2_OUTPUT_ROOT={{l2_output_root}}
L2_HEAD={{l2_head}}
L1_HEAD={{l1_head}}
L2_CHAIN_ID={{l2_chain_id}}

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

echo "Building client program..."
cargo build --bin kona --profile release-client-lto --features tracing-subscriber
echo "Running host program with native client program..."
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 \
--exec $CLIENT_BIN_PATH \
--data-dir ./data \
{{verbosity}}
Binary file not shown.
Binary file not shown.
54 changes: 28 additions & 26 deletions bin/host/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,27 @@ async fn start_server(cfg: HostCli) -> Result<()> {

let kv_store = cfg.construct_kv_store();

let beacon_client = OnlineBeaconClient::new_http(
cfg.l1_beacon_address.clone().expect("Beacon API URL must be set"),
);
let mut blob_provider = OnlineBlobProvider::new(beacon_client, None, None);
blob_provider
.load_configs()
.await
.map_err(|e| anyhow!("Failed to load blob provider configuration: {e}"))?;

let fetcher = (!cfg.is_offline()).then(|| {
let fetcher = if !cfg.is_offline() {
let beacon_client = OnlineBeaconClient::new_http(
cfg.l1_beacon_address.clone().expect("Beacon API URL must be set"),
);
let mut blob_provider = OnlineBlobProvider::new(beacon_client, None, None);
blob_provider
.load_configs()
.await
.map_err(|e| anyhow!("Failed to load blob provider configuration: {e}"))?;
let l1_provider = util::http_provider(&cfg.l1_node_address.expect("Provider must be set"));
let l2_provider = util::http_provider(&cfg.l2_node_address.expect("Provider must be set"));
Arc::new(RwLock::new(Fetcher::new(
Some(Arc::new(RwLock::new(Fetcher::new(
kv_store.clone(),
l1_provider,
blob_provider,
l2_provider,
cfg.l2_head,
)))
});
))))
} else {
None
};

// Start the server and wait for it to complete.
info!("Starting preimage server.");
Expand All @@ -96,28 +97,29 @@ async fn start_server_and_native_client(cfg: HostCli) -> Result<()> {
let (preimage_pipe, hint_pipe, files) = util::create_native_pipes()?;
let kv_store = cfg.construct_kv_store();

let beacon_client = OnlineBeaconClient::new_http(
cfg.l1_beacon_address.clone().expect("Beacon API URL must be set"),
);
let mut blob_provider = OnlineBlobProvider::new(beacon_client, None, None);
blob_provider
.load_configs()
.await
.map_err(|e| anyhow!("Failed to load blob provider configuration: {e}"))?;

let fetcher = (!cfg.is_offline()).then(|| {
let fetcher = if !cfg.is_offline() {
let beacon_client = OnlineBeaconClient::new_http(
cfg.l1_beacon_address.clone().expect("Beacon API URL must be set"),
);
let mut blob_provider = OnlineBlobProvider::new(beacon_client, None, None);
blob_provider
.load_configs()
.await
.map_err(|e| anyhow!("Failed to load blob provider configuration: {e}"))?;
let l1_provider =
util::http_provider(cfg.l1_node_address.as_ref().expect("Provider must be set"));
let l2_provider =
util::http_provider(cfg.l2_node_address.as_ref().expect("Provider must be set"));
Arc::new(RwLock::new(Fetcher::new(
Some(Arc::new(RwLock::new(Fetcher::new(
kv_store.clone(),
l1_provider,
blob_provider,
l2_provider,
cfg.l2_head,
)))
});
))))
} else {
None
};

// Create the server and start it.
let server_task =
Expand Down

0 comments on commit 58e5bb6

Please sign in to comment.