-
Notifications
You must be signed in to change notification settings - Fork 682
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
Pull apart writeCurrentStakers method - Part 1 #2074
Conversation
vms/platformvm/state/state.go
Outdated
weightDiffs, blsKeyDiffs, err := s.processCurrentStakers() | ||
if err != nil { | ||
return err | ||
} |
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 is the part where stakers-related content is scanned to extract specific information to be stored in different parts of the pchain state
vms/platformvm/state/state.go
Outdated
s.writeWeightDiffs(height, weightDiffs), | ||
s.writeBlsKeyDiffs(height, blsKeyDiffs), |
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.
these are some of methods where we only write the information collected in processCurrentStakers
e08c437
to
9b77852
Compare
vms/platformvm/state/state.go
Outdated
type subnetNodePair struct { | ||
subnetID ids.ID | ||
nodeID ids.NodeID | ||
} | ||
|
||
type results struct { | ||
weightDiffs map[subnetNodePair]*ValidatorWeightDiff | ||
blsKeyDiffs map[ids.NodeID]*bls.PublicKey | ||
} | ||
|
||
func (s *state) processCurrentStakers() (results, 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.
Can we improve the naming here? Maybe calculateDiffs
or something? processCurrentStakers
and results
is pretty generic... fwiw I'm not really sure results
is needed at all
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 change looks forward to next PRs and tries and mininize diffs.
- Process is indeed generic, but in next PR we'll pull out data to update validator set and to store stakers data in the very same method. Hence the generic name. Not sure I can do better
- results will be expanded too to include data to update validators set and stakers data to be store in the P-chain
I guess the three parts should be merge altogether. I split them in three in order to ease up diff
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.
+1 on rename, i would name this something like applyDiffs
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.
Out of popular request, I renamed processCurrentStakers
to calculateDiffs
and results
to `diffs.
We'll generalize naming as we review and merge next steps
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.
LGTM other than the one comment
Closing down since there is no agreement that this version is simpler to reason about |
Why this should be merged
writeCurrentStaker
is a bulky method in platformvm state package that process stakers diffs and store them.This PR begins to break
writeCurrentStaker
into smaller, easier to grok methods.Cleanup list:
How this works
writeCurrentStaker
is broken into two main parts:How this was tested
CI