diff --git a/rust/main/chains/hyperlane-sealevel/src/trait_builder.rs b/rust/main/chains/hyperlane-sealevel/src/trait_builder.rs index 50747ef8e3..13cc0b90a4 100644 --- a/rust/main/chains/hyperlane-sealevel/src/trait_builder.rs +++ b/rust/main/chains/hyperlane-sealevel/src/trait_builder.rs @@ -72,10 +72,11 @@ pub struct HeliusPriorityFeeOracleConfig { } /// The priority fee level to use -#[derive(Debug, Clone, Serialize)] +#[derive(Debug, Clone, Serialize, Default)] pub enum HeliusPriorityFeeLevel { /// 50th percentile, but a floor of 10k microlamports. /// The floor results in a staked Helius connection being used. (https://docs.helius.dev/guides/sending-transactions-on-solana#staked-connections) + #[default] Recommended, /// 0th percentile Min, diff --git a/rust/main/hyperlane-base/src/settings/parser/connection_parser.rs b/rust/main/hyperlane-base/src/settings/parser/connection_parser.rs index 087e9e041a..ff9ec9d409 100644 --- a/rust/main/hyperlane-base/src/settings/parser/connection_parser.rs +++ b/rust/main/hyperlane-base/src/settings/parser/connection_parser.rs @@ -243,6 +243,10 @@ fn parse_priority_fee_oracle_config( Some(PriorityFeeOracleConfig::Constant(fee)) } "helius" => { + let fee_level = parse_helius_priority_fee_level(&value_parser, err); + if !err.is_ok() { + return None; + } let config = HeliusPriorityFeeOracleConfig { url: value_parser .chain(err) @@ -250,7 +254,7 @@ fn parse_priority_fee_oracle_config( .parse_from_str("Invalid url") .end() .unwrap(), - fee_level: parse_helius_priority_fee_level(&value_parser, err), + fee_level: fee_level.unwrap(), }; Some(PriorityFeeOracleConfig::Helius(config)) } @@ -273,28 +277,33 @@ fn parse_priority_fee_oracle_config( fn parse_helius_priority_fee_level( value_parser: &ValueParser, err: &mut ConfigParsingError, -) -> HeliusPriorityFeeLevel { +) -> Option { let level = value_parser .chain(err) - .get_key("feeLevel") + .get_opt_key("feeLevel") .parse_string() - .end() - .unwrap_or_default(); + .end(); - match level.to_lowercase().as_str() { - "min" => HeliusPriorityFeeLevel::Min, - "low" => HeliusPriorityFeeLevel::Low, - "medium" => HeliusPriorityFeeLevel::Medium, - "high" => HeliusPriorityFeeLevel::High, - "veryhigh" => HeliusPriorityFeeLevel::VeryHigh, - "unsafemax" => HeliusPriorityFeeLevel::UnsafeMax, - _ => { - err.push( - &value_parser.cwp + "feeLevel", - eyre!("Unknown priority fee level"), - ); - HeliusPriorityFeeLevel::Medium + if let Some(level) = level { + match level.to_lowercase().as_str() { + "recommended" => Some(HeliusPriorityFeeLevel::Recommended), + "min" => Some(HeliusPriorityFeeLevel::Min), + "low" => Some(HeliusPriorityFeeLevel::Low), + "medium" => Some(HeliusPriorityFeeLevel::Medium), + "high" => Some(HeliusPriorityFeeLevel::High), + "veryhigh" => Some(HeliusPriorityFeeLevel::VeryHigh), + "unsafemax" => Some(HeliusPriorityFeeLevel::UnsafeMax), + _ => { + err.push( + &value_parser.cwp + "feeLevel", + eyre!("Unknown priority fee level"), + ); + None + } } + } else { + // If not specified at all, use the default + Some(HeliusPriorityFeeLevel::default()) } }