Skip to content

fix: default engine.persistence-threshold to 0#227

Open
fridrik01 wants to merge 1 commit intomainfrom
override-upstream-reth-defaults
Open

fix: default engine.persistence-threshold to 0#227
fridrik01 wants to merge 1 commit intomainfrom
override-upstream-reth-defaults

Conversation

@fridrik01
Copy link
Contributor

@fridrik01 fridrik01 commented Mar 21, 2026

This PR defaults --engine.persistence-threshold and --engine.memory-block-buffer-target to 0 by setting DefaultEngineValues before CLI parsing, so users don't need to remember to pass these flags manually.

Without this override, users who forget to set --engine.persistence-threshold 0 can experience panics in debug mode on fast machines, and risk state loss on unclean shutdown.

This aligns with our production checklist and all deployment scripts. Users can still override via the CLI if needed.

Test plan

> bera-reth node --help | grep -A5 "persistence-threshold"
 [default: 0]
> bera-reth node --help | grep -A5 "memory-block-buffer-target"
 [default: 0]

Summary by CodeRabbit

  • Chores
    • Updated application startup sequence to initialize engine configuration before argument parsing.
    • Adjusted default memory resource allocation settings.
    • Added error handling to ensure initialization requirements are met.

@fridrik01 fridrik01 self-assigned this Mar 21, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 21, 2026

📝 Walkthrough

Walkthrough

Engine defaults initialization has been added to main() before CLI parsing. The code sets persistence threshold and memory block buffer target to 0, calls try_init(), and aborts with an error message if initialization fails.

Changes

Cohort / File(s) Summary
Engine Defaults Initialization
src/main.rs
Added DefaultEngineValues initialization after version setup, configuring persistence and memory buffer targets with error handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hop hop, defaults are set,
Before the CLI takes flight,
Memory buffers cleared with care,
Engine ready, shiny bright!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: setting a default value for engine.persistence-threshold to 0, which matches the primary objective of the pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch override-upstream-reth-defaults

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can use TruffleHog to scan for secrets in your code with verification capabilities.

Add a TruffleHog config file (e.g. trufflehog-config.yml, trufflehog.yml) to your project to customize detectors and scanning behavior. The tool runs only when a config file is present.

@fridrik01 fridrik01 marked this pull request as ready for review March 21, 2026 14:20
@fridrik01 fridrik01 requested review from a team, bar-bera, calbera and Copilot and removed request for Copilot March 21, 2026 14:20
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main.rs (1)

28-28: Remove the newly added inline code comment.

Line [28] introduces a Rust code comment in a path covered by the no-comments rule.

As per coding guidelines, "src/**/*.rs: No comments in code unless explicitly requested".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main.rs` at line 28, Remove the inline Rust comment that reads "Override
bera-reth recommended defaults" from src/main.rs to comply with the no-comments
rule for src/**/*.rs; locate the exact comment string in the file and delete the
comment line so the code contains no inline comments unless explicitly
requested.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main.rs`:
- Around line 29-33: Replace the magic zeros and generic panic in the engine
defaults initialization: extract the literal 0 used in
DefaultEngineValues::default().with_persistence_threshold(0).with_memory_block_buffer_target(0)
into documented constants (e.g. DEFAULT_PERSISTENCE_THRESHOLD and
DEFAULT_MEMORY_BLOCK_BUFFER_TARGET) and use them in the calls; remove the
expect(...) on try_init() and propagate the error using a custom startup error
type (e.g. StartupError) or map the failure to a descriptive error variant and
return or log it at startup instead of panicking; update any function signatures
to return Result where needed so DefaultEngineValues::try_init() errors are
handled cleanly.

---

Nitpick comments:
In `@src/main.rs`:
- Line 28: Remove the inline Rust comment that reads "Override bera-reth
recommended defaults" from src/main.rs to comply with the no-comments rule for
src/**/*.rs; locate the exact comment string in the file and delete the comment
line so the code contains no inline comments unless explicitly requested.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ae9897a9-4305-4f1c-b544-1995eeaa4351

📥 Commits

Reviewing files that changed from the base of the PR and between 70ee934 and c0f6c73.

📒 Files selected for processing (1)
  • src/main.rs

Comment on lines +29 to +33
reth_node_core::args::DefaultEngineValues::default()
.with_persistence_threshold(0)
.with_memory_block_buffer_target(0)
.try_init()
.expect("engine defaults must be set before CLI parsing");
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Replace magic literals and generic panic in startup init.

Lines [30]-[31] add raw 0 defaults, and Line [33] adds a generic expect(...) panic path. Please promote these defaults to documented constants and handle init failure via a custom startup error flow instead of a generic panic.

As per coding guidelines, "src/**/*.rs: Extract magic numbers into documented constants" and "src/**/*.rs: Use custom error types over generic errors".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main.rs` around lines 29 - 33, Replace the magic zeros and generic panic
in the engine defaults initialization: extract the literal 0 used in
DefaultEngineValues::default().with_persistence_threshold(0).with_memory_block_buffer_target(0)
into documented constants (e.g. DEFAULT_PERSISTENCE_THRESHOLD and
DEFAULT_MEMORY_BLOCK_BUFFER_TARGET) and use them in the calls; remove the
expect(...) on try_init() and propagate the error using a custom startup error
type (e.g. StartupError) or map the failure to a descriptive error variant and
return or log it at startup instead of panicking; update any function signatures
to return Result where needed so DefaultEngineValues::try_init() errors are
handled cleanly.

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.

1 participant