Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaced direct additions (*count += 1) with saturating_add(1) to prevent potential integer overflows.
Added explicit type casting to u64 for multiplication thresholds (cur_failed_proposals as u64 * 100) to guarantee safety against overflows when calculating reputation heuristics.
Improved logging severity for critical database or sync failures from warn! to error!, explicitly noting that "leader election may degrade".
2. Safe Error Handling Practices (Removing Panics/Unwraps)
Removed unsafe .unwrap() calls across multiple core modules (gravity_node, reth_coordinator).
Replaced them with safe fallback handling such as .expect() with descriptive messages (e.g., "Failed to read block hash from DB") or properly structured .unwrap_or_else(|| panic!(...)) to ensure the exact missing block/layer causing the crash is fully verbosed.
Handled previously ignored Result objects properly. For instance, in consensus_mempool_handler.rs, an ignored let _ = ... result was replaced with an if let Err(e) check to output a warning log if the notification response fails.
3. State Transition Ordering Fixes
In block-buffer-manager.rs, the execution order was slightly adjusted during an epoch change. The BufferState is now explicitly stored as EpochChange before the internal state machine prunes (retain) older blocks, avoiding a potentially unsafe intermediate state.
4. General Cleanup
Removed leftover debugging println! macros (e.g., in config_storage.rs).