Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/fortuna/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/fortuna/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fortuna"
version = "7.6.0"
version = "7.6.1"
edition = "2021"

[lib]
Expand Down
3 changes: 3 additions & 0 deletions apps/fortuna/config.sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ chains:
# How much to charge in fees
fee: 1500000000000000

# Set this temporarily to false if you have changed the fees and want to apply a new baseline fee.
sync_fee_only_on_register: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a brittle config flag -- people will forget to unset it. I think it is better to auto-detect whether or not you need to set the fees differently.

E.g., can we run the same code we run in the keeper to set the fees based on the gas price?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is some state involved there (we don't update the fees if we are not seeing any new requests). I will add another task to improve it but since nothing bad happens if people forget to unset it, I think this is a good default behaviour.


# Configuration for dynamic fees under high gas prices. The keeper will set
# on-chain fees to make between [min_profit_pct, max_profit_pct] of the max callback
# cost in profit per transaction.
Expand Down
6 changes: 5 additions & 1 deletion apps/fortuna/src/command/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,11 @@ async fn setup_chain_state(
.cmp(&c2.original_commitment_sequence_number)
});

let provider_info = contract.get_provider_info(*provider).call().await?;
let provider_info = contract
.get_provider_info(*provider)
.call()
.await
.map_err(|e| anyhow!("Failed to get provider info: {}", e))?;
let latest_metadata = bincode::deserialize::<CommitmentMetadata>(
&provider_info.commitment_metadata,
)
Expand Down
8 changes: 5 additions & 3 deletions apps/fortuna/src/command/setup_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,11 @@ async fn setup_chain_provider(

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

sync_fee(&contract, &provider_info, chain_config.fee)
.in_current_span()
.await?;
if register || !chain_config.sync_fee_only_on_register {
sync_fee(&contract, &provider_info, chain_config.fee)
.in_current_span()
.await?;
}

let uri = get_register_uri(&provider_config.uri, chain_id)?;
sync_uri(&contract, &provider_info, uri)
Expand Down
9 changes: 9 additions & 0 deletions apps/fortuna/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ pub struct EthereumConfig {
#[serde(default)]
pub fee: u128,

/// Only set the provider's fee when the provider is registered for the first time. Default is true.
/// This is useful to avoid resetting the fees on service restarts.
#[serde(default = "default_sync_fee_only_on_register")]
pub sync_fee_only_on_register: bool,

/// Historical commitments made by the provider.
pub commitments: Option<Vec<Commitment>>,

Expand All @@ -186,6 +191,10 @@ pub struct EthereumConfig {
pub block_delays: Vec<u64>,
}

fn default_sync_fee_only_on_register() -> bool {
true
}

fn default_block_delays() -> Vec<u64> {
vec![5]
}
Expand Down
2 changes: 1 addition & 1 deletion apps/fortuna/src/eth_utils/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ pub async fn submit_tx_with_backoff<T: Middleware + NonceManaged + 'static>(
},
|e, dur| {
let retry_number = num_retries.load(std::sync::atomic::Ordering::Relaxed);
tracing::error!(
tracing::warn!(
"Error on retry {} at duration {:?}: {}",
retry_number,
dur,
Expand Down
8 changes: 7 additions & 1 deletion apps/fortuna/src/keeper/commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ pub async fn update_commitments_if_necessary(
.block(latest_safe_block) // To ensure we are not revealing sooner than we should
.call()
.await
.map_err(|e| anyhow!("Error while getting provider info. error: {:?}", e))?;
.map_err(|e| {
anyhow!(
"Error while getting provider info at block {}. error: {:?}",
latest_safe_block,
e
)
})?;
if provider_info.max_num_hashes == 0 {
return Ok(());
}
Expand Down
Loading