Connectivity Report spam mitigations#314
Conversation
SurfingNerd
commented
Nov 23, 2025
- Reduce Intervals for connectivity checks #313
- connectivity reports should not trigger if there is no block production #243
…idator Engine Actions. DMDcoin#313
connectivity reports should not trigger if there is no block production
There was a problem hiding this comment.
Pull request overview
This PR implements spam mitigations for connectivity reports in the HBBFT (Honey Badger BFT) consensus engine. The changes address issues #313 and #243 by introducing timing controls and cache optimizations to prevent unnecessary connectivity report spam.
- Adds block-based cache tracking to avoid redundant engine cache updates
- Separates early epoch end actions onto a dedicated timer (300s interval) to control connectivity report frequency
- Implements timestamp-based validation to prevent connectivity reports when block production is stalled
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 13 comments.
| File | Description |
|---|---|
crates/ethcore/src/engines/hbbft/hbbft_engine_cache.rs |
Adds block_last_update tracking to prevent duplicate cache refreshes and changes method signatures to static for better concurrency |
crates/ethcore/src/engines/hbbft/hbbft_engine.rs |
Introduces HBBFT_CONNECTIVITY_TOKEN timer and refactors validator engine actions into separate methods for regular actions vs. early epoch end connectivity checks |
crates/ethcore/src/engines/hbbft/hbbft_early_epoch_end_manager.rs |
Adds time-based validation to skip connectivity reports when block production has stalled (comparing block timestamp against current time) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // todo: | ||
| // this is max blocktime (hartbeat) x 2. | ||
| // on phoenix protocol triggers, this would also skip the block production. | ||
| if elapsed_since_last_block > 10 { |
There was a problem hiding this comment.
The threshold value of 10 seconds seems quite small and may be too restrictive. The comment mentions "max blocktime (hartbeat) x 2" which should be 300 seconds (based on HBBFT_CONNECTIVITY_TOKEN timer) * 2 = 600 seconds. Using 10 seconds could cause legitimate early epoch end reports to be skipped when there's a slight delay in block production. Consider using a more appropriate threshold value that aligns with the comment or clarifying the intention.
| if now >= block_time { | ||
| let elapsed_since_last_block = now - block_time; | ||
| // todo: | ||
| // this is max blocktime (hartbeat) x 2. |
There was a problem hiding this comment.
Typo in comment: "hartbeat" should be "heartbeat"
| // this is max blocktime (hartbeat) x 2. | |
| // this is max blocktime (heartbeat) x 2. |
| // this is max blocktime (hartbeat) x 2. | ||
| // on phoenix protocol triggers, this would also skip the block production. | ||
| if elapsed_since_last_block > 10 { | ||
| info!(target:"engine", "skipping early-epoch-end: now {now} ; block_time {block_time}: Block WAS created in the future ?!?! :-x. not sending early epoch end reports."); |
There was a problem hiding this comment.
Grammar issue: "Block WAS created" should use "was" in lowercase for consistent sentence capitalization.
| // or the blockchain really produces blocks from the future. | ||
| // we are just not sending reports in this case. | ||
|
|
||
| error!(target:"engine", "early-epoch-end: now {now} ; block_time {block_time}: Block WAS created in the future ?!?! :-x. not sending early epoch end reports."); |
There was a problem hiding this comment.
Grammar issue: "Block WAS created" should use "was" in lowercase for consistent sentence capitalization.
| /// decides on the memorium data if we should update to contract data. | ||
| /// end executes them. | ||
| /// decides on the memorium data if we should update to contract data, | ||
| /// end sends out transactions to do so. |
There was a problem hiding this comment.
Typo in comment: "end sends" should be "and sends"
| /// end sends out transactions to do so. | |
| /// and sends out transactions to do so. |
| /// hbbft early epoch end actions are executed on a different timing than the regular validator engine steps | ||
| fn do_validator_engine_early_epoch_end_actions(&self) -> Result<(), Error> { | ||
| // here we need to differentiate the different engine functions, | ||
| // that requre different levels of access to the client. |
There was a problem hiding this comment.
Typo in comment: "requre" should be "require"
| // that requre different levels of access to the client. | |
| // that require different levels of access to the client. |
| // if we do not have to do anything, we can return early. | ||
| if !(should_connect_to_validator_set || should_handle_early_epoch_end) { | ||
| return Ok(()); | ||
| if validator_set.len() > 0 { |
There was a problem hiding this comment.
The comparison if validator_set.len() > 0 is not idiomatic Rust. Consider using !validator_set.is_empty() instead, which is the preferred way to check if a collection is non-empty.
| if validator_set.len() > 0 { | |
| if !validator_set.is_empty() { |
| self.hbbft_engine_cache.lock().is_staked() | ||
| } | ||
|
|
||
| /** returns if the signer of hbbft is a current validator. */ |
There was a problem hiding this comment.
The documentation comment uses /** */ syntax instead of the more idiomatic Rust /// syntax for doc comments. Consider using /// returns if the signer of hbbft is a current validator. instead.
| /** returns if the signer of hbbft is a current validator. */ | |
| /// returns if the signer of hbbft is a current validator. |
| |e| warn!(target: "consensus", "ENGINE_PHOENIX_CHECK Timer failed: {}.", e), | ||
| ); | ||
|
|
||
| // ealry epoch end connecitity token should be the same lenght then the max blocktime. |
There was a problem hiding this comment.
Typo in comment: "lenght" should be "length"
| // ealry epoch end connecitity token should be the same lenght then the max blocktime. | |
| // ealry epoch end connecitity token should be the same length then the max blocktime. |
| // end of implementation for: | ||
| // https://github.com/DMDcoin/diamond-node/issues/243 | ||
|
|
||
| let treshold: u64 = 2; |
There was a problem hiding this comment.
Typo in comment: "treshold" should be "threshold"