Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Commit

Permalink
Bridge pangolin-pangoro code clean and update feemarket strategy (#588)
Browse files Browse the repository at this point in the history
* accurate log

* accurate log

* any one can relay order when timeout

* fix staging

* lint

* lint

* lint
  • Loading branch information
fewensa authored Sep 22, 2023
1 parent 99a4b6f commit 8df3c4a
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 39 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ jobs:
matrix:
package:
- bridger
# - darwinia-ethereum
# - pangolin-goerli
# - darwinia-crab
# - pangolin-pangoro
- darwinia-ethereum
- darwinia-crab
- pangolin-pangoro
- pangoro-goerli
# - pangoro-chapel
steps:
- uses: actions/checkout@v2

Expand Down
2 changes: 1 addition & 1 deletion assistants/bin-s2s/src/bridge/config/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct SoloWithParaConfig {
pub para_id: u32,
}

#[cfg(any(feature = "para-with-para"))]
#[cfg(feature = "para-with-para")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ParaWithParaConfig {
pub source_para_id: u32,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<
while let Err(e) = Self::start(bridge_config.clone()).await {
tracing::error!(
target: "bin-s2s",
"[header-relay] [{}-to-{}] an error occurred for header relay {:?}",
"[parahead-header-relay] [{}-to-{}] an error occurred for header relay {:?}",
config_chain.source_relay.chain().name(),
config_chain.target_para.chain().name(),
e,
Expand All @@ -74,7 +74,7 @@ impl<
tokio::time::sleep(duration).await;
tracing::error!(
target: "bin-s2s",
"[header-relay] [{}-to-{}] many errors occurred, wait {} seconds",
"[parahead-header-relay] [{}-to-{}] many errors occurred, wait {} seconds",
config_chain.source_relay.chain().name(),
config_chain.target_para.chain().name(),
duration.as_secs(),
Expand All @@ -83,7 +83,7 @@ impl<
tokio::time::sleep(std::time::Duration::from_secs(5)).await;
tracing::info!(
target: "bin-s2s",
"[header-relay] [{}-to-{}] try to restart header relay service.",
"[parahead-header-relay] [{}-to-{}] try to restart header relay service.",
config_chain.source_relay.chain().name(),
config_chain.target_para.chain().name(),
);
Expand Down Expand Up @@ -114,7 +114,7 @@ impl<
let config_chain = bridge_config.chain;
tracing::info!(
target: "bin-s2s",
"[header-{}-to-{}] SERVICE RESTARTING...",
"[parahead-header-{}-to-{}] SERVICE RESTARTING...",
config_chain.source_relay.chain().name(),
config_chain.target_para.chain().name(),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<
while let Err(e) = Self::start(bridge_config.clone()).await {
tracing::error!(
target: "bin-s2s",
"[header-relay] [{}-to-{}] an error occurred for header relay {:?}",
"[relayhead-header-relay] [{}-to-{}] an error occurred for header relay {:?}",
config_chain.source_relay.chain().name(),
config_chain.target_para.chain().name(),
e,
Expand All @@ -74,7 +74,7 @@ impl<
tokio::time::sleep(duration).await;
tracing::error!(
target: "bin-s2s",
"[header-relay] [{}-to-{}] many errors occurred, wait {} seconds",
"[relayhead-header-relay] [{}-to-{}] many errors occurred, wait {} seconds",
config_chain.source_relay.chain().name(),
config_chain.target_para.chain().name(),
duration.as_secs(),
Expand All @@ -83,7 +83,7 @@ impl<
tokio::time::sleep(std::time::Duration::from_secs(5)).await;
tracing::info!(
target: "bin-s2s",
"[header-relay] [{}-to-{}] try to restart header relay service.",
"[relayhead-header-relay] [{}-to-{}] try to restart header relay service.",
config_chain.source_relay.chain().name(),
config_chain.target_para.chain().name(),
);
Expand Down
2 changes: 1 addition & 1 deletion assistants/client-kusama/src/fastapi/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#[cfg(any(feature = "bridge-s2s"))]
#[cfg(feature = "bridge-s2s")]
mod client_common;
2 changes: 1 addition & 1 deletion assistants/client-moonbase/src/fastapi/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#[cfg(any(feature = "bridge-s2s"))]
#[cfg(feature = "bridge-s2s")]
mod client_common;
2 changes: 1 addition & 1 deletion assistants/client-polkadot/src/fastapi/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#[cfg(any(feature = "bridge-s2s"))]
#[cfg(feature = "bridge-s2s")]
mod client_common;
2 changes: 1 addition & 1 deletion assistants/client-rococo/src/fastapi/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#[cfg(any(feature = "bridge-s2s"))]
#[cfg(feature = "bridge-s2s")]
mod client_common;
43 changes: 22 additions & 21 deletions assistants/feemarket-s2s/src/relay/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,28 @@ impl<A: FeemarketApiRelay> RelayStrategy for BasicRelayStrategy<A> {
.await
.map_err(|e| S2SClientError::Custom(format!("[feemarket]: {:?}", e)))?;

// -----
// If the order timeout, anyone can relay this.
let ranges = relayers
.iter()
.map(|item| item.valid_range.clone())
.collect::<Vec<Range<<A::Chain as Chain>::BlockNumber>>>();

let mut maximum_timeout: <A::Chain as Chain>::BlockNumber = Default::default();
for range in ranges {
maximum_timeout = std::cmp::max(maximum_timeout, range.end);
}
// If this order has timed out, decide to relay
if finalized_block_number > maximum_timeout {
tracing::info!(
target: "feemarket",
"{} this nonce is timeout. so the decide is relay this nonce: {}",
logk::prefix_with_relation("feemarket", "relay", A::CHAIN, "::"),
nonce,
);
return Ok(true);
}

// If you are assigned relayer, you must relay this nonce.
// If you don't do that, the fee market pallet will slash your deposit.
// Even though it is a timeout, although it will slash your deposit after the timeout is delivered,
Expand Down Expand Up @@ -128,27 +150,6 @@ impl<A: FeemarketApiRelay> RelayStrategy for BasicRelayStrategy<A> {
return Ok(false);
}

// -----
// If you aren't assigned relayer, only participate in the part about time out, earn more rewards
let ranges = relayers
.iter()
.map(|item| item.valid_range.clone())
.collect::<Vec<Range<<A::Chain as Chain>::BlockNumber>>>();

let mut maximum_timeout: <A::Chain as Chain>::BlockNumber = Default::default();
for range in ranges {
maximum_timeout = std::cmp::max(maximum_timeout, range.end);
}
// If this order has timed out, decide to relay
if finalized_block_number > maximum_timeout {
tracing::info!(
target: "feemarket",
"{} you aren't assigned relayer. but this nonce is timeout. so the decide is relay this nonce: {}",
logk::prefix_with_relation("feemarket", "relay", A::CHAIN, "::"),
nonce,
);
return Ok(true);
}
tracing::info!(
target: "feemarket",
"{} you aren't assigned relay. and this nonce({}) is on-time. so don't relay this",
Expand Down
2 changes: 1 addition & 1 deletion assistants/relay-e2e/src/ecdsa/ecdsa_scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub trait EcdsaScanner<T: EcdsaClient> {
return Ok(());
}

let mut source = self.get_ecdsa_source();
let source = self.get_ecdsa_source();
loop {
let from = tracker
.current()
Expand Down

0 comments on commit 8df3c4a

Please sign in to comment.