From f639744e183464b952ba4a12a336fb61fb7b68b6 Mon Sep 17 00:00:00 2001 From: refcell Date: Tue, 17 Sep 2024 09:41:25 -0400 Subject: [PATCH] feat: large dependency update (#528) --- Cargo.lock | 163 +++--- Cargo.toml | 32 +- bin/client/Cargo.toml | 2 + bin/client/src/boot.rs | 2 +- bin/client/src/l1/blob_provider.rs | 3 +- bin/client/src/l1/chain_provider.rs | 2 +- bin/client/src/l1/driver.rs | 3 +- bin/client/src/l2/chain_provider.rs | 6 +- bin/host/Cargo.toml | 2 + bin/host/src/cli/mod.rs | 2 +- bin/host/src/fetcher/mod.rs | 3 +- crates/derive/Cargo.toml | 9 +- crates/derive/src/batch/mod.rs | 3 +- crates/derive/src/batch/single_batch.rs | 20 +- crates/derive/src/batch/span_batch/batch.rs | 71 +-- crates/derive/src/batch/span_batch/mod.rs | 4 +- crates/derive/src/batch/span_batch/prefix.rs | 2 +- crates/derive/src/batch/span_batch/raw.rs | 2 +- crates/derive/src/errors.rs | 24 +- crates/derive/src/online/alloy_providers.rs | 10 +- crates/derive/src/online/blob_provider.rs | 4 +- crates/derive/src/online/mod.rs | 3 - crates/derive/src/online/pipeline.rs | 8 +- crates/derive/src/pipeline/builder.rs | 3 +- crates/derive/src/pipeline/core.rs | 4 +- crates/derive/src/pipeline/mod.rs | 3 - crates/derive/src/sources/blobs.rs | 3 +- crates/derive/src/sources/calldata.rs | 2 +- crates/derive/src/sources/ethereum.rs | 6 +- crates/derive/src/stages/attributes_queue.rs | 6 +- .../src/stages/attributes_queue/builder.rs | 55 +- .../src/stages/attributes_queue/deposits.rs | 4 +- crates/derive/src/stages/batch_queue.rs | 19 +- crates/derive/src/stages/channel_bank.rs | 9 +- crates/derive/src/stages/channel_reader.rs | 3 +- crates/derive/src/stages/frame_queue.rs | 5 +- crates/derive/src/stages/l1_retrieval.rs | 5 +- crates/derive/src/stages/l1_traversal.rs | 5 +- .../src/stages/test_utils/attributes_queue.rs | 7 +- .../src/stages/test_utils/batch_queue.rs | 3 +- .../src/stages/test_utils/channel_bank.rs | 3 +- .../src/stages/test_utils/channel_reader.rs | 3 +- .../src/stages/test_utils/frame_queue.rs | 3 +- .../stages/test_utils/sys_config_fetcher.rs | 4 +- crates/derive/src/traits/attributes.rs | 3 +- crates/derive/src/traits/data_sources.rs | 4 +- crates/derive/src/traits/pipeline.rs | 3 +- crates/derive/src/traits/providers.rs | 6 +- crates/derive/src/traits/reset.rs | 3 +- crates/derive/src/traits/stages.rs | 3 +- crates/derive/src/traits/test_utils.rs | 8 +- crates/executor/Cargo.toml | 1 + crates/executor/benches/execution.rs | 5 +- crates/executor/src/builder.rs | 2 +- crates/executor/src/canyon.rs | 2 +- crates/executor/src/eip4788.rs | 3 +- crates/executor/src/lib.rs | 5 +- crates/primitives/Cargo.toml | 17 +- crates/primitives/src/attributes.rs | 3 +- crates/primitives/src/blob.rs | 3 +- crates/primitives/src/block_info.rs | 532 ------------------ crates/primitives/src/lib.rs | 38 -- crates/primitives/src/payload.rs | 23 +- crates/primitives/src/sidecar.rs | 7 +- examples/trusted-sync/Cargo.toml | 1 + examples/trusted-sync/src/validation.rs | 3 +- 66 files changed, 356 insertions(+), 854 deletions(-) delete mode 100644 crates/primitives/src/block_info.rs diff --git a/Cargo.lock b/Cargo.lock index f59b9a6a..a0b07b0a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -256,9 +256,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b4f201b0ac8f81315fbdc55269965a8ddadbc04ab47fa65a1a468f9a40f7a5f" +checksum = "b68b94c159bcc2ca5f758b8663d7b00fc7c5e40569984595ddf2221b0f7f7f6e" dependencies = [ "num_enum", "strum", @@ -266,9 +266,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1468e3128e07c7afe4ff13c17e8170c330d12c322f8924b8bf6986a27e0aad3d" +checksum = "c28ddd17ffb7e4d66ef3a84e7b179072a9320cdc4b26c7f6f44cbf1081631b36" dependencies = [ "alloy-eips", "alloy-primitives", @@ -303,9 +303,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c35df7b972b06f1b2f4e8b7a53328522fa788054a9d3e556faf2411c5a51d5a" +checksum = "2f6c5c0a383f14519531cf58d8440e74f10b938e289f803af870be6f79223110" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -321,9 +321,9 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7210f9206c0fa2a83c824cf8cb6c962126bc9fdc4f41ade1932f14150ef5f6" +checksum = "7db0ddc76399bb1a4010f630767f027cafe65ab406cfee8e6040128cd65e8325" dependencies = [ "alloy-primitives", "alloy-serde", @@ -332,9 +332,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8866562186d237f1dfeaf989ef941a24764f764bf5c33311e37ead3519c6a429" +checksum = "7111af869909275cffc5c84d16b6c892d6d512773e40cbe83187d0b9c5235e91" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -346,9 +346,9 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abe714e233f9eaf410de95a9af6bcd05d3a7f8c8de7a0817221e95a6b642a080" +checksum = "342028392a2d5050b7b93dd32a0715d3b3b9ce30072ecb69a35dd4895c005495" dependencies = [ "alloy-consensus", "alloy-eips", @@ -367,9 +367,9 @@ dependencies = [ [[package]] name = "alloy-network-primitives" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c5a38117974c5776a45e140226745a0b664f79736aa900995d8e4121558e064" +checksum = "a6e66d78c049dcadd065a926a9f2d9a9b2b10981a7889449e694fac7bccd2c6f" dependencies = [ "alloy-eips", "alloy-primitives", @@ -379,13 +379,14 @@ dependencies = [ [[package]] name = "alloy-node-bindings" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d149d4f3147b3494e1b1db8704e9fdb579e8c666c3deb7d070ebd5f38c2abb15" +checksum = "41eb6fd2c70b076b0953d05ff1d2814fc370629301676a578519f8769cc2bc82" dependencies = [ "alloy-genesis", "alloy-primitives", "k256", + "rand", "serde_json", "tempfile", "thiserror", @@ -417,9 +418,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c65633d6ef83c3626913c004eaf166a6dd50406f724772ea8567135efd6dc5d3" +checksum = "79f14ccc2a3c575cb17b1b4af8c772cf9b5b93b7ce7047d6640e53954abb558d" dependencies = [ "alloy-chains", "alloy-consensus", @@ -473,9 +474,9 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5fc328bb5d440599ba1b5aa44c0b9ab0625fbc3a403bb5ee94ed4a01ba23e07" +checksum = "4dc79aeca84abb122a2fffbc1c91fdf958dca5c95be3875977bc99672bde0027" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -494,9 +495,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f8ff679f94c497a8383f2cd09e2a099266e5f3d5e574bc82b4b379865707dbb" +checksum = "22045187a5ebf5b2af3f8b6831b66735b6556c5750ec5790aeeb45935260c1c2" dependencies = [ "alloy-rpc-types-eth", "alloy-serde", @@ -505,9 +506,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a59b1d7c86e0a653e7f3d29954f6de5a2878d8cfd1f010ff93be5c2c48cd3b1" +checksum = "238f494727ff861a803bd73b1274ef788a615bf8f8c4bfada4e6df42afa275d2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -516,17 +517,19 @@ dependencies = [ "alloy-rlp", "alloy-serde", "alloy-sol-types", + "cfg-if", + "derive_more 1.0.0", + "hashbrown 0.14.5", "itertools 0.13.0", "serde", "serde_json", - "thiserror", ] [[package]] name = "alloy-serde" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51db8a6428a2159e01b7a43ec7aac801edd0c4db1d4de06f310c288940f16fd3" +checksum = "6b95b6f024a558593dd3b8628af03f7df2ca50e4c56839293ad0a7546e471db0" dependencies = [ "alloy-primitives", "serde", @@ -535,9 +538,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebc1760c13592b7ba3fcd964abba546b8d6a9f10d15e8d92a8263731be33f36" +checksum = "da64740ff0518606c514eb0e03dd0a1daa8ff94d6d491a626fd8e50efd6c4f18" dependencies = [ "alloy-primitives", "async-trait", @@ -607,9 +610,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd5dc4e902f1860d54952446d246ac05386311ad61030a2b906ae865416d36e0" +checksum = "3c7a669caa427abe8802184c8776f5103302f9337bb30a5b36bdebc332946c14" dependencies = [ "alloy-json-rpc", "base64", @@ -626,9 +629,9 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1742b94bb814f1ca6b322a6f9dd38a0252ff45a3119e40e888fb7029afa500ce" +checksum = "4433ffa97aab6ae643de81c7bde9a2f043496f27368a607405a5c78a610caf74" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -711,9 +714,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.88" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e1496f8fb1fbf272686b8d37f523dab3e4a7443300055e74cdaa449f3114356" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "ark-ff" @@ -1143,9 +1146,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.1.18" +version = "1.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476" +checksum = "2d74707dde2ba56f86ae90effb3b43ddd369504387e718014de010cec7959800" dependencies = [ "jobserver", "libc", @@ -2283,6 +2286,8 @@ dependencies = [ "kona-primitives", "lru", "op-alloy-consensus", + "op-alloy-genesis", + "op-alloy-protocol", "revm", "serde", "serde_json", @@ -2335,6 +2340,8 @@ dependencies = [ "lru", "miniz_oxide", "op-alloy-consensus", + "op-alloy-genesis", + "op-alloy-protocol", "prometheus", "proptest", "reqwest", @@ -2360,6 +2367,7 @@ dependencies = [ "kona-mpt", "kona-primitives", "op-alloy-consensus", + "op-alloy-genesis", "pprof", "rand", "revm", @@ -2391,6 +2399,8 @@ dependencies = [ "kona-mpt", "kona-preimage", "kona-primitives", + "op-alloy-genesis", + "op-alloy-protocol", "os_pipe", "proptest", "reqwest", @@ -2453,12 +2463,12 @@ dependencies = [ "anyhow", "c-kzg", "op-alloy-consensus", + "op-alloy-genesis", "op-alloy-protocol", "revm", "serde", "serde_json", "sha2", - "superchain-primitives", "tracing", ] @@ -2605,9 +2615,9 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memmap2" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" +checksum = "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f" dependencies = [ "libc", ] @@ -2846,9 +2856,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "33ea5043e58958ee56f3e15a90aee535795cd7dfd319846288d93c5b57d85cbe" [[package]] name = "oorandom" @@ -2858,9 +2868,8 @@ checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" [[package]] name = "op-alloy-consensus" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad134a77fdfebac469526756b207c7889593657eeaca374200332ec89175e27a" +version = "0.2.11" +source = "git+https://github.com/alloy-rs/op-alloy?branch=main#95fdc87239d58079c8db2226779545f10758ba77" dependencies = [ "alloy-consensus", "alloy-eips", @@ -2872,18 +2881,33 @@ dependencies = [ "spin", ] +[[package]] +name = "op-alloy-genesis" +version = "0.2.11" +source = "git+https://github.com/alloy-rs/op-alloy?branch=main#95fdc87239d58079c8db2226779545f10758ba77" +dependencies = [ + "alloy-consensus", + "alloy-eips", + "alloy-primitives", + "alloy-sol-types", + "serde", + "serde_repr", +] + [[package]] name = "op-alloy-protocol" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ae2170e65eeef408d336e8f378b8c1341e5f6bbc618839f020b8b1a82786327" +version = "0.2.11" +source = "git+https://github.com/alloy-rs/op-alloy?branch=main#95fdc87239d58079c8db2226779545f10758ba77" dependencies = [ + "alloy-consensus", "alloy-eips", "alloy-primitives", "alloy-rlp", + "alloy-serde", "hashbrown 0.14.5", "op-alloy-consensus", - "superchain-primitives", + "op-alloy-genesis", + "serde", ] [[package]] @@ -3412,9 +3436,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" dependencies = [ "bitflags 2.6.0", ] @@ -3862,9 +3886,9 @@ dependencies = [ [[package]] name = "secp256k1-sys" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1433bd67156263443f14d603720b082dd3121779323fce20cba2aa07b874bc1b" +checksum = "d4387882333d3aa8cb20530a17c69a3752e97837832f34f6dccc760e715001d9" dependencies = [ "cc", ] @@ -4170,42 +4194,16 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "superchain" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc46041e66734c67d9ca020e8cb9af3a84986620c0b50d06208c0230de3d6022" -dependencies = [ - "superchain-primitives", - "superchain-registry", -] - -[[package]] -name = "superchain-primitives" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d0cd81318c6ad65932af03168da2095befebef0a851f17391fc773dbf49dbc" +checksum = "7d9113b97b12c98b213c77646077ef98f2b1f110e60a3f1b7813f46fb880e28d" dependencies = [ - "alloy-consensus", - "alloy-eips", - "alloy-genesis", "alloy-primitives", - "alloy-serde", - "alloy-sol-types", - "anyhow", - "serde", - "serde_repr", -] - -[[package]] -name = "superchain-registry" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef9478ce31da9bbe15dad2ed4ff5fa64652ae220c4d5a95681bf09cb5cb39867" -dependencies = [ "hashbrown 0.14.5", "lazy_static", + "op-alloy-genesis", "serde", "serde_json", - "superchain-primitives", ] [[package]] @@ -4671,6 +4669,7 @@ dependencies = [ "kona-derive", "kona-primitives", "lazy_static", + "op-alloy-genesis", "prometheus", "reqwest", "serde", diff --git a/Cargo.toml b/Cargo.toml index 195d45ac..86b0696c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,6 +35,12 @@ panic = "abort" codegen-units = 1 lto = "fat" +[patch.crates-io] +# Patch op-alloy to remove it's dependency on superchain-primitives +op-alloy-protocol = { git = "https://github.com/alloy-rs/op-alloy", branch = "main" } +op-alloy-consensus = { git = "https://github.com/alloy-rs/op-alloy", branch = "main" } +op-alloy-genesis = { git = "https://github.com/alloy-rs/op-alloy", branch = "main" } + [workspace.dependencies] # Workspace kona-client = { path = "bin/client", version = "0.1.0" } @@ -92,23 +98,23 @@ unsigned-varint = "0.8.0" revm = { version = "14.0", default-features = false } # Superchain -superchain = "0.4" -superchain-primitives = { version = "0.4", default-features = false } +superchain = { version = "0.5", default-features = false } # K/V database rocksdb = { version = "0.22", default-features = false, features = ["snappy"] } # Alloy -alloy-rlp = { version = "0.3.2", default-features = false } +alloy-rlp = { version = "0.3.8", default-features = false } alloy-trie = { version = "0.5", default-features = false } -alloy-provider = { version = "0.3.2", default-features = false } +alloy-provider = { version = "0.3.5", default-features = false } alloy-primitives = { version = "0.8", default-features = false } -alloy-rpc-types = { version = "0.3.2", default-features = false } -alloy-consensus = { version = "0.3.2", default-features = false } -alloy-transport = { version = "0.3.2", default-features = false } -alloy-transport-http = { version = "0.3.2", default-features = false } -alloy-eips = { version = "0.3.2", default-features = false } -alloy-rpc-client = { version = "0.3.2", default-features = false } -alloy-node-bindings = { version = "0.3.2", default-features = false } -op-alloy-consensus = { version = "0.2.9", default-features = false } -op-alloy-protocol = { version = "0.2.9", default-features = false } +alloy-rpc-types = { version = "0.3.5", default-features = false } +alloy-consensus = { version = "0.3.5", default-features = false } +alloy-transport = { version = "0.3.5", default-features = false } +alloy-transport-http = { version = "0.3.5", default-features = false } +alloy-eips = { version = "0.3.5", default-features = false } +alloy-rpc-client = { version = "0.3.5", default-features = false } +alloy-node-bindings = { version = "0.3.5", default-features = false } +op-alloy-consensus = { version = "0.2.11", default-features = false } +op-alloy-protocol = { version = "0.2.11", default-features = false } +op-alloy-genesis = { version = "0.2.11", default-features = false } diff --git a/bin/client/Cargo.toml b/bin/client/Cargo.toml index b1718e57..09200fdb 100644 --- a/bin/client/Cargo.toml +++ b/bin/client/Cargo.toml @@ -17,6 +17,8 @@ kona-mpt.workspace = true kona-derive.workspace = true kona-executor.workspace = true kona-primitives = { workspace = true, features = ["serde"] } +op-alloy-genesis = { workspace = true, features = ["serde"] } +op-alloy-protocol = { workspace = true, features = ["serde"] } # Revm + Alloy revm.workspace = true diff --git a/bin/client/src/boot.rs b/bin/client/src/boot.rs index 7a3bc605..4ad5c667 100644 --- a/bin/client/src/boot.rs +++ b/bin/client/src/boot.rs @@ -4,7 +4,7 @@ use alloy_primitives::{B256, U256}; use anyhow::{anyhow, Result}; use kona_preimage::{PreimageKey, PreimageOracleClient}; -use kona_primitives::RollupConfig; +use op_alloy_genesis::RollupConfig; use serde::{Deserialize, Serialize}; use tracing::warn; diff --git a/bin/client/src/l1/blob_provider.rs b/bin/client/src/l1/blob_provider.rs index dadfb540..8152e260 100644 --- a/bin/client/src/l1/blob_provider.rs +++ b/bin/client/src/l1/blob_provider.rs @@ -8,7 +8,8 @@ use alloy_primitives::keccak256; use async_trait::async_trait; use kona_derive::{errors::BlobProviderError, traits::BlobProvider}; use kona_preimage::{CommsClient, PreimageKey, PreimageKeyType}; -use kona_primitives::{BlockInfo, IndexedBlobHash}; +use kona_primitives::IndexedBlobHash; +use op_alloy_protocol::BlockInfo; /// An oracle-backed blob provider. #[derive(Debug, Clone)] diff --git a/bin/client/src/l1/chain_provider.rs b/bin/client/src/l1/chain_provider.rs index 940f905a..70c3484c 100644 --- a/bin/client/src/l1/chain_provider.rs +++ b/bin/client/src/l1/chain_provider.rs @@ -11,7 +11,7 @@ use async_trait::async_trait; use kona_derive::traits::ChainProvider; use kona_mpt::{OrderedListWalker, TrieDBFetcher}; use kona_preimage::{CommsClient, PreimageKey, PreimageKeyType}; -use kona_primitives::BlockInfo; +use op_alloy_protocol::BlockInfo; /// The oracle-backed L1 chain provider for the client program. #[derive(Debug, Clone)] diff --git a/bin/client/src/l1/driver.rs b/bin/client/src/l1/driver.rs index 7966ccdd..24e9d7e2 100644 --- a/bin/client/src/l1/driver.rs +++ b/bin/client/src/l1/driver.rs @@ -21,7 +21,8 @@ use kona_derive::{ }; use kona_mpt::TrieDBFetcher; use kona_preimage::{CommsClient, PreimageKey, PreimageKeyType}; -use kona_primitives::{BlockInfo, L2AttributesWithParent, L2BlockInfo}; +use kona_primitives::L2AttributesWithParent; +use op_alloy_protocol::{BlockInfo, L2BlockInfo}; use tracing::{info, warn}; /// An oracle-backed derivation pipeline. diff --git a/bin/client/src/l2/chain_provider.rs b/bin/client/src/l2/chain_provider.rs index f540ae24..6304f38e 100644 --- a/bin/client/src/l2/chain_provider.rs +++ b/bin/client/src/l2/chain_provider.rs @@ -11,10 +11,10 @@ use async_trait::async_trait; use kona_derive::traits::L2ChainProvider; use kona_mpt::{OrderedListWalker, TrieDBFetcher, TrieDBHinter}; use kona_preimage::{CommsClient, PreimageKey, PreimageKeyType}; -use kona_primitives::{ - L2BlockInfo, L2ExecutionPayloadEnvelope, OpBlock, RollupConfig, SystemConfig, -}; +use kona_primitives::{L2ExecutionPayloadEnvelope, OpBlock}; use op_alloy_consensus::OpTxEnvelope; +use op_alloy_genesis::{RollupConfig, SystemConfig}; +use op_alloy_protocol::L2BlockInfo; /// The oracle-backed L2 chain provider for the client program. #[derive(Debug, Clone)] diff --git a/bin/host/Cargo.toml b/bin/host/Cargo.toml index 5dae44e1..9f00a9f8 100644 --- a/bin/host/Cargo.toml +++ b/bin/host/Cargo.toml @@ -16,6 +16,8 @@ kona-common.workspace = true kona-preimage.workspace = true kona-derive = { workspace = true, features = ["online"] } kona-primitives = { workspace = true, features = ["online"] } +op-alloy-genesis = { workspace = true, features = ["std", "serde"] } +op-alloy-protocol = { workspace = true, features = ["std", "serde"] } # Alloy & Revm alloy-eips.workspace = true diff --git a/bin/host/src/cli/mod.rs b/bin/host/src/cli/mod.rs index 4a2e16af..3aa6b3d0 100644 --- a/bin/host/src/cli/mod.rs +++ b/bin/host/src/cli/mod.rs @@ -7,7 +7,7 @@ use crate::kv::{ use alloy_primitives::B256; use anyhow::{anyhow, Result}; use clap::{ArgAction, Parser}; -use kona_primitives::RollupConfig; +use op_alloy_genesis::RollupConfig; use serde::Serialize; use std::{path::PathBuf, sync::Arc}; use tokio::sync::RwLock; diff --git a/bin/host/src/fetcher/mod.rs b/bin/host/src/fetcher/mod.rs index 58b72a13..55a674ca 100644 --- a/bin/host/src/fetcher/mod.rs +++ b/bin/host/src/fetcher/mod.rs @@ -14,7 +14,8 @@ use anyhow::{anyhow, Result}; use kona_client::HintType; use kona_derive::online::{OnlineBeaconClient, OnlineBlobProvider, SimpleSlotDerivation}; use kona_preimage::{PreimageKey, PreimageKeyType}; -use kona_primitives::{BlockInfo, IndexedBlobHash}; +use kona_primitives::IndexedBlobHash; +use op_alloy_protocol::BlockInfo; use std::sync::Arc; use tokio::sync::RwLock; use tracing::trace; diff --git a/crates/derive/Cargo.toml b/crates/derive/Cargo.toml index c427bcc3..32128c05 100644 --- a/crates/derive/Cargo.toml +++ b/crates/derive/Cargo.toml @@ -15,6 +15,8 @@ alloy-rlp = { workspace = true, features = ["derive"] } alloy-consensus = { workspace = true, features = ["k256"] } alloy-primitives = { workspace = true, features = ["rlp", "k256"] } op-alloy-consensus = { workspace = true, features = ["k256"] } +op-alloy-protocol.workspace = true +op-alloy-genesis.workspace = true # General hashbrown.workspace = true @@ -66,7 +68,9 @@ serde = [ "kona-primitives/serde", "alloy-primitives/serde", "alloy-consensus/serde", - "op-alloy-consensus/serde" + "op-alloy-consensus/serde", + "op-alloy-protocol/serde", + "op-alloy-genesis/serde", ] metrics = ["dep:prometheus", "dep:lazy_static"] online = [ @@ -78,6 +82,9 @@ online = [ "alloy-consensus/serde", "kona-primitives/online", "kona-primitives/serde", + "op-alloy-consensus/std", + "op-alloy-protocol/std", + "op-alloy-genesis/std", ] test-utils = [ "dep:spin", diff --git a/crates/derive/src/batch/mod.rs b/crates/derive/src/batch/mod.rs index b9128c29..f26058c5 100644 --- a/crates/derive/src/batch/mod.rs +++ b/crates/derive/src/batch/mod.rs @@ -2,7 +2,8 @@ //! [SingleBatch]. use alloy_rlp::{Buf, Decodable}; -use kona_primitives::{BlockInfo, L2BlockInfo, RollupConfig}; +use op_alloy_genesis::RollupConfig; +use op_alloy_protocol::{BlockInfo, L2BlockInfo}; use crate::{errors::DecodeError, traits::L2ChainProvider}; diff --git a/crates/derive/src/batch/single_batch.rs b/crates/derive/src/batch/single_batch.rs index 41bbae3b..fd3134d6 100644 --- a/crates/derive/src/batch/single_batch.rs +++ b/crates/derive/src/batch/single_batch.rs @@ -2,9 +2,11 @@ use super::validity::BatchValidity; use alloc::vec::Vec; +use alloy_eips::BlockNumHash; use alloy_primitives::{BlockHash, Bytes}; use alloy_rlp::{RlpDecodable, RlpEncodable}; -use kona_primitives::{starts_with_2718_deposit, BlockID, BlockInfo, L2BlockInfo, RollupConfig}; +use op_alloy_genesis::RollupConfig; +use op_alloy_protocol::{starts_with_2718_deposit, BlockInfo, L2BlockInfo}; use tracing::{info, warn}; /// Represents a single batch: a single encoded L2 block @@ -29,9 +31,9 @@ impl SingleBatch { self.transactions.iter().any(|tx| tx.0.is_empty() || tx.0[0] == 0x7E) } - /// Returns the [BlockID] of the batch. - pub fn epoch(&self) -> BlockID { - BlockID { number: self.epoch_num, hash: self.epoch_hash } + /// Returns the [BlockNumHash] of the batch. + pub fn epoch(&self) -> BlockNumHash { + BlockNumHash { number: self.epoch_num, hash: self.epoch_hash } } /// Checks if the batch is valid. @@ -81,7 +83,7 @@ impl SingleBatch { // Check the L1 origin of the batch let mut batch_origin = epoch; if self.epoch_num < epoch.number { - warn!("dropped batch, epoch is too old, minimum: {}", epoch.id()); + warn!("dropped batch, epoch is too old, minimum: {:?}", epoch.id()); return BatchValidity::Drop; } else if self.epoch_num == epoch.number { // Batch is sticking to the current epoch, continue. @@ -92,23 +94,23 @@ impl SingleBatch { // more information otherwise the eager algorithm may diverge from a non-eager // algorithm. if l1_blocks.len() < 2 { - info!("eager batch wants to advance epoch, but could not without more L1 blocks at epoch: {}", epoch.id()); + info!("eager batch wants to advance epoch, but could not without more L1 blocks at epoch: {:?}", epoch.id()); return BatchValidity::Undecided; } batch_origin = l1_blocks[1]; } else { - warn!("dropped batch, epoch is too far ahead, maximum: {}", epoch.id()); + warn!("dropped batch, epoch is too far ahead, maximum: {:?}", epoch.id()); return BatchValidity::Drop; } // Validate the batch epoch hash if self.epoch_hash != batch_origin.hash { - warn!("dropped batch, epoch hash does not match, expected: {}", batch_origin.id()); + warn!("dropped batch, epoch hash does not match, expected: {:?}", batch_origin.id()); return BatchValidity::Drop; } if self.timestamp < batch_origin.timestamp { - warn!("dropped batch, batch timestamp is less than L1 origin timestamp, l2_timestamp: {}, l1_timestamp: {}, origin: {}", self.timestamp, batch_origin.timestamp, batch_origin.id()); + warn!("dropped batch, batch timestamp is less than L1 origin timestamp, l2_timestamp: {}, l1_timestamp: {}, origin: {:?}", self.timestamp, batch_origin.timestamp, batch_origin.id()); return BatchValidity::Drop; } diff --git a/crates/derive/src/batch/span_batch/batch.rs b/crates/derive/src/batch/span_batch/batch.rs index 671575b7..b1c5492d 100644 --- a/crates/derive/src/batch/span_batch/batch.rs +++ b/crates/derive/src/batch/span_batch/batch.rs @@ -2,8 +2,9 @@ use alloc::vec::Vec; use alloy_primitives::FixedBytes; -use kona_primitives::{BlockInfo, L2BlockInfo, RollupConfig}; use op_alloy_consensus::OpTxType; +use op_alloy_genesis::RollupConfig; +use op_alloy_protocol::{BlockInfo, L2BlockInfo}; use tracing::{info, warn}; use super::{SpanBatchBits, SpanBatchElement, SpanBatchError, SpanBatchTransactions}; @@ -77,7 +78,7 @@ impl SpanBatch { let starting_epoch_num = self.starting_epoch_num(); if starting_epoch_num == batch_origin.number + 1 { if l1_blocks.len() < 2 { - info!("eager batch wants to advance current epoch {}, but could not without more L1 blocks", epoch.id()); + info!("eager batch wants to advance current epoch {:?}, but could not without more L1 blocks", epoch.id()); return BatchValidity::Undecided; } batch_origin = l1_blocks[1]; @@ -86,7 +87,7 @@ impl SpanBatch { // Span batches are only valid after the Delta hard fork. if !cfg.is_delta_active(batch_origin.timestamp) { warn!( - "received SpanBatch (id {}) with L1 origin (timestamp {}) before Delta hard fork", + "received SpanBatch (id {:?}) with L1 origin (timestamp {}) before Delta hard fork", batch_origin.id(), batch_origin.timestamp ); @@ -187,7 +188,7 @@ impl SpanBatch { // Check if the batch is too old. if starting_epoch_num < parent_block.l1_origin.number { - warn!("dropped batch, epoch is too old, minimum: {}", parent_block.block_info.id()); + warn!("dropped batch, epoch is too old, minimum: {:?}", parent_block.block_info.id()); return BatchValidity::Drop; } @@ -214,7 +215,7 @@ impl SpanBatch { let block_timestamp = batch.timestamp; if block_timestamp < l1_origin.timestamp { warn!( - "block timestamp is less than L1 origin timestamp, l2_timestamp: {}, l1_timestamp: {}, origin: {}", + "block timestamp is less than L1 origin timestamp, l2_timestamp: {}, l1_timestamp: {}, origin: {:?}", block_timestamp, l1_origin.timestamp, l1_origin.id() @@ -420,9 +421,11 @@ mod tests { traits::test_utils::TestL2ChainProvider, }; use alloc::vec; + use alloy_eips::BlockNumHash; use alloy_primitives::{b256, Bytes, B256}; - use kona_primitives::{BlockID, ChainGenesis, L2ExecutionPayload, L2ExecutionPayloadEnvelope}; + use kona_primitives::{L2ExecutionPayload, L2ExecutionPayloadEnvelope}; use op_alloy_consensus::OpTxType; + use op_alloy_genesis::ChainGenesis; use tracing::Level; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; @@ -529,7 +532,7 @@ mod tests { let logs = trace_store.get_by_level(Level::INFO); assert_eq!(logs.len(), 1); let str = alloc::format!( - "eager batch wants to advance current epoch {}, but could not without more L1 blocks", + "eager batch wants to advance current epoch {:?}, but could not without more L1 blocks", block.id() ); assert!(logs[0].contains(&str)); @@ -556,7 +559,7 @@ mod tests { let logs = trace_store.get_by_level(Level::WARN); assert_eq!(logs.len(), 1); let str = alloc::format!( - "received SpanBatch (id {}) with L1 origin (timestamp {}) before Delta hard fork", + "received SpanBatch (id {:?}) with L1 origin (timestamp {}) before Delta hard fork", block.id(), block.timestamp ); @@ -715,7 +718,7 @@ mod tests { let inclusion_block = BlockInfo::default(); let l2_block = L2BlockInfo { block_info: BlockInfo { number: 41, timestamp: 10, ..Default::default() }, - l1_origin: BlockID { number: 9, ..Default::default() }, + l1_origin: BlockNumHash { number: 9, ..Default::default() }, ..Default::default() }; let mut fetcher = TestL2ChainProvider { blocks: vec![l2_block], ..Default::default() }; @@ -798,7 +801,7 @@ mod tests { let parent_hash = b256!("1111111111111111111111111111111111111111000000000000000000000000"); let l2_safe_head = L2BlockInfo { block_info: BlockInfo { number: 41, timestamp: 10, parent_hash, ..Default::default() }, - l1_origin: BlockID { number: 8, ..Default::default() }, + l1_origin: BlockNumHash { number: 8, ..Default::default() }, ..Default::default() }; let inclusion_block = BlockInfo { number: 50, ..Default::default() }; @@ -809,7 +812,7 @@ mod tests { timestamp: 10, ..Default::default() }, - l1_origin: BlockID { number: 8, ..Default::default() }, + l1_origin: BlockNumHash { number: 8, ..Default::default() }, ..Default::default() }; let mut fetcher = TestL2ChainProvider { blocks: vec![l2_block], ..Default::default() }; @@ -856,7 +859,7 @@ mod tests { hash: parent_hash, ..Default::default() }, - l1_origin: BlockID { number: 9, ..Default::default() }, + l1_origin: BlockNumHash { number: 9, ..Default::default() }, ..Default::default() }; let inclusion_block = BlockInfo { number: 50, ..Default::default() }; @@ -867,7 +870,7 @@ mod tests { hash: parent_hash, ..Default::default() }, - l1_origin: BlockID { number: 9, ..Default::default() }, + l1_origin: BlockNumHash { number: 9, ..Default::default() }, ..Default::default() }; let mut fetcher = TestL2ChainProvider { blocks: vec![l2_block], ..Default::default() }; @@ -911,7 +914,7 @@ mod tests { let parent_hash = b256!("1111111111111111111111111111111111111111000000000000000000000000"); let l2_safe_head = L2BlockInfo { block_info: BlockInfo { number: 41, timestamp: 10, parent_hash, ..Default::default() }, - l1_origin: BlockID { number: 9, ..Default::default() }, + l1_origin: BlockNumHash { number: 9, ..Default::default() }, ..Default::default() }; let inclusion_block = BlockInfo { number: 50, ..Default::default() }; @@ -922,7 +925,7 @@ mod tests { hash: parent_hash, ..Default::default() }, - l1_origin: BlockID { number: 9, ..Default::default() }, + l1_origin: BlockNumHash { number: 9, ..Default::default() }, ..Default::default() }; let mut fetcher = TestL2ChainProvider { blocks: vec![l2_block], ..Default::default() }; @@ -963,7 +966,7 @@ mod tests { let parent_hash = b256!("1111111111111111111111111111111111111111000000000000000000000000"); let l2_safe_head = L2BlockInfo { block_info: BlockInfo { number: 41, timestamp: 10, parent_hash, ..Default::default() }, - l1_origin: BlockID { number: 13, ..Default::default() }, + l1_origin: BlockNumHash { number: 13, ..Default::default() }, ..Default::default() }; let inclusion_block = BlockInfo { number: 50, ..Default::default() }; @@ -974,7 +977,7 @@ mod tests { hash: parent_hash, ..Default::default() }, - l1_origin: BlockID { number: 14, ..Default::default() }, + l1_origin: BlockNumHash { number: 14, ..Default::default() }, ..Default::default() }; let mut fetcher = TestL2ChainProvider { blocks: vec![l2_block], ..Default::default() }; @@ -993,7 +996,7 @@ mod tests { let logs = trace_store.get_by_level(Level::WARN); assert_eq!(logs.len(), 1); let str = alloc::format!( - "dropped batch, epoch is too old, minimum: {}", + "dropped batch, epoch is too old, minimum: {:?}", l2_block.block_info.id(), ); assert!(logs[0].contains(&str)); @@ -1031,7 +1034,7 @@ mod tests { hash: parent_hash, ..Default::default() }, - l1_origin: BlockID { number: 9, ..Default::default() }, + l1_origin: BlockNumHash { number: 9, ..Default::default() }, ..Default::default() }; let inclusion_block = BlockInfo { number: 50, ..Default::default() }; @@ -1086,7 +1089,7 @@ mod tests { hash: parent_hash, ..Default::default() }, - l1_origin: BlockID { number: 9, ..Default::default() }, + l1_origin: BlockNumHash { number: 9, ..Default::default() }, ..Default::default() }; let inclusion_block = BlockInfo { number: 50, ..Default::default() }; @@ -1144,7 +1147,7 @@ mod tests { hash: parent_hash, ..Default::default() }, - l1_origin: BlockID { number: 9, ..Default::default() }, + l1_origin: BlockNumHash { number: 9, ..Default::default() }, ..Default::default() }; let inclusion_block = BlockInfo { number: 50, ..Default::default() }; @@ -1212,7 +1215,7 @@ mod tests { hash: parent_hash, ..Default::default() }, - l1_origin: BlockID { number: 9, ..Default::default() }, + l1_origin: BlockNumHash { number: 9, ..Default::default() }, ..Default::default() }; let inclusion_block = BlockInfo { number: 50, ..Default::default() }; @@ -1276,7 +1279,7 @@ mod tests { hash: parent_hash, ..Default::default() }, - l1_origin: BlockID { number: 9, ..Default::default() }, + l1_origin: BlockNumHash { number: 9, ..Default::default() }, ..Default::default() }; let inclusion_block = BlockInfo { number: 50, ..Default::default() }; @@ -1334,7 +1337,7 @@ mod tests { let parent_hash = b256!("1111111111111111111111111111111111111111000000000000000000000000"); let l2_safe_head = L2BlockInfo { block_info: BlockInfo { number: 41, timestamp: 10, parent_hash, ..Default::default() }, - l1_origin: BlockID { number: 9, ..Default::default() }, + l1_origin: BlockNumHash { number: 9, ..Default::default() }, ..Default::default() }; let inclusion_block = BlockInfo { number: 50, ..Default::default() }; @@ -1345,7 +1348,7 @@ mod tests { hash: parent_hash, ..Default::default() }, - l1_origin: BlockID { number: 9, ..Default::default() }, + l1_origin: BlockNumHash { number: 9, ..Default::default() }, ..Default::default() }; let mut fetcher = TestL2ChainProvider { blocks: vec![l2_block], ..Default::default() }; @@ -1390,7 +1393,7 @@ mod tests { let parent_hash = b256!("1111111111111111111111111111111111111111000000000000000000000000"); let l2_safe_head = L2BlockInfo { block_info: BlockInfo { number: 41, timestamp: 10, parent_hash, ..Default::default() }, - l1_origin: BlockID { number: 9, ..Default::default() }, + l1_origin: BlockNumHash { number: 9, ..Default::default() }, ..Default::default() }; let inclusion_block = BlockInfo { number: 50, ..Default::default() }; @@ -1401,7 +1404,7 @@ mod tests { hash: parent_hash, ..Default::default() }, - l1_origin: BlockID { number: 9, ..Default::default() }, + l1_origin: BlockNumHash { number: 9, ..Default::default() }, ..Default::default() }; let payload = L2ExecutionPayloadEnvelope { @@ -1447,7 +1450,7 @@ mod tests { delta_time: Some(0), block_time: 10, genesis: ChainGenesis { - l2: BlockID { number: 41, hash: payload_block_hash }, + l2: BlockNumHash { number: 41, hash: payload_block_hash }, ..Default::default() }, ..Default::default() @@ -1460,7 +1463,7 @@ mod tests { let parent_hash = b256!("1111111111111111111111111111111111111111000000000000000000000000"); let l2_safe_head = L2BlockInfo { block_info: BlockInfo { number: 41, timestamp: 10, parent_hash, ..Default::default() }, - l1_origin: BlockID { number: 9, ..Default::default() }, + l1_origin: BlockNumHash { number: 9, ..Default::default() }, ..Default::default() }; let inclusion_block = BlockInfo { number: 50, ..Default::default() }; @@ -1471,7 +1474,7 @@ mod tests { timestamp: 10, ..Default::default() }, - l1_origin: BlockID { number: 9, ..Default::default() }, + l1_origin: BlockNumHash { number: 9, ..Default::default() }, ..Default::default() }; let payload = L2ExecutionPayloadEnvelope { @@ -1517,8 +1520,8 @@ mod tests { delta_time: Some(0), block_time: 10, genesis: ChainGenesis { - l2: BlockID { number: 41, hash: payload_block_hash }, - l1: BlockID { number: 10, ..Default::default() }, + l2: BlockNumHash { number: 41, hash: payload_block_hash }, + l1: BlockNumHash { number: 10, ..Default::default() }, ..Default::default() }, ..Default::default() @@ -1536,7 +1539,7 @@ mod tests { hash: parent_hash, ..Default::default() }, - l1_origin: BlockID { number: 9, ..Default::default() }, + l1_origin: BlockNumHash { number: 9, ..Default::default() }, ..Default::default() }; let inclusion_block = BlockInfo { number: 50, ..Default::default() }; @@ -1547,7 +1550,7 @@ mod tests { timestamp: 10, ..Default::default() }, - l1_origin: BlockID { number: 9, ..Default::default() }, + l1_origin: BlockNumHash { number: 9, ..Default::default() }, ..Default::default() }; let payload = L2ExecutionPayloadEnvelope { diff --git a/crates/derive/src/batch/span_batch/mod.rs b/crates/derive/src/batch/span_batch/mod.rs index 33d8863b..c4b6a719 100644 --- a/crates/derive/src/batch/span_batch/mod.rs +++ b/crates/derive/src/batch/span_batch/mod.rs @@ -15,14 +15,14 @@ /// /// This value cannot be larger than MaxRLPBytesPerChannel because single batch cannot be larger /// than channel size. -pub const MAX_SPAN_BATCH_BYTES: u64 = kona_primitives::MAX_RLP_BYTES_PER_CHANNEL; +pub const MAX_SPAN_BATCH_BYTES: u64 = op_alloy_protocol::MAX_RLP_BYTES_PER_CHANNEL; /// [FJORD_MAX_SPAN_BATCH_BYTES] is the maximum amount of bytes that will be needed /// to decode every span batch field after the Fjord Hardfork. /// /// This value cannot be larger than MaxRLPBytesPerChannel because single batch /// cannot be larger than channel size. -pub const FJORD_MAX_SPAN_BATCH_BYTES: u64 = kona_primitives::FJORD_MAX_RLP_BYTES_PER_CHANNEL; +pub const FJORD_MAX_SPAN_BATCH_BYTES: u64 = op_alloy_protocol::FJORD_MAX_RLP_BYTES_PER_CHANNEL; mod batch; pub use batch::SpanBatch; diff --git a/crates/derive/src/batch/span_batch/prefix.rs b/crates/derive/src/batch/span_batch/prefix.rs index 55110ee3..f546db41 100644 --- a/crates/derive/src/batch/span_batch/prefix.rs +++ b/crates/derive/src/batch/span_batch/prefix.rs @@ -2,7 +2,7 @@ use alloc::vec::Vec; use alloy_primitives::FixedBytes; -use kona_primitives::RollupConfig; +use op_alloy_genesis::RollupConfig; use crate::batch::{SpanBatchError, SpanDecodingError}; diff --git a/crates/derive/src/batch/span_batch/raw.rs b/crates/derive/src/batch/span_batch/raw.rs index 4e2d7854..be096cfb 100644 --- a/crates/derive/src/batch/span_batch/raw.rs +++ b/crates/derive/src/batch/span_batch/raw.rs @@ -1,7 +1,7 @@ //! Raw Span Batch use alloc::{vec, vec::Vec}; -use kona_primitives::RollupConfig; +use op_alloy_genesis::RollupConfig; use super::{SpanBatch, SpanBatchElement, SpanBatchError, SpanBatchPayload, SpanBatchPrefix}; use crate::batch::{BatchType, SpanDecodingError}; diff --git a/crates/derive/src/errors.rs b/crates/derive/src/errors.rs index 535133cc..63bd56f7 100644 --- a/crates/derive/src/errors.rs +++ b/crates/derive/src/errors.rs @@ -2,9 +2,11 @@ use crate::batch::SpanBatchError; use alloc::vec::Vec; +use alloy_eips::BlockNumHash; use alloy_primitives::{Bytes, B256}; use core::fmt::Display; -use kona_primitives::{BlockID, Frame}; +use op_alloy_genesis::system::SystemConfigUpdateError; +use op_alloy_protocol::Frame; /// A result type for the derivation pipeline stages. pub type StageResult = Result; @@ -45,10 +47,10 @@ pub enum StageError { ReorgDetected(B256, B256), /// Receipt fetching error. ReceiptFetch(anyhow::Error), - /// [kona_primitives::BlockInfo] fetching error. + /// [op_alloy_protocol::BlockInfo] fetching error. BlockInfoFetch(anyhow::Error), - /// [kona_primitives::SystemConfig] update error. - SystemConfigUpdate(anyhow::Error), + /// [op_alloy_genesis::SystemConfig] update error. + SystemConfigUpdate(SystemConfigUpdateError), /// Other wildcard error. Custom(anyhow::Error), } @@ -255,15 +257,15 @@ impl Display for DecodeError { #[derive(Debug)] pub enum BuilderError { /// Mismatched blocks. - BlockMismatch(BlockID, BlockID), + BlockMismatch(BlockNumHash, BlockNumHash), /// Mismatched blocks for the start of an Epoch. - BlockMismatchEpochReset(BlockID, BlockID, B256), + BlockMismatchEpochReset(BlockNumHash, BlockNumHash, B256), /// [SystemConfig] update failed. /// - /// [SystemConfig]: kona_primitives::SystemConfig + /// [SystemConfig]: op_alloy_genesis::SystemConfig SystemConfigUpdate, /// Broken time invariant between L2 and L1. - BrokenTimeInvariant(BlockID, u64, BlockID, u64), + BrokenTimeInvariant(BlockNumHash, u64, BlockNumHash, u64), /// A custom error wrapping [anyhow::Error]. Custom(anyhow::Error), } @@ -299,12 +301,12 @@ impl Display for BuilderError { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { BuilderError::BlockMismatch(block_id, parent) => { - write!(f, "Block mismatch with L1 origin {} (parent {})", block_id, parent) + write!(f, "Block mismatch with L1 origin {:?} (parent {:?})", block_id, parent) } BuilderError::BlockMismatchEpochReset(block_id, parent, origin) => { write!( f, - "Block mismatch with L1 origin {} (parent {}) on top of L1 origin {}", + "Block mismatch with L1 origin {:?} (parent {:?}) on top of L1 origin {}", block_id, parent, origin ) } @@ -312,7 +314,7 @@ impl Display for BuilderError { BuilderError::BrokenTimeInvariant(block_id, l2_time, parent, l1_time) => { write!( f, - "Cannot build L2 block on top {} (time {}) before L1 origin {} (time {})", + "Cannot build L2 block on top {:?} (time {}) before L1 origin {:?} (time {})", block_id, l2_time, parent, l1_time ) } diff --git a/crates/derive/src/online/alloy_providers.rs b/crates/derive/src/online/alloy_providers.rs index acf5fe30..ba94c3bd 100644 --- a/crates/derive/src/online/alloy_providers.rs +++ b/crates/derive/src/online/alloy_providers.rs @@ -10,10 +10,10 @@ use alloy_transport::TransportResult; use anyhow::{anyhow, Result}; use async_trait::async_trait; use core::num::NonZeroUsize; -use kona_primitives::{ - Block, BlockInfo, L2BlockInfo, L2ExecutionPayloadEnvelope, OpBlock, RollupConfig, SystemConfig, -}; +use kona_primitives::{Block, L2ExecutionPayloadEnvelope, OpBlock}; use lru::LruCache; +use op_alloy_genesis::{RollupConfig, SystemConfig}; +use op_alloy_protocol::{BlockInfo, L2BlockInfo}; use crate::traits::{ChainProvider, L2ChainProvider}; @@ -408,7 +408,7 @@ impl L2ChainProvider for AlloyL2ChainProvider { timer ); if let Some(system_config) = self.system_config_by_number_cache.get(&number) { - return Ok(system_config.clone()); + return Ok(*system_config); } let envelope = match self.payload_by_number(number).await { @@ -433,7 +433,7 @@ impl L2ChainProvider for AlloyL2ChainProvider { return Err(e); } }; - self.system_config_by_number_cache.put(number, sys_config.clone()); + self.system_config_by_number_cache.put(number, sys_config); Ok(sys_config) } } diff --git a/crates/derive/src/online/blob_provider.rs b/crates/derive/src/online/blob_provider.rs index 0f1384e2..1ce98911 100644 --- a/crates/derive/src/online/blob_provider.rs +++ b/crates/derive/src/online/blob_provider.rs @@ -1,10 +1,12 @@ //! Contains an online implementation of the [BlobProvider] trait. use alloc::{boxed::Box, string::String, vec::Vec}; +use alloy_eips::eip4844::Blob; use anyhow::{anyhow, ensure}; use async_trait::async_trait; use core::marker::PhantomData; -use kona_primitives::{APIBlobSidecar, Blob, BlobSidecar, BlockInfo, IndexedBlobHash}; +use kona_primitives::{APIBlobSidecar, BlobSidecar, IndexedBlobHash}; +use op_alloy_protocol::BlockInfo; use tracing::warn; use crate::{ diff --git a/crates/derive/src/online/mod.rs b/crates/derive/src/online/mod.rs index cc929e72..182f8ea2 100644 --- a/crates/derive/src/online/mod.rs +++ b/crates/derive/src/online/mod.rs @@ -8,9 +8,6 @@ pub use crate::{ traits::{ChainProvider, L2ChainProvider, OriginProvider, Pipeline, StepResult}, }; -// Re-export kona primitives types. -pub use kona_primitives::{BlockInfo, RollupConfig}; - mod pipeline; pub use pipeline::{ new_online_pipeline, OnlineAttributesBuilder, OnlineAttributesQueue, OnlineDataProvider, diff --git a/crates/derive/src/online/pipeline.rs b/crates/derive/src/online/pipeline.rs index 05aa11bb..c3586504 100644 --- a/crates/derive/src/online/pipeline.rs +++ b/crates/derive/src/online/pipeline.rs @@ -1,11 +1,13 @@ //! Contains online pipeline types. use super::{ - AlloyChainProvider, AlloyL2ChainProvider, BlockInfo, DerivationPipeline, EthereumDataSource, - OnlineBeaconClient, OnlineBlobProviderWithFallback, PipelineBuilder, RollupConfig, - SimpleSlotDerivation, StatefulAttributesBuilder, + AlloyChainProvider, AlloyL2ChainProvider, DerivationPipeline, EthereumDataSource, + OnlineBeaconClient, OnlineBlobProviderWithFallback, PipelineBuilder, SimpleSlotDerivation, + StatefulAttributesBuilder, }; use alloc::sync::Arc; +use op_alloy_genesis::RollupConfig; +use op_alloy_protocol::BlockInfo; // Pipeline internal stages aren't re-exported at the module-level. use crate::stages::{ AttributesQueue, BatchQueue, ChannelBank, ChannelReader, FrameQueue, L1Retrieval, L1Traversal, diff --git a/crates/derive/src/pipeline/builder.rs b/crates/derive/src/pipeline/builder.rs index ae4b137e..b29e070f 100644 --- a/crates/derive/src/pipeline/builder.rs +++ b/crates/derive/src/pipeline/builder.rs @@ -8,7 +8,8 @@ use crate::stages::{ }; use alloc::sync::Arc; use core::fmt::Debug; -use kona_primitives::{BlockInfo, RollupConfig}; +use op_alloy_genesis::RollupConfig; +use op_alloy_protocol::BlockInfo; type L1TraversalStage

= L1Traversal

; type L1RetrievalStage = L1Retrieval>; diff --git a/crates/derive/src/pipeline/core.rs b/crates/derive/src/pipeline/core.rs index 0037d77e..85153af8 100644 --- a/crates/derive/src/pipeline/core.rs +++ b/crates/derive/src/pipeline/core.rs @@ -8,7 +8,9 @@ use alloc::{boxed::Box, collections::VecDeque, sync::Arc}; use anyhow::bail; use async_trait::async_trait; use core::fmt::Debug; -use kona_primitives::{BlockInfo, L2AttributesWithParent, L2BlockInfo, RollupConfig}; +use kona_primitives::L2AttributesWithParent; +use op_alloy_genesis::RollupConfig; +use op_alloy_protocol::{BlockInfo, L2BlockInfo}; use tracing::{error, trace, warn}; /// The derivation pipeline is responsible for deriving L2 inputs from L1 data. diff --git a/crates/derive/src/pipeline/mod.rs b/crates/derive/src/pipeline/mod.rs index 67ea0b24..e360e0e3 100644 --- a/crates/derive/src/pipeline/mod.rs +++ b/crates/derive/src/pipeline/mod.rs @@ -9,9 +9,6 @@ pub use crate::traits::{ /// Re-export stage types that are needed as inputs. pub use crate::stages::AttributesBuilder; -/// Re-export kona primitive types. -pub use kona_primitives::{BlockInfo, RollupConfig}; - /// Re-export error types. pub use crate::errors::{StageError, StageResult}; diff --git a/crates/derive/src/sources/blobs.rs b/crates/derive/src/sources/blobs.rs index 6f5785ae..eb0982ef 100644 --- a/crates/derive/src/sources/blobs.rs +++ b/crates/derive/src/sources/blobs.rs @@ -5,7 +5,8 @@ use alloy_consensus::{Transaction, TxEip4844Variant, TxEnvelope, TxType}; use alloy_primitives::{Address, Bytes, TxKind}; use anyhow::{anyhow, Result}; use async_trait::async_trait; -use kona_primitives::{BlobData, BlockInfo, IndexedBlobHash}; +use kona_primitives::{BlobData, IndexedBlobHash}; +use op_alloy_protocol::BlockInfo; use tracing::warn; use crate::{ diff --git a/crates/derive/src/sources/calldata.rs b/crates/derive/src/sources/calldata.rs index 0eecaa61..38a42b8f 100644 --- a/crates/derive/src/sources/calldata.rs +++ b/crates/derive/src/sources/calldata.rs @@ -5,7 +5,7 @@ use alloy_consensus::{Transaction, TxEnvelope}; use alloy_primitives::{Address, Bytes, TxKind}; use anyhow::Result; use async_trait::async_trait; -use kona_primitives::BlockInfo; +use op_alloy_protocol::BlockInfo; use crate::{ errors::{StageError, StageResult}, diff --git a/crates/derive/src/sources/ethereum.rs b/crates/derive/src/sources/ethereum.rs index 48b2e7c6..3f39744c 100644 --- a/crates/derive/src/sources/ethereum.rs +++ b/crates/derive/src/sources/ethereum.rs @@ -9,7 +9,8 @@ use alloc::{boxed::Box, fmt::Debug}; use alloy_primitives::{Address, Bytes}; use anyhow::Result; use async_trait::async_trait; -use kona_primitives::{BlockInfo, RollupConfig}; +use op_alloy_genesis::RollupConfig; +use op_alloy_protocol::BlockInfo; /// A factory for creating an Ethereum data source provider. #[derive(Debug, Clone, Copy)] @@ -88,7 +89,8 @@ mod tests { use alloy_consensus::TxEnvelope; use alloy_eips::eip2718::Decodable2718; use alloy_primitives::address; - use kona_primitives::{BlockInfo, RollupConfig, SystemConfig}; + use op_alloy_genesis::{RollupConfig, SystemConfig}; + use op_alloy_protocol::BlockInfo; use crate::{ sources::{EthereumDataSource, EthereumDataSourceVariant}, diff --git a/crates/derive/src/stages/attributes_queue.rs b/crates/derive/src/stages/attributes_queue.rs index 693dd3a4..392bb4f4 100644 --- a/crates/derive/src/stages/attributes_queue.rs +++ b/crates/derive/src/stages/attributes_queue.rs @@ -3,9 +3,9 @@ use alloc::{boxed::Box, sync::Arc}; use async_trait::async_trait; use core::fmt::Debug; -use kona_primitives::{ - BlockInfo, L2AttributesWithParent, L2BlockInfo, L2PayloadAttributes, RollupConfig, SystemConfig, -}; +use kona_primitives::{L2AttributesWithParent, L2PayloadAttributes}; +use op_alloy_genesis::{RollupConfig, SystemConfig}; +use op_alloy_protocol::{BlockInfo, L2BlockInfo}; use tracing::info; use crate::{ diff --git a/crates/derive/src/stages/attributes_queue/builder.rs b/crates/derive/src/stages/attributes_queue/builder.rs index 0b11ce87..4955c0a0 100644 --- a/crates/derive/src/stages/attributes_queue/builder.rs +++ b/crates/derive/src/stages/attributes_queue/builder.rs @@ -7,13 +7,14 @@ use crate::{ traits::{ChainProvider, L2ChainProvider}, }; use alloc::{boxed::Box, fmt::Debug, sync::Arc, vec, vec::Vec}; -use alloy_eips::eip2718::Encodable2718; +use alloy_eips::{eip2718::Encodable2718, BlockNumHash}; use alloy_primitives::Bytes; use alloy_rlp::Encodable; use async_trait::async_trait; -use kona_primitives::{ - BlockID, Hardforks, L1BlockInfoTx, L2BlockInfo, L2PayloadAttributes, RollupConfig, -}; +use kona_primitives::L2PayloadAttributes; +use op_alloy_consensus::Hardforks; +use op_alloy_genesis::RollupConfig; +use op_alloy_protocol::{L1BlockInfoTx, L2BlockInfo}; /// The [AttributesBuilder] is responsible for preparing [L2PayloadAttributes] /// that can be used to construct an L2 Block containing only deposits. @@ -29,7 +30,7 @@ pub trait AttributesBuilder { async fn prepare_payload_attributes( &mut self, l2_parent: L2BlockInfo, - epoch: BlockID, + epoch: BlockNumHash, ) -> Result; } @@ -68,7 +69,7 @@ where async fn prepare_payload_attributes( &mut self, l2_parent: L2BlockInfo, - epoch: BlockID, + epoch: BlockNumHash, ) -> Result { let l1_header; let deposit_transactions: Vec; @@ -90,7 +91,9 @@ where )); } let receipts = self.receipts_fetcher.receipts_by_hash(epoch.hash).await?; - sys_config.update_with_receipts(&receipts, &self.rollup_cfg, header.timestamp)?; + sys_config + .update_with_receipts(&receipts, &self.rollup_cfg, header.timestamp) + .map_err(|e| BuilderError::Custom(anyhow::anyhow!(e)))?; let deposits = derive_deposits(epoch.hash, receipts, self.rollup_cfg.deposit_contract_address) .await?; @@ -116,7 +119,7 @@ where return Err(BuilderError::BrokenTimeInvariant( l2_parent.l1_origin, next_l2_time, - BlockID { hash: l1_header.hash_slow(), number: l1_header.number }, + BlockNumHash { hash: l1_header.hash_slow(), number: l1_header.number }, l1_header.timestamp, )); } @@ -140,7 +143,8 @@ where sequence_number, &l1_header, next_l2_time, - )?; + ) + .map_err(|e| BuilderError::Custom(anyhow::anyhow!(e)))?; let mut encoded_l1_info_tx = Vec::with_capacity(l1_info_tx_envelope.length()); l1_info_tx_envelope.encode_2718(&mut encoded_l1_info_tx); @@ -184,7 +188,8 @@ mod tests { }; use alloy_consensus::Header; use alloy_primitives::B256; - use kona_primitives::{BlockInfo, SystemConfig}; + use op_alloy_genesis::SystemConfig; + use op_alloy_protocol::BlockInfo; #[tokio::test] async fn test_prepare_payload_block_mismatch_epoch_reset() { @@ -197,10 +202,10 @@ mod tests { let hash = header.hash_slow(); provider.insert_header(hash, header); let mut builder = StatefulAttributesBuilder::new(cfg, fetcher, provider); - let epoch = BlockID { hash, number: l2_number }; + let epoch = BlockNumHash { hash, number: l2_number }; let l2_parent = L2BlockInfo { block_info: BlockInfo { hash: B256::ZERO, number: l2_number, ..Default::default() }, - l1_origin: BlockID { hash: B256::left_padding_from(&[0xFF]), number: 2 }, + l1_origin: BlockNumHash { hash: B256::left_padding_from(&[0xFF]), number: 2 }, seq_num: 0, }; // This should error because the l2 parent's l1_origin.hash should equal the epoch header @@ -222,10 +227,10 @@ mod tests { let hash = header.hash_slow(); provider.insert_header(hash, header); let mut builder = StatefulAttributesBuilder::new(cfg, fetcher, provider); - let epoch = BlockID { hash, number: l2_number }; + let epoch = BlockNumHash { hash, number: l2_number }; let l2_parent = L2BlockInfo { block_info: BlockInfo { hash: B256::ZERO, number: l2_number, ..Default::default() }, - l1_origin: BlockID { hash: B256::ZERO, number: l2_number }, + l1_origin: BlockNumHash { hash: B256::ZERO, number: l2_number }, seq_num: 0, }; // This should error because the l2 parent's l1_origin.hash should equal the epoch hash @@ -248,14 +253,14 @@ mod tests { let hash = header.hash_slow(); provider.insert_header(hash, header); let mut builder = StatefulAttributesBuilder::new(cfg, fetcher, provider); - let epoch = BlockID { hash, number: l2_number }; + let epoch = BlockNumHash { hash, number: l2_number }; let l2_parent = L2BlockInfo { block_info: BlockInfo { hash: B256::ZERO, number: l2_number, ..Default::default() }, - l1_origin: BlockID { hash, number: l2_number }, + l1_origin: BlockNumHash { hash, number: l2_number }, seq_num: 0, }; let next_l2_time = l2_parent.block_info.timestamp + block_time; - let block_id = BlockID { hash, number: 0 }; + let block_id = BlockNumHash { hash, number: 0 }; let expected = BuilderError::BrokenTimeInvariant( l2_parent.l1_origin, next_l2_time, @@ -280,7 +285,7 @@ mod tests { let hash = header.hash_slow(); provider.insert_header(hash, header); let mut builder = StatefulAttributesBuilder::new(cfg, fetcher, provider); - let epoch = BlockID { hash, number: l2_number }; + let epoch = BlockNumHash { hash, number: l2_number }; let l2_parent = L2BlockInfo { block_info: BlockInfo { hash: B256::ZERO, @@ -288,7 +293,7 @@ mod tests { timestamp, parent_hash: hash, }, - l1_origin: BlockID { hash, number: l2_number }, + l1_origin: BlockNumHash { hash, number: l2_number }, seq_num: 0, }; let next_l2_time = l2_parent.block_info.timestamp + block_time; @@ -323,7 +328,7 @@ mod tests { let hash = header.hash_slow(); provider.insert_header(hash, header); let mut builder = StatefulAttributesBuilder::new(cfg, fetcher, provider); - let epoch = BlockID { hash, number: l2_number }; + let epoch = BlockNumHash { hash, number: l2_number }; let l2_parent = L2BlockInfo { block_info: BlockInfo { hash: B256::ZERO, @@ -331,7 +336,7 @@ mod tests { timestamp, parent_hash: hash, }, - l1_origin: BlockID { hash, number: l2_number }, + l1_origin: BlockNumHash { hash, number: l2_number }, seq_num: 0, }; let next_l2_time = l2_parent.block_info.timestamp + block_time; @@ -368,7 +373,7 @@ mod tests { let hash = header.hash_slow(); provider.insert_header(hash, header); let mut builder = StatefulAttributesBuilder::new(cfg, fetcher, provider); - let epoch = BlockID { hash, number: l2_number }; + let epoch = BlockNumHash { hash, number: l2_number }; let l2_parent = L2BlockInfo { block_info: BlockInfo { hash: B256::ZERO, @@ -376,7 +381,7 @@ mod tests { timestamp, parent_hash: hash, }, - l1_origin: BlockID { hash, number: l2_number }, + l1_origin: BlockNumHash { hash, number: l2_number }, seq_num: 0, }; let next_l2_time = l2_parent.block_info.timestamp + block_time; @@ -412,7 +417,7 @@ mod tests { let hash = header.hash_slow(); provider.insert_header(hash, header); let mut builder = StatefulAttributesBuilder::new(cfg, fetcher, provider); - let epoch = BlockID { hash, number: l2_number }; + let epoch = BlockNumHash { hash, number: l2_number }; let l2_parent = L2BlockInfo { block_info: BlockInfo { hash: B256::ZERO, @@ -420,7 +425,7 @@ mod tests { timestamp, parent_hash: hash, }, - l1_origin: BlockID { hash, number: l2_number }, + l1_origin: BlockNumHash { hash, number: l2_number }, seq_num: 0, }; let next_l2_time = l2_parent.block_info.timestamp + block_time; diff --git a/crates/derive/src/stages/attributes_queue/deposits.rs b/crates/derive/src/stages/attributes_queue/deposits.rs index 512e8ecd..7420c8bb 100644 --- a/crates/derive/src/stages/attributes_queue/deposits.rs +++ b/crates/derive/src/stages/attributes_queue/deposits.rs @@ -3,7 +3,7 @@ use alloc::vec::Vec; use alloy_consensus::{Eip658Value, Receipt}; use alloy_primitives::{Address, Bytes, B256}; -use kona_primitives::{decode_deposit, DEPOSIT_EVENT_ABI_HASH}; +use op_alloy_protocol::{decode_deposit, DEPOSIT_EVENT_ABI_HASH}; /// Derive deposits for transaction receipts. /// @@ -43,7 +43,7 @@ mod tests { use super::*; use alloc::vec; use alloy_primitives::{address, Bytes, Log, LogData, U256, U64}; - use kona_primitives::DepositError; + use op_alloy_protocol::DepositError; fn generate_valid_log() -> Log { let deposit_contract = address!("1111111111111111111111111111111111111111"); diff --git a/crates/derive/src/stages/batch_queue.rs b/crates/derive/src/stages/batch_queue.rs index b5acf90a..609083d0 100644 --- a/crates/derive/src/stages/batch_queue.rs +++ b/crates/derive/src/stages/batch_queue.rs @@ -4,7 +4,8 @@ use alloc::{boxed::Box, sync::Arc, vec::Vec}; use anyhow::anyhow; use async_trait::async_trait; use core::fmt::Debug; -use kona_primitives::{BlockInfo, L2BlockInfo, RollupConfig, SystemConfig}; +use op_alloy_genesis::{RollupConfig, SystemConfig}; +use op_alloy_protocol::{BlockInfo, L2BlockInfo}; use tracing::{error, info, warn}; use crate::{ @@ -457,13 +458,13 @@ mod tests { traits::test_utils::TestL2ChainProvider, }; use alloc::vec; + use alloy_eips::BlockNumHash; use alloy_primitives::{address, b256, Address, Bytes, TxKind, B256, U256}; use alloy_rlp::{BytesMut, Encodable}; - use kona_primitives::{ - BlockID, ChainGenesis, L1BlockInfoBedrock, L1BlockInfoTx, L2ExecutionPayload, - L2ExecutionPayloadEnvelope, - }; + use kona_primitives::{L2ExecutionPayload, L2ExecutionPayloadEnvelope}; use op_alloy_consensus::{OpTxType, TxDeposit}; + use op_alloy_genesis::ChainGenesis; + use op_alloy_protocol::{L1BlockInfoBedrock, L1BlockInfoTx}; use tracing::Level; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; @@ -514,7 +515,7 @@ mod tests { let fetcher = TestL2ChainProvider::default(); let mut bq = BatchQueue::new(cfg, mock, fetcher); let parent = L2BlockInfo { - l1_origin: BlockID { number: 10, ..Default::default() }, + l1_origin: BlockNumHash { number: 10, ..Default::default() }, ..Default::default() }; let res = bq.next_batch(parent).await.unwrap_err(); @@ -536,8 +537,8 @@ mod tests { max_sequencer_drift: 10000000, seq_window_size: 10000000, genesis: ChainGenesis { - l2: BlockID { number: 8, hash: payload_block_hash }, - l1: BlockID { number: 16988980031808077784, ..Default::default() }, + l2: BlockNumHash { number: 8, hash: payload_block_hash }, + l1: BlockNumHash { number: 16988980031808077784, ..Default::default() }, ..Default::default() }, batch_inbox_address: address!("6887246668a3b87f54deb3b94ba47a6f63f32985"), @@ -641,7 +642,7 @@ mod tests { parent_hash: parent_check, hash: origin_check, }, - l1_origin: BlockID { number: 16988980031808077784, hash: origin_check }, + l1_origin: BlockNumHash { number: 16988980031808077784, hash: origin_check }, ..Default::default() }; let res = bq.next_batch(parent).await.unwrap_err(); diff --git a/crates/derive/src/stages/channel_bank.rs b/crates/derive/src/stages/channel_bank.rs index 845c1c8e..d1272be9 100644 --- a/crates/derive/src/stages/channel_bank.rs +++ b/crates/derive/src/stages/channel_bank.rs @@ -12,7 +12,8 @@ use anyhow::anyhow; use async_trait::async_trait; use core::fmt::Debug; use hashbrown::HashMap; -use kona_primitives::{BlockInfo, Channel, ChannelId, Frame, RollupConfig, SystemConfig}; +use op_alloy_genesis::{RollupConfig, SystemConfig}; +use op_alloy_protocol::{BlockInfo, Channel, ChannelId, Frame}; use tracing::{trace, warn}; /// Provides frames for the [ChannelBank] stage. @@ -274,7 +275,7 @@ mod tests { test_utils::{CollectingLayer, MockChannelBankProvider, TraceStorage}, }; use alloc::vec; - use kona_primitives::{BASE_MAINNET_CONFIG, OP_MAINNET_CONFIG}; + use op_alloy_genesis::{BASE_MAINNET_CONFIG, OP_MAINNET_CONFIG}; use tracing::Level; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; @@ -302,11 +303,11 @@ mod tests { assert!(channel_bank.channels.is_empty()); assert_eq!(trace_store.lock().iter().filter(|(l, _)| matches!(l, &Level::WARN)).count(), 0); assert_eq!(channel_bank.ingest_frame(frame.clone()), Ok(())); - assert_eq!(channel_bank.size(), kona_primitives::FRAME_OVERHEAD); + assert_eq!(channel_bank.size(), op_alloy_protocol::FRAME_OVERHEAD); assert_eq!(channel_bank.channels.len(), 1); // This should fail since the frame is already ingested. assert_eq!(channel_bank.ingest_frame(frame), Ok(())); - assert_eq!(channel_bank.size(), kona_primitives::FRAME_OVERHEAD); + assert_eq!(channel_bank.size(), op_alloy_protocol::FRAME_OVERHEAD); assert_eq!(channel_bank.channels.len(), 1); assert_eq!(trace_store.lock().iter().filter(|(l, _)| matches!(l, &Level::WARN)).count(), 1); } diff --git a/crates/derive/src/stages/channel_reader.rs b/crates/derive/src/stages/channel_reader.rs index 1fc36c0d..ccde829a 100644 --- a/crates/derive/src/stages/channel_reader.rs +++ b/crates/derive/src/stages/channel_reader.rs @@ -6,7 +6,8 @@ use crate::{ stages::{decompress_brotli, BatchQueueProvider}, traits::{OriginAdvancer, OriginProvider, ResettableStage}, }; -use kona_primitives::{BlockInfo, RollupConfig, SystemConfig}; +use op_alloy_genesis::{RollupConfig, SystemConfig}; +use op_alloy_protocol::BlockInfo; use alloc::{boxed::Box, sync::Arc, vec::Vec}; use alloy_primitives::Bytes; diff --git a/crates/derive/src/stages/frame_queue.rs b/crates/derive/src/stages/frame_queue.rs index 46c9d2e2..067f2eeb 100644 --- a/crates/derive/src/stages/frame_queue.rs +++ b/crates/derive/src/stages/frame_queue.rs @@ -10,7 +10,8 @@ use alloy_primitives::Bytes; use anyhow::anyhow; use async_trait::async_trait; use core::fmt::Debug; -use kona_primitives::{BlockInfo, Frame, SystemConfig}; +use op_alloy_genesis::SystemConfig; +use op_alloy_protocol::{BlockInfo, Frame}; use tracing::{debug, error, trace}; /// Provides data frames for the [FrameQueue] stage. @@ -130,7 +131,7 @@ pub(crate) mod tests { use super::*; use crate::stages::test_utils::MockFrameQueueProvider; use alloc::{vec, vec::Vec}; - use kona_primitives::DERIVATION_VERSION_0; + use op_alloy_protocol::DERIVATION_VERSION_0; pub(crate) fn new_test_frames(count: usize) -> Vec { (0..count) diff --git a/crates/derive/src/stages/l1_retrieval.rs b/crates/derive/src/stages/l1_retrieval.rs index 94bf555c..f98e1fa3 100644 --- a/crates/derive/src/stages/l1_retrieval.rs +++ b/crates/derive/src/stages/l1_retrieval.rs @@ -11,7 +11,8 @@ use alloc::boxed::Box; use alloy_primitives::Address; use anyhow::anyhow; use async_trait::async_trait; -use kona_primitives::{BlockInfo, SystemConfig}; +use op_alloy_genesis::SystemConfig; +use op_alloy_protocol::BlockInfo; /// Provides L1 blocks for the [L1Retrieval] stage. /// This is the previous stage in the pipeline. @@ -25,7 +26,7 @@ pub trait L1RetrievalProvider { /// [L1Traversal]: crate::stages::L1Traversal async fn next_l1_block(&mut self) -> StageResult>; - /// Returns the batcher [Address] from the [kona_primitives::SystemConfig]. + /// Returns the batcher [Address] from the [op_alloy_genesis::SystemConfig]. fn batcher_addr(&self) -> Address; } diff --git a/crates/derive/src/stages/l1_traversal.rs b/crates/derive/src/stages/l1_traversal.rs index 28e428c4..92d17aa2 100644 --- a/crates/derive/src/stages/l1_traversal.rs +++ b/crates/derive/src/stages/l1_traversal.rs @@ -8,7 +8,8 @@ use crate::{ use alloc::{boxed::Box, sync::Arc}; use alloy_primitives::Address; use async_trait::async_trait; -use kona_primitives::{BlockInfo, RollupConfig, SystemConfig}; +use op_alloy_genesis::{RollupConfig, SystemConfig}; +use op_alloy_protocol::BlockInfo; use tracing::warn; /// The [L1Traversal] stage of the derivation pipeline. @@ -124,7 +125,7 @@ impl ResettableStage for L1Traversal { async fn reset(&mut self, base: BlockInfo, cfg: &SystemConfig) -> StageResult<()> { self.block = Some(base); self.done = false; - self.system_config = cfg.clone(); + self.system_config = *cfg; crate::inc!(STAGE_RESETS, &["l1-traversal"]); Ok(()) } diff --git a/crates/derive/src/stages/test_utils/attributes_queue.rs b/crates/derive/src/stages/test_utils/attributes_queue.rs index 45002fbd..9c127cc5 100644 --- a/crates/derive/src/stages/test_utils/attributes_queue.rs +++ b/crates/derive/src/stages/test_utils/attributes_queue.rs @@ -7,8 +7,11 @@ use crate::{ traits::{OriginAdvancer, OriginProvider, ResettableStage}, }; use alloc::{boxed::Box, vec::Vec}; +use alloy_eips::BlockNumHash; use async_trait::async_trait; -use kona_primitives::{BlockID, BlockInfo, L2BlockInfo, L2PayloadAttributes, SystemConfig}; +use kona_primitives::L2PayloadAttributes; +use op_alloy_genesis::SystemConfig; +use op_alloy_protocol::{BlockInfo, L2BlockInfo}; /// A mock implementation of the [`AttributesBuilder`] for testing. #[derive(Debug, Default)] @@ -23,7 +26,7 @@ impl AttributesBuilder for MockAttributesBuilder { async fn prepare_payload_attributes( &mut self, _l2_parent: L2BlockInfo, - _epoch: BlockID, + _epoch: BlockNumHash, ) -> Result { match self.attributes.pop() { Some(Ok(attrs)) => Ok(attrs), diff --git a/crates/derive/src/stages/test_utils/batch_queue.rs b/crates/derive/src/stages/test_utils/batch_queue.rs index ca2e71c1..1baa3934 100644 --- a/crates/derive/src/stages/test_utils/batch_queue.rs +++ b/crates/derive/src/stages/test_utils/batch_queue.rs @@ -8,7 +8,8 @@ use crate::{ }; use alloc::{boxed::Box, vec::Vec}; use async_trait::async_trait; -use kona_primitives::{BlockInfo, SystemConfig}; +use op_alloy_genesis::SystemConfig; +use op_alloy_protocol::BlockInfo; /// A mock provider for the [BatchQueue] stage. #[derive(Debug, Default)] diff --git a/crates/derive/src/stages/test_utils/channel_bank.rs b/crates/derive/src/stages/test_utils/channel_bank.rs index c5e5e5de..5da07b72 100644 --- a/crates/derive/src/stages/test_utils/channel_bank.rs +++ b/crates/derive/src/stages/test_utils/channel_bank.rs @@ -7,7 +7,8 @@ use crate::{ }; use alloc::{boxed::Box, vec::Vec}; use async_trait::async_trait; -use kona_primitives::{BlockInfo, Frame, SystemConfig}; +use op_alloy_genesis::SystemConfig; +use op_alloy_protocol::{BlockInfo, Frame}; /// A mock [ChannelBankProvider] for testing the [ChannelBank] stage. #[derive(Debug, Default)] diff --git a/crates/derive/src/stages/test_utils/channel_reader.rs b/crates/derive/src/stages/test_utils/channel_reader.rs index 87b1ed5b..ce1fa7e6 100644 --- a/crates/derive/src/stages/test_utils/channel_reader.rs +++ b/crates/derive/src/stages/test_utils/channel_reader.rs @@ -8,7 +8,8 @@ use crate::{ use alloc::{boxed::Box, vec::Vec}; use alloy_primitives::Bytes; use async_trait::async_trait; -use kona_primitives::{BlockInfo, SystemConfig}; +use op_alloy_genesis::SystemConfig; +use op_alloy_protocol::BlockInfo; /// A mock [ChannelReaderProvider] for testing the [ChannelReader] stage. #[derive(Debug, Default)] diff --git a/crates/derive/src/stages/test_utils/frame_queue.rs b/crates/derive/src/stages/test_utils/frame_queue.rs index 05a6dcbd..6d849100 100644 --- a/crates/derive/src/stages/test_utils/frame_queue.rs +++ b/crates/derive/src/stages/test_utils/frame_queue.rs @@ -8,7 +8,8 @@ use crate::{ use alloc::{boxed::Box, vec::Vec}; use alloy_primitives::Bytes; use async_trait::async_trait; -use kona_primitives::{BlockInfo, SystemConfig}; +use op_alloy_genesis::SystemConfig; +use op_alloy_protocol::BlockInfo; /// A mock [FrameQueueProvider] for testing the [FrameQueue] stage. #[derive(Debug, Default)] diff --git a/crates/derive/src/stages/test_utils/sys_config_fetcher.rs b/crates/derive/src/stages/test_utils/sys_config_fetcher.rs index 21c59c38..5829d442 100644 --- a/crates/derive/src/stages/test_utils/sys_config_fetcher.rs +++ b/crates/derive/src/stages/test_utils/sys_config_fetcher.rs @@ -5,7 +5,9 @@ use alloc::{boxed::Box, sync::Arc}; use anyhow::Result; use async_trait::async_trait; use hashbrown::HashMap; -use kona_primitives::{L2BlockInfo, L2ExecutionPayloadEnvelope, RollupConfig, SystemConfig}; +use kona_primitives::L2ExecutionPayloadEnvelope; +use op_alloy_genesis::{RollupConfig, SystemConfig}; +use op_alloy_protocol::L2BlockInfo; /// A mock implementation of the [`SystemConfigL2Fetcher`] for testing. #[derive(Debug, Default)] diff --git a/crates/derive/src/traits/attributes.rs b/crates/derive/src/traits/attributes.rs index 260661f5..d0d38f41 100644 --- a/crates/derive/src/traits/attributes.rs +++ b/crates/derive/src/traits/attributes.rs @@ -2,7 +2,8 @@ use alloc::boxed::Box; use async_trait::async_trait; -use kona_primitives::{L2AttributesWithParent, L2BlockInfo}; +use kona_primitives::L2AttributesWithParent; +use op_alloy_protocol::L2BlockInfo; use crate::errors::StageResult; diff --git a/crates/derive/src/traits/data_sources.rs b/crates/derive/src/traits/data_sources.rs index f06cd883..40cc8e0f 100644 --- a/crates/derive/src/traits/data_sources.rs +++ b/crates/derive/src/traits/data_sources.rs @@ -2,10 +2,12 @@ //! pipeline's stages. use alloc::{boxed::Box, fmt::Debug, vec::Vec}; +use alloy_eips::eip4844::Blob; use alloy_primitives::Bytes; use anyhow::Result; use async_trait::async_trait; -use kona_primitives::{Blob, BlockInfo, IndexedBlobHash}; +use kona_primitives::IndexedBlobHash; +use op_alloy_protocol::BlockInfo; use crate::errors::{BlobProviderError, StageResult}; diff --git a/crates/derive/src/traits/pipeline.rs b/crates/derive/src/traits/pipeline.rs index f509d2b2..04d12333 100644 --- a/crates/derive/src/traits/pipeline.rs +++ b/crates/derive/src/traits/pipeline.rs @@ -3,7 +3,8 @@ use alloc::boxed::Box; use async_trait::async_trait; use core::iter::Iterator; -use kona_primitives::{BlockInfo, L2AttributesWithParent, L2BlockInfo}; +use kona_primitives::L2AttributesWithParent; +use op_alloy_protocol::{BlockInfo, L2BlockInfo}; use super::OriginProvider; use crate::errors::StageError; diff --git a/crates/derive/src/traits/providers.rs b/crates/derive/src/traits/providers.rs index 0b27f86e..98c26588 100644 --- a/crates/derive/src/traits/providers.rs +++ b/crates/derive/src/traits/providers.rs @@ -3,9 +3,9 @@ use alloy_consensus::{Header, Receipt, TxEnvelope}; use alloy_primitives::B256; use anyhow::Result; use async_trait::async_trait; -use kona_primitives::{ - BlockInfo, L2BlockInfo, L2ExecutionPayloadEnvelope, RollupConfig, SystemConfig, -}; +use kona_primitives::L2ExecutionPayloadEnvelope; +use op_alloy_genesis::{RollupConfig, SystemConfig}; +use op_alloy_protocol::{BlockInfo, L2BlockInfo}; /// Describes the functionality of a data source that can provide information from the blockchain. #[async_trait] diff --git a/crates/derive/src/traits/reset.rs b/crates/derive/src/traits/reset.rs index f86d7d4f..07184ff6 100644 --- a/crates/derive/src/traits/reset.rs +++ b/crates/derive/src/traits/reset.rs @@ -2,7 +2,8 @@ use alloc::boxed::Box; use async_trait::async_trait; -use kona_primitives::{BlockInfo, SystemConfig}; +use op_alloy_genesis::SystemConfig; +use op_alloy_protocol::BlockInfo; /// Provides the [BlockInfo] and [SystemConfig] for the stack to reset the stages. #[async_trait] diff --git a/crates/derive/src/traits/stages.rs b/crates/derive/src/traits/stages.rs index 235db918..8055b12e 100644 --- a/crates/derive/src/traits/stages.rs +++ b/crates/derive/src/traits/stages.rs @@ -2,7 +2,8 @@ use alloc::boxed::Box; use async_trait::async_trait; -use kona_primitives::{BlockInfo, SystemConfig}; +use op_alloy_genesis::SystemConfig; +use op_alloy_protocol::BlockInfo; use crate::errors::StageResult; diff --git a/crates/derive/src/traits/test_utils.rs b/crates/derive/src/traits/test_utils.rs index a1601fae..e16fbf50 100644 --- a/crates/derive/src/traits/test_utils.rs +++ b/crates/derive/src/traits/test_utils.rs @@ -2,15 +2,15 @@ use alloc::{boxed::Box, sync::Arc, vec, vec::Vec}; use alloy_consensus::{Header, Receipt, TxEnvelope}; +use alloy_eips::eip4844::Blob; use alloy_primitives::{Address, Bytes, B256}; use anyhow::Result; use async_trait::async_trait; use core::fmt::Debug; use hashbrown::HashMap; -use kona_primitives::{ - Blob, BlockInfo, IndexedBlobHash, L2BlockInfo, L2ExecutionPayloadEnvelope, RollupConfig, - SystemConfig, -}; +use kona_primitives::{IndexedBlobHash, L2ExecutionPayloadEnvelope}; +use op_alloy_genesis::{RollupConfig, SystemConfig}; +use op_alloy_protocol::{BlockInfo, L2BlockInfo}; use crate::{ errors::{BlobProviderError, StageError, StageResult}, diff --git a/crates/executor/Cargo.toml b/crates/executor/Cargo.toml index c76bfaaa..d5cb84cd 100644 --- a/crates/executor/Cargo.toml +++ b/crates/executor/Cargo.toml @@ -16,6 +16,7 @@ alloy-primitives = { workspace = true, features = ["rlp"] } alloy-eips.workspace = true alloy-consensus = { workspace = true, features = ["k256"] } op-alloy-consensus.workspace = true +op-alloy-genesis.workspace = true revm = { workspace = true, features = ["optimism"] } # Workspace diff --git a/crates/executor/benches/execution.rs b/crates/executor/benches/execution.rs index f61860c8..732cf98a 100644 --- a/crates/executor/benches/execution.rs +++ b/crates/executor/benches/execution.rs @@ -7,9 +7,8 @@ use anyhow::{anyhow, Result}; use criterion::{criterion_group, criterion_main, Bencher, Criterion}; use kona_executor::StatelessL2BlockExecutor; use kona_mpt::{NoopTrieDBHinter, TrieDBFetcher}; -use kona_primitives::{ - L2PayloadAttributes, RollupConfig, OP_BASE_FEE_PARAMS, OP_CANYON_BASE_FEE_PARAMS, -}; +use kona_primitives::L2PayloadAttributes; +use op_alloy_genesis::{RollupConfig, OP_BASE_FEE_PARAMS, OP_CANYON_BASE_FEE_PARAMS}; use pprof::criterion::{Output, PProfProfiler}; use serde::Deserialize; use std::collections::HashMap; diff --git a/crates/executor/src/builder.rs b/crates/executor/src/builder.rs index 62a1a06d..0388115d 100644 --- a/crates/executor/src/builder.rs +++ b/crates/executor/src/builder.rs @@ -4,7 +4,7 @@ use crate::StatelessL2BlockExecutor; use alloy_consensus::{Header, Sealable, Sealed}; use anyhow::Result; use kona_mpt::{TrieDB, TrieDBFetcher, TrieDBHinter}; -use kona_primitives::RollupConfig; +use op_alloy_genesis::RollupConfig; use revm::{db::State, handler::register::EvmHandler}; /// A type alias for the [revm::handler::register::HandleRegister] for kona's block executor. diff --git a/crates/executor/src/canyon.rs b/crates/executor/src/canyon.rs index 3c1b9cf2..7e082d10 100644 --- a/crates/executor/src/canyon.rs +++ b/crates/executor/src/canyon.rs @@ -3,7 +3,7 @@ use alloy_primitives::{address, b256, hex, Address, Bytes, B256}; use anyhow::Result; use kona_mpt::{TrieDB, TrieDBFetcher, TrieDBHinter}; -use kona_primitives::RollupConfig; +use op_alloy_genesis::RollupConfig; use revm::{ primitives::{Account, Bytecode, HashMap}, DatabaseCommit, State, diff --git a/crates/executor/src/eip4788.rs b/crates/executor/src/eip4788.rs index f8c4efa7..5b939868 100644 --- a/crates/executor/src/eip4788.rs +++ b/crates/executor/src/eip4788.rs @@ -4,7 +4,8 @@ use alloc::{boxed::Box, vec::Vec}; use alloy_eips::eip4788::BEACON_ROOTS_ADDRESS; use alloy_primitives::{Address, Bytes, B256, U256}; use anyhow::{anyhow, Result}; -use kona_primitives::{L2PayloadAttributes, RollupConfig}; +use kona_primitives::L2PayloadAttributes; +use op_alloy_genesis::RollupConfig; use revm::{ primitives::{ BlockEnv, CfgEnvWithHandlerCfg, Env, EnvWithHandlerCfg, OptimismFields, TransactTo, TxEnv, diff --git a/crates/executor/src/lib.rs b/crates/executor/src/lib.rs index 699f5b12..241f96f5 100644 --- a/crates/executor/src/lib.rs +++ b/crates/executor/src/lib.rs @@ -13,8 +13,9 @@ use alloy_eips::eip2718::{Decodable2718, Encodable2718}; use alloy_primitives::{address, keccak256, Address, Bytes, TxKind, B256, U256}; use anyhow::{anyhow, Result}; use kona_mpt::{ordered_trie_with_encoder, TrieDB, TrieDBFetcher, TrieDBHinter}; -use kona_primitives::{L2PayloadAttributes, RollupConfig}; +use kona_primitives::L2PayloadAttributes; use op_alloy_consensus::{OpReceiptEnvelope, OpTxEnvelope}; +use op_alloy_genesis::RollupConfig; use revm::{ db::{states::bundle_state::BundleRetention, State}, primitives::{ @@ -626,7 +627,7 @@ mod test { use alloy_primitives::{address, b256, hex}; use alloy_rlp::Decodable; use kona_mpt::NoopTrieDBHinter; - use kona_primitives::{OP_BASE_FEE_PARAMS, OP_CANYON_BASE_FEE_PARAMS}; + use op_alloy_genesis::{OP_BASE_FEE_PARAMS, OP_CANYON_BASE_FEE_PARAMS}; use serde::Deserialize; use std::{collections::HashMap, format}; diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index a72def6c..1277afda 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -19,9 +19,7 @@ alloy-rlp = { workspace = true, features = ["derive"] } alloy-primitives = { workspace = true, features = ["rlp"] } op-alloy-consensus.workspace = true op-alloy-protocol.workspace = true - -# SCR Repo Primitives -superchain-primitives.workspace = true +op-alloy-genesis.workspace = true # `serde` feature dependencies serde = { workspace = true, optional = true } @@ -37,5 +35,14 @@ serde_json.workspace = true [features] default = ["serde"] -serde = ["dep:serde", "superchain-primitives/serde"] -online = ["dep:c-kzg", "dep:sha2", "dep:revm", "dep:tracing", "revm/default"] +serde = ["dep:serde", "op-alloy-consensus/serde", "op-alloy-protocol/serde", "op-alloy-genesis/serde"] +online = [ + "dep:c-kzg", + "dep:sha2", + "dep:revm", + "dep:tracing", + "revm/default", + "op-alloy-consensus/std", + "op-alloy-protocol/std", + "op-alloy-genesis/std", +] diff --git a/crates/primitives/src/attributes.rs b/crates/primitives/src/attributes.rs index 76f9f3cc..2a2af904 100644 --- a/crates/primitives/src/attributes.rs +++ b/crates/primitives/src/attributes.rs @@ -3,9 +3,10 @@ #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; -use super::{L2BlockInfo, Withdrawal}; use alloc::vec::Vec; +use alloy_eips::eip4895::Withdrawal; use alloy_primitives::{Address, Bytes, B256}; +use op_alloy_protocol::L2BlockInfo; /// Payload attributes. #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] diff --git a/crates/primitives/src/blob.rs b/crates/primitives/src/blob.rs index 297b67a7..089c8e9a 100644 --- a/crates/primitives/src/blob.rs +++ b/crates/primitives/src/blob.rs @@ -1,11 +1,10 @@ //! EIP4844 Blob Type use alloc::vec; +use alloy_eips::eip4844::{Blob, BYTES_PER_BLOB, VERSIONED_HASH_VERSION_KZG}; use alloy_primitives::{Bytes, B256}; use anyhow::Result; -use super::{Blob, BYTES_PER_BLOB, VERSIONED_HASH_VERSION_KZG}; - /// The blob encoding version pub(crate) const BLOB_ENCODING_VERSION: u8 = 0; diff --git a/crates/primitives/src/block_info.rs b/crates/primitives/src/block_info.rs deleted file mode 100644 index 294fc344..00000000 --- a/crates/primitives/src/block_info.rs +++ /dev/null @@ -1,532 +0,0 @@ -//! This module contains the [L1BlockInfoTx] type, and various encoding / decoding methods for it. - -use super::{BlockID, DepositSourceDomain, L1InfoDepositSource, RollupConfig, SystemConfig}; -use alloc::vec::Vec; -use alloy_consensus::Header; -use alloy_primitives::{address, Address, Bytes, TxKind, B256, U256}; -use anyhow::{anyhow, Result}; -use op_alloy_consensus::{OpTxEnvelope, TxDeposit}; - -/// The system transaction gas limit post-Regolith -const REGOLITH_SYSTEM_TX_GAS: u128 = 1_000_000; -/// The type byte identifier for the L1 scalar format in Ecotone. -const L1_SCALAR_ECOTONE: u8 = 1; -/// The length of an L1 info transaction in Bedrock. -const L1_INFO_TX_LEN_BEDROCK: usize = 4 + 32 * 8; -/// The length of an L1 info transaction in Ecotone. -const L1_INFO_TX_LEN_ECOTONE: usize = 4 + 32 * 5; -/// The 4 byte selector of the -/// "setL1BlockValues(uint64,uint64,uint256,bytes32,uint64,bytes32,uint256,uint256)" function -const L1_INFO_TX_SELECTOR_BEDROCK: [u8; 4] = [0x01, 0x5d, 0x8e, 0xb9]; -/// The 4 byte selector of "setL1BlockValuesEcotone()" -const L1_INFO_TX_SELECTOR_ECOTONE: [u8; 4] = [0x44, 0x0a, 0x5e, 0x20]; -/// The address of the L1 Block contract -const L1_BLOCK_ADDRESS: Address = address!("4200000000000000000000000000000000000015"); -/// The depositor address of the L1 info transaction -const L1_INFO_DEPOSITOR_ADDRESS: Address = address!("deaddeaddeaddeaddeaddeaddeaddeaddead0001"); - -/// The [L1BlockInfoTx] enum contains variants for the different versions of the L1 block info -/// transaction on OP Stack chains. -/// -/// This transaction always sits at the top of the block, and alters the `L1 Block` contract's -/// knowledge of the L1 chain. -#[derive(Debug)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum L1BlockInfoTx { - /// A Bedrock L1 info transaction - Bedrock(L1BlockInfoBedrock), - /// An Ecotone L1 info transaction - Ecotone(L1BlockInfoEcotone), -} - -/// Represents the fields within a Bedrock L1 block info transaction. -/// -/// Bedrock Binary Format -// +---------+--------------------------+ -// | Bytes | Field | -// +---------+--------------------------+ -// | 4 | Function signature | -// | 32 | Number | -// | 32 | Time | -// | 32 | BaseFee | -// | 32 | BlockHash | -// | 32 | SequenceNumber | -// | 32 | BatcherHash | -// | 32 | L1FeeOverhead | -// | 32 | L1FeeScalar | -// +---------+--------------------------+ -#[derive(Debug, Clone, Hash, Eq, PartialEq, Default)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct L1BlockInfoBedrock { - /// The current L1 origin block number - pub number: u64, - /// The current L1 origin block's timestamp - pub time: u64, - /// The current L1 origin block's basefee - pub base_fee: u64, - /// The current L1 origin block's hash - pub block_hash: B256, - /// The current sequence number - pub sequence_number: u64, - /// The address of the batch submitter - pub batcher_address: Address, - /// The fee overhead for L1 data - pub l1_fee_overhead: U256, - /// The fee scalar for L1 data - pub l1_fee_scalar: U256, -} - -/// Represents the fields within an Ecotone L1 block info transaction. -/// -/// Ecotone Binary Format -/// +---------+--------------------------+ -/// | Bytes | Field | -/// +---------+--------------------------+ -/// | 4 | Function signature | -/// | 4 | BaseFeeScalar | -/// | 4 | BlobBaseFeeScalar | -/// | 8 | SequenceNumber | -/// | 8 | Timestamp | -/// | 8 | L1BlockNumber | -/// | 32 | BaseFee | -/// | 32 | BlobBaseFee | -/// | 32 | BlockHash | -/// | 32 | BatcherHash | -/// +---------+--------------------------+ -#[derive(Debug, Clone, Hash, Eq, PartialEq, Default)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct L1BlockInfoEcotone { - /// The current L1 origin block number - pub number: u64, - /// The current L1 origin block's timestamp - pub time: u64, - /// The current L1 origin block's basefee - pub base_fee: u64, - /// The current L1 origin block's hash - pub block_hash: B256, - /// The current sequence number - pub sequence_number: u64, - /// The address of the batch submitter - pub batcher_address: Address, - /// The current blob base fee on L1 - pub blob_base_fee: u128, - /// The fee scalar for L1 blobspace data - pub blob_base_fee_scalar: u32, - /// The fee scalar for L1 data - pub base_fee_scalar: u32, -} - -impl L1BlockInfoTx { - /// Creates a new [L1BlockInfoTx] from the given information. - pub fn try_new( - rollup_config: &RollupConfig, - system_config: &SystemConfig, - sequence_number: u64, - l1_header: &Header, - l2_block_time: u64, - ) -> Result { - // In the first block of Ecotone, the L1Block contract has not been upgraded yet due to the - // upgrade transactions being placed after the L1 info transaction. Because of this, - // for the first block of Ecotone, we send a Bedrock style L1 block info transaction - if rollup_config.is_ecotone_active(l2_block_time) && - rollup_config.ecotone_time.unwrap_or_default() != l2_block_time - { - let scalar = system_config.scalar.to_be_bytes::<32>(); - let blob_base_fee_scalar = (scalar[0] == L1_SCALAR_ECOTONE) - .then(|| { - Ok::(u32::from_be_bytes( - scalar[24..28] - .try_into() - .map_err(|_| anyhow!("Failed to parse L1 blob base fee scalar"))?, - )) - }) - .transpose()? - .unwrap_or_default(); - let base_fee_scalar = u32::from_be_bytes( - scalar[28..32] - .try_into() - .map_err(|_| anyhow!("Failed to parse base fee scalar"))?, - ); - Ok(Self::Ecotone(L1BlockInfoEcotone { - number: l1_header.number, - time: l1_header.timestamp, - base_fee: l1_header.base_fee_per_gas.unwrap_or(0) as u64, - block_hash: l1_header.hash_slow(), - sequence_number, - batcher_address: system_config.batcher_address, - blob_base_fee: l1_header.blob_fee().unwrap_or(1), - blob_base_fee_scalar, - base_fee_scalar, - })) - } else { - Ok(Self::Bedrock(L1BlockInfoBedrock { - number: l1_header.number, - time: l1_header.timestamp, - base_fee: l1_header.base_fee_per_gas.unwrap_or(0) as u64, - block_hash: l1_header.hash_slow(), - sequence_number, - batcher_address: system_config.batcher_address, - l1_fee_overhead: system_config.overhead, - l1_fee_scalar: system_config.scalar, - })) - } - } - - /// Creates a new [L1BlockInfoTx] from the given information and returns a typed [TxDeposit] to - /// include at the top of a block. - pub fn try_new_with_deposit_tx( - rollup_config: &RollupConfig, - system_config: &SystemConfig, - sequence_number: u64, - l1_header: &Header, - l2_block_time: u64, - ) -> Result<(L1BlockInfoTx, OpTxEnvelope)> { - let l1_info = - Self::try_new(rollup_config, system_config, sequence_number, l1_header, l2_block_time)?; - let l1_block_hash = match l1_info { - Self::Bedrock(ref tx) => tx.block_hash, - Self::Ecotone(ref tx) => tx.block_hash, - }; - - let source = DepositSourceDomain::L1Info(L1InfoDepositSource { - l1_block_hash, - seq_number: sequence_number, - }); - - let mut deposit_tx = TxDeposit { - source_hash: source.source_hash(), - from: L1_INFO_DEPOSITOR_ADDRESS, - to: TxKind::Call(L1_BLOCK_ADDRESS), - mint: None, - value: U256::ZERO, - gas_limit: 150_000_000, - is_system_transaction: true, - input: l1_info.encode_calldata(), - }; - - // With the regolith hardfork, system transactions were deprecated, and we allocate - // a constant amount of gas for special transactions like L1 block info. - if rollup_config.is_regolith_active(l2_block_time) { - deposit_tx.is_system_transaction = false; - deposit_tx.gas_limit = REGOLITH_SYSTEM_TX_GAS; - } - - Ok((l1_info, OpTxEnvelope::Deposit(deposit_tx))) - } - - /// Decodes the [L1BlockInfoEcotone] object from ethereum transaction calldata. - pub fn decode_calldata(r: &[u8]) -> Result { - let selector = r[0..4].try_into().expect("Failed to convert 4byte slice to array"); - match selector { - L1_INFO_TX_SELECTOR_BEDROCK => { - Ok(Self::Bedrock(L1BlockInfoBedrock::decode_calldata(r)?)) - } - L1_INFO_TX_SELECTOR_ECOTONE => { - Ok(Self::Ecotone(L1BlockInfoEcotone::decode_calldata(r)?)) - } - _ => anyhow::bail!("Unreachable case; Invalid L1 info transaction selector."), - } - } - - /// Encodes the [L1BlockInfoTx] object into Ethereum transaction calldata. - pub fn encode_calldata(&self) -> Bytes { - match self { - Self::Bedrock(bedrock_tx) => bedrock_tx.encode_calldata(), - Self::Ecotone(ecotone_tx) => ecotone_tx.encode_calldata(), - } - } - - /// Returns the L1 [BlockID] for the info transaction. - pub fn id(&self) -> BlockID { - match self { - Self::Ecotone(L1BlockInfoEcotone { number, block_hash, .. }) => { - BlockID { number: *number, hash: *block_hash } - } - Self::Bedrock(L1BlockInfoBedrock { number, block_hash, .. }) => { - BlockID { number: *number, hash: *block_hash } - } - } - } - - /// Returns the L1 fee overhead for the info transaction. After ecotone, this value is ignored. - pub fn l1_fee_overhead(&self) -> U256 { - match self { - Self::Bedrock(L1BlockInfoBedrock { l1_fee_overhead, .. }) => *l1_fee_overhead, - Self::Ecotone(_) => U256::ZERO, - } - } - - /// Returns the batcher address for the info transaction - pub fn batcher_address(&self) -> Address { - match self { - Self::Bedrock(L1BlockInfoBedrock { batcher_address, .. }) => *batcher_address, - Self::Ecotone(L1BlockInfoEcotone { batcher_address, .. }) => *batcher_address, - } - } - - /// Returns the sequence number for the info transaction - pub fn sequence_number(&self) -> u64 { - match self { - Self::Bedrock(L1BlockInfoBedrock { sequence_number, .. }) => *sequence_number, - Self::Ecotone(L1BlockInfoEcotone { sequence_number, .. }) => *sequence_number, - } - } -} - -impl L1BlockInfoBedrock { - /// Encodes the [L1BlockInfoBedrock] object into Ethereum transaction calldata. - pub fn encode_calldata(&self) -> Bytes { - let mut buf = Vec::with_capacity(L1_INFO_TX_LEN_BEDROCK); - buf.extend_from_slice(L1_INFO_TX_SELECTOR_BEDROCK.as_ref()); - buf.extend_from_slice(U256::from(self.number).to_be_bytes::<32>().as_slice()); - buf.extend_from_slice(U256::from(self.time).to_be_bytes::<32>().as_slice()); - buf.extend_from_slice(U256::from(self.base_fee).to_be_bytes::<32>().as_slice()); - buf.extend_from_slice(self.block_hash.as_slice()); - buf.extend_from_slice(U256::from(self.sequence_number).to_be_bytes::<32>().as_slice()); - buf.extend_from_slice(self.batcher_address.into_word().as_slice()); - buf.extend_from_slice(self.l1_fee_overhead.to_be_bytes::<32>().as_slice()); - buf.extend_from_slice(self.l1_fee_scalar.to_be_bytes::<32>().as_slice()); - buf.into() - } - - /// Decodes the [L1BlockInfoBedrock] object from ethereum transaction calldata. - pub fn decode_calldata(r: &[u8]) -> Result { - if r.len() != L1_INFO_TX_LEN_BEDROCK { - anyhow::bail!("Invalid calldata length for Bedrock L1 info transaction"); - } - - let number = - u64::from_be_bytes(r[28..36].try_into().map_err(|_| anyhow!("Conversion error"))?); - let time = - u64::from_be_bytes(r[60..68].try_into().map_err(|_| anyhow!("Conversion error"))?); - let base_fee = - u64::from_be_bytes(r[92..100].try_into().map_err(|_| anyhow!("Conversion error"))?); - let block_hash = B256::from_slice(r[100..132].as_ref()); - let sequence_number = - u64::from_be_bytes(r[156..164].try_into().map_err(|_| anyhow!("Conversion error"))?); - let batcher_address = Address::from_slice(r[176..196].as_ref()); - let l1_fee_overhead = U256::from_be_slice(r[196..228].as_ref()); - let l1_fee_scalar = U256::from_be_slice(r[228..260].as_ref()); - - Ok(Self { - number, - time, - base_fee, - block_hash, - sequence_number, - batcher_address, - l1_fee_overhead, - l1_fee_scalar, - }) - } -} - -impl L1BlockInfoEcotone { - /// Encodes the [L1BlockInfoEcotone] object into Ethereum transaction calldata. - pub fn encode_calldata(&self) -> Bytes { - let mut buf = Vec::with_capacity(L1_INFO_TX_LEN_ECOTONE); - buf.extend_from_slice(L1_INFO_TX_SELECTOR_ECOTONE.as_ref()); - buf.extend_from_slice(self.base_fee_scalar.to_be_bytes().as_ref()); - buf.extend_from_slice(self.blob_base_fee_scalar.to_be_bytes().as_ref()); - buf.extend_from_slice(self.sequence_number.to_be_bytes().as_ref()); - buf.extend_from_slice(self.time.to_be_bytes().as_ref()); - buf.extend_from_slice(self.number.to_be_bytes().as_ref()); - buf.extend_from_slice(U256::from(self.base_fee).to_be_bytes::<32>().as_ref()); - buf.extend_from_slice(U256::from(self.blob_base_fee).to_be_bytes::<32>().as_ref()); - buf.extend_from_slice(self.block_hash.as_ref()); - buf.extend_from_slice(self.batcher_address.into_word().as_ref()); - buf.into() - } - - /// Decodes the [L1BlockInfoEcotone] object from ethereum transaction calldata. - pub fn decode_calldata(r: &[u8]) -> Result { - if r.len() != L1_INFO_TX_LEN_ECOTONE { - anyhow::bail!("Invalid calldata length for Ecotone L1 info transaction"); - } - - let base_fee_scalar = - u32::from_be_bytes(r[4..8].try_into().map_err(|_| anyhow!("Conversion error"))?); - let blob_base_fee_scalar = - u32::from_be_bytes(r[8..12].try_into().map_err(|_| anyhow!("Conversion error"))?); - let sequence_number = - u64::from_be_bytes(r[12..20].try_into().map_err(|_| anyhow!("Conversion error"))?); - let timestamp = - u64::from_be_bytes(r[20..28].try_into().map_err(|_| anyhow!("Conversion error"))?); - let l1_block_number = - u64::from_be_bytes(r[28..36].try_into().map_err(|_| anyhow!("Conversion error"))?); - let base_fee = - u64::from_be_bytes(r[60..68].try_into().map_err(|_| anyhow!("Conversion error"))?); - let blob_base_fee = - u128::from_be_bytes(r[84..100].try_into().map_err(|_| anyhow!("Conversion error"))?); - let block_hash = B256::from_slice(r[100..132].as_ref()); - let batcher_address = Address::from_slice(r[144..164].as_ref()); - - Ok(Self { - number: l1_block_number, - time: timestamp, - base_fee, - block_hash, - sequence_number, - batcher_address, - blob_base_fee, - blob_base_fee_scalar, - base_fee_scalar, - }) - } -} - -#[cfg(test)] -mod test { - use super::*; - use alloc::string::ToString; - use alloy_primitives::{address, b256, hex}; - - const RAW_BEDROCK_INFO_TX: [u8; L1_INFO_TX_LEN_BEDROCK] = hex!("015d8eb9000000000000000000000000000000000000000000000000000000000117c4eb0000000000000000000000000000000000000000000000000000000065280377000000000000000000000000000000000000000000000000000000026d05d953392012032675be9f94aae5ab442de73c5f4fb1bf30fa7dd0d2442239899a40fc00000000000000000000000000000000000000000000000000000000000000040000000000000000000000006887246668a3b87f54deb3b94ba47a6f63f3298500000000000000000000000000000000000000000000000000000000000000bc00000000000000000000000000000000000000000000000000000000000a6fe0"); - const RAW_ECOTONE_INFO_TX: [u8; L1_INFO_TX_LEN_ECOTONE] = hex!("440a5e2000000558000c5fc5000000000000000500000000661c277300000000012bec20000000000000000000000000000000000000000000000000000000026e9f109900000000000000000000000000000000000000000000000000000000000000011c4c84c50740386c7dc081efddd644405f04cde73e30a2e381737acce9f5add30000000000000000000000006887246668a3b87f54deb3b94ba47a6f63f32985"); - - #[test] - fn bedrock_l1_block_info_invalid_len() { - let err = L1BlockInfoBedrock::decode_calldata(&[0xde, 0xad]); - assert!(err.is_err()); - assert_eq!( - err.err().unwrap().to_string(), - "Invalid calldata length for Bedrock L1 info transaction" - ); - } - - #[test] - fn ecotone_l1_block_info_invalid_len() { - let err = L1BlockInfoEcotone::decode_calldata(&[0xde, 0xad]); - assert!(err.is_err()); - assert_eq!( - err.err().unwrap().to_string(), - "Invalid calldata length for Ecotone L1 info transaction" - ); - } - - #[test] - fn bedrock_l1_block_info_tx_roundtrip() { - let expected = L1BlockInfoBedrock { - number: 18334955, - time: 1697121143, - base_fee: 10419034451, - block_hash: b256!("392012032675be9f94aae5ab442de73c5f4fb1bf30fa7dd0d2442239899a40fc"), - sequence_number: 4, - batcher_address: address!("6887246668a3b87f54deb3b94ba47a6f63f32985"), - l1_fee_overhead: U256::from(0xbc), - l1_fee_scalar: U256::from(0xa6fe0), - }; - - let L1BlockInfoTx::Bedrock(decoded) = - L1BlockInfoTx::decode_calldata(RAW_BEDROCK_INFO_TX.as_ref()).unwrap() - else { - panic!("Wrong fork"); - }; - assert_eq!(expected, decoded); - assert_eq!(RAW_BEDROCK_INFO_TX, decoded.encode_calldata().as_ref()); - } - - #[test] - fn ecotone_l1_block_info_tx_roundtrip() { - let expected = L1BlockInfoEcotone { - number: 19655712, - time: 1713121139, - base_fee: 10445852825, - block_hash: b256!("1c4c84c50740386c7dc081efddd644405f04cde73e30a2e381737acce9f5add3"), - sequence_number: 5, - batcher_address: address!("6887246668a3b87f54deb3b94ba47a6f63f32985"), - blob_base_fee: 1, - blob_base_fee_scalar: 810949, - base_fee_scalar: 1368, - }; - - let L1BlockInfoTx::Ecotone(decoded) = - L1BlockInfoTx::decode_calldata(RAW_ECOTONE_INFO_TX.as_ref()).unwrap() - else { - panic!("Wrong fork"); - }; - assert_eq!(expected, decoded); - assert_eq!(decoded.encode_calldata().as_ref(), RAW_ECOTONE_INFO_TX); - } - - #[test] - fn try_new_with_deposit_tx_bedrock() { - let rollup_config = RollupConfig::default(); - let system_config = SystemConfig::default(); - let sequence_number = 0; - let l1_header = Header::default(); - let l2_block_time = 0; - - let l1_info = L1BlockInfoTx::try_new( - &rollup_config, - &system_config, - sequence_number, - &l1_header, - l2_block_time, - ) - .unwrap(); - - let L1BlockInfoTx::Bedrock(l1_info) = l1_info else { - panic!("Wrong fork"); - }; - - assert_eq!(l1_info.number, l1_header.number); - assert_eq!(l1_info.time, l1_header.timestamp); - assert_eq!(l1_info.base_fee, l1_header.base_fee_per_gas.unwrap_or(0) as u64); - assert_eq!(l1_info.block_hash, l1_header.hash_slow()); - assert_eq!(l1_info.sequence_number, sequence_number); - assert_eq!(l1_info.batcher_address, system_config.batcher_address); - assert_eq!(l1_info.l1_fee_overhead, system_config.overhead); - assert_eq!(l1_info.l1_fee_scalar, system_config.scalar); - } - - #[test] - fn try_new_with_deposit_tx_ecotone() { - let rollup_config = RollupConfig { ecotone_time: Some(1), ..Default::default() }; - let system_config = SystemConfig::default(); - let sequence_number = 0; - let l1_header = Header::default(); - let l2_block_time = 0xFF; - - let l1_info = L1BlockInfoTx::try_new( - &rollup_config, - &system_config, - sequence_number, - &l1_header, - l2_block_time, - ) - .unwrap(); - - let L1BlockInfoTx::Ecotone(l1_info) = l1_info else { - panic!("Wrong fork"); - }; - - assert_eq!(l1_info.number, l1_header.number); - assert_eq!(l1_info.time, l1_header.timestamp); - assert_eq!(l1_info.base_fee, l1_header.base_fee_per_gas.unwrap_or(0) as u64); - assert_eq!(l1_info.block_hash, l1_header.hash_slow()); - assert_eq!(l1_info.sequence_number, sequence_number); - assert_eq!(l1_info.batcher_address, system_config.batcher_address); - assert_eq!(l1_info.blob_base_fee, l1_header.blob_fee().unwrap_or(1)); - - let scalar = system_config.scalar.to_be_bytes::<32>(); - let blob_base_fee_scalar = (scalar[0] == L1_SCALAR_ECOTONE) - .then(|| { - u32::from_be_bytes( - scalar[24..28] - .try_into() - .map_err(|_| anyhow!("Failed to parse L1 blob base fee scalar")) - .unwrap(), - ) - }) - .unwrap_or_default(); - let base_fee_scalar = u32::from_be_bytes( - scalar[28..32] - .try_into() - .map_err(|_| anyhow!("Failed to parse base fee scalar")) - .unwrap(), - ); - assert_eq!(l1_info.blob_base_fee_scalar, blob_base_fee_scalar); - assert_eq!(l1_info.base_fee_scalar, base_fee_scalar); - } -} diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index dbc75e5c..aa1703bc 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -7,47 +7,9 @@ extern crate alloc; -// Re-export `op-alloy-consensus` types. -pub use op_alloy_consensus::Hardforks; - -// Re-export `op-alloy-protocol` types. -pub use op_alloy_protocol::{ - starts_with_2718_deposit, BlockInfo, Channel, ChannelId, Frame, L2BlockInfo, CHANNEL_ID_LENGTH, - DERIVATION_VERSION_0, FJORD_MAX_RLP_BYTES_PER_CHANNEL, FRAME_OVERHEAD, MAX_FRAME_LEN, - MAX_RLP_BYTES_PER_CHANNEL, -}; - -// Re-export `superchain-primitives` types. -pub use superchain_primitives::*; - -// Re-export `alloy-primitives`. -pub use alloy_primitives; - -// Re-export `alloy-consensus` types. -pub use alloy_consensus::{ - Header, Receipt, Signed, TxEip1559, TxEip2930, TxEip4844, TxEip4844Variant, - TxEip4844WithSidecar, TxEnvelope, TxLegacy, -}; - -pub use op_alloy_protocol::deposits::{ - decode_deposit, DepositError, DepositSourceDomain, DepositSourceDomainIdentifier, - L1InfoDepositSource, UpgradeDepositSource, UserDepositSource, DEPOSIT_EVENT_ABI_HASH, -}; - -// Re-export `alloy-eips` eip4844 types. -pub use alloy_eips::eip4844::{Blob, BYTES_PER_BLOB, VERSIONED_HASH_VERSION_KZG}; - -/// Re-export the [Withdrawal] type from the [alloy_eips] crate. -/// -/// [Withdrawal]: alloy_eips::eip4895::Withdrawal -pub use alloy_eips::eip4895::Withdrawal; - pub mod block; pub use block::{Block, BlockKind, OpBlock}; -pub mod block_info; -pub use block_info::{L1BlockInfoBedrock, L1BlockInfoEcotone, L1BlockInfoTx}; - pub mod payload; pub use payload::{ L2ExecutionPayload, L2ExecutionPayloadEnvelope, PAYLOAD_MEM_FIXED_COST, PAYLOAD_TX_MEM_OVERHEAD, diff --git a/crates/primitives/src/payload.rs b/crates/primitives/src/payload.rs index dfbd7778..843d54ed 100644 --- a/crates/primitives/src/payload.rs +++ b/crates/primitives/src/payload.rs @@ -1,10 +1,18 @@ //! Contains the execution payload type. use alloc::vec::Vec; -use alloy_eips::eip2718::{Decodable2718, Encodable2718}; +use alloy_eips::{ + eip2718::{Decodable2718, Encodable2718}, + eip4895::Withdrawal, +}; use alloy_primitives::{Address, Bloom, Bytes, B256}; +use alloy_rlp::Encodable; use anyhow::Result; use op_alloy_consensus::{OpTxEnvelope, OpTxType}; +use op_alloy_genesis::{RollupConfig, SystemConfig}; +use op_alloy_protocol::{ + BlockInfo, L1BlockInfoBedrock, L1BlockInfoEcotone, L1BlockInfoTx, L2BlockInfo, +}; /// Fixed and variable memory costs for a payload. /// ~1000 bytes per payload, with some margin for overhead like map data. @@ -14,11 +22,7 @@ pub const PAYLOAD_MEM_FIXED_COST: u64 = 1000; /// 24 bytes per tx overhead (size of slice header in memory). pub const PAYLOAD_TX_MEM_OVERHEAD: u64 = 24; -use super::{ - BlockInfo, L1BlockInfoBedrock, L1BlockInfoEcotone, L1BlockInfoTx, L2BlockInfo, OpBlock, - RollupConfig, SystemConfig, Withdrawal, -}; -use alloy_rlp::Encodable; +use super::OpBlock; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -150,7 +154,8 @@ impl L2ExecutionPayloadEnvelope { anyhow::bail!("First payload transaction has unexpected type: {:?}", tx.tx_type()); }; - let l1_info = L1BlockInfoTx::decode_calldata(tx.input.as_ref())?; + let l1_info = L1BlockInfoTx::decode_calldata(tx.input.as_ref()) + .map_err(|e| anyhow::anyhow!(e))?; (l1_info.id(), l1_info.sequence_number()) }; @@ -177,7 +182,6 @@ impl L2ExecutionPayloadEnvelope { return rollup_config .genesis .system_config - .clone() .ok_or_else(|| anyhow::anyhow!("Missing system config in genesis block")); } @@ -198,7 +202,8 @@ impl L2ExecutionPayloadEnvelope { anyhow::bail!("First payload transaction has unexpected type: {:?}", tx.tx_type()); }; - let l1_info = L1BlockInfoTx::decode_calldata(tx.input.as_ref())?; + let l1_info = + L1BlockInfoTx::decode_calldata(tx.input.as_ref()).map_err(|e| anyhow::anyhow!(e))?; let l1_fee_scalar = match l1_info { L1BlockInfoTx::Bedrock(L1BlockInfoBedrock { l1_fee_scalar, .. }) => l1_fee_scalar, L1BlockInfoTx::Ecotone(L1BlockInfoEcotone { diff --git a/crates/primitives/src/sidecar.rs b/crates/primitives/src/sidecar.rs index aea287a4..a48486a2 100644 --- a/crates/primitives/src/sidecar.rs +++ b/crates/primitives/src/sidecar.rs @@ -4,6 +4,9 @@ use alloc::{string::String, vec::Vec}; use alloy_eips::eip4844::Blob; use alloy_primitives::FixedBytes; +#[cfg(feature = "online")] +use alloy_eips::eip4844::VERSIONED_HASH_VERSION_KZG; + #[cfg(feature = "online")] use crate::IndexedBlobHash; #[cfg(feature = "online")] @@ -29,10 +32,6 @@ pub const KZG_PROOF_SIZE: usize = 48; /// KZG Commitment Size pub const KZG_COMMITMENT_SIZE: usize = 48; -/// The versioned hash version for KZG. -#[cfg(feature = "online")] -pub(crate) const VERSIONED_HASH_VERSION_KZG: u8 = 0x01; - #[cfg(feature = "serde")] fn parse_u64_string<'de, T, D>(de: D) -> Result where diff --git a/examples/trusted-sync/Cargo.toml b/examples/trusted-sync/Cargo.toml index 30f38cbb..230bc7f5 100644 --- a/examples/trusted-sync/Cargo.toml +++ b/examples/trusted-sync/Cargo.toml @@ -33,3 +33,4 @@ alloy-rpc-types = { workspace = true, features = ["eth"] } alloy-primitives = { workspace = true, features = ["serde"] } alloy-provider = { workspace = true, default-features = false } alloy-transport = { workspace = true, default-features = false } +op-alloy-genesis.workspace = true diff --git a/examples/trusted-sync/src/validation.rs b/examples/trusted-sync/src/validation.rs index f676293e..387506ea 100644 --- a/examples/trusted-sync/src/validation.rs +++ b/examples/trusted-sync/src/validation.rs @@ -5,7 +5,8 @@ use alloy_provider::{Provider, ReqwestProvider}; use alloy_rpc_types::{BlockNumberOrTag, BlockTransactionsKind, Header}; use alloy_transport::TransportResult; use anyhow::Result; -use kona_primitives::{L2AttributesWithParent, L2PayloadAttributes, RollupConfig}; +use kona_primitives::{L2AttributesWithParent, L2PayloadAttributes}; +use op_alloy_genesis::RollupConfig; use std::vec::Vec; use tracing::{error, warn};