Skip to content

Client: purge history helper #3934

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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

Client: purge history helper #3934

wants to merge 5 commits into from

Conversation

ScottyPoi
Copy link
Contributor

@ScottyPoi ScottyPoi commented Mar 25, 2025

Task related to #3931
Add utility function purgeHistory exported from client/src/util/purge.ts

This function will delete block bodies, receipts, and optionally headers from client DB.

Parameters:

  • dataDir: database directory
  • chain: defaults to mainnet
  • before: blockNumber cutoff (defaults to MERGE_BLOCK)
  • headers: option to delete headers (defaults to false)

purgeHistorydeletes directly from the DB, and operates as an independent process from the client itself. Therefore, it can be run while the client is running or stopped.

Block and Transaction indexing are left untouched. So NumberToHash, etc. will still be possible for deleted blocks.

Copy link

codecov bot commented Mar 25, 2025

Codecov Report

Attention: Patch coverage is 14.70588% with 58 lines in your changes missing coverage. Please review.

Project coverage is 79.18%. Comparing base (8017184) to head (eddc0ab).

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block 83.29% <ø> (ø)
blockchain 89.49% <ø> (ø)
client 67.87% <14.70%> (-0.23%) ⬇️
common 98.49% <ø> (ø)
devp2p ?
evm 72.94% <ø> (ø)
genesis 99.98% <ø> (ø)
mpt 89.76% <ø> (ø)
rlp 91.43% <ø> (ø)
statemanager 69.16% <ø> (ø)
tx 90.58% <ø> (ø)
util 81.96% <ø> (ø)
vm 57.20% <ø> (ø)
wallet 88.55% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jochem-brouwer
Copy link
Member

Therefore, it can be run while the client is running or stopped.

Is this true? I thought that opening a DB (we use LevelDB right?) can only be done by one process?

@scorbajio
Copy link
Contributor

Is this testable? Maybe on a synced client.

@ScottyPoi ScottyPoi marked this pull request as draft March 25, 2025 20:32
@ScottyPoi
Copy link
Contributor Author

Therefore, it can be run while the client is running or stopped.

Is this true? I thought that opening a DB (we use LevelDB right?) can only be done by one process?

Will test and get back on this. If that's true, than we should also revisit the export history as era1 function from era package. That was also written as a script acting on a DB, in the interest of being able to run it independently of the client.

If this turns out impossible (deleting from DB while client is running) than I may prefer to code this function (and the export history function) into the client itself, maybe as RPC methods.

@ScottyPoi
Copy link
Contributor Author

Is this testable? Maybe on a synced client.

Right. Not sure that "unit test" is possible here. Testing on a live client will also expose other places in our code that need work for 4444

Copy link
Contributor

@acolytec3 acolytec3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to do some tests on this today now that client sync is working again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants