Skip to content

Commit 19e8abb

Browse files
authored
feat(fortuna): better logging + avoid unnecessary fee syncs (#2708)
* feat(fortuna): better logging + avoid unnecessary fee syncs
1 parent 3292f62 commit 19e8abb

File tree

8 files changed

+32
-8
lines changed

8 files changed

+32
-8
lines changed

apps/fortuna/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/fortuna/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fortuna"
3-
version = "7.6.0"
3+
version = "7.6.1"
44
edition = "2021"
55

66
[lib]

apps/fortuna/config.sample.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ chains:
3232
# How much to charge in fees
3333
fee: 1500000000000000
3434

35+
# Set this temporarily to false if you have changed the fees and want to apply a new baseline fee.
36+
sync_fee_only_on_register: true
37+
3538
# Configuration for dynamic fees under high gas prices. The keeper will set
3639
# on-chain fees to make between [min_profit_pct, max_profit_pct] of the max callback
3740
# cost in profit per transaction.

apps/fortuna/src/command/run.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,11 @@ async fn setup_chain_state(
222222
.cmp(&c2.original_commitment_sequence_number)
223223
});
224224

225-
let provider_info = contract.get_provider_info(*provider).call().await?;
225+
let provider_info = contract
226+
.get_provider_info(*provider)
227+
.call()
228+
.await
229+
.map_err(|e| anyhow!("Failed to get provider info: {}", e))?;
226230
let latest_metadata = bincode::deserialize::<CommitmentMetadata>(
227231
&provider_info.commitment_metadata,
228232
)

apps/fortuna/src/command/setup_provider.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,11 @@ async fn setup_chain_provider(
149149

150150
let provider_info = contract.get_provider_info(provider_address).call().await?;
151151

152-
sync_fee(&contract, &provider_info, chain_config.fee)
153-
.in_current_span()
154-
.await?;
152+
if register || !chain_config.sync_fee_only_on_register {
153+
sync_fee(&contract, &provider_info, chain_config.fee)
154+
.in_current_span()
155+
.await?;
156+
}
155157

156158
let uri = get_register_uri(&provider_config.uri, chain_id)?;
157159
sync_uri(&contract, &provider_info, uri)

apps/fortuna/src/config.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ pub struct EthereumConfig {
172172
#[serde(default)]
173173
pub fee: u128,
174174

175+
/// Only set the provider's fee when the provider is registered for the first time. Default is true.
176+
/// This is useful to avoid resetting the fees on service restarts.
177+
#[serde(default = "default_sync_fee_only_on_register")]
178+
pub sync_fee_only_on_register: bool,
179+
175180
/// Historical commitments made by the provider.
176181
pub commitments: Option<Vec<Commitment>>,
177182

@@ -186,6 +191,10 @@ pub struct EthereumConfig {
186191
pub block_delays: Vec<u64>,
187192
}
188193

194+
fn default_sync_fee_only_on_register() -> bool {
195+
true
196+
}
197+
189198
fn default_block_delays() -> Vec<u64> {
190199
vec![5]
191200
}

apps/fortuna/src/eth_utils/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ pub async fn submit_tx_with_backoff<T: Middleware + NonceManaged + 'static>(
187187
},
188188
|e, dur| {
189189
let retry_number = num_retries.load(std::sync::atomic::Ordering::Relaxed);
190-
tracing::error!(
190+
tracing::warn!(
191191
"Error on retry {} at duration {:?}: {}",
192192
retry_number,
193193
dur,

apps/fortuna/src/keeper/commitment.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ pub async fn update_commitments_if_necessary(
4242
.block(latest_safe_block) // To ensure we are not revealing sooner than we should
4343
.call()
4444
.await
45-
.map_err(|e| anyhow!("Error while getting provider info. error: {:?}", e))?;
45+
.map_err(|e| {
46+
anyhow!(
47+
"Error while getting provider info at block {}. error: {:?}",
48+
latest_safe_block,
49+
e
50+
)
51+
})?;
4652
if provider_info.max_num_hashes == 0 {
4753
return Ok(());
4854
}

0 commit comments

Comments
 (0)