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

Drop Pending Stakers 3 - persist stakers' StartTime #2306

Merged
merged 132 commits into from
Dec 14, 2023

Conversation

abi87
Copy link
Contributor

@abi87 abi87 commented Nov 14, 2023

Why this should be merged

Staking will start at a time different from the tx.StartTime specified in each AddStakerTx. Hence we need to explicitly store the start time of each staker to be able to duly rebuild it once we start a node and load data from disk

How this works

Slicing #2175 up

How this was tested

CI

@abi87 abi87 self-assigned this Nov 14, 2023
@abi87 abi87 changed the title Persist stakers' StartTIme Persist stakers' StartTime Nov 15, 2023
@abi87 abi87 changed the title Persist stakers' StartTime Drop Pending Stakers - persist stakers' StartTime Nov 15, 2023
@abi87 abi87 changed the title Drop Pending Stakers - persist stakers' StartTime Drop Pending Stakers - persisted stakers' StartTime Nov 15, 2023
@abi87 abi87 changed the title Drop Pending Stakers - persisted stakers' StartTime Drop Pending Stakers 2 - persisted stakers' StartTime Nov 15, 2023
}

func writeDelegatorMetadata(db database.KeyValueWriter, metadata *delegatorMetadata) error {
return database.PutUInt64(db, metadata.txID[:], metadata.PotentialReward)
metadataBytes, err := metadataCodec.Marshal(v1, metadata)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we store start time as soon as we deploy code, without waiting for fork activation

Copy link
Contributor

Choose a reason for hiding this comment

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

Can people downgrade after updating to a version with this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The versioning should allow smooth handling of upgrades/downgrades
When reading from disk:

  1. If metadata have version zero, start time won't be loaded from disk and the default value AddStakerTx.StartTime() will be used.
  2. If metadata have version 1, start time will be read from disk.

This is why we don't need a data migration here, which may cause problems with downgrades.
The downside is that it'd be writing the StartTime to disk as soon as the code is deployed, even if Durango is not active. This is an extra int64 written for each staker promoted from pending to current among code deploy and code activation.

Copy link
Contributor

Choose a reason for hiding this comment

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

What happens when I upgrade my node to this PR and write codec version v1 and then downgrade to a node that does not support parsing codec version v1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dhrubabasu right! I fixed it by reintroducing the config.Confg and by selecting codec version based on the fork activation. Code will be cleaned up as soon as fork is activated

@abi87 abi87 marked this pull request as ready for review November 15, 2023 13:35
@abi87 abi87 force-pushed the post_durango_staker_txs branch 2 times, most recently from 0deb60a to 8e8ab33 Compare November 15, 2023 15:14
@dhrubabasu dhrubabasu self-assigned this Dec 12, 2023
@StephenButtolph StephenButtolph added this to the v1.10.18 milestone Dec 13, 2023
@StephenButtolph StephenButtolph added this pull request to the merge queue Dec 14, 2023
@StephenButtolph StephenButtolph changed the title Drop Pending Stakers 3 - persisted stakers' StartTime Drop Pending Stakers 3 - persist stakers' StartTime Dec 14, 2023
Merged via the queue into dev with commit abf4fbc Dec 14, 2023
17 checks passed
@StephenButtolph StephenButtolph deleted the post_durango_startTime_storing branch December 14, 2023 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Durango durango fork
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Drop Pending Stakers
3 participants