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 LogIndex Prune #9733

Merged
merged 1 commit into from
Mar 18, 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
7 changes: 4 additions & 3 deletions eth/stagedsync/stage_log_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,8 @@ func PruneLogIndex(s *PruneState, tx kv.RwTx, cfg LogIndexCfg, ctx context.Conte
}

pruneTo := cfg.prune.Receipts.PruneTo(s.ForwardProgress)
if err = pruneLogIndex(logPrefix, tx, cfg.tmpdir, pruneTo, ctx, logger, cfg.noPruneContracts); err != nil {
// s.PruneProgress
if err = pruneLogIndex(logPrefix, tx, cfg.tmpdir, s.PruneProgress, pruneTo, ctx, logger, cfg.noPruneContracts); err != nil {
return err
}
if err = s.Done(tx); err != nil {
Expand All @@ -426,7 +427,7 @@ func PruneLogIndex(s *PruneState, tx kv.RwTx, cfg LogIndexCfg, ctx context.Conte
return nil
}

func pruneLogIndex(logPrefix string, tx kv.RwTx, tmpDir string, pruneTo uint64, ctx context.Context, logger log.Logger, noPruneContracts map[libcommon.Address]bool) error {
func pruneLogIndex(logPrefix string, tx kv.RwTx, tmpDir string, pruneFrom, pruneTo uint64, ctx context.Context, logger log.Logger, noPruneContracts map[libcommon.Address]bool) error {
logEvery := time.NewTicker(logInterval)
defer logEvery.Stop()

Expand All @@ -444,7 +445,7 @@ func pruneLogIndex(logPrefix string, tx kv.RwTx, tmpDir string, pruneTo uint64,
}
defer c.Close()

for k, v, err := c.First(); k != nil; k, v, err = c.Next() {
for k, v, err := c.Seek(dbutils.LogKey(pruneFrom, 0)); k != nil; k, v, err = c.Next() {
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions eth/stagedsync/stage_log_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func TestPruneLogIndex(t *testing.T) {
require.NoError(err)

// Mode test
err = pruneLogIndex("", tx, tmpDir, 50, ctx, logger, nil)
err = pruneLogIndex("", tx, tmpDir, 0, 50, ctx, logger, nil)
require.NoError(err)

{
Expand Down Expand Up @@ -175,7 +175,7 @@ func TestUnwindLogIndex(t *testing.T) {
require.NoError(err)

// Mode test
err = pruneLogIndex("", tx, tmpDir, 50, ctx, logger, nil)
err = pruneLogIndex("", tx, tmpDir, 0, 50, ctx, logger, nil)
require.NoError(err)

// Unwind test
Expand Down
Loading