-
Notifications
You must be signed in to change notification settings - Fork 11k
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
[Consensus 2.0] Small refactoring in scores for CommittedSubDag #17768
[Consensus 2.0] Small refactoring in scores for CommittedSubDag #17768
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
3 Ignored Deployments
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know mutating CommittedSubDag just to set reputation scores is a bit weird. But sending reputation scores to linearizer just to construct CommittedSubDag does not seem the most ideal either. Have we settled on always sending a copy of reputation score with CommittedSubDag, or do we still want to only send a version of scores once? The setter way seems easier to only set the scores once.
My preference is always to have as less mutation as possible as we seemed to touch the sub dag a couple of times after its construction and lots of things can go wrong there - I’ve realised that when I tried to refactor that code. Even if we decide to set the scores only once it’s still fine. Alternatively we can inject the leader schedule in the linearizer. |
I like the safety provided by not mutating the subdag but I would still vote for keeping the setter method especially because I left a todo so that we only set the scores on leader schedule change. If we do set the scores only on each new version then passing the leader schedule in to the linearizer also would not work as we would have to do it at the commit observer level (that is how I saw it playing out originally atleast) |
Yeah I thought that we can pass this info to the linearizer and set it it self only once when the scores change. Ok , shall I attempt to do that and if you guys still don’t like it we can pass on it? |
Oh I also realised that I somehow nuked your TODO @arun-koshy and never put it back - although I did have it on my mind. Apologies for that! |
fac6cf4
to
ce92ac3
Compare
I think the main issue we have here and in the other PR (commit digest) is this mismatch: for output, we are using |
Yep that's the issue. I've ended up to similar conclusions and refactored how we construct the Commit & the committed subdag to be more coherent (see #17765). Hopefully this would make more sense now. For this PR I've ended up moving things mostly to the linearizer. Please have another look @mwtian @arun-koshy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works for me 👍🏽
f516e8d
to
0c4f61f
Compare
4867ca9
to
d5e2df7
Compare
@mwtian any comments before I get this merged? |
consensus/core/src/dag_state.rs
Outdated
vec![], | ||
); // We don't mind recovering the reputation scores |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vec![], | |
); // We don't mind recovering the reputation scores | |
// We don't need to recover reputation scores for unscored_committed_subdags | |
vec![], | |
); |
/// Checks whether the dag state unscored sub dags list is empty. If yes then that means that | ||
/// either (1) the system has just started and there is no unscored sub dag available (2) the | ||
/// schedule has updated - new scores have been calculated. Both cases we consider as valid cases | ||
/// where the schedule has been updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure (1) is a valid reason. DagState has to fully recover unscored commits before leader schedule can start to make decisions. Otherwise there can be a fork. Or are you seeing something else when starting consensus?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but if it's a fresh system then there are not sub dags to recover.
/// either (1) the system has just started and there is no unscored sub dag available (2) the | ||
/// schedule has updated - new scores have been calculated. Both cases we consider as valid cases | ||
/// where the schedule has been updated. | ||
pub(crate) fn leader_schedule_updated(&self, dag_state: Arc<RwLock<DagState>>) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub(crate) fn leader_schedule_updated(&self, dag_state: Arc<RwLock<DagState>>) -> bool { | |
pub(crate) fn leader_schedule_updated(&self, dag_state: &RwLock<DagState>) -> bool { |
consensus/core/src/linearizer.rs
Outdated
// part of the first sub dag. | ||
let schedule_updated = self | ||
.leader_schedule | ||
.leader_schedule_updated(self.dag_state.clone()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.leader_schedule_updated(self.dag_state.clone()); | |
.leader_schedule_updated(&self.dag_state); |
Description
Initialise the consensus scores in committed sub dag during construction. Also always pre-sort the blocks , that should be the default anyways either during commit or recover.
Test plan
CI
Release notes
Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.
For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.