Skip to content

Commit cc7edeb

Browse files
mattsseRjected
andauthored
chore: dont treat invalid fork as fatal (#19888)
Co-authored-by: Dan Cline <[email protected]>
1 parent 9cdcc8e commit cc7edeb

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

crates/net/network/src/error.rs

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,22 @@ impl SessionError for EthStreamError {
113113
P2PHandshakeError::HelloNotInHandshake |
114114
P2PHandshakeError::NonHelloMessageInHandshake,
115115
)) => true,
116-
Self::EthHandshakeError(err) => !matches!(err, EthHandshakeError::NoResponse),
116+
Self::EthHandshakeError(err) => {
117+
#[allow(clippy::match_same_arms)]
118+
match err {
119+
EthHandshakeError::NoResponse => {
120+
// this happens when the conn simply stalled
121+
false
122+
}
123+
EthHandshakeError::InvalidFork(_) => {
124+
// this can occur when the remote or our node is running an outdated client,
125+
// we shouldn't treat this as fatal, because the node can come back online
126+
// with an updated version any time
127+
false
128+
}
129+
_ => true,
130+
}
131+
}
117132
_ => false,
118133
}
119134
}
@@ -144,7 +159,22 @@ impl SessionError for EthStreamError {
144159
P2PStreamError::MismatchedProtocolVersion { .. }
145160
)
146161
}
147-
Self::EthHandshakeError(err) => !matches!(err, EthHandshakeError::NoResponse),
162+
Self::EthHandshakeError(err) => {
163+
#[allow(clippy::match_same_arms)]
164+
match err {
165+
EthHandshakeError::NoResponse => {
166+
// this happens when the conn simply stalled
167+
false
168+
}
169+
EthHandshakeError::InvalidFork(_) => {
170+
// this can occur when the remote or our node is running an outdated client,
171+
// we shouldn't treat this as fatal, because the node can come back online
172+
// with an updated version any time
173+
false
174+
}
175+
_ => true,
176+
}
177+
}
148178
_ => false,
149179
}
150180
}
@@ -196,6 +226,11 @@ impl SessionError for EthStreamError {
196226
P2PStreamError::PingerError(_) |
197227
P2PStreamError::Snap(_),
198228
) => Some(BackoffKind::Medium),
229+
Self::EthHandshakeError(EthHandshakeError::InvalidFork(_)) => {
230+
// the remote can come back online after updating client version, so we can back off
231+
// for a bit
232+
Some(BackoffKind::Medium)
233+
}
199234
_ => None,
200235
}
201236
}

0 commit comments

Comments
 (0)