From 87796e2ac066775add07f04d9018c8f28fb28549 Mon Sep 17 00:00:00 2001 From: Nam Chu Hoai Date: Fri, 10 Nov 2023 08:21:52 -0500 Subject: [PATCH] Set a default gas policy (#2830) ### Description When no gas enforcement policy is set, by default, we should apply None --------- Co-authored-by: Trevor Porter --- rust/agents/relayer/src/msg/gas_payment/mod.rs | 2 ++ rust/agents/relayer/src/settings/mod.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/rust/agents/relayer/src/msg/gas_payment/mod.rs b/rust/agents/relayer/src/msg/gas_payment/mod.rs index 4ed30c9572..132fc286c2 100644 --- a/rust/agents/relayer/src/msg/gas_payment/mod.rs +++ b/rust/agents/relayer/src/msg/gas_payment/mod.rs @@ -44,6 +44,8 @@ pub struct GasPaymentEnforcer { } impl GasPaymentEnforcer { + /// Note that `policy_configs` should not be empty. In the settings, + /// a default of vec![GasPaymentEnforcementConf::default()] is used. pub fn new( policy_configs: impl IntoIterator, db: HyperlaneRocksDB, diff --git a/rust/agents/relayer/src/settings/mod.rs b/rust/agents/relayer/src/settings/mod.rs index 4071154752..18ea52dddb 100644 --- a/rust/agents/relayer/src/settings/mod.rs +++ b/rust/agents/relayer/src/settings/mod.rs @@ -187,7 +187,7 @@ impl FromRawConf for RelayerSettings { matching_list, }) }).collect_vec() - }).unwrap_or_default(); + }).unwrap_or_else(|_| vec![GasPaymentEnforcementConf::default()]); let whitelist = p .chain(&mut err)