-
Notifications
You must be signed in to change notification settings - Fork 30
feat(code/engine): Store proposed values in WAL #896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 34 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
4da7504
feat(code/engine): Store locally proposed value in WAL and re-use it …
romac 4065d06
Cleanup
romac 6b70046
Merge all three WalAppend effects into one
romac b041f19
Cleanup
romac bf848d0
Merge branch 'main' into romac/wal-proposed-value
romac 9dc0042
Add multi-round test with timeouts
romac 4f201b2
Cleanup
romac 580a450
Add a middleware to the test context to override vote building
romac d0eb574
Less noisy logs in test app
romac 8e6dd5c
Merge remote-tracking branch 'origin/main' into romac/wal-proposed-value
romac 23ab356
Add concept of middleware to change from the tests how votes and prop…
romac fb33d28
Merge remote-tracking branch 'origin/main' into romac/wal-proposed-value
romac 1fe7b38
Deduplicate timeout elapsed code
romac a9f73f0
Replay proposed values before other entries
romac 091c277
Split `StartHeight` into `PrepareHeight` and `StartHeight`
romac cf49f0e
Add check that we are in the right state before starting a height
romac fd34681
Actually replay the proposed values
romac 2649113
Cleanup
romac f2462b0
Store proposed values for other rounds
romac 254b9c5
Better naming
romac e0ccb97
Replay locally proposed value as an `ProposedValue` input instead of …
romac 434cc37
Fix unused variable warning
romac 0267c25
Merge branch 'main' into romac/wal-proposed-value
romac b142a49
Replay proposals
romac 8416236
On GetValue output from the driver, re-use any full proposal proposed…
romac 62019c9
Remove outdated check in Starknet tests
romac 81d7709
Merge branch 'main' into romac/wal-proposed-value
romac 9965158
Cleanup
romac 2fce398
Merge branch 'main' into romac/wal-proposed-value
romac 1debb22
Simplify WAL replay
romac 7e1fda6
Re-enable checks in byzantine WAL tests
romac ed8554b
Cleanup
romac eb9c5dc
Cleanup protos
romac d426a5f
Replay ProposedValue exactly as stored in the WAL
ancazamfir cb696f6
Log proposed values to WAL only if not already seen and therefore
ancazamfir 1868db0
Fix issue with last commit, store proposed values before getting the
ancazamfir 66e7ca5
Fix comments
romac 25c37a6
Ensure all timeouts can be decoded
romac 130008a
Re-add check that was previously removed when we were replaying WAL b…
romac 8f9679f
Merge `WalReplay` events into one
romac f3e06a9
Review comments
ancazamfir f92b07f
Apply suggestions from code review
ancazamfir adecaf7
Apply suggestions from code review
ancazamfir 9d7ce77
Add comments to handler functions
ancazamfir 6035541
Add comments to on_propose handler
ancazamfir a960ae4
Add encode and decode functions for all wal entries
ancazamfir 31a926f
Merge branch 'main' into romac/wal-proposed-value
romac f631c01
Apply suggestion from code review
romac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,61 @@ | ||
use crate::prelude::*; | ||
|
||
use crate::handle::driver::apply_driver_input; | ||
use crate::types::{LocallyProposedValue, ProposedValue}; | ||
use crate::types::{LocallyProposedValue, ProposedValue, WalEntry}; | ||
|
||
pub async fn on_propose<Ctx>( | ||
ancazamfir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
co: &Co<Ctx>, | ||
state: &mut State<Ctx>, | ||
metrics: &Metrics, | ||
value: LocallyProposedValue<Ctx>, | ||
local_value: LocallyProposedValue<Ctx>, | ||
) -> Result<(), Error<Ctx>> | ||
where | ||
Ctx: Context, | ||
{ | ||
let LocallyProposedValue { | ||
height, | ||
round, | ||
value, | ||
} = value; | ||
|
||
if state.driver.height() != height { | ||
if state.driver.height() != local_value.height { | ||
warn!( | ||
"Ignoring proposal for height {height}, current height: {}", | ||
"Ignoring proposal for height {}, current height: {}", | ||
ancazamfir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
local_value.height, | ||
state.driver.height() | ||
); | ||
|
||
return Ok(()); | ||
} | ||
|
||
if state.driver.round() != round { | ||
if state.driver.round() != local_value.round { | ||
warn!( | ||
"Ignoring propose value for round {round}, current round: {}", | ||
"Ignoring proposal for round {}, current round: {}", | ||
ancazamfir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
local_value.round, | ||
state.driver.round() | ||
); | ||
|
||
return Ok(()); | ||
} | ||
|
||
#[cfg(feature = "metrics")] | ||
metrics.consensus_start(); | ||
|
||
state.store_value(&ProposedValue { | ||
height, | ||
round, | ||
let proposed_value = ProposedValue { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this comment answer your question? |
||
height: local_value.height, | ||
round: local_value.round, | ||
valid_round: Round::Nil, | ||
proposer: state.address().clone(), | ||
value: value.clone(), | ||
value: local_value.value.clone(), | ||
validity: Validity::Valid, | ||
}); | ||
}; | ||
|
||
state.store_value(&proposed_value); | ||
|
||
#[cfg(feature = "metrics")] | ||
metrics.consensus_start(); | ||
|
||
apply_driver_input(co, state, metrics, DriverInput::ProposeValue(round, value)).await | ||
perform!( | ||
co, | ||
Effect::WalAppend(WalEntry::ProposedValue(proposed_value), Default::default()) | ||
); | ||
|
||
apply_driver_input( | ||
co, | ||
state, | ||
metrics, | ||
DriverInput::ProposeValue(local_value.round, local_value.value), | ||
ancazamfir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
.await | ||
} |
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.