-
Notifications
You must be signed in to change notification settings - Fork 4
feat: pruning #332
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
base: main
Are you sure you want to change the base?
feat: pruning #332
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,3 +22,56 @@ func TestStateIO(t *testing.T) { | |||||||||||||||||||||
| require.NoError(t, gotErr) | ||||||||||||||||||||||
| assert.True(t, exists) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| func TestPrune_RemovesPerHeightABCIKeysUpToTarget(t *testing.T) { | ||||||||||||||||||||||
| db := ds.NewMapDatastore() | ||||||||||||||||||||||
| absciStore := store.NewExecABCIStore(db) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ctx := t.Context() | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Seed per-height block ID and block response keys for heights 1..5. | ||||||||||||||||||||||
| for h := 1; h <= 5; h++ { | ||||||||||||||||||||||
| heightKey := ds.NewKey("/abci/bid").ChildString(string(rune(h + '0'))) | ||||||||||||||||||||||
| require.NoError(t, db.Put(ctx, heightKey, []byte("bid"))) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| respKey := ds.NewKey("/abci/br").ChildString(string(rune(h + '0'))) | ||||||||||||||||||||||
| require.NoError(t, db.Put(ctx, respKey, []byte("br"))) | ||||||||||||||||||||||
|
Comment on lines
+34
to
+38
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The key generation in this test uses
Suggested change
|
||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Seed state to ensure it is not affected by pruning. | ||||||||||||||||||||||
| require.NoError(t, db.Put(ctx, ds.NewKey("/abci/s"), []byte("state"))) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Prune up to height 3. | ||||||||||||||||||||||
| require.NoError(t, absciStore.Prune(ctx, 3)) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Heights 1..3 should be deleted. | ||||||||||||||||||||||
| for h := 1; h <= 3; h++ { | ||||||||||||||||||||||
| bidKey := ds.NewKey("/abci/bid").ChildString(string(rune(h + '0'))) | ||||||||||||||||||||||
| exists, err := db.Has(ctx, bidKey) | ||||||||||||||||||||||
| require.NoError(t, err) | ||||||||||||||||||||||
| assert.False(t, exists) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| respKey := ds.NewKey("/abci/br").ChildString(string(rune(h + '0'))) | ||||||||||||||||||||||
| exists, err = db.Has(ctx, respKey) | ||||||||||||||||||||||
| require.NoError(t, err) | ||||||||||||||||||||||
| assert.False(t, exists) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Heights 4..5 should remain. | ||||||||||||||||||||||
| for h := 4; h <= 5; h++ { | ||||||||||||||||||||||
| bidKey := ds.NewKey("/abci/bid").ChildString(string(rune(h + '0'))) | ||||||||||||||||||||||
| exists, err := db.Has(ctx, bidKey) | ||||||||||||||||||||||
| require.NoError(t, err) | ||||||||||||||||||||||
| assert.True(t, exists) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| respKey := ds.NewKey("/abci/br").ChildString(string(rune(h + '0'))) | ||||||||||||||||||||||
| exists, err = db.Has(ctx, respKey) | ||||||||||||||||||||||
| require.NoError(t, err) | ||||||||||||||||||||||
| assert.True(t, exists) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // State should not be pruned. | ||||||||||||||||||||||
| exists, err := db.Has(ctx, ds.NewKey("/abci/s")) | ||||||||||||||||||||||
| require.NoError(t, err) | ||||||||||||||||||||||
| assert.True(t, exists) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.