Skip to content

Commit

Permalink
No longer ban peers for BEEFY justifications (#1614)
Browse files Browse the repository at this point in the history
* No longer ban peers for BEEFY justifications

* PR link
  • Loading branch information
tomaka authored Jan 26, 2024
1 parent d9d3ef7 commit 422cf08
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 25 deletions.
24 changes: 16 additions & 8 deletions full-node/src/consensus_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2950,14 +2950,22 @@ impl SyncBackground {
(self, true)
}
(sync_out, all::FinalityProofVerifyOutcome::JustificationError(error)) => {
self.network_service
.ban_and_disconnect(
sender.clone(),
self.network_chain_id,
network_service::BanSeverity::High,
"bad-warp-sync-fragment",
)
.await;
// Errors of type `JustificationEngineMismatch` indicate that the chain
// uses a finality engine that smoldot doesn't recognize. This is a benign
// error that shouldn't lead to a ban.
if !matches!(
error,
all::JustificationVerifyError::JustificationEngineMismatch
) {
self.network_service
.ban_and_disconnect(
sender.clone(),
self.network_chain_id,
network_service::BanSeverity::High,
"bad-warp-sync-fragment",
)
.await;
}
self.log_callback.log(
LogLevel::Warn,
format!(
Expand Down
5 changes: 3 additions & 2 deletions lib/src/sync/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ use core::{
};

pub use crate::executor::vm::ExecHint;
pub use blocks_tree::{CommitVerifyError, JustificationVerifyError};
pub use warp_sync::{
BuildChainInformationError as WarpSyncBuildChainInformationError,
BuildRuntimeError as WarpSyncBuildRuntimeError, ConfigCodeTrieNodeHint, VerifyFragmentError,
Expand Down Expand Up @@ -2046,9 +2047,9 @@ pub enum FinalityProofVerifyOutcome<TBl> {
/// GrandPa commit cannot be verified yet and has been stored for later.
GrandpaCommitPending,
/// Problem while verifying justification.
JustificationError(blocks_tree::JustificationVerifyError),
JustificationError(JustificationVerifyError),
/// Problem while verifying GrandPa commit.
GrandpaCommitError(blocks_tree::CommitVerifyError),
GrandpaCommitError(CommitVerifyError),
}

pub struct WarpSyncFragmentVerify<TRq, TSrc, TBl> {
Expand Down
36 changes: 21 additions & 15 deletions light-base/src/sync_service/standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1364,22 +1364,28 @@ impl<TPlat: PlatformRef> Task<TPlat> {
sender,
);

// TODO: don't print for consensusenginemismatch?
log!(
&self.platform,
Warn,
&self.log_target,
format!("Error while verifying justification: {error}")
);
// Errors of type `JustificationEngineMismatch` indicate that the chain
// uses a finality engine that smoldot doesn't recognize. This is a benign
// error that shouldn't lead to a ban.
if !matches!(
error,
all::JustificationVerifyError::JustificationEngineMismatch
) {
log!(
&self.platform,
Warn,
&self.log_target,
format!("Error while verifying justification: {error}")
);

// TODO: don't ban for consensusenginemismatch?
self.network_service
.ban_and_disconnect(
sender,
network_service::BanSeverity::High,
"bad-justification",
)
.await;
self.network_service
.ban_and_disconnect(
sender,
network_service::BanSeverity::High,
"bad-justification",
)
.await;
}
}

(sync, all::FinalityProofVerifyOutcome::GrandpaCommitError(error)) => {
Expand Down
4 changes: 4 additions & 0 deletions wasm-node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Fixed

- Non-Grandpa justifications are now silently ignored, instead of leading to a ban of the peer that sent the justification. This makes smoldot work better on chains that use BEEFY. ([#1614](https://github.com/smol-dot/smoldot/pull/1614))

## 2.0.18 - 2024-01-24

### Changed
Expand Down

0 comments on commit 422cf08

Please sign in to comment.