Skip to content
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

Small fixes pre-audit #565

Merged
merged 15 commits into from
Sep 20, 2024
Merged

Small fixes pre-audit #565

merged 15 commits into from
Sep 20, 2024

Conversation

geoff-vball
Copy link
Contributor

@geoff-vball geoff-vball commented Sep 19, 2024

Why this should be merged

Fixes a bug where the map for nodeID -> ValidationID was only populated once a validation period was active, and deleted when the validation period was Completed or Invalidated.
Someone could have registered two validation periods with the same NodeID, if one came back as active first, and then the second came back as invalid, this would delete the nodeID -> ValidationID entry in the map.
I chose to add the NodeID to the map when the validator is registered, that way any NodeID can only ever be registered once at a time.

Separates some requires cases, and eliminates some checks that are not possible to hit.

Renames PoSValidatorRequirements to PoSValidatorInfo since owner is not a requirement. We can also put the cached uptime into this struct in a future PR.

For delegations, adds checks that the unpacked validation ID matches the delegator's validation ID.

Fixes the case where a Validator exits while a Delegator is PendingAdded. The Delegator's start time would be greater than it's end time, causing an underflow in the reward calculation, causing a revert in the completion step.

Adds a new external method endDelegationCompletedValidator to account for the case where a validator has fully exited and the Delegator will not be able to get a SubnetValidatorWeightUpdateMessage signed by the p-chain because the validator's state will have been removed.

How this works

How this was tested

How is this documented

@geoff-vball geoff-vball changed the base branch from main to staking-contract September 19, 2024 19:30
@geoff-vball geoff-vball merged commit 09e69d7 into staking-contract Sep 20, 2024
12 checks passed
@cam-schultz cam-schultz deleted the gstuart/fixups branch September 20, 2024 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants