diff --git a/fendermint/app/settings/src/lib.rs b/fendermint/app/settings/src/lib.rs index 3b0fb0247..b46c59fc1 100644 --- a/fendermint/app/settings/src/lib.rs +++ b/fendermint/app/settings/src/lib.rs @@ -128,6 +128,9 @@ pub struct TopDownSettings { pub exponential_retry_limit: usize, /// The parent rpc http endpoint pub parent_http_endpoint: Url, + /// Timeout for calls to the parent Ethereum API. + #[serde_as(as = "Option>")] + pub parent_http_timeout: Option, /// The parent registry address #[serde(deserialize_with = "deserialize_eth_address_from_str")] pub parent_registry: Address, diff --git a/fendermint/app/src/cmd/genesis.rs b/fendermint/app/src/cmd/genesis.rs index 00cebc7c8..261ceb111 100644 --- a/fendermint/app/src/cmd/genesis.rs +++ b/fendermint/app/src/cmd/genesis.rs @@ -294,6 +294,7 @@ async fn new_genesis_from_parent( .ok_or_else(|| anyhow!("subnet is not a child"))?, config: SubnetConfig::Fevm(EVMSubnet { provider_http: args.parent_endpoint.clone(), + provider_timeout: None, auth_token: None, registry_addr: args.parent_registry, gateway_addr: args.parent_gateway, diff --git a/fendermint/app/src/cmd/run.rs b/fendermint/app/src/cmd/run.rs index fc4327f77..a55fe4b5d 100644 --- a/fendermint/app/src/cmd/run.rs +++ b/fendermint/app/src/cmd/run.rs @@ -348,6 +348,7 @@ fn make_ipc_provider_proxy(settings: &Settings) -> anyhow::Result Option { + match &self.config { + SubnetConfig::Fevm(s) => s.provider_timeout, + } + } + pub fn gateway_addr(&self) -> Address { match &self.config { SubnetConfig::Fevm(s) => s.gateway_addr, @@ -74,10 +82,13 @@ pub struct FVMSubnet { #[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq)] pub struct EVMSubnet { pub provider_http: Url, + pub provider_timeout: Option, pub auth_token: Option, + #[serde(deserialize_with = "deserialize_eth_address_from_str")] #[serde(serialize_with = "serialize_eth_address_to_str")] pub registry_addr: Address, + #[serde(deserialize_with = "deserialize_eth_address_from_str")] #[serde(serialize_with = "serialize_eth_address_to_str")] pub gateway_addr: Address, diff --git a/ipc/provider/src/manager/evm/manager.rs b/ipc/provider/src/manager/evm/manager.rs index f95c8885d..915ab0c4c 100644 --- a/ipc/provider/src/manager/evm/manager.rs +++ b/ipc/provider/src/manager/evm/manager.rs @@ -15,6 +15,8 @@ use ipc_actors_abis::{ }; use ipc_api::evm::{fil_to_eth_amount, payload_to_evm_address, subnet_id_to_evm_addresses}; use ipc_api::validator::from_contract_validators; +use reqwest::header::HeaderValue; +use reqwest::Client; use std::net::{IpAddr, SocketAddr}; use ipc_api::subnet::{PermissionMode, SupplyKind, SupplySource}; @@ -65,7 +67,7 @@ const ETH_PROVIDER_POLLING_TIME: Duration = Duration::from_secs(1); const TRANSACTION_RECEIPT_RETRIES: usize = 200; /// The majority vote percentage for checkpoint submission when creating a subnet. -const SUBNET_MAJORITY_PERCENTAGE: u8 = 60; +const SUBNET_MAJORITY_PERCENTAGE: u8 = 67; pub struct EthSubnetManager { keystore: Option>>>, @@ -937,11 +939,26 @@ impl EthSubnetManager { let SubnetConfig::Fevm(config) = &subnet.config; - let provider = if auth_token.is_some() { - Http::new_with_auth(url, Authorization::Bearer(auth_token.unwrap()))? - } else { - Http::new(url) - }; + let mut client = Client::builder(); + + if let Some(auth_token) = auth_token { + let auth = Authorization::Bearer(auth_token); + let mut auth_value = HeaderValue::from_str(&auth.to_string())?; + auth_value.set_sensitive(true); + + let mut headers = reqwest::header::HeaderMap::new(); + headers.insert(reqwest::header::AUTHORIZATION, auth_value); + + client = client.default_headers(headers); + } + + if let Some(timeout) = subnet.rpc_timeout() { + client = client.timeout(timeout); + } + + let client = client.build()?; + + let provider = Http::new_with_client(url, client); let mut provider = Provider::new(provider); // set polling interval for provider to fit fast child subnets block times.