From bd8e6e36e0b095444ad048b173b41635ecd34612 Mon Sep 17 00:00:00 2001 From: rishflab Date: Wed, 9 Dec 2020 14:45:09 +1100 Subject: [PATCH] Fix monero blocktime config --- swap/tests/e2e.rs | 3 +-- xmr-btc/src/config.rs | 12 ++++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/swap/tests/e2e.rs b/swap/tests/e2e.rs index a7f8fd17..237543b2 100644 --- a/swap/tests/e2e.rs +++ b/swap/tests/e2e.rs @@ -10,9 +10,9 @@ use swap::{ }; use tempfile::tempdir; use testcontainers::clients::Cli; +use tracing_subscriber::util::SubscriberInitExt as _; use uuid::Uuid; use xmr_btc::{bitcoin, config::Config, cross_curve_dleq}; -use tracing_subscriber::util::SubscriberInitExt as _; /// Run the following tests with RUST_MIN_STACK=10000000 @@ -109,7 +109,6 @@ async fn happy_path() { /// the encsig and fail to refund or redeem. Alice punishes. #[tokio::test] async fn alice_punishes_if_bob_never_acts_after_fund() { - let _guard = tracing_subscriber::fmt() .with_env_filter("trace,hyper=warn") .set_default(); diff --git a/xmr-btc/src/config.rs b/xmr-btc/src/config.rs index dc5745b9..3fce9f04 100644 --- a/xmr-btc/src/config.rs +++ b/xmr-btc/src/config.rs @@ -15,7 +15,9 @@ impl Config { bob_time_to_act: *mainnet::BOB_TIME_TO_ACT, bitcoin_finality_confirmations: mainnet::BITCOIN_FINALITY_CONFIRMATIONS, bitcoin_avg_block_time: *mainnet::BITCOIN_AVG_BLOCK_TIME, - monero_max_finality_time: *mainnet::MONERO_AVG_BLOCK_TIME + // We apply a scaling factor (1.5) so that the swap is not aborted when the + // blockchain is slow + monero_max_finality_time: (*mainnet::MONERO_AVG_BLOCK_TIME).mul_f64(1.5) * mainnet::MONERO_FINALITY_CONFIRMATIONS, } } @@ -25,7 +27,9 @@ impl Config { bob_time_to_act: *regtest::BOB_TIME_TO_ACT, bitcoin_finality_confirmations: regtest::BITCOIN_FINALITY_CONFIRMATIONS, bitcoin_avg_block_time: *regtest::BITCOIN_AVG_BLOCK_TIME, - monero_max_finality_time: *regtest::MONERO_AVG_BLOCK_TIME + // We apply a scaling factor (1.5) so that the swap is not aborted when the + // blockchain is slow + monero_max_finality_time: (*regtest::MONERO_AVG_BLOCK_TIME).mul_f64(1.5) * regtest::MONERO_FINALITY_CONFIRMATIONS, } } @@ -41,7 +45,7 @@ mod mainnet { pub static BITCOIN_AVG_BLOCK_TIME: Lazy = Lazy::new(|| Duration::from_secs(10 * 60)); - pub static MONERO_FINALITY_CONFIRMATIONS: u32 = 10; + pub static MONERO_FINALITY_CONFIRMATIONS: u32 = 15; pub static MONERO_AVG_BLOCK_TIME: Lazy = Lazy::new(|| Duration::from_secs(2 * 60)); } @@ -58,5 +62,5 @@ mod regtest { pub static MONERO_FINALITY_CONFIRMATIONS: u32 = 1; - pub static MONERO_AVG_BLOCK_TIME: Lazy = Lazy::new(|| Duration::from_secs(5)); + pub static MONERO_AVG_BLOCK_TIME: Lazy = Lazy::new(|| Duration::from_secs(60)); }