Feat/adaptive consensus timeouts#406
Merged
Xhristin3 merged 2 commits intorinafcode:mainfrom Apr 28, 2026
Merged
Conversation
- Add NetworkHealth enum and NetworkCondition struct to types.rs - Add NETWORK_STATE storage key - Implement get_network_condition, update_network_condition, adaptive_timeout in BFTConsensus (Healthy=1x, Degraded=2x, Critical=3x base timeout) - create_proposal uses adaptive_timeout instead of hard-coded constant - vote_on_proposal increments miss counter on expiry (graceful degradation) - execute_proposal resets miss counter on successful consensus (self-healing) - Expose update_network_condition and get_network_condition via contract API - Add 4 tests covering all health states and miss counter lifecycle
|
@Chrisland58 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
feat: Adaptive Consensus Timeouts with Network Condition Monitoring
Problem
BFT consensus proposals used a hard-coded 24h timeout. During network degradation, validators
couldn't reach quorum in time, causing proposals to expire and consensus to fail with no
recovery mechanism.
Solution
Introduce a dynamic timeout system driven by observed network conditions:
Monitor — NetworkCondition tracks avg_latency_ms, consecutive_misses, and a derived
NetworkHealth (Healthy / Degraded / Critical)
Dynamic timeouts — create_proposal calls adaptive_timeout() which scales the base 24h timeout
by health:
Graceful degradation — vote_on_proposal auto-increments the miss counter when a proposal
expires; execute_proposal resets it to 0 on success, so the system self-heals as network
conditions improve
Observability — update_network_condition and get_network_condition are exposed as contract
entry points for external oracles/admins to feed in latency data
Changes
closes Fix potential consensus timeout in network degradation #250