mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-20 06:55:42 +00:00
Better error for spurious cache misses. (#4669)
Happened on Kusama for some not yet known reason.
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
//! Error handling related code and Error/Result definitions.
|
//! Error handling related code and Error/Result definitions.
|
||||||
|
|
||||||
use polkadot_node_network_protocol::request_response::outgoing::RequestError;
|
use polkadot_node_network_protocol::request_response::outgoing::RequestError;
|
||||||
|
use polkadot_primitives::v1::SessionIndex;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use futures::channel::oneshot;
|
use futures::channel::oneshot;
|
||||||
@@ -76,8 +77,8 @@ pub enum NonFatal {
|
|||||||
QueryAvailableDataResponseChannel(#[source] oneshot::Canceled),
|
QueryAvailableDataResponseChannel(#[source] oneshot::Canceled),
|
||||||
|
|
||||||
/// We tried accessing a session that was not cached.
|
/// We tried accessing a session that was not cached.
|
||||||
#[error("Session is not cached.")]
|
#[error("Session {missing_session} is not cached, cached sessions: {available_sessions:?}.")]
|
||||||
NoSuchCachedSession,
|
NoSuchCachedSession { available_sessions: Vec<SessionIndex>, missing_session: SessionIndex },
|
||||||
|
|
||||||
/// Sending request response failed (Can happen on timeouts for example).
|
/// Sending request response failed (Can happen on timeouts for example).
|
||||||
#[error("Sending a request's response failed.")]
|
#[error("Sending a request's response failed.")]
|
||||||
@@ -120,7 +121,7 @@ pub fn log_error(result: Result<()>, ctx: &'static str) -> std::result::Result<(
|
|||||||
match error {
|
match error {
|
||||||
NonFatal::UnexpectedPoV |
|
NonFatal::UnexpectedPoV |
|
||||||
NonFatal::InvalidValidatorIndex |
|
NonFatal::InvalidValidatorIndex |
|
||||||
NonFatal::NoSuchCachedSession |
|
NonFatal::NoSuchCachedSession { .. } |
|
||||||
NonFatal::QueryAvailableDataResponseChannel(_) |
|
NonFatal::QueryAvailableDataResponseChannel(_) |
|
||||||
NonFatal::QueryChunkResponseChannel(_) =>
|
NonFatal::QueryChunkResponseChannel(_) =>
|
||||||
tracing::warn!(target: LOG_TARGET, error = %error, ctx),
|
tracing::warn!(target: LOG_TARGET, error = %error, ctx),
|
||||||
|
|||||||
@@ -144,10 +144,13 @@ impl SessionCache {
|
|||||||
/// We assume validators in a group are tried in reverse order, so the reported bad validators
|
/// We assume validators in a group are tried in reverse order, so the reported bad validators
|
||||||
/// will be put at the beginning of the group.
|
/// will be put at the beginning of the group.
|
||||||
pub fn report_bad(&mut self, report: BadValidators) -> crate::Result<()> {
|
pub fn report_bad(&mut self, report: BadValidators) -> crate::Result<()> {
|
||||||
let session = self
|
let available_sessions = self.session_info_cache.iter().map(|(k, _)| *k).collect();
|
||||||
.session_info_cache
|
let session = self.session_info_cache.get_mut(&report.session_index).ok_or(
|
||||||
.get_mut(&report.session_index)
|
NonFatal::NoSuchCachedSession {
|
||||||
.ok_or(NonFatal::NoSuchCachedSession)?;
|
available_sessions,
|
||||||
|
missing_session: report.session_index,
|
||||||
|
},
|
||||||
|
)?;
|
||||||
let group = session.validator_groups.get_mut(report.group_index.0 as usize).expect(
|
let group = session.validator_groups.get_mut(report.group_index.0 as usize).expect(
|
||||||
"A bad validator report must contain a valid group for the reported session. qed.",
|
"A bad validator report must contain a valid group for the reported session. qed.",
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user