-
Notifications
You must be signed in to change notification settings - Fork 668
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
Split writeCurrentStakers
into multiple functions
#3500
base: implement-acp-77-add-subnetid-nodeid
Are you sure you want to change the base?
Split writeCurrentStakers
into multiple functions
#3500
Conversation
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.
There are no testing changes because this is a pure refactor.
@@ -273,6 +274,34 @@ type diffValidator struct { | |||
deletedDelegators map[ids.ID]*Staker | |||
} | |||
|
|||
func (d *diffValidator) WeightDiff() (ValidatorWeightDiff, error) { |
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 was previously implemented in writeCurrentStakersSubnetDiff
.
// | ||
// Note: This function may return a nil public key and no error if the primary | ||
// network validator does not have a public key. | ||
func (s *state) getInheritedPublicKey(nodeID ids.NodeID) (*bls.PublicKey, error) { |
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 logic previously existed as part of writeCurrentStakersSubnetDiff
.
s.updateValidatorManager(updateValidators), | ||
s.writeValidatorDiffs(height), | ||
s.writeCurrentStakers(codecVersion), |
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.
While splitting these out is technically less efficient (and contains similar code). The functions were just getting too complex to understand. This is explicitly trading off some (imo insignificant) level of performance for clarity.
Why this should be merged
writeCurrentStakers
is extremely complex as it is doing 3 things:As we implement ACP-77:
and
become more complex, as it is possible that the same
subnetID + nodeID
pair are removed from the pre-ACP-77 validator sets and added to the post-ACP-77 validator sets.To avoid
writeCurrentStakers
from including ACP-77 validators as well (making one of the most complex functions even more complex), this PR moves the functionality into separate functions.How this works
Moves code around and implements helper functions where possible.
How this was tested
Existing tests.
Need to be documented in RELEASES.md?
There are no user facing changes.