Skip to content

refactor(block): allow pruning when da disabled#3075

Merged
julienrbrt merged 6 commits intomainfrom
julien/pruning-2
Feb 17, 2026
Merged

refactor(block): allow pruning when da disabled#3075
julienrbrt merged 6 commits intomainfrom
julien/pruning-2

Conversation

@julienrbrt
Copy link
Member

Overview

follow-up of #2984 (ref #2984 (comment))

@github-actions
Copy link
Contributor

github-actions bot commented Feb 16, 2026

The latest Buf updates on your PR. Results from workflow CI / buf-check (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed⏩ skipped✅ passed✅ passedFeb 17, 2026, 1:09 PM

@claude
Copy link
Contributor

claude bot commented Feb 16, 2026

Claude finished @julienrbrt's task in 1m 23s —— View job


Code Review

  • Read changed files
  • Analyze pruner logic
  • Review tests
  • Provide feedback

Overall this is a clean, well-scoped change. The core approach — using daAddress != "" to determine if DA is enabled and conditionally skipping the DA inclusion check — is straightforward and correct. A few notes below.

block/internal/pruner/pruner.go

Conflated error handling in pruneBlocks (line 122–127)

currentDAIncludedBz, err := p.store.GetMetadata(p.ctx, store.DAIncludedHeightKey)
if err == nil && len(currentDAIncludedBz) == 8 {
    currentDAIncluded = binary.LittleEndian.Uint64(currentDAIncludedBz)
} else {
    p.logger.Debug().Msg("skipping pruning: DA is enabled but DA included height is not available yet")
    return nil
}

The else branch conflates two distinct cases:

  1. Key not found in store (expected early-lifecycle state — DA height not yet written)
  2. A genuine store read error (unexpected)
  3. Key found but with wrong length (data corruption)

For cases 2 and 3, silently skipping with a debug-level log may hide real issues. Consider logging at Warn level when err != nil or when the byte slice has an unexpected length, reserving the Debug log for the ErrNotFound case. Fix this →

pruneBlocks doesn't persist batchEnd as last pruned height

Looking at pruneBlocks, after calling p.store.PruneBlocks(p.ctx, batchEnd), there's no call to persist the new batchEnd as the last pruned block height (unlike pruneMetadata which calls p.setLastPrunedStateHeight). The pruner does call p.getLastPrunedBlockHeight to compute the batch — so presumably PruneBlocks on the store updates that key itself. Worth confirming this is handled inside store.PruneBlocks and not an omission.

block/internal/pruner/pruner_test.go

Missing regression test (noted by @alpe)

There's no test for the case where storeHeight < daInclusionHeight. The line upperBound = min(storeHeight, currentDAIncluded) at pruner.go:130 handles this, but it's untested. A node could be temporarily behind DA (e.g., store at height 50, DA says 100) — the pruner should use storeHeight (50) as the upper bound and not try to prune beyond what's stored. Fix this →

Comment/expectation discrepancy in TestPrunerPruneBlocksWithoutDA

Lines 110-113 check h <= 40 for pruned blocks, while line 122 checks h < 40 for exec metadata (PruneExec is called with batchEnd=40 and uses h < height). The comment on line 103 says "prune from height 1 up to min(0 + 40, 90) = 40". This is correct but the asymmetry between <= 40 for block data and < 40 for exec metadata (h=40 is kept in exec) should be explained in the test comment to avoid confusion.

TestPrunerPruneBlocksWithDAEnabled — verifies no-op when DA height missing, but not the normal DA path

The test confirms that pruning is skipped when DAIncludedHeightKey is absent. A complementary test that sets DAIncludedHeightKey and verifies pruning actually occurs with DA enabled would be valuable for completeness (and would exercise the regression @alpe mentioned above).

block/components.go

Clean, minimal change. Passing config.DA.Address to pruner.New is the correct approach.

docs/learn/config.md

The two new bullet points (lines 343–344) clearly explain the behavior difference between DA-enabled and DA-disabled pruning. Good addition.


Summary: The change is correct and well-structured. The main actionable items are: (1) improve error differentiation in the else branch of the DA height read, and (2) add the regression test for storeHeight < daInclusionHeight as requested by @alpe.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @julienrbrt, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the block pruning logic to enable nodes to prune blocks regardless of whether Data Availability (DA) is configured. Previously, pruning was strictly tied to DA inclusion, which prevented non-DA nodes from managing their storage. The changes introduce a conditional pruning mechanism that adapts based on DA enablement, ensuring efficient disk space management for all node types while maintaining data integrity for DA-enabled setups.

Highlights

  • Pruning Logic Enhancement: The block pruning mechanism has been refactored to allow pruning even when Data Availability (DA) is disabled, addressing a limitation where nodes without DA configured could not manage their disk space effectively.
  • Conditional DA-Aware Pruning: A new daEnabled flag was introduced in the Pruner component, which determines whether pruning should rely on DA inclusion height. If DA is disabled, pruning proceeds based solely on the store's block height.
  • Configuration Integration: The pruner.New function now accepts the DA address from the configuration, enabling the pruner to dynamically adapt its behavior based on whether DA is active.
  • Expanded Test Coverage: New unit tests were added to thoroughly validate the pruning functionality under both DA-enabled and DA-disabled scenarios, ensuring correct behavior in various operational modes.
  • Documentation Update: The config.md documentation was updated to clearly explain the different pruning behaviors when DA is enabled versus when it is not, providing better guidance for users.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • CHANGELOG.md
    • Updated changelog with an entry about storing pending blocks separately from executed blocks key.
  • block/components.go
    • Modified NewSyncComponents and NewAggregatorComponents to pass the DA address to the pruner initialization.
  • block/internal/pruner/pruner.go
    • Refactored the Pruner struct to include a daEnabled flag.
    • Adjusted the New function to determine daEnabled based on the provided DA address.
    • Modified the pruneBlocks method to conditionally prune based on the daEnabled flag, using DA inclusion height only when DA is active.
  • block/internal/pruner/pruner_test.go
    • Extended test suite with new cases for pruning blocks when DA is disabled.
    • Added tests to verify pruning behavior when DA is enabled and DA inclusion height is not yet available.
  • docs/learn/config.md
    • Updated documentation to explain pruning behavior with and without Data Availability (DA) enabled.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@julienrbrt julienrbrt requested a review from pthmas February 16, 2026 12:35
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the pruning mechanism to allow it to function even when the Data Availability (DA) layer is disabled. This is achieved by passing the DA address to the pruner, which then conditionally checks for DA inclusion height before pruning. If DA is disabled (no address provided), pruning proceeds based on the store height. The changes are well-implemented, include thorough tests for both DA-enabled and DA-disabled scenarios, and update the documentation accordingly. My only suggestion is to correct the changelog entry to accurately reflect the changes in this PR.


### Changes

- Store pending blocks separately from executed blocks key. [#3073](https://github.com/evstack/ev-node/pull/3073)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This changelog entry appears to be from a different pull request. This PR's changes are about allowing pruning when the DA layer is disabled. Please update the changelog to reflect the correct changes.

Suggested change
- Store pending blocks separately from executed blocks key. [#3073](https://github.com/evstack/ev-node/pull/3073)
- Allow pruning when the Data Availability (DA) layer is disabled.

Copy link
Member Author

Choose a reason for hiding this comment

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

nope, the changelog is unrelated to this pr (that do not require any)

@codecov
Copy link

codecov bot commented Feb 16, 2026

Codecov Report

❌ Patch coverage is 71.42857% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.10%. Comparing base (1da7634) to head (d36055b).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
block/internal/pruner/pruner.go 66.66% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3075      +/-   ##
==========================================
+ Coverage   61.04%   61.10%   +0.05%     
==========================================
  Files         113      113              
  Lines       11440    11444       +4     
==========================================
+ Hits         6984     6993       +9     
+ Misses       3674     3663      -11     
- Partials      782      788       +6     
Flag Coverage Δ
combined 61.10% <71.42%> (+0.05%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@julienrbrt julienrbrt requested a review from alpe February 16, 2026 14:51
@julienrbrt julienrbrt enabled auto-merge February 16, 2026 14:51
Copy link
Contributor

@alpe alpe left a comment

Choose a reason for hiding this comment

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

nice work. minor nits and comments

}

// Never prune blocks that are not DA included
upperBound = min(storeHeight, currentDAIncluded)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

func TestPrunerPruneBlocksWithoutDA(t *testing.T) {
t.Parallel()

ctx := context.Background()
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: here and others: use t.Context() instead

_, _, err := stateStore.GetBlockData(ctx, h)
require.NoError(t, err, "expected block data at height %d to still exist (no pruning should have happened)", h)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

it would be good to also test store height < da incl height for regression

@julienrbrt julienrbrt added this pull request to the merge queue Feb 17, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 17, 2026
Copilot AI added a commit that referenced this pull request Feb 17, 2026
… regression test

Co-authored-by: julienrbrt <29894366+julienrbrt@users.noreply.github.com>
* Initial plan

* Implement PR #3075 review comments: update test context usage and add regression test

Co-authored-by: julienrbrt <29894366+julienrbrt@users.noreply.github.com>

* Remove invalid regression test - DA inclusion height cannot exceed store height

Co-authored-by: julienrbrt <29894366+julienrbrt@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: julienrbrt <29894366+julienrbrt@users.noreply.github.com>
@julienrbrt julienrbrt enabled auto-merge February 17, 2026 09:29
@julienrbrt julienrbrt added this pull request to the merge queue Feb 17, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 17, 2026
@julienrbrt julienrbrt merged commit d4394f6 into main Feb 17, 2026
28 of 30 checks passed
@julienrbrt julienrbrt deleted the julien/pruning-2 branch February 17, 2026 15:07
@github-actions
Copy link
Contributor

PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-02-17 15:07 UTC

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants