Skip to content
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

Fix older logs pruning #9932

Merged
merged 4 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion eth/stagedsync/stage_log_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,8 @@ func pruneLogIndex(logPrefix string, tx kv.RwTx, tmpDir string, pruneFrom, prune

notToPrune := false // To identify whether this log key has addr in noPruneContracts
for _, l := range logs {
if noPruneContracts != nil && noPruneContracts[l.Address] {
// If any of the logs have an address in noPruneContracts, then the whole tx is related to it, and must not be pruned, including addr and topic indexes
if noPruneContracts != nil && noPruneContracts[l.Address] || notToPrune {
notToPrune = true
continue
}
Expand Down
6 changes: 3 additions & 3 deletions eth/stagedsync/stage_log_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func TestPruneLogIndex(t *testing.T) {
require, tmpDir, ctx := require.New(t), t.TempDir(), context.Background()
_, tx := memdb.NewTestTx(t)

_, _ = genReceipts(t, tx, 100)
_, _ = genReceipts(t, tx, 90)

cfg := StageLogIndexCfg(nil, prune.DefaultMode, "", nil)
cfgCopy := cfg
Expand All @@ -135,7 +135,7 @@ func TestPruneLogIndex(t *testing.T) {
require.NoError(err)

// Mode test
err = pruneLogIndex("", tx, tmpDir, 0, 50, ctx, logger, nil)
err = pruneLogIndex("", tx, tmpDir, 0, 45, ctx, logger, map[libcommon.Address]bool{{1}: true}) // using addr {1} from genReceipts
require.NoError(err)

{
Expand Down Expand Up @@ -165,7 +165,7 @@ func TestPruneLogIndex(t *testing.T) {
return nil
})
require.NoError(err)
require.True(total == 49) // 51 logs have been pruned
require.Equal(total, 60) // 1/3rd of 45 not pruned as it has address "1", so 30 Pruned in total, remaining 90-30
}
}

Expand Down
Loading