diff --git a/relays/messages/src/message_race_delivery.rs b/relays/messages/src/message_race_delivery.rs index 8a667fdbdb..06e02a0601 100644 --- a/relays/messages/src/message_race_delivery.rs +++ b/relays/messages/src/message_race_delivery.rs @@ -343,31 +343,6 @@ where // There's additional condition in the message delivery race: target would reject messages // if there are too much unconfirmed messages at the inbound lane. - // The receiving race is responsible to deliver confirmations back to the source chain. So - // if there's a lot of unconfirmed messages, let's wait until it'll be able to do its job. - let latest_received_nonce_at_target = target_nonces.latest_nonce; - let confirmations_missing = - latest_received_nonce_at_target.checked_sub(latest_confirmed_nonce_at_source); - match confirmations_missing { - Some(confirmations_missing) - if confirmations_missing >= self.max_unconfirmed_nonces_at_target => - { - log::debug!( - target: "bridge", - "Cannot deliver any more messages from {} to {}. Too many unconfirmed nonces \ - at target: target.latest_received={:?}, source.latest_confirmed={:?}, max={:?}", - MessageDeliveryRace::
::source_name(), - MessageDeliveryRace::
::target_name(),
- latest_received_nonce_at_target,
- latest_confirmed_nonce_at_source,
- self.max_unconfirmed_nonces_at_target,
- );
-
- return None
- },
- _ => (),
- }
-
// Ok - we may have new nonces to deliver. But target may still reject new messages, because
// we haven't notified it that (some) messages have been confirmed. So we may want to
// include updated `source.latest_confirmed` in the proof.
@@ -375,6 +350,7 @@ where
// Important note: we're including outbound state lane proof whenever there are unconfirmed
// nonces on the target chain. Other strategy is to include it only if it's absolutely
// necessary.
+ let latest_received_nonce_at_target = target_nonces.latest_nonce;
let latest_confirmed_nonce_at_target = target_nonces.nonces_data.confirmed_nonce;
let outbound_state_proof_required =
latest_confirmed_nonce_at_target < latest_confirmed_nonce_at_source;
@@ -585,6 +561,11 @@ where
self.strategy.source_nonces_updated(at_block, nonces)
}
+ fn reset_best_target_nonces(&mut self) {
+ self.target_nonces = None;
+ self.strategy.reset_best_target_nonces();
+ }
+
fn best_target_nonces_updated >>(
&mut self,
nonces: TargetClientNonces >(
P::target_name(),
);
- race_state.reset_nonces_to_submit();
race_state.nonces_submitted = Some(artifacts.nonces);
target_tx_tracker.set(artifacts.tx_tracker.wait().fuse());
},
&mut target_go_offline_future,
async_std::task::sleep,
|| format!("Error submitting proof {}", P::target_name()),
- ).fail_if_error(FailedClient::Target).map(|_| true)?;
+ ).fail_if_connection_error(FailedClient::Target)?;
+
+ // in any case - we don't need to retry submitting the same nonces again until
+ // we read nonces from the target client
+ race_state.reset_nonces_to_submit();
+ // if we have failed to submit transaction AND that is not the connection issue,
+ // then we need to read best target nonces before selecting nonces again
+ if !target_client_is_online {
+ strategy.reset_best_target_nonces();
+ }
},
target_transaction_status = target_tx_tracker => {
match (target_transaction_status, race_state.nonces_submitted.as_ref()) {
@@ -699,7 +710,13 @@ pub async fn run >(
.fuse(),
);
} else if let Some(source_required_header) = source_required_header.clone() {
- log::debug!(target: "bridge", "Going to require {} header {:?} at {}", P::source_name(), source_required_header, P::target_name());
+ log::debug!(
+ target: "bridge",
+ "Going to require {} header {:?} at {}",
+ P::source_name(),
+ source_required_header,
+ P::target_name(),
+ );
target_require_source_header
.set(race_target.require_source_header(source_required_header).fuse());
} else if target_best_nonces_required {
diff --git a/relays/messages/src/message_race_strategy.rs b/relays/messages/src/message_race_strategy.rs
index 718c296391..5c8f9a162b 100644
--- a/relays/messages/src/message_race_strategy.rs
+++ b/relays/messages/src/message_race_strategy.rs
@@ -254,6 +254,10 @@ impl<
)
}
+ fn reset_best_target_nonces(&mut self) {
+ self.best_target_nonce = None;
+ }
+
fn best_target_nonces_updated<
RS: RaceState<
HeaderId