Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic committed Feb 8, 2024
1 parent 9caaac3 commit 81e7ebe
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion proto/osmosis/twap/v1beta1/twap_record.proto
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ message PruningState {
// last_key_seen is the last key of the TWAP records that were pruned
// before reaching the block's prune limit
bytes last_key_seen = 3;
}
}
2 changes: 0 additions & 2 deletions x/twap/listeners_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,6 @@ func (s *TestSuite) TestAfterEpochEnd() {
err = s.App.TwapKeeper.EpochHooks().AfterEpochEnd(s.Ctx, allEpochs[i].Identifier, int64(1))
s.Require().NoError(err)

//recordsAfterEpoch, err := s.twapkeeper.GetAllHistoricalTimeIndexedTWAPs(s.Ctx)

lastKeptTime := s.Ctx.BlockTime().Add(-s.twapkeeper.RecordHistoryKeepPeriod(s.Ctx))
pruneState := s.twapkeeper.GetPruningState(s.Ctx)

Expand Down
7 changes: 7 additions & 0 deletions x/twap/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ func (k Keeper) StoreHistoricalTWAP(ctx sdk.Context, twap types.TwapRecord) {
// So, in order to have correct behavior for the desired guarantee,
// we keep the newest record that is older than the pruning time.
// This is why we would keep the -50 hour and -1hour twaps despite a 48hr pruning period
//
// If we reach the per block pruning limit, we store the last key seen in the pruning state.
// This is so that we can continue pruning from where we left off in the next block.
// If we have pruned all records, we set the pruning state to not pruning.
// There is a small bug here where we store more seenPoolAssetTriplets than we need to.
// Issue added here: https://github.com/osmosis-labs/osmosis/issues/7435
// The bloat is minimal though, and is not at risk of getting out of hand.
func (k Keeper) pruneRecordsBeforeTimeButNewest(ctx sdk.Context, state types.PruningState) error {
store := ctx.KVStore(k.storeKey)

Expand Down

0 comments on commit 81e7ebe

Please sign in to comment.