diff --git a/Cargo.lock b/Cargo.lock index 481fae2e8..226eb988e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,7 +65,7 @@ dependencies = [ [[package]] name = "aggregation" -version = "3.4.0-rc.1" +version = "3.4.0" dependencies = [ "alloy-consensus", "alloy-primitives", @@ -2671,7 +2671,7 @@ dependencies = [ [[package]] name = "canoe-bindings" version = "0.1.0" -source = "git+https://github.com/Layr-Labs/hokulea?rev=a465144d9b3fc5202898b320ed7573c5e5922ac5#a465144d9b3fc5202898b320ed7573c5e5922ac5" +source = "git+https://github.com/Layr-Labs/hokulea?tag=hokulea-client%2Fv1.1.2#a465144d9b3fc5202898b320ed7573c5e5922ac5" dependencies = [ "alloy-sol-types", "serde", @@ -2680,7 +2680,7 @@ dependencies = [ [[package]] name = "canoe-provider" version = "0.1.0" -source = "git+https://github.com/Layr-Labs/hokulea?rev=a465144d9b3fc5202898b320ed7573c5e5922ac5#a465144d9b3fc5202898b320ed7573c5e5922ac5" +source = "git+https://github.com/Layr-Labs/hokulea?tag=hokulea-client%2Fv1.1.2#a465144d9b3fc5202898b320ed7573c5e5922ac5" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -2694,7 +2694,7 @@ dependencies = [ [[package]] name = "canoe-sp1-cc-host" version = "0.1.0" -source = "git+https://github.com/Layr-Labs/hokulea?rev=a465144d9b3fc5202898b320ed7573c5e5922ac5#a465144d9b3fc5202898b320ed7573c5e5922ac5" +source = "git+https://github.com/Layr-Labs/hokulea?tag=hokulea-client%2Fv1.1.2#a465144d9b3fc5202898b320ed7573c5e5922ac5" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -2717,7 +2717,7 @@ dependencies = [ [[package]] name = "canoe-sp1-cc-verifier" version = "0.1.0" -source = "git+https://github.com/Layr-Labs/hokulea?rev=a465144d9b3fc5202898b320ed7573c5e5922ac5#a465144d9b3fc5202898b320ed7573c5e5922ac5" +source = "git+https://github.com/Layr-Labs/hokulea?tag=hokulea-client%2Fv1.1.2#a465144d9b3fc5202898b320ed7573c5e5922ac5" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -2736,7 +2736,7 @@ dependencies = [ [[package]] name = "canoe-verifier" version = "0.1.0" -source = "git+https://github.com/Layr-Labs/hokulea?rev=a465144d9b3fc5202898b320ed7573c5e5922ac5#a465144d9b3fc5202898b320ed7573c5e5922ac5" +source = "git+https://github.com/Layr-Labs/hokulea?tag=hokulea-client%2Fv1.1.2#a465144d9b3fc5202898b320ed7573c5e5922ac5" dependencies = [ "alloy-genesis", "alloy-primitives", @@ -2752,7 +2752,7 @@ dependencies = [ [[package]] name = "canoe-verifier-address-fetcher" version = "0.1.0" -source = "git+https://github.com/Layr-Labs/hokulea?rev=a465144d9b3fc5202898b320ed7573c5e5922ac5#a465144d9b3fc5202898b320ed7573c5e5922ac5" +source = "git+https://github.com/Layr-Labs/hokulea?tag=hokulea-client%2Fv1.1.2#a465144d9b3fc5202898b320ed7573c5e5922ac5" dependencies = [ "alloy-primitives", "eigenda-cert", @@ -3950,7 +3950,7 @@ dependencies = [ [[package]] name = "eigenda-cert" version = "0.1.0" -source = "git+https://github.com/Layr-Labs/hokulea?rev=a465144d9b3fc5202898b320ed7573c5e5922ac5#a465144d9b3fc5202898b320ed7573c5e5922ac5" +source = "git+https://github.com/Layr-Labs/hokulea?tag=hokulea-client%2Fv1.1.2#a465144d9b3fc5202898b320ed7573c5e5922ac5" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -5111,7 +5111,7 @@ dependencies = [ [[package]] name = "hokulea-client" version = "0.1.0" -source = "git+https://github.com/Layr-Labs/hokulea?rev=a465144d9b3fc5202898b320ed7573c5e5922ac5#a465144d9b3fc5202898b320ed7573c5e5922ac5" +source = "git+https://github.com/Layr-Labs/hokulea?tag=hokulea-client%2Fv1.1.2#a465144d9b3fc5202898b320ed7573c5e5922ac5" dependencies = [ "alloy-consensus", "alloy-evm 0.22.6", @@ -5132,7 +5132,7 @@ dependencies = [ [[package]] name = "hokulea-client-bin" version = "0.1.0" -source = "git+https://github.com/Layr-Labs/hokulea?rev=a465144d9b3fc5202898b320ed7573c5e5922ac5#a465144d9b3fc5202898b320ed7573c5e5922ac5" +source = "git+https://github.com/Layr-Labs/hokulea?tag=hokulea-client%2Fv1.1.2#a465144d9b3fc5202898b320ed7573c5e5922ac5" dependencies = [ "alloy-evm 0.22.6", "alloy-op-evm", @@ -5152,7 +5152,7 @@ dependencies = [ [[package]] name = "hokulea-compute-proof" version = "0.1.0" -source = "git+https://github.com/Layr-Labs/hokulea?rev=a465144d9b3fc5202898b320ed7573c5e5922ac5#a465144d9b3fc5202898b320ed7573c5e5922ac5" +source = "git+https://github.com/Layr-Labs/hokulea?tag=hokulea-client%2Fv1.1.2#a465144d9b3fc5202898b320ed7573c5e5922ac5" dependencies = [ "alloy-primitives", "hokulea-proof", @@ -5166,7 +5166,7 @@ dependencies = [ [[package]] name = "hokulea-eigenda" version = "0.1.0" -source = "git+https://github.com/Layr-Labs/hokulea?rev=a465144d9b3fc5202898b320ed7573c5e5922ac5#a465144d9b3fc5202898b320ed7573c5e5922ac5" +source = "git+https://github.com/Layr-Labs/hokulea?tag=hokulea-client%2Fv1.1.2#a465144d9b3fc5202898b320ed7573c5e5922ac5" dependencies = [ "alloy-primitives", "async-trait", @@ -5181,7 +5181,7 @@ dependencies = [ [[package]] name = "hokulea-host-bin" version = "0.1.0" -source = "git+https://github.com/Layr-Labs/hokulea?rev=a465144d9b3fc5202898b320ed7573c5e5922ac5#a465144d9b3fc5202898b320ed7573c5e5922ac5" +source = "git+https://github.com/Layr-Labs/hokulea?tag=hokulea-client%2Fv1.1.2#a465144d9b3fc5202898b320ed7573c5e5922ac5" dependencies = [ "alloy-primitives", "anyhow", @@ -5208,7 +5208,7 @@ dependencies = [ [[package]] name = "hokulea-proof" version = "0.1.0" -source = "git+https://github.com/Layr-Labs/hokulea?rev=a465144d9b3fc5202898b320ed7573c5e5922ac5#a465144d9b3fc5202898b320ed7573c5e5922ac5" +source = "git+https://github.com/Layr-Labs/hokulea?tag=hokulea-client%2Fv1.1.2#a465144d9b3fc5202898b320ed7573c5e5922ac5" dependencies = [ "alloy-primitives", "ark-bn254", @@ -5230,7 +5230,7 @@ dependencies = [ [[package]] name = "hokulea-witgen" version = "0.1.0" -source = "git+https://github.com/Layr-Labs/hokulea?rev=a465144d9b3fc5202898b320ed7573c5e5922ac5#a465144d9b3fc5202898b320ed7573c5e5922ac5" +source = "git+https://github.com/Layr-Labs/hokulea?tag=hokulea-client%2Fv1.1.2#a465144d9b3fc5202898b320ed7573c5e5922ac5" dependencies = [ "alloy-consensus", "alloy-rlp", @@ -5249,7 +5249,7 @@ dependencies = [ [[package]] name = "hokulea-zkvm-verification" version = "0.1.0" -source = "git+https://github.com/Layr-Labs/hokulea?rev=a465144d9b3fc5202898b320ed7573c5e5922ac5#a465144d9b3fc5202898b320ed7573c5e5922ac5" +source = "git+https://github.com/Layr-Labs/hokulea?tag=hokulea-client%2Fv1.1.2#a465144d9b3fc5202898b320ed7573c5e5922ac5" dependencies = [ "canoe-verifier", "canoe-verifier-address-fetcher", @@ -8430,7 +8430,7 @@ dependencies = [ [[package]] name = "op-succinct-bindings" -version = "3.4.0-rc.1" +version = "3.4.0" dependencies = [ "alloy", "alloy-sol-types", @@ -8440,7 +8440,7 @@ dependencies = [ [[package]] name = "op-succinct-build-utils" -version = "3.4.0-rc.1" +version = "3.4.0" dependencies = [ "cargo_metadata", "sp1-build", @@ -8448,7 +8448,7 @@ dependencies = [ [[package]] name = "op-succinct-celestia-client-utils" -version = "3.4.0-rc.1" +version = "3.4.0" dependencies = [ "anyhow", "async-trait", @@ -8466,7 +8466,7 @@ dependencies = [ [[package]] name = "op-succinct-celestia-host-utils" -version = "3.4.0-rc.1" +version = "3.4.0" dependencies = [ "alloy-consensus", "alloy-eips", @@ -8495,7 +8495,7 @@ dependencies = [ [[package]] name = "op-succinct-client-utils" -version = "3.4.0-rc.1" +version = "3.4.0" dependencies = [ "alloy-consensus", "alloy-eips", @@ -8549,7 +8549,7 @@ dependencies = [ [[package]] name = "op-succinct-eigenda-host-utils" -version = "3.4.0-rc.1" +version = "3.4.0" dependencies = [ "alloy-eips", "alloy-primitives", @@ -8576,11 +8576,11 @@ dependencies = [ [[package]] name = "op-succinct-elfs" -version = "3.4.0-rc.1" +version = "3.4.0" [[package]] name = "op-succinct-ethereum-client-utils" -version = "3.4.0-rc.1" +version = "3.4.0" dependencies = [ "anyhow", "async-trait", @@ -8596,7 +8596,7 @@ dependencies = [ [[package]] name = "op-succinct-ethereum-host-utils" -version = "3.4.0-rc.1" +version = "3.4.0" dependencies = [ "alloy-eips", "alloy-primitives", @@ -8615,7 +8615,7 @@ dependencies = [ [[package]] name = "op-succinct-fp" -version = "3.4.0-rc.1" +version = "3.4.0" dependencies = [ "alloy", "alloy-contract", @@ -8660,7 +8660,7 @@ dependencies = [ [[package]] name = "op-succinct-host-utils" -version = "3.4.0-rc.1" +version = "3.4.0" dependencies = [ "alloy-consensus", "alloy-contract", @@ -8715,7 +8715,7 @@ dependencies = [ [[package]] name = "op-succinct-proof-utils" -version = "3.4.0-rc.1" +version = "3.4.0" dependencies = [ "cfg-if", "op-succinct-celestia-host-utils", @@ -8728,7 +8728,7 @@ dependencies = [ [[package]] name = "op-succinct-prove" -version = "3.4.0-rc.1" +version = "3.4.0" dependencies = [ "alloy-contract", "alloy-eips", @@ -8762,7 +8762,7 @@ dependencies = [ [[package]] name = "op-succinct-range-utils" -version = "3.4.0-rc.1" +version = "3.4.0" dependencies = [ "anyhow", "kona-proof", @@ -8775,7 +8775,7 @@ dependencies = [ [[package]] name = "op-succinct-scripts" -version = "3.4.0-rc.1" +version = "3.4.0" dependencies = [ "alloy-eips", "alloy-network", @@ -8809,7 +8809,7 @@ dependencies = [ [[package]] name = "op-succinct-signer-utils" -version = "3.4.0-rc.1" +version = "3.4.0" dependencies = [ "alloy-consensus", "alloy-eips", @@ -8831,7 +8831,7 @@ dependencies = [ [[package]] name = "op-succinct-validity" -version = "3.4.0-rc.1" +version = "3.4.0" dependencies = [ "alloy-eips", "alloy-primitives", @@ -10262,7 +10262,7 @@ dependencies = [ [[package]] name = "range" -version = "3.4.0-rc.1" +version = "3.4.0" dependencies = [ "kona-proof", "op-succinct-client-utils", @@ -10275,7 +10275,7 @@ dependencies = [ [[package]] name = "range-celestia" -version = "3.4.0-rc.1" +version = "3.4.0" dependencies = [ "kona-proof", "op-succinct-celestia-client-utils", diff --git a/Cargo.toml b/Cargo.toml index 5ac458fb8..a988f6293 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ edition = "2021" authors = ["ratankaliani", "zachobront", "fakedev9999", "yuwen01"] homepage = "https://succinctlabs.github.io/op-succinct/" repository = "https://github.com/succinctlabs/op-succinct" -version = "3.4.0-rc.1" +version = "3.4.0" [workspace.dependencies] # general @@ -102,15 +102,15 @@ hana-host = { git = "https://github.com/celestiaorg/hana", tag = "v1.4.0-mocha" hana-oracle = { git = "https://github.com/celestiaorg/hana", tag = "v1.4.0-mocha" } # hokulea -hokulea-compute-proof = { git = "https://github.com/Layr-Labs/hokulea", rev = "a465144d9b3fc5202898b320ed7573c5e5922ac5" } -hokulea-eigenda = { git = "https://github.com/Layr-Labs/hokulea", rev = "a465144d9b3fc5202898b320ed7573c5e5922ac5" } -hokulea-host-bin = { git = "https://github.com/Layr-Labs/hokulea", rev = "a465144d9b3fc5202898b320ed7573c5e5922ac5" } -hokulea-proof = { git = "https://github.com/Layr-Labs/hokulea", rev = "a465144d9b3fc5202898b320ed7573c5e5922ac5" } -hokulea-witgen = { git = "https://github.com/Layr-Labs/hokulea", rev = "a465144d9b3fc5202898b320ed7573c5e5922ac5" } -hokulea-zkvm-verification = { git = "https://github.com/Layr-Labs/hokulea", rev = "a465144d9b3fc5202898b320ed7573c5e5922ac5" } -canoe-sp1-cc-host = { git = "https://github.com/Layr-Labs/hokulea", rev = "a465144d9b3fc5202898b320ed7573c5e5922ac5" } -canoe-sp1-cc-verifier = { git = "https://github.com/Layr-Labs/hokulea", rev = "a465144d9b3fc5202898b320ed7573c5e5922ac5" } -canoe-verifier-address-fetcher = { git = "https://github.com/Layr-Labs/hokulea", rev = "a465144d9b3fc5202898b320ed7573c5e5922ac5" } +hokulea-compute-proof = { git = "https://github.com/Layr-Labs/hokulea", tag = "hokulea-client/v1.1.2" } +hokulea-eigenda = { git = "https://github.com/Layr-Labs/hokulea", tag = "hokulea-client/v1.1.2" } +hokulea-host-bin = { git = "https://github.com/Layr-Labs/hokulea", tag = "hokulea-client/v1.1.2" } +hokulea-proof = { git = "https://github.com/Layr-Labs/hokulea", tag = "hokulea-client/v1.1.2" } +hokulea-witgen = { git = "https://github.com/Layr-Labs/hokulea", tag = "hokulea-client/v1.1.2" } +hokulea-zkvm-verification = { git = "https://github.com/Layr-Labs/hokulea", tag = "hokulea-client/v1.1.2" } +canoe-sp1-cc-host = { git = "https://github.com/Layr-Labs/hokulea", tag = "hokulea-client/v1.1.2" } +canoe-sp1-cc-verifier = { git = "https://github.com/Layr-Labs/hokulea", tag = "hokulea-client/v1.1.2" } +canoe-verifier-address-fetcher = { git = "https://github.com/Layr-Labs/hokulea", tag = "hokulea-client/v1.1.2" } # op-succinct op-succinct-prove = { path = "scripts/prove" } diff --git a/book/fault_proofs/proposer.md b/book/fault_proofs/proposer.md index b0625d1d2..8b2b2892d 100644 --- a/book/fault_proofs/proposer.md +++ b/book/fault_proofs/proposer.md @@ -78,6 +78,7 @@ Depending on the one you choose, you must provide the corresponding environment | Variable | Description | Default Value | |----------|-------------|---------------| +| `RPC_CONCURRENCY` | Maximum number of concurrent RPC requests. Lower this value (e.g., `3`-`5`) if hitting 429 rate limit errors. | `10` | | `L1_CONFIG_DIR` | The directory containing the L1 chain configuration files. | `/configs/L1` | | `L2_CONFIG_DIR` | Directory containing L2 chain configuration files | `/configs/L2` | | `MOCK_MODE` | Whether to use mock mode | `false` | diff --git a/book/troubleshooting.md b/book/troubleshooting.md index 25c6eb9ff..626798b3b 100644 --- a/book/troubleshooting.md +++ b/book/troubleshooting.md @@ -48,3 +48,38 @@ let l1_head_number = l1_head_number + 100; The error occurs in the derivation pipeline when attempting to validate L2 blocks. The L1 head must be sufficiently ahead of the batch posting block to ensure all required data is available and the safe head state is consistent. The buffer of 20 blocks is added empirically to handle most cases where RPCs may have an incorrect view of the safe head state and have minimum overhead for the derivation process. Reference: [Fetcher Implementation](https://github.com/succinctlabs/op-succinct/blob/5dfc43928c75cef0ebf881d10bd8b3dcbe273419/utils/host/src/fetcher.rs#L773) + +### RPC Rate Limit Errors (429) + +**Error Message:** + +```text +error code 429: Too Many Requests +``` + +or + +```text +rate limit exceeded +``` + +**Cause:** +This error occurs when your RPC provider is rate-limiting requests due to too many concurrent calls. OP Succinct makes concurrent RPC requests to fetch block data efficiently, which can exceed the limits of free or low-tier RPC plans. + +**Solution:** +Set the `RPC_CONCURRENCY` environment variable to a lower value: + +```bash +# For low-tier RPC plans, try 3-5 concurrent requests +export RPC_CONCURRENCY=5 + +# For very restrictive plans +export RPC_CONCURRENCY=3 +``` + +The default is `10` concurrent requests. Reducing this value will make operations slower but more reliable for rate-limited RPC endpoints. + +**Recommendations:** +- Free RPC tiers: Set `RPC_CONCURRENCY=3` +- Basic paid tiers: Set `RPC_CONCURRENCY=5` +- Professional tiers: Default `10` should work, or increase for faster performance diff --git a/book/validity/proposer.md b/book/validity/proposer.md index a1631d934..080045a13 100644 --- a/book/validity/proposer.md +++ b/book/validity/proposer.md @@ -39,6 +39,7 @@ Before starting the proposer, ensure you have deployed the relevant contracts an | Parameter | Description | |-----------|-------------| | `L1_BEACON_RPC` | L1 Consensus (Beacon) Node. Could be required for integrations that access consensus-layer data. | +| `RPC_CONCURRENCY` | Default: `10`. Maximum number of concurrent RPC requests. Lower this value (e.g., `3`-`5`) if you're hitting 429 rate limit errors from your RPC provider. | | `NETWORK_RPC_URL` | Default: `https://rpc.production.succinct.xyz`. RPC URL for the Succinct Prover Network. | | `DATABASE_URL` | Default: `postgres://op-succinct@postgres:5432/op-succinct`. The address of a Postgres database for storing the intermediate proposer state. | | `L1_CONFIG_DIR` | Default: `/configs/L1`. The directory containing the L1 chain configuration files. | diff --git a/elf/aggregation-elf b/elf/aggregation-elf index a98d378e8..43c0f57e3 100755 Binary files a/elf/aggregation-elf and b/elf/aggregation-elf differ diff --git a/elf/celestia-range-elf-embedded b/elf/celestia-range-elf-embedded index 375818b05..03e144a97 100755 Binary files a/elf/celestia-range-elf-embedded and b/elf/celestia-range-elf-embedded differ diff --git a/elf/eigenda-range-elf-embedded b/elf/eigenda-range-elf-embedded index 8bc2fe759..59dcdf989 100755 Binary files a/elf/eigenda-range-elf-embedded and b/elf/eigenda-range-elf-embedded differ diff --git a/elf/range-elf-bump b/elf/range-elf-bump index c0d2beeaa..9cce1689e 100755 Binary files a/elf/range-elf-bump and b/elf/range-elf-bump differ diff --git a/elf/range-elf-embedded b/elf/range-elf-embedded index 6629304a2..3144a09ef 100755 Binary files a/elf/range-elf-embedded and b/elf/range-elf-embedded differ diff --git a/scripts/utils/bin/cost_estimator.rs b/scripts/utils/bin/cost_estimator.rs index 9f2d62e27..39e02ef9f 100644 --- a/scripts/utils/bin/cost_estimator.rs +++ b/scripts/utils/bin/cost_estimator.rs @@ -7,7 +7,7 @@ use op_succinct_host_utils::{ get_rolling_block_range, get_validated_block_range, split_range_based_on_safe_heads, split_range_basic, SpanBatchRange, }, - fetcher::OPSuccinctDataFetcher, + fetcher::{get_rpc_concurrency_from_env, OPSuccinctDataFetcher}, host::OPSuccinctHost, stats::ExecutionStats, witness_generation::WitnessGenerator, @@ -45,7 +45,7 @@ async fn execute_blocks_and_write_stats_csv( .expect("Failed to fetch block data range."); (range, block_data) }) - .buffered(15) + .buffered(get_rpc_concurrency_from_env()) .collect::>() .await; @@ -227,7 +227,7 @@ async fn main() -> Result<()> { .await .expect("Failed to get host CLI args") }) - .buffered(15) + .buffered(get_rpc_concurrency_from_env()) .collect::>() .await; diff --git a/scripts/utils/bin/gen_sp1_test_artifacts.rs b/scripts/utils/bin/gen_sp1_test_artifacts.rs index 963fc3614..139d4da07 100644 --- a/scripts/utils/bin/gen_sp1_test_artifacts.rs +++ b/scripts/utils/bin/gen_sp1_test_artifacts.rs @@ -4,7 +4,7 @@ use futures::StreamExt; use log::info; use op_succinct_host_utils::{ block_range::{get_validated_block_range, split_range_basic}, - fetcher::OPSuccinctDataFetcher, + fetcher::{get_rpc_concurrency_from_env, OPSuccinctDataFetcher}, host::OPSuccinctHost, witness_generation::WitnessGenerator, }; @@ -49,7 +49,7 @@ async fn main() -> Result<()> { .await .expect("Failed to get host CLI args") }) - .buffered(15) + .buffered(get_rpc_concurrency_from_env()) .collect::>() .await; diff --git a/utils/host/src/block_range.rs b/utils/host/src/block_range.rs index 85b73d736..5084d6596 100644 --- a/utils/host/src/block_range.rs +++ b/utils/host/src/block_range.rs @@ -10,7 +10,7 @@ use kona_rpc::{OutputResponse, SafeHeadResponse}; use serde::{Deserialize, Serialize}; use crate::{ - fetcher::{OPSuccinctDataFetcher, RPCMode}, + fetcher::{get_rpc_concurrency_from_env, OPSuccinctDataFetcher, RPCMode}, host::OPSuccinctHost, }; @@ -154,7 +154,7 @@ pub async fn split_range_based_on_safe_heads( .expect("Failed to fetch safe head"); result.safe_head.number }) - .buffered(15) + .buffered(get_rpc_concurrency_from_env()) .collect::>() .await; diff --git a/utils/host/src/fetcher.rs b/utils/host/src/fetcher.rs index 04435ae71..8c8b7913b 100644 --- a/utils/host/src/fetcher.rs +++ b/utils/host/src/fetcher.rs @@ -55,6 +55,9 @@ pub struct RPCConfig { pub l2_rpc: Url, // TODO(fakedev9999): Make optional if possible. pub l2_node_rpc: Url, + /// Maximum number of concurrent RPC requests. Default: 5. + /// Configure via RPC_CONCURRENCY environment variable. + pub concurrency: usize, } /// The mode corresponding to the chain we are fetching data for. @@ -66,12 +69,26 @@ pub enum RPCMode { L2Node, } +/// Default RPC concurrency limit. +/// Set RPC_CONCURRENCY env var to a lower value (e.g., 3-5) if hitting 429 rate limits. +pub const DEFAULT_RPC_CONCURRENCY: usize = 10; + +/// Gets the RPC concurrency from the RPC_CONCURRENCY environment variable. +/// Returns DEFAULT_RPC_CONCURRENCY (10) if not set or invalid. +pub fn get_rpc_concurrency_from_env() -> usize { + env::var("RPC_CONCURRENCY") + .ok() + .and_then(|s| s.parse::().ok()) + .unwrap_or(DEFAULT_RPC_CONCURRENCY) +} + /// Gets the RPC URLs from environment variables. /// /// L1_RPC: The L1 RPC URL. /// L1_BEACON_RPC: The L1 beacon RPC URL. /// L2_RPC: The L2 RPC URL. /// L2_NODE_RPC: The L2 node RPC URL. +/// RPC_CONCURRENCY: Maximum concurrent RPC requests (default: 5). pub fn get_rpcs_from_env() -> RPCConfig { let l1_rpc = env::var("L1_RPC").expect("L1_RPC must be set"); let maybe_l1_beacon_rpc = env::var("L1_BEACON_RPC").ok(); @@ -91,6 +108,7 @@ pub fn get_rpcs_from_env() -> RPCConfig { l1_beacon_rpc, l2_rpc: Url::parse(&l2_rpc).expect("L2_RPC must be a valid URL"), l2_node_rpc: Url::parse(&l2_node_rpc).expect("L2_NODE_RPC must be a valid URL"), + concurrency: get_rpc_concurrency_from_env(), } } @@ -213,7 +231,7 @@ impl OPSuccinctDataFetcher { total_tx_fees, }) }) - .buffered(10) + .buffered(self.rpc_config.concurrency) .collect::>>() .await; @@ -486,7 +504,7 @@ impl OPSuccinctDataFetcher { // Process blocks in batches of 10, but maintain original order let results = stream::iter(block_numbers) .map(|block_number| self.get_l1_header(block_number.into())) - .buffered(10) + .buffered(self.rpc_config.concurrency) .collect::>() .await; diff --git a/validity/src/proposer.rs b/validity/src/proposer.rs index 7fe6f91f1..01b132bf7 100644 --- a/validity/src/proposer.rs +++ b/validity/src/proposer.rs @@ -286,7 +286,7 @@ where self.driver_config.fetcher.clone(), ) }) - .buffered(10) // Do 10 at a time, otherwise it's too slow when fetching the block range data. + .buffered(self.driver_config.fetcher.rpc_config.concurrency) .try_collect::>() .await?;