Skip to content

Commit e19fa40

Browse files
authored
Merge pull request #828 from openmina/fix/p2p/webrtc/streaming_rpc/timeout
Fix P2P/WebRTC: staged ledger parts fetching timing out for webnode, causing bootstrap to never finish
2 parents 5eefb0c + 7a02302 commit e19fa40

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

p2p/src/channels/streaming_rpc/p2p_channels_streaming_rpc_reducer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ impl P2pChannelsStreamingRpcState {
215215
progress: StagedLedgerPartsSendProgress::LedgerGetIdle { time: meta.time() }
216216
.into(),
217217
};
218+
// async ledger request will be triggered by `LedgerReadAction::FindTodos`.
218219
Ok(())
219220
}
220221
P2pChannelsStreamingRpcAction::ResponsePending { .. } => {

p2p/src/channels/streaming_rpc/p2p_channels_streaming_rpc_state.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ impl P2pChannelsStreamingRpcState {
9090
Self::Ready {
9191
local:
9292
P2pStreamingRpcLocalState::Requested {
93-
time, id, request, ..
93+
id,
94+
request,
95+
progress,
96+
..
9497
},
9598
..
9699
} => {
@@ -99,7 +102,7 @@ impl P2pChannelsStreamingRpcState {
99102
.kind()
100103
.timeout(config)
101104
.and_then(|timeout| {
102-
let dur = now.checked_sub(*time)?;
105+
let dur = now.checked_sub(progress.last_updated())?;
103106
Some(dur >= timeout)
104107
})
105108
.unwrap_or(false)

p2p/src/channels/streaming_rpc/rpcs/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ impl P2pStreamingRpcReceiveProgress {
144144
}
145145
}
146146

147+
pub fn last_updated(&self) -> redux::Timestamp {
148+
match self {
149+
Self::StagedLedgerParts(s) => s.last_updated(),
150+
}
151+
}
152+
147153
pub fn update(&mut self, time: redux::Timestamp, resp: P2pStreamingRpcResponse) -> bool {
148154
match (self, resp) {
149155
(

p2p/src/channels/streaming_rpc/rpcs/staged_ledger_parts.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,19 @@ impl Default for StagedLedgerPartsSendProgress {
192192
}
193193

194194
impl StagedLedgerPartsReceiveProgress {
195+
pub fn last_updated(&self) -> redux::Timestamp {
196+
match self {
197+
Self::BasePending { time }
198+
| Self::BaseSuccess { time, .. }
199+
| Self::PreviousIncompleteZkappUpdatesPending { time, .. }
200+
| Self::PreviousIncompleteZkappUpdatesSuccess { time, .. }
201+
| Self::ScanStateBasePending { time, .. }
202+
| Self::ScanStateBaseSuccess { time, .. }
203+
| Self::ScanStateTreesPending { time, .. }
204+
| Self::Success { time, .. } => *time,
205+
}
206+
}
207+
195208
pub fn update(&mut self, time: redux::Timestamp, resp: StagedLedgerPartsResponse) -> bool {
196209
match (std::mem::take(self), resp) {
197210
(Self::BasePending { .. }, StagedLedgerPartsResponse::Base(base)) => {

0 commit comments

Comments
 (0)