-
Notifications
You must be signed in to change notification settings - Fork 249
feat: block Pruning #2984
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
Open
pthmas
wants to merge
28
commits into
main
Choose a base branch
from
pierrick/prunning
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+543
−24
Open
feat: block Pruning #2984
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
5509d38
basic prunning
pthmas 95a3876
prune metadata from ev-node store
pthmas b8ca7fb
wiring prunning config to go-header
pthmas d09b803
prune evm exec store
pthmas c329f76
add parameters validation
pthmas 9ae2f6a
make error handling consistent
pthmas 907f28c
add method to tracedstore to respect interface
pthmas b022f10
add prune block to mockstore
pthmas 99d586b
fix helper for flag for consistency
pthmas f798b18
add replace statement for local packages
pthmas 70e4901
flags
pthmas 9315c6c
add safetey mechanism for pruning only da included blocks
pthmas 23af6b7
fix rebase
pthmas f250b64
remove useless check
pthmas 135c925
use lastprunedheight in Tail() to optimize
pthmas c1168c9
move pruning from executor to dainclusionloop
pthmas 155ed5c
don't prune go-header store
pthmas 52c005e
update tail function
pthmas 9e046c4
rename execmetapruner to execpruner
pthmas 3c1641b
Update core/execution/execution.go
pthmas 2566dae
Update execution/evm/execution.go
pthmas 535cf1c
trigger pruning every ticker
pthmas 4ee40d6
add store to store adapter
pthmas a4434d1
invalidate cache store data after pruning
pthmas 86eb1a2
nit
pthmas ca26acd
move pruning to it's own function
pthmas b1a6a09
update config.md file
pthmas fec4fb4
remove ai comments
pthmas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| package evm | ||
|
|
||
| import ( | ||
| "context" | ||
| "encoding/binary" | ||
| "testing" | ||
|
|
||
| ds "github.com/ipfs/go-datastore" | ||
| dssync "github.com/ipfs/go-datastore/sync" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| // newTestDatastore creates an in-memory datastore for testing. | ||
| func newTestDatastore(t *testing.T) ds.Batching { | ||
| t.Helper() | ||
| // Wrap the in-memory MapDatastore to satisfy the Batching interface. | ||
| return dssync.MutexWrap(ds.NewMapDatastore()) | ||
| } | ||
|
|
||
| func TestPruneExec_PrunesUpToTargetHeight(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| ctx := context.Background() | ||
| db := newTestDatastore(t) | ||
| store := NewEVMStore(db) | ||
|
|
||
| // Seed ExecMeta entries at heights 1..5 | ||
| for h := uint64(1); h <= 5; h++ { | ||
| meta := &ExecMeta{Height: h} | ||
| require.NoError(t, store.SaveExecMeta(ctx, meta)) | ||
| } | ||
|
|
||
| // Sanity: all heights should be present | ||
| for h := uint64(1); h <= 5; h++ { | ||
| meta, err := store.GetExecMeta(ctx, h) | ||
| require.NoError(t, err) | ||
| require.NotNil(t, meta) | ||
| require.Equal(t, h, meta.Height) | ||
| } | ||
|
|
||
| // Prune up to height 3 | ||
| require.NoError(t, store.PruneExec(ctx, 3)) | ||
|
|
||
| // Heights 1..3 should be gone | ||
| for h := uint64(1); h <= 3; h++ { | ||
| meta, err := store.GetExecMeta(ctx, h) | ||
| require.NoError(t, err) | ||
| require.Nil(t, meta) | ||
| } | ||
|
|
||
| // Heights 4..5 should remain | ||
| for h := uint64(4); h <= 5; h++ { | ||
| meta, err := store.GetExecMeta(ctx, h) | ||
| require.NoError(t, err) | ||
| require.NotNil(t, meta) | ||
| } | ||
|
|
||
| // Re-pruning with the same height should be a no-op | ||
| require.NoError(t, store.PruneExec(ctx, 3)) | ||
| } | ||
|
|
||
| func TestPruneExec_TracksLastPrunedHeight(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| ctx := context.Background() | ||
| db := newTestDatastore(t) | ||
| store := NewEVMStore(db) | ||
|
|
||
| // Seed ExecMeta entries at heights 1..5 | ||
| for h := uint64(1); h <= 5; h++ { | ||
| meta := &ExecMeta{Height: h} | ||
| require.NoError(t, store.SaveExecMeta(ctx, meta)) | ||
| } | ||
|
|
||
| // First prune up to 2 | ||
| require.NoError(t, store.PruneExec(ctx, 2)) | ||
|
|
||
| // Then prune up to 4; heights 3..4 should be deleted in this run | ||
| require.NoError(t, store.PruneExec(ctx, 4)) | ||
|
|
||
| // Verify all heights 1..4 are gone, 5 remains | ||
| for h := uint64(1); h <= 4; h++ { | ||
| meta, err := store.GetExecMeta(ctx, h) | ||
| require.NoError(t, err) | ||
| require.Nil(t, meta) | ||
| } | ||
|
|
||
| meta, err := store.GetExecMeta(ctx, 5) | ||
| require.NoError(t, err) | ||
| require.NotNil(t, meta) | ||
| require.Equal(t, uint64(5), meta.Height) | ||
|
|
||
| // Ensure last-pruned marker is set to 4 | ||
| raw, err := db.Get(ctx, ds.NewKey(lastPrunedExecMetaKey)) | ||
| require.NoError(t, err) | ||
| require.Len(t, raw, 8) | ||
| last := binary.BigEndian.Uint64(raw) | ||
| require.Equal(t, uint64(4), last) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 seems blocking? since we are pruning data that will not be modified we should be able to handle it async. Can we get some benchmarks on what the potential slow down to a node operating at 100ms is going to experience with different settings
Uh oh!
There was an error while loading. Please reload this page.
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.
If we want to extract it, then i suppose we should create a
pruningpackage under internal and have it be a new component. It was to put it insubmittingso it would be called by both syncer and executor.Having it its own component will make it async.