diff --git a/CHANGELOG.md b/CHANGELOG.md index 669c7e0e6..22f5f80ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ git # Deoxys Changelog ## Next release +- feat(api_key): api key passed to FetchConfig correctly +- feat(api_key): Added support for --gateway-api to avoid rate limit from the gateway - fix(latest): Retrieve latest synced block via internal client - perf(l2 sync): parallelize commitment computation and refactor part of l2 io sync - refactor: rpc methods and removed rpc-core diff --git a/Cargo.lock b/Cargo.lock index 913fad78a..2b0557127 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5058,9 +5058,9 @@ dependencies = [ [[package]] name = "lambdaworks-crypto" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d4c222d5b2fdc0faf702d3ab361d14589b097f40eac9dc550e27083483edc65" +checksum = "458fee521f12d0aa97a2e06eaf134398a5d2ae7b2074af77eb402b0d93138c47" dependencies = [ "lambdaworks-math", "serde", @@ -5070,9 +5070,9 @@ dependencies = [ [[package]] name = "lambdaworks-math" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ee7dcab3968c71896b8ee4dc829147acc918cffe897af6265b1894527fe3add" +checksum = "6c74ce6f0d9cb672330b6ca59e85a6c3607a3329e0372ab0d3fe38c2d38e50f9" dependencies = [ "serde", "serde_json", @@ -10975,7 +10975,7 @@ dependencies = [ [[package]] name = "starknet-core" version = "0.8.0" -source = "git+https://github.com/jbcaron/starknet-rs.git?branch=classes#664bfce5e9cf9e5eb7905255d5f3abafa90c9935" +source = "git+https://github.com/jbcaron/starknet-rs.git?branch=classes#3f59288f2bdd9702713d05fd4417c3ae34dd58e2" dependencies = [ "base64 0.21.5", "flate2", @@ -11030,7 +11030,7 @@ dependencies = [ [[package]] name = "starknet-crypto" version = "0.6.1" -source = "git+https://github.com/jbcaron/starknet-rs.git?branch=classes#664bfce5e9cf9e5eb7905255d5f3abafa90c9935" +source = "git+https://github.com/jbcaron/starknet-rs.git?branch=classes#3f59288f2bdd9702713d05fd4417c3ae34dd58e2" dependencies = [ "crypto-bigint", "hex", @@ -11097,7 +11097,7 @@ dependencies = [ [[package]] name = "starknet-crypto-codegen" version = "0.3.2" -source = "git+https://github.com/jbcaron/starknet-rs.git?branch=classes#664bfce5e9cf9e5eb7905255d5f3abafa90c9935" +source = "git+https://github.com/jbcaron/starknet-rs.git?branch=classes#3f59288f2bdd9702713d05fd4417c3ae34dd58e2" dependencies = [ "starknet-curve 0.4.0 (git+https://github.com/jbcaron/starknet-rs.git?branch=classes)", "starknet-ff 0.3.5 (git+https://github.com/jbcaron/starknet-rs.git?branch=classes)", @@ -11127,7 +11127,7 @@ dependencies = [ [[package]] name = "starknet-curve" version = "0.4.0" -source = "git+https://github.com/jbcaron/starknet-rs.git?branch=classes#664bfce5e9cf9e5eb7905255d5f3abafa90c9935" +source = "git+https://github.com/jbcaron/starknet-rs.git?branch=classes#3f59288f2bdd9702713d05fd4417c3ae34dd58e2" dependencies = [ "starknet-ff 0.3.5 (git+https://github.com/jbcaron/starknet-rs.git?branch=classes)", ] @@ -11160,7 +11160,7 @@ dependencies = [ [[package]] name = "starknet-ff" version = "0.3.5" -source = "git+https://github.com/jbcaron/starknet-rs.git?branch=classes#664bfce5e9cf9e5eb7905255d5f3abafa90c9935" +source = "git+https://github.com/jbcaron/starknet-rs.git?branch=classes#3f59288f2bdd9702713d05fd4417c3ae34dd58e2" dependencies = [ "ark-ff", "bigdecimal", @@ -11220,7 +11220,7 @@ dependencies = [ [[package]] name = "starknet-providers" version = "0.8.0" -source = "git+https://github.com/jbcaron/starknet-rs.git?branch=classes#664bfce5e9cf9e5eb7905255d5f3abafa90c9935" +source = "git+https://github.com/jbcaron/starknet-rs.git?branch=classes#3f59288f2bdd9702713d05fd4417c3ae34dd58e2" dependencies = [ "async-trait", "auto_impl", @@ -11274,8 +11274,8 @@ dependencies = [ [[package]] name = "starknet-types-core" -version = "0.0.9" -source = "git+https://github.com/starknet-io/types-rs.git?branch=main#36f5be1e849b60d60697b873e428836305429ca6" +version = "0.0.11" +source = "git+https://github.com/starknet-io/types-rs.git?branch=main#bcb3fc518620635dbb172ce5f80e63177aa913ef" dependencies = [ "bitvec", "lambdaworks-crypto", @@ -12311,7 +12311,7 @@ checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", "digest 0.10.7", - "rand 0.8.5", + "rand 0.7.3", "static_assertions", ] diff --git a/crates/client/rpc/src/methods/write/add_declare_transaction.rs b/crates/client/rpc/src/methods/write/add_declare_transaction.rs index 49c038027..1203caa74 100644 --- a/crates/client/rpc/src/methods/write/add_declare_transaction.rs +++ b/crates/client/rpc/src/methods/write/add_declare_transaction.rs @@ -44,7 +44,7 @@ where error!("Failed to get config: {e}"); StarknetRpcApiError::InternalServerError })?; - let sequencer = SequencerGatewayProvider::new(config.feeder_gateway, config.gateway, config.chain_id); + let sequencer = SequencerGatewayProvider::new(config.feeder_gateway, config.gateway, config.chain_id, None); let sequencer_response = match sequencer.add_declare_transaction(declare_transaction).await { Ok(response) => response, diff --git a/crates/client/rpc/src/methods/write/add_deploy_account_transaction.rs b/crates/client/rpc/src/methods/write/add_deploy_account_transaction.rs index ba346dfc3..e58a1f16c 100644 --- a/crates/client/rpc/src/methods/write/add_deploy_account_transaction.rs +++ b/crates/client/rpc/src/methods/write/add_deploy_account_transaction.rs @@ -45,7 +45,7 @@ where error!("Failed to get config: {e}"); StarknetRpcApiError::InternalServerError })?; - let sequencer = SequencerGatewayProvider::new(config.feeder_gateway, config.gateway, config.chain_id); + let sequencer = SequencerGatewayProvider::new(config.feeder_gateway, config.gateway, config.chain_id, None); let sequencer_response = match sequencer.add_deploy_account_transaction(deploy_account_transaction).await { Ok(response) => response, diff --git a/crates/client/rpc/src/methods/write/add_invoke_transaction.rs b/crates/client/rpc/src/methods/write/add_invoke_transaction.rs index 323c42e09..164f34330 100644 --- a/crates/client/rpc/src/methods/write/add_invoke_transaction.rs +++ b/crates/client/rpc/src/methods/write/add_invoke_transaction.rs @@ -44,7 +44,7 @@ where error!("Failed to get config: {e}"); StarknetRpcApiError::InternalServerError })?; - let sequencer = SequencerGatewayProvider::new(config.feeder_gateway, config.gateway, config.chain_id); + let sequencer = SequencerGatewayProvider::new(config.feeder_gateway, config.gateway, config.chain_id, None); let sequencer_response = match sequencer.add_invoke_transaction(invoke_transaction).await { Ok(response) => response, diff --git a/crates/client/sync/src/fetch/fetchers.rs b/crates/client/sync/src/fetch/fetchers.rs index d4a8ebefe..eaf2e9eec 100644 --- a/crates/client/sync/src/fetch/fetchers.rs +++ b/crates/client/sync/src/fetch/fetchers.rs @@ -45,6 +45,8 @@ pub struct FetchConfig { pub l1_core_address: H160, /// Whether to check the root of the state update pub verify: bool, + /// The optional API_KEY to avoid rate limiting from the sequencer gateway. + pub api_key: Option, } pub async fn fetch_block(client: &SequencerGatewayProvider, block_number: u64) -> Result { @@ -75,6 +77,7 @@ where match block.as_ref().err().or(state_update.as_ref().err()) { Some(L2SyncError::Provider(ProviderError::RateLimited)) => { + log::info!("The fetching process has been rate limited"); log::debug!("The fetching process has been rate limited, retrying in {:?} seconds", base_delay); attempt += 1; if attempt >= MAX_RETRY { @@ -93,7 +96,12 @@ where } pub async fn fetch_apply_genesis_block(config: FetchConfig) -> Result { - let client = SequencerGatewayProvider::new(config.gateway.clone(), config.feeder_gateway.clone(), config.chain_id); + let client = SequencerGatewayProvider::new( + config.gateway.clone(), + config.feeder_gateway.clone(), + config.chain_id, + config.api_key.clone(), + ); let block = client.get_block(BlockId::Number(0)).await.map_err(|e| format!("failed to get block: {e}"))?; Ok(crate::convert::block(block).await) diff --git a/crates/client/sync/src/l2.rs b/crates/client/sync/src/l2.rs index 44671f447..9e0401b66 100644 --- a/crates/client/sync/src/l2.rs +++ b/crates/client/sync/src/l2.rs @@ -157,6 +157,7 @@ pub async fn sync( fetch_config.gateway.clone(), fetch_config.feeder_gateway.clone(), fetch_config.chain_id, + fetch_config.api_key, )); let mut last_block_hash = None; diff --git a/crates/node/src/commands/run.rs b/crates/node/src/commands/run.rs index 9d84d861a..e26139918 100644 --- a/crates/node/src/commands/run.rs +++ b/crates/node/src/commands/run.rs @@ -81,7 +81,16 @@ impl NetworkType { let feeder_gateway = format!("{uri}/feeder_gateway").parse().unwrap(); let l1_core_address = self.l1_core_address(); - FetchConfig { gateway, feeder_gateway, chain_id, workers: 5, sound: false, l1_core_address, verify: true } + FetchConfig { + gateway, + feeder_gateway, + chain_id, + workers: 5, + sound: false, + l1_core_address, + verify: true, + api_key: None, + } } } @@ -126,6 +135,10 @@ pub struct ExtendedRunCmd { #[clap(long)] pub disable_root: bool, + /// Gateway api key to avoid rate limiting (optional) + #[clap(long)] + pub gateway_key: Option, + /// A flag to run the TUI dashboard #[cfg(feature = "tui")] #[clap(long)] @@ -168,6 +181,7 @@ pub fn run_node(mut cli: Cli) -> Result<()> { let mut fetch_block_config = cli.run.network.block_fetch_config(); fetch_block_config.sound = cli.run.sound; fetch_block_config.verify = !cli.run.disable_root; + fetch_block_config.api_key = cli.run.gateway_key.clone(); update_config(&fetch_block_config); log::debug!("Using fetch block config: {:?}", fetch_block_config);