Skip to content

Commit 30efd19

Browse files
svyatonikTarekkMA
authored andcommitted
Bridge: ignore client errors when calling recently added *_free_headers_interval methods (paritytech#4350)
see paritytech/parity-bridges-common#2974 : we still need to support unupgraded chains (BHK and BHP) in relay We may need to revert this change when all chains are upgraded
1 parent 1a7163a commit 30efd19

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

bridges/relays/lib-substrate-relay/src/finality/target.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,24 @@ impl<P: SubstrateFinalitySyncPipeline> TargetClient<FinalitySyncPipelineAdapter<
107107
async fn free_source_headers_interval(
108108
&self,
109109
) -> Result<Option<BlockNumberOf<P::SourceChain>>, Self::Error> {
110-
self.client
110+
Ok(self
111+
.client
111112
.typed_state_call(
112113
P::SourceChain::FREE_HEADERS_INTERVAL_METHOD.into(),
113114
(),
114115
Some(self.client.best_header().await?.hash()),
115116
)
116117
.await
118+
.unwrap_or_else(|e| {
119+
log::info!(
120+
target: "bridge",
121+
"Call of {} at {} has failed with an error: {:?}. Treating as `None`",
122+
P::SourceChain::FREE_HEADERS_INTERVAL_METHOD,
123+
P::TargetChain::NAME,
124+
e,
125+
);
126+
None
127+
}))
117128
}
118129

119130
async fn submit_finality_proof(

bridges/relays/lib-substrate-relay/src/parachains/target.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,20 @@ where
122122
async fn free_source_relay_headers_interval(
123123
&self,
124124
) -> Result<Option<BlockNumberOf<P::SourceRelayChain>>, Self::Error> {
125-
self.target_client
125+
Ok(self
126+
.target_client
126127
.typed_state_call(P::SourceRelayChain::FREE_HEADERS_INTERVAL_METHOD.into(), (), None)
127128
.await
129+
.unwrap_or_else(|e| {
130+
log::info!(
131+
target: "bridge",
132+
"Call of {} at {} has failed with an error: {:?}. Treating as `None`",
133+
P::SourceRelayChain::FREE_HEADERS_INTERVAL_METHOD,
134+
P::TargetChain::NAME,
135+
e,
136+
);
137+
None
138+
}))
128139
}
129140

130141
async fn parachain_head(

0 commit comments

Comments
 (0)