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

Tune past epochs in storage #1944

Merged
merged 26 commits into from
Oct 24, 2023
Merged

Tune past epochs in storage #1944

merged 26 commits into from
Oct 24, 2023

Conversation

brentstone
Copy link
Collaborator

@brentstone brentstone commented Sep 26, 2023

Describe your changes

Closes #1798, closes #1857, closes #1903, closes #1783. All of these relate to changing how many past epochs are kept in storage for various PoS data. A refactor is needed to communicate the max_proposal_period governance parameter to the data.

Closes #1961. The validator's protocol keys are moved into PoS and now epoched as well.

Indicate on which release or other PRs this topic is based on

Based on #1943, which is based on v0.23.0

Checklist before merging to draft

  • I have added a changelog
  • Git history is in acceptable state

@brentstone brentstone force-pushed the brent/tune-storage-past-epochs branch from 1abd194 to bab044f Compare September 27, 2023 00:29
@brentstone brentstone marked this pull request as ready for review September 28, 2023 00:23
@brentstone brentstone force-pushed the brent/tune-storage-past-epochs branch from 256a0bb to 514c7b6 Compare September 28, 2023 00:26
@brentstone
Copy link
Collaborator Author

@tzemanovic @Fraccaman @sug0

The PR is ready for a look for anyone who wants to check it out. Here's a summary of the main storage changes:

  • consensus_validator_set kept for max_proposal_period + 2 epochs in the past (previously 2)
  • validator_deltas kept for max(max_proposal_period, slash_processing_delay) + 2 epochs in the past (previously 23)
  • validator_addresses kept for 2 epochs in the past (previously infinite)
  • validator_positions kept for 2 epochs in the past (previously infinite)

I've used a +2 epochs in the past for these things just to err on the side of safety. We can adjust if desired. The bonds are already kept for all epochs, so this and the validator_deltas should hopefully suffice for governance. At minimum, validator_deltas need to be kept for slash_processing_delay epochs, hence the max.

@brentstone brentstone force-pushed the brent/tune-storage-past-epochs branch from 514c7b6 to 432d143 Compare September 28, 2023 00:39
Copy link
Collaborator

@sug0 sug0 left a comment

Choose a reason for hiding this comment

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

left some nits & questions, mostly

core/src/ledger/storage_api/governance.rs Outdated Show resolved Hide resolved
proof_of_stake/src/epoched.rs Outdated Show resolved Hide resolved
proof_of_stake/src/epoched.rs Outdated Show resolved Hide resolved
proof_of_stake/src/epoched.rs Outdated Show resolved Hide resolved
proof_of_stake/src/epoched.rs Outdated Show resolved Hide resolved
@brentstone brentstone force-pushed the brent/tune-storage-past-epochs branch from d3048b3 to 311c192 Compare September 28, 2023 15:18
brentstone added a commit that referenced this pull request Sep 28, 2023
@brentstone brentstone force-pushed the brent/tune-storage-past-epochs branch from 311c192 to d1535ac Compare September 28, 2023 15:27
@brentstone
Copy link
Collaborator Author

pls update wasms

@brentstone
Copy link
Collaborator Author

brentstone commented Oct 2, 2023

@sug0 All the epoch-length changes to the PoS data are being made in this PR, as this is the relevant topic. The eth keys have been changed in 7c7ee02.

Also want to note that you are able to query the total consensus stake of any epoch in the past directly from storage without computation using the total_consensus_stake_key_handle (may change the name later to remove key though). Currently this is already kept for all past epochs.

@tzemanovic the enqueued slashes are now manually cleared in 85770be.

@brentstone brentstone force-pushed the brent/tune-storage-past-epochs branch 2 times, most recently from 7337c5c to 01b6815 Compare October 4, 2023 03:42
@brentstone brentstone requested review from sug0 and tzemanovic October 4, 2023 03:42
pub type ValidatorProtocolKeys = crate::epoched::Epoched<
common::PublicKey,
crate::epoched::OffsetPipelineLen,
crate::epoched::OffsetMaxProposalPeriodPlus,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the offset can be reduced in the future. I'm not sure what the appropriate value for this should be, though.

@brentstone brentstone mentioned this pull request Oct 13, 2023
brentstone added a commit that referenced this pull request Oct 16, 2023
* brent/tune-storage-past-epochs:
  move protocol keys into epoched PoS data
  keep `total_deltas` for same period of time as `validator_deltas`
  clear old enqueued slashes when processing slashes
  keep validator eth keys for max proposal period
  fixup! pos/types: configure number of past epochs kept for PoS data
  fixed `epoched` tests and `test_validator_sets`
  [ci] wasm checksums update
  changelog: add #1944
  PoS: refactor usages of `Epoch::checked_sub`
  core/types/storage:m ore flexible fn checked_sub param
  fixup! replace direct storage read of PosParams with an RPC fn
  replace direct storage read of PosParams with an RPC fn
  fix PoS crate standalone build
  fixup! Apply suggestions from code review
  Apply suggestions from code review
  docstring cleanup
  new impl for purging old validator sets
  pos/types: configure number of past epochs kept for PoS data
  add PosParams type with added gov param
  WIP want to pass `max_proposal_period` from gov params into PoS
brentstone added a commit that referenced this pull request Oct 16, 2023
* brent/tune-storage-past-epochs:
  move protocol keys into epoched PoS data
  keep `total_deltas` for same period of time as `validator_deltas`
  clear old enqueued slashes when processing slashes
  keep validator eth keys for max proposal period
  fixup! pos/types: configure number of past epochs kept for PoS data
  fixed `epoched` tests and `test_validator_sets`
  [ci] wasm checksums update
  changelog: add #1944
  PoS: refactor usages of `Epoch::checked_sub`
  core/types/storage:m ore flexible fn checked_sub param
  fixup! replace direct storage read of PosParams with an RPC fn
  replace direct storage read of PosParams with an RPC fn
  fix PoS crate standalone build
  fixup! Apply suggestions from code review
  Apply suggestions from code review
  docstring cleanup
  new impl for purging old validator sets
  pos/types: configure number of past epochs kept for PoS data
  add PosParams type with added gov param
  WIP want to pass `max_proposal_period` from gov params into PoS
brentstone added a commit that referenced this pull request Oct 16, 2023
* brent/tune-storage-past-epochs:
  move protocol keys into epoched PoS data
  keep `total_deltas` for same period of time as `validator_deltas`
  clear old enqueued slashes when processing slashes
  keep validator eth keys for max proposal period
  fixup! pos/types: configure number of past epochs kept for PoS data
  fixed `epoched` tests and `test_validator_sets`
  [ci] wasm checksums update
  changelog: add #1944
  PoS: refactor usages of `Epoch::checked_sub`
  core/types/storage:m ore flexible fn checked_sub param
  fixup! replace direct storage read of PosParams with an RPC fn
  replace direct storage read of PosParams with an RPC fn
  fix PoS crate standalone build
  fixup! Apply suggestions from code review
  Apply suggestions from code review
  docstring cleanup
  new impl for purging old validator sets
  pos/types: configure number of past epochs kept for PoS data
  add PosParams type with added gov param
  WIP want to pass `max_proposal_period` from gov params into PoS
brentstone added a commit that referenced this pull request Oct 16, 2023
* brent/tune-storage-past-epochs:
  move protocol keys into epoched PoS data
  keep `total_deltas` for same period of time as `validator_deltas`
  clear old enqueued slashes when processing slashes
  keep validator eth keys for max proposal period
  fixup! pos/types: configure number of past epochs kept for PoS data
  fixed `epoched` tests and `test_validator_sets`
  [ci] wasm checksums update
  changelog: add #1944
  PoS: refactor usages of `Epoch::checked_sub`
  core/types/storage:m ore flexible fn checked_sub param
  fixup! replace direct storage read of PosParams with an RPC fn
  replace direct storage read of PosParams with an RPC fn
  fix PoS crate standalone build
  fixup! Apply suggestions from code review
  Apply suggestions from code review
  docstring cleanup
  new impl for purging old validator sets
  pos/types: configure number of past epochs kept for PoS data
  add PosParams type with added gov param
  WIP want to pass `max_proposal_period` from gov params into PoS
@cwgoes cwgoes mentioned this pull request Oct 20, 2023
29 tasks
Fraccaman added a commit that referenced this pull request Oct 23, 2023
* origin/brent/tune-storage-past-epochs:
  move protocol keys into epoched PoS data
  keep `total_deltas` for same period of time as `validator_deltas`
  clear old enqueued slashes when processing slashes
  keep validator eth keys for max proposal period
  fixup! pos/types: configure number of past epochs kept for PoS data
  fixed `epoched` tests and `test_validator_sets`
  [ci] wasm checksums update
  changelog: add #1944
  PoS: refactor usages of `Epoch::checked_sub`
  core/types/storage:m ore flexible fn checked_sub param
  fixup! replace direct storage read of PosParams with an RPC fn
  replace direct storage read of PosParams with an RPC fn
  fix PoS crate standalone build
  fixup! Apply suggestions from code review
  Apply suggestions from code review
  docstring cleanup
  new impl for purging old validator sets
  pos/types: configure number of past epochs kept for PoS data
  add PosParams type with added gov param
  WIP want to pass `max_proposal_period` from gov params into PoS
tzemanovic pushed a commit that referenced this pull request Oct 24, 2023
* origin/brent/tune-storage-past-epochs:
  move protocol keys into epoched PoS data
  keep `total_deltas` for same period of time as `validator_deltas`
  clear old enqueued slashes when processing slashes
  keep validator eth keys for max proposal period
  fixup! pos/types: configure number of past epochs kept for PoS data
  fixed `epoched` tests and `test_validator_sets`
  [ci] wasm checksums update
  changelog: add #1944
  PoS: refactor usages of `Epoch::checked_sub`
  core/types/storage:m ore flexible fn checked_sub param
  fixup! replace direct storage read of PosParams with an RPC fn
  replace direct storage read of PosParams with an RPC fn
  fix PoS crate standalone build
  fixup! Apply suggestions from code review
  Apply suggestions from code review
  docstring cleanup
  new impl for purging old validator sets
  pos/types: configure number of past epochs kept for PoS data
  add PosParams type with added gov param
  WIP want to pass `max_proposal_period` from gov params into PoS
@tzemanovic tzemanovic mentioned this pull request Oct 24, 2023
@tzemanovic tzemanovic merged commit 64e817b into main Oct 24, 2023
11 of 12 checks passed
@tzemanovic tzemanovic deleted the brent/tune-storage-past-epochs branch October 24, 2023 11:26
brentstone added a commit that referenced this pull request Nov 11, 2023
brentstone pushed a commit that referenced this pull request Nov 11, 2023
* origin/brent/tune-storage-past-epochs:
  move protocol keys into epoched PoS data
  keep `total_deltas` for same period of time as `validator_deltas`
  clear old enqueued slashes when processing slashes
  keep validator eth keys for max proposal period
  fixup! pos/types: configure number of past epochs kept for PoS data
  fixed `epoched` tests and `test_validator_sets`
  [ci] wasm checksums update
  changelog: add #1944
  PoS: refactor usages of `Epoch::checked_sub`
  core/types/storage:m ore flexible fn checked_sub param
  fixup! replace direct storage read of PosParams with an RPC fn
  replace direct storage read of PosParams with an RPC fn
  fix PoS crate standalone build
  fixup! Apply suggestions from code review
  Apply suggestions from code review
  docstring cleanup
  new impl for purging old validator sets
  pos/types: configure number of past epochs kept for PoS data
  add PosParams type with added gov param
  WIP want to pass `max_proposal_period` from gov params into PoS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants