-
Notifications
You must be signed in to change notification settings - Fork 35
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
refactor: address snapshot/pruning refactor comments upstream #184
Conversation
snapshots/manager.go
Outdated
@@ -314,6 +314,11 @@ func (m *Manager) shouldTakeSnapshot(height int64) bool { | |||
func (m *Manager) snapshot(height int64) { | |||
m.logger.Info("creating state snapshot", "height", height) | |||
|
|||
if height < 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be <= 0 (I asked based on the error message)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right. I will get that changed
pruning/manager.go
Outdated
@@ -59,13 +62,14 @@ func (m *Manager) GetPruningHeights() []int64 { | |||
|
|||
// ResetPruningHeights resets the heights to be pruned. | |||
func (m *Manager) ResetPruningHeights() { | |||
m.pruneHeights = make([]int64, 0) | |||
// reuse previously allocated memory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// reuse previously allocated memory. | |
// reuse previously allocated memory |
pruning/manager.go
Outdated
} | ||
} | ||
|
||
// TODO: convert to a generic version with Go 1.18. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This this really necessary? How would this change?
If we must do this, let's reference (and create) an issue. I'd like to avoid "naked" TODOs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, you are right. It's not really necessary unless we start reusing this functionality with other types. I removed the comment
@@ -0,0 +1,11 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err, what's this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ugh, I've been switching frequently between this repo and the SDK repo, likely merged by accident
will ve removed
@@ -0,0 +1,5 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this file too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be removed
@alexanderbez thanks for the review. Will get back to your comments. I might have to update this PR with more changes from the comments in the upstream so marking this as a draft for now |
270bdd1
to
5b2697d
Compare
e684bda
to
95e8071
Compare
All comments are now addressed. I backported all changes from the upstream up until: #187 I will do everything including and after it in a separate PR to limit the scope here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewing both of these PRs in the SDK and our fork is not tenable IMO. Can we wait till the SDK one is merged or vice versa? I left a bunch of comments in the core repo.
pruning/manager.go
Outdated
snapshotInterval uint64 | ||
pruneHeights []int64 | ||
pruneSnapshotHeights *list.List | ||
mx sync.Mutex | ||
} | ||
|
||
const ( | ||
pruneHeightsKey = "s/pruneheights" | ||
pruneSnapshotHeightsKey = "s/pruneSnheights" | ||
errNegativeHeightsFmt = "failed to get pruned heights: %d" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a string. It should not start with err
Sounds good. I agree. Let's wait until the core is accepted |
4fcdd02
to
cf03c8e
Compare
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
5c12960
to
6d2ac52
Compare
Hi @alexanderbez This is a backport of all commits in cosmos#11496 Can we merge this? |
Description
Addressing functional and security comments from review upstream:
cosmos#11496
Testing
Tested this on Osmosis v7.x: #206
main
is unstableprune-everything
the interval and keep-recent are both 10Following the Logs
If we specify a small
snapshot-interval
(such as 100) and snapshots overlap, the new requests to snapshot will be skipped if there is one that is already in progress. Therefore, I split the snapshot height tests into 2 cases:Snapshot Heights - Snapshot Performed
Verified that it works as expected by exposing some debug logs:
When we would normally prune height
4080000
(at4080010
), the snapshot height does not show up anymore because it is kept until after a snapshot is done:Eventually we see the following log message signifying that a snapshot height was pruned away:
Snapshot Heights - Skipped
Snapshot heights that overlap with an already in progress snapshot are skipped and pruned almost immediately:
4080100
is out of order because it was added to the list in a separate goroutine after we checked for an in progress snapshot.Regular Heights
For heights that are not multiples of snapshot-interval are removed right away according to the pruning strategy:
Querying
I attempted to query epochs at a specific height. As soon as the queried height went beyond keep-recent, I would get an error. Ths indicates that pruning functions correctly.
Flow of events:
10:03PM INF pruning heights heights=[4080130,4080131,4080132,4080133,4080134,4080135,4080136,4080137,4080138,4080139]
in the logs