diff --git a/crates/blockifier_reexecution/src/state_reader/test_state_reader.rs b/crates/blockifier_reexecution/src/state_reader/test_state_reader.rs index a77be1b7d3..496e662b0e 100644 --- a/crates/blockifier_reexecution/src/state_reader/test_state_reader.rs +++ b/crates/blockifier_reexecution/src/state_reader/test_state_reader.rs @@ -50,7 +50,8 @@ use crate::state_reader::utils::{ pub const DEFAULT_RETRY_COUNT: usize = 3; pub const DEFAULT_RETRY_WAIT_TIME: u64 = 1000; -pub const DEFAULT_EXPECTED_ERROR_STRING: &str = "Connection error"; +pub const DEFAULT_EXPECTED_ERROR_STRINGS: [&str; 3] = + ["Connection error", "RPCError", "429 Too Many Requests"]; pub const DEFAULT_RETRY_FAILURE_MESSAGE: &str = "Failed to connect to the RPC node."; pub type ReexecutionResult = Result; @@ -143,7 +144,7 @@ impl From for OfflineReexecutionData { pub struct RetryConfig { pub(crate) n_retries: usize, pub(crate) retry_interval_milliseconds: u64, - pub(crate) expected_error_string: &'static str, + pub(crate) expected_error_strings: Vec<&'static str>, pub(crate) retry_failure_message: &'static str, } @@ -152,7 +153,7 @@ impl Default for RetryConfig { Self { n_retries: DEFAULT_RETRY_COUNT, retry_interval_milliseconds: DEFAULT_RETRY_WAIT_TIME, - expected_error_string: DEFAULT_EXPECTED_ERROR_STRING, + expected_error_strings: DEFAULT_EXPECTED_ERROR_STRINGS.to_vec(), retry_failure_message: DEFAULT_RETRY_FAILURE_MESSAGE, } } diff --git a/crates/blockifier_reexecution/src/state_reader/utils.rs b/crates/blockifier_reexecution/src/state_reader/utils.rs index 81349c190b..2add48e4bb 100644 --- a/crates/blockifier_reexecution/src/state_reader/utils.rs +++ b/crates/blockifier_reexecution/src/state_reader/utils.rs @@ -121,7 +121,12 @@ macro_rules! retry_request { match $closure() { Ok(value) => retry::OperationResult::Ok(value), // If the error contains the expected_error_string , we want to retry. - Err(e) if e.to_string().contains($retry_config.expected_error_string) => { + Err(e) + if $retry_config + .expected_error_strings + .iter() + .any(|s| e.to_string().contains(s)) => + { retry::OperationResult::Retry(e) } // For all other errors, do not retry and return immediately. @@ -130,7 +135,8 @@ macro_rules! retry_request { }, ) .map_err(|e| { - if e.error.to_string().contains($retry_config.expected_error_string) { + if $retry_config.expected_error_strings.iter().any(|s| e.error.to_string().contains(s)) + { panic!("{}: {:?}", $retry_config.retry_failure_message, e.error); } e.error