-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(consensus)!: use temporary status updates for blocks > locked blo…
…ck (#706) Description --- - Creates state updates per block per transaction as blocks are processed to allow for forks. - Changes sync protocol to send many smaller messages due to substate data for full blocks exceeding 4Mb limit in RPC, preventing sync - Only lock substate objects when a block has been justified (i.e. is a new leaf block) Motivation and Context --- Up to two justified blocks can be forked out. Since we process blocks as they come in to determine what commands to propose in the next block, which require state changes, a fork can result in invalid new proposals. Forks occur in non-malicious cases (stress test) due to high message volumes which can prevent a node both from sending and receiving proposal messages before leader timeout, though this is notably improved after #681 and #693. After leader failure, new proposals with dummy block parents supersede previously processed blocks. This PR tracks state changes above the locked block and uses the correct transaction phases/stages from the locked block and current leaf for new proposals. Stress testing (up to 1000 transactions in a batch) largely went better and the chain always continued. Some issues were encountered when a node fell behind during stress tests and switched to sync. Some nodes were left with already finalised transactions in their pool (TBD BUG) and would re-propose them when it was their turn to be leader. The block would not be voted on and leader failure would result in the chain continuing. Fixing this bug will be a focus for subsequent PRs. How Has This Been Tested? --- Existing consensus tests, manually with 8 VNs and stress testing, existing cucumbers What process can a PR reviewer use to test or verify this change? --- Run a multi-node network Breaking Changes --- - [ ] None - [x] Requires data directory to be deleted - [ ] Other - Please specify
- Loading branch information
Showing
61 changed files
with
2,015 additions
and
663 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2023 The Tari Project | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
use tari_consensus::hotstuff::{ConsensusCurrentState, HotstuffEvent}; | ||
use tokio::sync::{broadcast, watch}; | ||
|
||
use crate::event_subscription::EventSubscription; | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct ConsensusHandle { | ||
rx_current_state: watch::Receiver<ConsensusCurrentState>, | ||
events_subscription: EventSubscription<HotstuffEvent>, | ||
} | ||
|
||
impl ConsensusHandle { | ||
pub(super) fn new( | ||
rx_current_state: watch::Receiver<ConsensusCurrentState>, | ||
events_subscription: EventSubscription<HotstuffEvent>, | ||
) -> Self { | ||
Self { | ||
rx_current_state, | ||
events_subscription, | ||
} | ||
} | ||
|
||
pub fn subscribe_to_hotstuff_events(&mut self) -> broadcast::Receiver<HotstuffEvent> { | ||
self.events_subscription.subscribe() | ||
} | ||
|
||
pub fn get_current_state(&self) -> ConsensusCurrentState { | ||
*self.rx_current_state.borrow() | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.