From 69c70fa7c3eece373559ddc1af317ae4ddd7e445 Mon Sep 17 00:00:00 2001 From: Itay Tsabary Date: Tue, 10 Dec 2024 06:48:28 +0200 Subject: [PATCH 1/4] fix(papyrus_load_test): activate missing dependency feature commit-id:640fe6f5 --- crates/papyrus_load_test/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/papyrus_load_test/Cargo.toml b/crates/papyrus_load_test/Cargo.toml index b321a4481c..ce1ffdaf6a 100644 --- a/crates/papyrus_load_test/Cargo.toml +++ b/crates/papyrus_load_test/Cargo.toml @@ -17,7 +17,7 @@ rand.workspace = true reqwest.workspace = true serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true, features = ["arbitrary_precision"] } -starknet_api.workspace = true +starknet_api = { workspace = true, features = ["testing"] } tokio.workspace = true [dev-dependencies] From 1c3413aba4dcd57799d61bb3e26e72e9d5001166 Mon Sep 17 00:00:00 2001 From: Itay Tsabary Date: Tue, 10 Dec 2024 07:20:21 +0200 Subject: [PATCH 2/4] chore(starknet_gateway): use const for json rpc version commit-id:69ba79bd --- crates/starknet_gateway/src/config.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/crates/starknet_gateway/src/config.rs b/crates/starknet_gateway/src/config.rs index f0e02aee90..2ce2c97654 100644 --- a/crates/starknet_gateway/src/config.rs +++ b/crates/starknet_gateway/src/config.rs @@ -11,6 +11,8 @@ use validator::Validate; use crate::compiler_version::VersionId; +const JSON_RPC_VERSION: &str = "2.0"; + #[derive(Clone, Debug, Default, Serialize, Deserialize, Validate, PartialEq)] pub struct GatewayConfig { pub stateless_tx_validator_config: StatelessTransactionValidatorConfig, @@ -119,16 +121,28 @@ impl SerializeConfig for StatelessTransactionValidatorConfig { } } -#[derive(Clone, Debug, Default, Serialize, Deserialize, Validate, PartialEq)] +#[derive(Clone, Debug, Serialize, Deserialize, Validate, PartialEq)] pub struct RpcStateReaderConfig { pub url: String, pub json_rpc_version: String, } +impl RpcStateReaderConfig { + pub fn from_url(url: String) -> Self { + Self { url, ..Default::default() } + } +} + +impl Default for RpcStateReaderConfig { + fn default() -> Self { + Self { url: Default::default(), json_rpc_version: JSON_RPC_VERSION.to_string() } + } +} + #[cfg(any(feature = "testing", test))] impl RpcStateReaderConfig { pub fn create_for_testing() -> Self { - Self { url: "http://localhost:8080".to_string(), json_rpc_version: "2.0".to_string() } + Self::from_url("http://localhost:8080".to_string()) } } From f29ebe5774dc129e9a0c8d003b92aed53e540468 Mon Sep 17 00:00:00 2001 From: Itay Tsabary Date: Tue, 10 Dec 2024 07:26:17 +0200 Subject: [PATCH 3/4] chore(blockifier_reexecution): remove const for json rpc version commit-id:81012ae2 --- crates/blockifier_reexecution/src/main.rs | 6 +----- .../src/state_reader/rpc_https_test.rs | 2 +- .../blockifier_reexecution/src/state_reader/utils.rs | 11 +++-------- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/crates/blockifier_reexecution/src/main.rs b/crates/blockifier_reexecution/src/main.rs index fa99d0ecc2..f058390dbe 100644 --- a/crates/blockifier_reexecution/src/main.rs +++ b/crates/blockifier_reexecution/src/main.rs @@ -8,7 +8,6 @@ use blockifier_reexecution::state_reader::utils::{ guess_chain_id_from_node_url, reexecute_and_verify_correctness, write_block_reexecution_data_to_file, - JSON_RPC_VERSION, }; use clap::{Args, Parser, Subcommand}; use google_cloud_storage::client::{Client, ClientConfig}; @@ -181,10 +180,7 @@ async fn main() { rpc_args.node_url ); - let config = RpcStateReaderConfig { - url: rpc_args.node_url.clone(), - json_rpc_version: JSON_RPC_VERSION.to_string(), - }; + let config = RpcStateReaderConfig::from_url(rpc_args.node_url.clone()); // RPC calls are "synchronous IO" (see, e.g., https://stackoverflow.com/questions/74547541/when-should-you-use-tokios-spawn-blocking) // for details), so should be executed in a blocking thread. diff --git a/crates/blockifier_reexecution/src/state_reader/rpc_https_test.rs b/crates/blockifier_reexecution/src/state_reader/rpc_https_test.rs index 55e48c3911..49084ecdb6 100644 --- a/crates/blockifier_reexecution/src/state_reader/rpc_https_test.rs +++ b/crates/blockifier_reexecution/src/state_reader/rpc_https_test.rs @@ -89,7 +89,7 @@ pub fn get_test_block_id() -> BlockId { } pub fn get_test_rpc_config() -> RpcStateReaderConfig { - RpcStateReaderConfig { url: get_test_url(), json_rpc_version: "2.0".to_string() } + RpcStateReaderConfig::from_url(get_test_url()) } #[fixture] diff --git a/crates/blockifier_reexecution/src/state_reader/utils.rs b/crates/blockifier_reexecution/src/state_reader/utils.rs index 3742e1e033..edbfa1b99f 100644 --- a/crates/blockifier_reexecution/src/state_reader/utils.rs +++ b/crates/blockifier_reexecution/src/state_reader/utils.rs @@ -31,7 +31,6 @@ pub static RPC_NODE_URL: LazyLock = LazyLock::new(|| { env::var("TEST_URL") .unwrap_or_else(|_| "https://free-rpc.nethermind.io/mainnet-juno/".to_string()) }); -pub const JSON_RPC_VERSION: &str = "2.0"; pub fn guess_chain_id_from_node_url(node_url: &str) -> ReexecutionResult { match ( @@ -59,12 +58,9 @@ pub fn get_fee_token_addresses(chain_id: &ChainId) -> FeeTokenAddresses { } } -/// Returns the RPC state reader configuration with the constants RPC_NODE_URL and JSON_RPC_VERSION. +/// Returns the RPC state reader configuration with the constant RPC_NODE_URL. pub fn get_rpc_state_reader_config() -> RpcStateReaderConfig { - RpcStateReaderConfig { - url: RPC_NODE_URL.clone(), - json_rpc_version: JSON_RPC_VERSION.to_string(), - } + RpcStateReaderConfig::from_url(RPC_NODE_URL.clone()) } /// Returns the chain info of mainnet. @@ -260,8 +256,7 @@ pub fn write_block_reexecution_data_to_file( node_url: String, chain_id: ChainId, ) { - let config = - RpcStateReaderConfig { url: node_url, json_rpc_version: JSON_RPC_VERSION.to_string() }; + let config = RpcStateReaderConfig::from_url(node_url); let consecutive_state_readers = ConsecutiveTestStateReaders::new( block_number.prev().expect("Should not run with block 0"), From 2d7e21e172e8fc567a3a85e8ba5dfbfd89d9f2f1 Mon Sep 17 00:00:00 2001 From: Itay Tsabary Date: Tue, 10 Dec 2024 09:37:53 +0200 Subject: [PATCH 4/4] chore(starknet_integration_tests): remove const for json rpc version commit-id:bfb3bef3 --- crates/starknet_integration_tests/src/config_utils.rs | 1 - crates/starknet_integration_tests/src/utils.rs | 6 +----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/crates/starknet_integration_tests/src/config_utils.rs b/crates/starknet_integration_tests/src/config_utils.rs index 6715c197b1..09fef5ddfa 100644 --- a/crates/starknet_integration_tests/src/config_utils.rs +++ b/crates/starknet_integration_tests/src/config_utils.rs @@ -60,7 +60,6 @@ pub(crate) fn dump_config_file_changes( required_params.eth_fee_token_address, required_params.strk_fee_token_address, required_params.validator_id, - config.rpc_state_reader_config.json_rpc_version, config.rpc_state_reader_config.url, config.batcher_config.storage.db_config.path_prefix, config.http_server_config.ip, diff --git a/crates/starknet_integration_tests/src/utils.rs b/crates/starknet_integration_tests/src/utils.rs index f54e7a4d61..0afe826368 100644 --- a/crates/starknet_integration_tests/src/utils.rs +++ b/crates/starknet_integration_tests/src/utils.rs @@ -128,11 +128,7 @@ pub fn create_consensus_manager_configs_and_channels( pub fn test_rpc_state_reader_config(rpc_server_addr: SocketAddr) -> RpcStateReaderConfig { // TODO(Tsabary): get the latest version from the RPC crate. const RPC_SPEC_VERSION: &str = "V0_8"; - const JSON_RPC_VERSION: &str = "2.0"; - RpcStateReaderConfig { - url: format!("http://{rpc_server_addr:?}/rpc/{RPC_SPEC_VERSION}"), - json_rpc_version: JSON_RPC_VERSION.to_string(), - } + RpcStateReaderConfig::from_url(format!("http://{rpc_server_addr:?}/rpc/{RPC_SPEC_VERSION}")) } /// Creates a multi-account transaction generator for integration tests.