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

[PVM] Adjustment of validator uptime on reactivation #189

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

charalarg
Copy link

@charalarg charalarg commented Feb 23, 2023

Description

This PR adjusts the uptime of a suspended validator at its reactivation time because by default when its moved back to the current set, its uptime starts from 0 but the uptime percentage is calculated from its initial start time ending up in an invalid value.

Important note: This invalid value is only stored on a mapping in state and not on disc. And this happens because when we reactivate the validator, the LoadUptime is being called which is not altering anything on disc. So, if we boot up a brand new node and request the uptime of the reactivated validator it will be calculated from its initial value.

With this PR we are updating the uptime of the reactivated validator both on the mapping and in db's state, thus they will be in sync.

Changes

  • Added the setValidatorUptime call on validator reactivation
  • implemented the setValidatorUptime function in state
  • In order to call state's original setUptimefunction we needed to make a cross reference between state and caminoState.

Remarks

This implementation is just a POC proving that the uptime update works.
Further discussions, thoughts and tests needed in order to conclude to this implementation

@charalarg charalarg changed the title [PVM] Adjustment of validator uptime on reactivation [PVM, STATE] Adjustment of validator uptime on reactivation Feb 23, 2023
@charalarg charalarg force-pushed the poc-update-uptime branch 2 times, most recently from 7a36def to 2072568 Compare February 23, 2023 09:54
@charalarg charalarg changed the title [PVM, STATE] Adjustment of validator uptime on reactivation TECH-72: Adjustment of validator uptime on reactivation Feb 23, 2023
@charalarg charalarg changed the title TECH-72: Adjustment of validator uptime on reactivation TECH-727: Adjustment of validator uptime on reactivation Feb 23, 2023
@charalarg charalarg changed the title TECH-727: Adjustment of validator uptime on reactivation TECH-724: Adjustment of validator uptime on reactivation Feb 23, 2023
@charalarg charalarg marked this pull request as ready for review February 24, 2023 09:42
vms/platformvm/state/camino_diff.go Outdated Show resolved Hide resolved
vms/platformvm/state/state.go Show resolved Hide resolved
vms/platformvm/state/camino_stakers.go Show resolved Hide resolved
vms/platformvm/state/camino.go Outdated Show resolved Hide resolved
Copy link

@c4t-ag c4t-ag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be much easier regarding implementation if we wrap the *Staker around a struct which has a member "suspendedUptime"? Something like:

struct {
  Staker
  suspendUptime
}

@charalarg charalarg changed the title TECH-724: Adjustment of validator uptime on reactivation [PVM] Adjustment of validator uptime on reactivation Apr 6, 2023
@charalarg charalarg force-pushed the poc-update-uptime branch 2 times, most recently from 974e562 to 058d579 Compare May 31, 2023 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants