Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ order-stream = { path = "crates/order-stream" }
async-stream = "0.3"
alloy = { version = "1.0", default-features = false }
alloy-primitives = { version = "1.0" }
alloy-provider = { version = "1.0" }
alloy-sol-types = { version = "1.0", features = ["json"] }
alloy-chains = "0.2.0"
anyhow = { version = "1.0" }
Expand Down
1 change: 1 addition & 0 deletions crates/boundless-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ shadow-rs = "1.1"

[dependencies]
alloy = { workspace = true, features = ["full"] }
alloy-provider = { workspace = true, features = ["throttle"] }
anyhow = { workspace = true }
atomicwrites = "0.4.4"
bincode = { workspace = true }
Expand Down
3 changes: 3 additions & 0 deletions crates/boundless-cli/src/bin/boundless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,7 @@ mod tests {

let config = GlobalConfig {
rpc_url: Some(anvil.endpoint_url()),
rps: u32::MAX,
private_key: Some(private_key),
deployment: Some(ctx.deployment.clone()),
tx_timeout: None,
Expand Down Expand Up @@ -1957,6 +1958,7 @@ mod tests {

let prover_config = GlobalConfig {
rpc_url: Some(anvil.endpoint_url()),
rps: u32::MAX,
private_key: Some(ctx.prover_signer.clone()),
deployment: Some(ctx.deployment),
tx_timeout: None,
Expand Down Expand Up @@ -2292,6 +2294,7 @@ mod tests {

let prover_config = GlobalConfig {
rpc_url: Some(anvil.endpoint_url()),
rps: u32::MAX,
private_key: Some(ctx.prover_signer.clone()),
deployment: Some(ctx.deployment),
tx_timeout: None,
Expand Down
16 changes: 11 additions & 5 deletions crates/boundless-cli/src/commands/povw/claim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ use alloy::{
contract::Event,
primitives::{Address, U256},
providers::{Provider, ProviderBuilder},
rpc::types::{Filter, Log},
rpc::{
client::RpcClient,
types::{Filter, Log},
},
sol_types::SolEvent,
transports::layers::ThrottleLayer,
};
use anyhow::{bail, ensure, Context};
use boundless_povw::{
Expand Down Expand Up @@ -99,12 +103,14 @@ impl PovwClaim {
let tx_signer = global_config.require_private_key()?;
let rpc_url = global_config.require_rpc_url()?;

// Connect to the chain.
let provider = ProviderBuilder::new()
.wallet(tx_signer.clone())
let client = RpcClient::builder()
.layer(ThrottleLayer::new(global_config.rps))
.connect(rpc_url.as_str())
.await
.with_context(|| format!("failed to connect provider to {rpc_url}"))?;
.with_context(|| format!("failed to connect to {rpc_url}"))?;

// Connect to the chain.
let provider = ProviderBuilder::new().wallet(tx_signer).connect_client(client);

let chain_id = provider.get_chain_id().await.context("Failed to query the chain ID")?;
let chain_spec = CHAIN_SPECS.get(&chain_id).with_context(|| {
Expand Down
4 changes: 4 additions & 0 deletions crates/boundless-cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ pub struct GlobalConfig {
#[clap(long, env = "RPC_URL", global = true)]
pub rpc_url: Option<Url>,

/// Limit the requests per second to the RPC endpoint
#[clap(long, env = "RPS", global = true, default_value_t = 25)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure defaulting the value to 25 is a good idea. I'd say that the majority of provers are not using a free RPC endpoint, so they would be affected.

Also for backwards compatibility, set the default to unlimited (current behaviour), but allow one configure to a different value

pub rps: u32,

/// Private key of the wallet (without 0x prefix)
#[clap(long, env = "PRIVATE_KEY", global = true, hide_env_values = true)]
pub private_key: Option<PrivateKeySigner>,
Expand Down
Loading