osmosis icon indicating copy to clipboard operation
osmosis copied to clipboard

feat(twap): historic pruning

Open p0mvn opened this issue 2 years ago • 1 comments

Closes: #2197

What is the purpose of the change

Adds TWAP historic pruning and tests.

Brief Changelog

  • [x] implement pruning in pruneRecordsBeforeTime
  • [x] implement getters for all records and unit test them (helpers_test.go)
  • [x] use getters to test the pruning logic
  • [x] reuse denom constants in tests
  • [x] Create follow-up issue for AfterEpochEnd tests: https://github.com/osmosis-labs/osmosis/issues/2372
  • [x] Create follow-up issue for setting pruning-keep period via parameter: https://github.com/osmosis-labs/osmosis/issues/2371

Testing and Verifying

This change added tests and can be verified as follows:

  • TestGetAllHistoricalPoolIndexedTWAPs
  • TestGetAllHistoricalTimeIndexedTWAPs
  • TestPruneRecordsBeforeTime

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? yes
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? no
  • How is the feature or change documented? not applicable

p0mvn avatar Aug 03 '22 21:08 p0mvn

We should remove

//nolint:unused,deadcode

right above

//nolint:unused,deadcode
func (k Keeper) deleteHistoricalRecord(ctx sdk.Context, twap types.TwapRecord) {

ValarDragon avatar Aug 12 '22 02:08 ValarDragon

Thanks for the reviews everyone!

p0mvn avatar Aug 18 '22 14:08 p0mvn