Use real conversion rate in greedy relayer strategy (#1035)

* use real conversion rate in greedy relayer strategy

* only accept positive, normal numbers in FloatJsonValueMetric
This commit is contained in:
Svyatoslav Nikolsky
2021-07-01 09:26:54 +03:00
committed by Bastian Köcher
parent 084c2e6c64
commit fd39d3519e
9 changed files with 78 additions and 17 deletions
@@ -212,7 +212,7 @@ pub trait TargetClient<P: MessageLane>: RelayClient {
nonces: RangeInclusive<MessageNonce>,
total_dispatch_weight: Weight,
total_size: u32,
) -> P::SourceChainBalance;
) -> Result<P::SourceChainBalance, Self::Error>;
}
/// State of the client.
@@ -775,10 +775,12 @@ pub(crate) mod tests {
nonces: RangeInclusive<MessageNonce>,
total_dispatch_weight: Weight,
total_size: u32,
) -> TestSourceChainBalance {
BASE_MESSAGE_DELIVERY_TRANSACTION_COST * (nonces.end() - nonces.start() + 1)
+ total_dispatch_weight
+ total_size as TestSourceChainBalance
) -> Result<TestSourceChainBalance, TestError> {
Ok(
BASE_MESSAGE_DELIVERY_TRANSACTION_COST * (nonces.end() - nonces.start() + 1)
+ total_dispatch_weight
+ total_size as TestSourceChainBalance,
)
}
}
@@ -654,7 +654,15 @@ async fn select_nonces_for_delivery_transaction<P: MessageLane>(
new_selected_unpaid_weight,
new_selected_size as u32,
)
.await;
.await
.map_err(|err| {
log::debug!(
target: "bridge",
"Failed to estimate delivery transaction cost: {:?}. No nonces selected for delivery",
err,
);
})
.ok()?;
// if it is the first message that makes reward less than cost, let's log it
// if this message makes batch profitable again, let's log it