diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..fed30a4 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,26 @@ +name: Tests + +on: + push: + branches: + - main + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + + - name: Build + run: cargo build + + - name: Run tests + run: cargo test \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 7363039..e0aa343 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -349,6 +349,53 @@ dependencies = [ "serde", ] +[[package]] +name = "alloy-rpc-types-admin" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fefd12e99dd6b7de387ed13ad047ce2c90d8950ca62fc48b8a457ebb8f936c61" +dependencies = [ + "alloy-genesis", + "alloy-primitives", + "serde", + "serde_json", +] + +[[package]] +name = "alloy-rpc-types-anvil" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25cb45ad7c0930dd62eecf164d2afe4c3d2dd2c82af85680ad1f118e1e5cb83" +dependencies = [ + "alloy-primitives", + "alloy-serde", + "serde", +] + +[[package]] +name = "alloy-rpc-types-beacon" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e7081d2206dca51ce23a06338d78d9b536931cc3f15134fc1c6535eb2b77f18" +dependencies = [ + "alloy-eips", + "alloy-primitives", + "alloy-rpc-types-engine", + "serde", + "serde_with", + "thiserror", +] + +[[package]] +name = "alloy-rpc-types-debug" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f9f9033796bb3078d11cc9c839f00e277431ef997db2849a46045fcffee3835" +dependencies = [ + "alloy-primitives", + "serde", +] + [[package]] name = "alloy-rpc-types-engine" version = "0.3.6" @@ -389,6 +436,45 @@ dependencies = [ "serde_json", ] +[[package]] +name = "alloy-rpc-types-mev" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "922d92389e5022650c4c60ffd2f9b2467c3f853764f0f74ff16a23106f9017d5" +dependencies = [ + "alloy-eips", + "alloy-primitives", + "alloy-serde", + "serde", + "serde_json", +] + +[[package]] +name = "alloy-rpc-types-trace" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98db35cd42c90b484377e6bc44d95377a7a38a5ebee996e67754ac0446d542ab" +dependencies = [ + "alloy-primitives", + "alloy-rpc-types-eth", + "alloy-serde", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "alloy-rpc-types-txpool" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bac37082c3b21283b3faf5cc0e08974272aee2f756ce1adeb26db56a5fce0d5" +dependencies = [ + "alloy-primitives", + "alloy-rpc-types-eth", + "alloy-serde", + "serde", +] + [[package]] name = "alloy-serde" version = "0.3.6" @@ -758,6 +844,22 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" +[[package]] +name = "assert_cmd" +version = "2.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1835b7f27878de8525dc71410b5a31cdcc5f230aed5ba5df968e09c201b23d" +dependencies = [ + "anstyle", + "bstr", + "doc-comment", + "libc", + "predicates", + "predicates-core", + "predicates-tree", + "wait-timeout", +] + [[package]] name = "async-stream" version = "0.3.5" @@ -956,6 +1058,17 @@ dependencies = [ "zeroize", ] +[[package]] +name = "bstr" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" +dependencies = [ + "memchr", + "regex-automata 0.4.7", + "serde", +] + [[package]] name = "bumpalo" version = "3.16.0" @@ -1361,6 +1474,12 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + [[package]] name = "digest" version = "0.9.0" @@ -1382,6 +1501,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + [[package]] name = "dotenv" version = "0.15.0" @@ -1552,6 +1677,15 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" +dependencies = [ + "num-traits", +] + [[package]] name = "fnv" version = "1.0.7" @@ -2554,6 +2688,12 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "normalize-line-endings" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" + [[package]] name = "notify" version = "6.1.1" @@ -3036,6 +3176,36 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "predicates" +version = "3.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e9086cc7640c29a356d1a29fd134380bee9d8f79a17410aa76e7ad295f42c97" +dependencies = [ + "anstyle", + "difflib", + "float-cmp", + "normalize-line-endings", + "predicates-core", + "regex", +] + +[[package]] +name = "predicates-core" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae8177bee8e75d6846599c6b9ff679ed51e882816914eec639944d7c9aa11931" + +[[package]] +name = "predicates-tree" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41b740d195ed3166cd147c8047ec98db0e22ec019eb8eeb76d343b795304fb13" +dependencies = [ + "predicates-core", + "termtree", +] + [[package]] name = "primeorder" version = "0.13.6" @@ -3330,7 +3500,7 @@ dependencies = [ [[package]] name = "reth-basic-payload-builder" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -3354,7 +3524,7 @@ dependencies = [ [[package]] name = "reth-blockchain-tree-api" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-primitives", "reth-consensus", @@ -3367,7 +3537,7 @@ dependencies = [ [[package]] name = "reth-chain-state" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-eips", "alloy-primitives", @@ -3391,7 +3561,7 @@ dependencies = [ [[package]] name = "reth-chainspec" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-chains", "alloy-eips", @@ -3404,7 +3574,6 @@ dependencies = [ "op-alloy-rpc-types", "reth-ethereum-forks", "reth-network-peers", - "reth-optimism-forks", "reth-primitives-traits", "reth-trie-common", "serde", @@ -3414,7 +3583,7 @@ dependencies = [ [[package]] name = "reth-codecs" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-consensus", "alloy-eips", @@ -3431,7 +3600,7 @@ dependencies = [ [[package]] name = "reth-codecs-derive" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "convert_case", "proc-macro2", @@ -3442,7 +3611,7 @@ dependencies = [ [[package]] name = "reth-consensus" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-primitives", "auto_impl", @@ -3453,7 +3622,7 @@ dependencies = [ [[package]] name = "reth-consensus-common" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-primitives", "reth-chainspec", @@ -3464,7 +3633,7 @@ dependencies = [ [[package]] name = "reth-db" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-primitives", "bytes", @@ -3495,9 +3664,8 @@ dependencies = [ [[package]] name = "reth-db-api" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ - "alloy-genesis", "alloy-primitives", "bytes", "derive_more", @@ -3518,7 +3686,7 @@ dependencies = [ [[package]] name = "reth-db-models" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-primitives", "bytes", @@ -3531,9 +3699,9 @@ dependencies = [ [[package]] name = "reth-engine-primitives" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ - "alloy-primitives", + "reth-chainspec", "reth-execution-types", "reth-payload-primitives", "reth-primitives", @@ -3544,7 +3712,7 @@ dependencies = [ [[package]] name = "reth-errors" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "reth-blockchain-tree-api", "reth-consensus", @@ -3557,10 +3725,9 @@ dependencies = [ [[package]] name = "reth-eth-wire-types" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-chains", - "alloy-eips", "alloy-genesis", "alloy-primitives", "alloy-rlp", @@ -3575,10 +3742,8 @@ dependencies = [ [[package]] name = "reth-ethereum-engine-primitives" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ - "alloy-eips", - "alloy-primitives", "alloy-rlp", "reth-chain-state", "reth-chainspec", @@ -3594,7 +3759,7 @@ dependencies = [ [[package]] name = "reth-ethereum-forks" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-chains", "alloy-primitives", @@ -3611,7 +3776,7 @@ dependencies = [ [[package]] name = "reth-evm" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-eips", "auto_impl", @@ -3632,7 +3797,7 @@ dependencies = [ [[package]] name = "reth-evm-optimism" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-primitives", "reth-chainspec", @@ -3642,7 +3807,6 @@ dependencies = [ "reth-execution-types", "reth-optimism-chainspec", "reth-optimism-consensus", - "reth-optimism-forks", "reth-primitives", "reth-prune-types", "reth-revm", @@ -3655,7 +3819,7 @@ dependencies = [ [[package]] name = "reth-execution-errors" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-eips", "alloy-primitives", @@ -3671,7 +3835,7 @@ dependencies = [ [[package]] name = "reth-execution-types" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "reth-chainspec", "reth-execution-errors", @@ -3683,7 +3847,7 @@ dependencies = [ [[package]] name = "reth-fs-util" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "serde", "serde_json", @@ -3693,7 +3857,7 @@ dependencies = [ [[package]] name = "reth-libmdbx" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "bitflags 2.6.0", "byteorder", @@ -3709,7 +3873,7 @@ dependencies = [ [[package]] name = "reth-mdbx-sys" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "bindgen", "cc", @@ -3718,7 +3882,7 @@ dependencies = [ [[package]] name = "reth-metrics" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "metrics", "reth-metrics-derive", @@ -3727,7 +3891,7 @@ dependencies = [ [[package]] name = "reth-metrics-derive" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "proc-macro2", "quote", @@ -3738,7 +3902,7 @@ dependencies = [ [[package]] name = "reth-net-banlist" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-primitives", ] @@ -3746,9 +3910,8 @@ dependencies = [ [[package]] name = "reth-network-p2p" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ - "alloy-eips", "alloy-primitives", "auto_impl", "derive_more", @@ -3766,7 +3929,7 @@ dependencies = [ [[package]] name = "reth-network-peers" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -3779,7 +3942,7 @@ dependencies = [ [[package]] name = "reth-network-types" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "reth-ethereum-forks", "reth-net-banlist", @@ -3791,7 +3954,7 @@ dependencies = [ [[package]] name = "reth-nippy-jar" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "anyhow", "bincode", @@ -3808,7 +3971,7 @@ dependencies = [ [[package]] name = "reth-node-types" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "reth-chainspec", "reth-db-api", @@ -3818,7 +3981,7 @@ dependencies = [ [[package]] name = "reth-optimism-chainspec" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-chains", "alloy-primitives", @@ -3826,7 +3989,6 @@ dependencies = [ "once_cell", "reth-chainspec", "reth-ethereum-forks", - "reth-optimism-forks", "reth-primitives-traits", "serde_json", ] @@ -3834,44 +3996,30 @@ dependencies = [ [[package]] name = "reth-optimism-consensus" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-primitives", "reth-chainspec", "reth-consensus", "reth-consensus-common", - "reth-optimism-forks", "reth-primitives", "reth-trie-common", "tracing", ] -[[package]] -name = "reth-optimism-forks" -version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" -dependencies = [ - "alloy-chains", - "alloy-primitives", - "once_cell", - "reth-ethereum-forks", -] - [[package]] name = "reth-optimism-payload-builder" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-primitives", "alloy-rlp", - "op-alloy-rpc-types-engine", "reth-basic-payload-builder", "reth-chain-state", "reth-chainspec", "reth-evm", "reth-evm-optimism", "reth-execution-types", - "reth-optimism-forks", "reth-payload-builder", "reth-payload-primitives", "reth-primitives", @@ -3887,31 +4035,24 @@ dependencies = [ "tracing", ] -[[package]] -name = "reth-optimism-primitives" -version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" -dependencies = [ - "alloy-primitives", - "reth-primitives", - "reth-primitives-traits", -] - [[package]] name = "reth-payload-builder" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-primitives", - "alloy-rpc-types", - "async-trait", "futures-util", "metrics", + "pin-project", + "reth-errors", "reth-ethereum-engine-primitives", "reth-metrics", "reth-payload-primitives", "reth-primitives", "reth-provider", + "reth-rpc-types", + "reth-transaction-pool", + "thiserror", "tokio", "tokio-stream", "tracing", @@ -3920,32 +4061,28 @@ dependencies = [ [[package]] name = "reth-payload-primitives" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-primitives", - "alloy-rpc-types", - "async-trait", - "op-alloy-rpc-types-engine", - "pin-project", "reth-chain-state", "reth-chainspec", "reth-errors", "reth-primitives", + "reth-rpc-types", "reth-transaction-pool", "serde", "thiserror", "tokio", - "tokio-stream", - "tracing", ] [[package]] name = "reth-primitives" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-consensus", "alloy-eips", + "alloy-genesis", "alloy-primitives", "alloy-rlp", "bytes", @@ -3960,7 +4097,6 @@ dependencies = [ "reth-codecs", "reth-ethereum-forks", "reth-optimism-chainspec", - "reth-optimism-forks", "reth-primitives-traits", "reth-static-file-types", "reth-trie-common", @@ -3973,7 +4109,7 @@ dependencies = [ [[package]] name = "reth-primitives-traits" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-consensus", "alloy-eips", @@ -3993,7 +4129,7 @@ dependencies = [ [[package]] name = "reth-provider" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-eips", "alloy-primitives", @@ -4019,7 +4155,6 @@ dependencies = [ "reth-network-p2p", "reth-nippy-jar", "reth-node-types", - "reth-optimism-primitives", "reth-primitives", "reth-prune-types", "reth-stages-types", @@ -4036,7 +4171,7 @@ dependencies = [ [[package]] name = "reth-prune-types" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-primitives", "bytes", @@ -4050,7 +4185,7 @@ dependencies = [ [[package]] name = "reth-revm" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "reth-chainspec", "reth-consensus-common", @@ -4065,7 +4200,7 @@ dependencies = [ [[package]] name = "reth-rpc-layer" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-rpc-types-engine", "http 1.1.0", @@ -4078,24 +4213,32 @@ dependencies = [ [[package]] name = "reth-rpc-types" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-primitives", "alloy-rpc-types", + "alloy-rpc-types-admin", + "alloy-rpc-types-anvil", + "alloy-rpc-types-beacon", + "alloy-rpc-types-debug", "alloy-rpc-types-engine", + "alloy-rpc-types-mev", + "alloy-rpc-types-trace", + "alloy-rpc-types-txpool", + "alloy-serde", "jsonrpsee-types", + "op-alloy-rpc-types", + "op-alloy-rpc-types-engine", ] [[package]] name = "reth-rpc-types-compat" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-rpc-types", - "alloy-rpc-types-eth", - "alloy-serde", "reth-primitives", "reth-rpc-types", "reth-trie-common", @@ -4104,7 +4247,7 @@ dependencies = [ [[package]] name = "reth-stages-types" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-primitives", "bytes", @@ -4117,7 +4260,7 @@ dependencies = [ [[package]] name = "reth-static-file-types" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-primitives", "derive_more", @@ -4128,7 +4271,7 @@ dependencies = [ [[package]] name = "reth-storage-api" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-eips", "alloy-primitives", @@ -4147,7 +4290,7 @@ dependencies = [ [[package]] name = "reth-storage-errors" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-eips", "alloy-primitives", @@ -4160,7 +4303,7 @@ dependencies = [ [[package]] name = "reth-tasks" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "auto_impl", "dyn-clone", @@ -4176,7 +4319,7 @@ dependencies = [ [[package]] name = "reth-tracing" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "clap", "eyre", @@ -4191,7 +4334,7 @@ dependencies = [ [[package]] name = "reth-transaction-pool" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-eips", "alloy-primitives", @@ -4225,7 +4368,7 @@ dependencies = [ [[package]] name = "reth-trie" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -4247,7 +4390,7 @@ dependencies = [ [[package]] name = "reth-trie-common" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-consensus", "alloy-genesis", @@ -4267,7 +4410,7 @@ dependencies = [ [[package]] name = "reth-trie-db" version = "1.0.7" -source = "git+https://github.com/paradigmxyz/reth.git?branch=main#ab66f58e5cf4f6030621ca3a63fd5a5af1ac89ed" +source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.0.7#75b7172cf77eb4fd65fe1a6924f75066fb09fcd1" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -4426,6 +4569,7 @@ dependencies = [ "alloy-rpc-types-engine", "alloy-rpc-types-eth", "anyhow", + "assert_cmd", "clap", "dotenv", "http 1.1.0", @@ -4436,6 +4580,7 @@ dependencies = [ "jsonrpsee", "op-alloy-rpc-types", "op-alloy-rpc-types-engine", + "predicates", "reqwest", "reth-optimism-payload-builder", "reth-rpc-layer", @@ -5155,6 +5300,12 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "termtree" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" + [[package]] name = "thiserror" version = "1.0.63" diff --git a/Cargo.toml b/Cargo.toml index cd1183e..7fc589e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,8 +26,10 @@ http-body-util = "0.1.2" hyper = { version = "1.4.1", features = ["full"] } hyper-util = { version = "0.1", features = ["full"] } serde_json = "1.0.96" -reth-rpc-layer = { git = "https://github.com/paradigmxyz/reth.git", branch = "main" } -reth-optimism-payload-builder = { git = "https://github.com/paradigmxyz/reth.git", branch = "main", features = ["optimism"] } +reth-rpc-layer = { git = "https://github.com/paradigmxyz/reth.git", tag = "v1.0.7" } +reth-optimism-payload-builder = { git = "https://github.com/paradigmxyz/reth.git", tag = "v1.0.7", features = ["optimism"] } [dev-dependencies] anyhow = "1.0" +assert_cmd = "2.0.10" +predicates = "3.1.2" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index c909484..771c641 100644 --- a/src/main.rs +++ b/src/main.rs @@ -68,6 +68,11 @@ async fn main() -> Result<()> { dotenv().ok(); let args: Args = Args::parse(); + // Initialize logging + tracing_subscriber::fmt() + .with_env_filter(EnvFilter::new(args.log_level.to_string())) // Set the log level + .init(); + // Handle JWT secret let jwt_secret = match (args.jwt_path, args.jwt_token) { (Some(file), None) => { @@ -86,11 +91,6 @@ async fn main() -> Result<()> { } }; - // Initialize logging - tracing_subscriber::fmt() - .with_env_filter(EnvFilter::new(args.log_level.to_string())) // Set the log level - .init(); - // Initialize the l2 client let l2_client = create_client(&args.l2_url, jwt_secret)?; @@ -142,3 +142,101 @@ fn create_client( .build(url) .map_err(|e| Error::InitRPCClient(e.to_string())) } + +#[cfg(test)] +mod tests { + use assert_cmd::Command; + use jsonrpsee::core::client::ClientT; + use jsonrpsee::http_client::transport::Error as TransportError; + use jsonrpsee::{ + core::ClientError, + rpc_params, + server::{ServerBuilder, ServerHandle}, + }; + use predicates::prelude::*; + use reth_rpc_layer::{AuthLayer, JwtAuthValidator}; + use std::result::Result; + + use super::*; + + const AUTH_PORT: u32 = 8551; + const AUTH_ADDR: &str = "0.0.0.0"; + const SECRET: &str = "f79ae8046bc11c9927afe911db7143c51a806c4a537cc08e0d37140b0192f430"; + + #[test] + fn test_invalid_args() { + let mut cmd = Command::cargo_bin("rollup-boost").unwrap(); + cmd.arg("--invalid-arg"); + + cmd.assert().failure().stderr(predicate::str::contains( + "error: unexpected argument '--invalid-arg' found", + )); + } + + #[tokio::test] + async fn test_create_client() { + valid_jwt().await; + invalid_jwt().await; + } + + async fn valid_jwt() { + let secret = JwtSecret::from_hex(SECRET).unwrap(); + let url = format!("http://{}:{}", AUTH_ADDR, AUTH_PORT); + let client = create_client(url.as_str(), secret); + let response = send_request(client.unwrap()).await; + assert!(response.is_ok()); + assert_eq!(response.unwrap(), "You are the dark lord"); + } + + async fn invalid_jwt() { + let secret = JwtSecret::random(); + let url = format!("http://{}:{}", AUTH_ADDR, AUTH_PORT); + let client = create_client(url.as_str(), secret); + let response = send_request(client.unwrap()).await; + assert!(response.is_err()); + assert!(matches!( + response.unwrap_err(), + ClientError::Transport(e) + if matches!(e.downcast_ref::(), Some(TransportError::Rejected { status_code: 401 })) + )); + } + + async fn send_request( + client: HttpClient>, + ) -> Result { + let server = spawn_server().await; + + let response = client + .request::("greet_melkor", rpc_params![]) + .await; + + server.stop().unwrap(); + server.stopped().await; + + response + } + + /// Spawn a new RPC server equipped with a `JwtLayer` auth middleware. + async fn spawn_server() -> ServerHandle { + let secret = JwtSecret::from_hex(SECRET).unwrap(); + let addr = format!("{AUTH_ADDR}:{AUTH_PORT}"); + let validator = JwtAuthValidator::new(secret); + let layer = AuthLayer::new(validator); + let middleware = tower::ServiceBuilder::default().layer(layer); + + // Create a layered server + let server = ServerBuilder::default() + .set_http_middleware(middleware) + .build(addr.parse::().unwrap()) + .await + .unwrap(); + + // Create a mock rpc module + let mut module = RpcModule::new(()); + module + .register_method("greet_melkor", |_, _, _| "You are the dark lord") + .unwrap(); + + server.start(module) + } +} diff --git a/src/proxy.rs b/src/proxy.rs index 94d57bb..2e8f80b 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -103,3 +103,113 @@ where Box::pin(fut) } } + +#[cfg(test)] +mod tests { + use std::net::SocketAddr; + + use jsonrpsee::{ + core::{client::ClientT, ClientError}, + http_client::HttpClient, + rpc_params, + server::{ServerBuilder, ServerHandle}, + types::{ErrorCode, ErrorObject}, + RpcModule, + }; + + use super::*; + + const PORT: u32 = 8552; + const ADDR: &str = "0.0.0.0"; + const PROXY_PORT: u32 = 8553; + + #[tokio::test] + async fn test_proxy_service() { + proxy_success().await; + proxy_failure().await; + does_not_proxy_engine_method().await; + } + + async fn proxy_success() { + let response = send_request("greet_melkor").await; + assert!(response.is_ok()); + assert_eq!(response.unwrap(), "You are the dark lord"); + } + + async fn proxy_failure() { + let response = send_request("non_existent_method").await; + assert!(response.is_err()); + let expected_error = ErrorObject::from(ErrorCode::MethodNotFound).into_owned(); + assert!(matches!( + response.unwrap_err(), + ClientError::Call(e) if e == expected_error + )); + } + + async fn does_not_proxy_engine_method() { + let response = send_request("engine_method").await; + assert!(response.is_ok()); + assert_eq!(response.unwrap(), "engine response"); + } + + async fn send_request(method: &str) -> Result { + let server = spawn_server().await; + let proxy_server = spawn_proxy_server().await; + let proxy_client = HttpClient::builder() + .build(format!("http://{ADDR}:{PORT}")) + .unwrap(); + + let response = proxy_client + .request::(method, rpc_params![]) + .await; + + server.stop().unwrap(); + server.stopped().await; + proxy_server.stop().unwrap(); + proxy_server.stopped().await; + + response + } + + async fn spawn_server() -> ServerHandle { + let server = ServerBuilder::default() + .build( + format!("{ADDR}:{PROXY_PORT}") + .parse::() + .unwrap(), + ) + .await + .unwrap(); + + // Create a mock rpc module + let mut module = RpcModule::new(()); + module + .register_method("greet_melkor", |_, _, _| "You are the dark lord") + .unwrap(); + + server.start(module) + } + + /// Spawn a new RPC server with a proxy layer. + async fn spawn_proxy_server() -> ServerHandle { + let addr = format!("{ADDR}:{PORT}"); + let proxy_layer = ProxyLayer::new(format!("http://{ADDR}:{PROXY_PORT}").parse().unwrap()); + // Create a layered server + let server = ServerBuilder::default() + .set_http_middleware(tower::ServiceBuilder::new().layer(proxy_layer)) + .build(addr.parse::().unwrap()) + .await + .unwrap(); + + // Create a mock rpc module + let mut module = RpcModule::new(()); + module + .register_method("engine_method", |_, _, _| "engine response") + .unwrap(); + module + .register_method("non_existent_method", |_, _, _| "no proxy response") + .unwrap(); + + server.start(module) + } +}