Skip to content

Commit

Permalink
feat(workspace): Isolate FPVM-specific platform code (op-rs#821)
Browse files Browse the repository at this point in the history
* feat(workspace): Isolate FPVM-specific platform code

* rebase

* lint

* feat(host): Run client program natively in process (op-rs#836)

* feat(host): Run client program natively

* lint

* rebase

* fix

* monorepo update

* lint
  • Loading branch information
clabby authored Nov 26, 2024
1 parent 657d313 commit 05915c3
Show file tree
Hide file tree
Showing 60 changed files with 822 additions and 1,018 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/client_host.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Build `asterisc`
if: "!contains(matrix.target, 'native')"
run: |
cd asterisc && git checkout v1.1.0 && make build-rvgo
cd asterisc && git checkout v1.1.2 && make build-rvgo
mv ./rvgo/bin/asterisc /usr/local/bin/
- name: Set run environment
run: |
Expand Down
2 changes: 1 addition & 1 deletion .monorepo
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2fecdde0d8ee5ef549a80ff47c679961dc82e4f9
e52030dba4d6130874f80e80900961c342c8c074
129 changes: 73 additions & 56 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ lto = "fat"
[workspace.dependencies]
# Workspace
kona-mpt = { path = "crates/mpt", version = "0.1.0", default-features = false }
kona-client = { path = "bin/client", version = "0.1.0", default-features = false }
kona-derive = { path = "crates/derive", version = "0.1.0", default-features = false }
kona-driver = { path = "crates/driver", version = "0.1.0", default-features = false }
kona-executor = { path = "crates/executor", version = "0.1.0", default-features = false }
kona-proof = { path = "crates/proof-sdk/proof", version = "0.1.0", default-features = false }
kona-common = { path = "crates/proof-sdk/common", version = "0.1.0", default-features = false }
kona-client = { path = "bin/client", version = "0.1.0", default-features = false }
kona-std-fpvm = { path = "crates/proof-sdk/std-fpvm", version = "0.1.0", default-features = false }
kona-std-fpvm-proc = { path = "crates/proof-sdk/std-fpvm-proc", version = "0.1.0", default-features = false }
kona-preimage = { path = "crates/proof-sdk/preimage", version = "0.1.0", default-features = false }
kona-common-proc = { path = "crates/proof-sdk/common-proc", version = "0.1.0", default-features = false }
kona-proof = { path = "crates/proof-sdk/proof", version = "0.1.0", default-features = false }

# Alloy
alloy-rlp = { version = "0.3.9", default-features = false }
Expand Down Expand Up @@ -101,18 +101,16 @@ spin = "0.9.8"
rand = "0.8.5"
clap = "4.5.19"
tokio = "1.40.0"
async-channel = "2.3.1"
cfg-if = "1.0.0"
os_pipe = "1.2.1"
reqwest = "0.12.8"
command-fds = "0.3.0"
async-trait = "0.1.83"
linked_list_allocator = "0.10.5"

# General
sha2 = { version = "0.10.8", default-features = false }
c-kzg = { version = "1.0.3", default-features = false }
anyhow = { version = "1.0.89", default-features = false }
futures = { version = "0.3.30", default-features = false }
thiserror = { version = "2.0", default-features = false }

# Tracing
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ see the [SDK section of the book](https://anton-rs.github.io/kona/sdk/intro.html

**Proof SDK**

- [`common`](./crates/proof-sdk/common): A suite of utilities for developing `client` programs to be run on top of Fault Proof VMs.
- [`common-proc`](./crates/proof-sdk/common-proc): Proc macro for the `client` program entrypoint.
- [`preimage`](./crates/proof-sdk/preimage): High level interfaces to the [`PreimageOracle`][fpp-specs] ABI
- [`kona-proof`](./crates/proof-sdk/proof): High level OP Stack state transition proof SDK.
- [`preimage`](./crates/proof-sdk/preimage): High level interfaces to the [`PreimageOracle`][fpp-specs] ABI.
- [`std-fpvm`](./crates/proof-sdk/std-fpvm): Platform specific [Fault Proof VM][g-fault-proof-vm] kernel APIs.
- [`std-fpvm-proc`](./crates/proof-sdk/std-fpvm-proc): Proc macro for [Fault Proof Program][fpp-specs] entrypoints.

## Book

Expand Down
10 changes: 4 additions & 6 deletions bin/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ repository.workspace = true
[dependencies]
# Workspace
kona-mpt.workspace = true
kona-common.workspace = true
kona-derive.workspace = true
kona-driver.workspace = true
kona-preimage.workspace = true
kona-executor.workspace = true
kona-common-proc.workspace = true
kona-proof.workspace = true
kona-std-fpvm.workspace = true
kona-std-fpvm-proc.workspace = true

# Alloy
alloy-rlp.workspace = true
Expand Down Expand Up @@ -45,11 +45,9 @@ serde_json.workspace = true
async-trait.workspace = true
thiserror.workspace = true

# `tracing-subscriber` feature dependencies
tracing-subscriber = { workspace = true, optional = true, features = ["fmt"] }

[features]
tracing-subscriber = ["dep:tracing-subscriber"]
default = ["client-tracing"]
client-tracing = ["kona-std-fpvm/tracing"]

[[bin]]
name = "kona"
Expand Down
20 changes: 6 additions & 14 deletions bin/client/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ run-client-asterisc block_number l1_rpc l1_beacon_rpc l2_rpc rollup_node_rpc ver

# Get the info for the previous block
AGREED_L2_OUTPUT_ROOT=$(cast rpc --rpc-url $OP_NODE_ADDRESS "optimism_outputAtBlock" $(cast 2h $((CLAIMED_L2_BLOCK_NUMBER - 1))) | jq -r .outputRoot)
AGREED_L2_HEAD_HASH=$(cast block --rpc-url $L2_NODE_ADDRESS $((CLAIMED_L2_BLOCK_NUMBER - 1)) -j | jq -r .hash)
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)) -j | jq -r .hash)
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
Expand Down Expand Up @@ -79,18 +79,14 @@ run-client-native block_number l1_rpc l1_beacon_rpc l2_rpc rollup_node_rpc verbo

# Get the info for the previous block
AGREED_L2_OUTPUT_ROOT=$(cast rpc --rpc-url $OP_NODE_ADDRESS "optimism_outputAtBlock" $(cast 2h $((CLAIMED_L2_BLOCK_NUMBER - 1))) | jq -r .outputRoot)
AGREED_L2_HEAD_HASH=$(cast block --rpc-url $L2_NODE_ADDRESS $((CLAIMED_L2_BLOCK_NUMBER - 1)) -j | jq -r .hash)
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)) -j | jq -r .hash)
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)

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 --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 \
Expand All @@ -102,16 +98,14 @@ run-client-native block_number l1_rpc l1_beacon_rpc l2_rpc rollup_node_rpc verbo
--l1-node-address $L1_NODE_ADDRESS \
--l1-beacon-address $L1_BEACON_ADDRESS \
--l2-node-address $L2_NODE_ADDRESS \
--exec $CLIENT_BIN_PATH \
--native \
--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"

CLAIMED_L2_BLOCK_NUMBER={{block_number}}
CLAIMED_L2_OUTPUT_ROOT={{l2_claim}}
AGREED_L2_OUTPUT_ROOT={{l2_output_root}}
Expand All @@ -122,8 +116,6 @@ run-client-native-offline block_number l2_claim l2_output_root l2_head l1_head l
# 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 \
Expand All @@ -132,7 +124,7 @@ run-client-native-offline block_number l2_claim l2_output_root l2_head l1_head l
--agreed-l2-output-root $AGREED_L2_OUTPUT_ROOT \
--claimed-l2-block-number $CLAIMED_L2_BLOCK_NUMBER \
--l2-chain-id $L2_CHAIN_ID \
--exec $CLIENT_BIN_PATH \
--native \
--data-dir ./data \
{{verbosity}}

Expand Down
Loading

0 comments on commit 05915c3

Please sign in to comment.