Skip to content

docs(block_producer): correct test-budget mechanism narrative#1438

Merged
JesseTheRobot merged 2 commits into
masterfrom
fix/block-producer-budget-narrative
Jun 2, 2026
Merged

docs(block_producer): correct test-budget mechanism narrative#1438
JesseTheRobot merged 2 commits into
masterfrom
fix/block-producer-budget-narrative

Conversation

@JesseTheRobot

@JesseTheRobot JesseTheRobot commented Jun 2, 2026

Copy link
Copy Markdown
Member

Follow-up to #1436 (comments + test names only — no behaviour change).

Why

#1436 fixed a real CI flake (heavy3_pending_chunks_test hanging because a duplicate-height production consumed two test-budget slots), and the fix is correct. But its explanation was wrong: it attributed the duplicate-height block to "two valid solutions built on the same parent before the first was validated — a sibling."

Tracing the actual CI logs to the production events tells a different story:

12.025  Finished producing height=3  DNsrHT
12.026  Block publication completed  DNsrHT   ← budget slot consumed here
12.035  ERROR prevalidation: "Transaction 3nFh5… found in multiple previous blocks
                              (first occurrence in Submit ledger at block height 1)"
12.053  Finished producing height=3  ELTMij   ← replacement, second slot consumed

The first height-3 block was published (consuming a budget slot), then failed its own prevalidation with DuplicateTransaction — it re-included a transaction already confirmed in a recent block, because the producer's mempool view hadn't caught up under fast mining. It was rebuilt at the same height, consuming a second slot. The parent-selection tracker (BlockValidationTracker) is not at fault: it correctly reverts to the prior tip when a published block is rejected.

The height-counting fix from #1436 handles this correctly regardless of cause, so this PR only corrects:

  • the doc comment on blocks_remaining_for_test / highest_test_block_height_produced,
  • the inline comment and apply_test_budget_after_production doc,
  • test names (replacement_at_same_height_does_not_consume_a_slot, rejected_and_replaced_block_still_reaches_target_height).

Related

The underlying producer behaviour — building a block that re-includes an already-confirmed tx under fast mining, caught by the prevalidation DuplicateTransaction check — is tracked separately in #1439.

Testing

cargo nextest run -p irys-actors test_budget_tests (5 pass); fmt + clippy clean.

Summary by CodeRabbit

  • Documentation
    • Clarified test-only block production budget wording to specify that replacing a rejected block at the same height does not consume budget.
    • Updated test descriptions, assertion messages, and the CI replay narrative to use the new "same-height replacement" terminology for clarity.

Follow-up to #1436. The fix landed correct, but its comments, test names, and
description attributed the duplicate-height production to "two valid solutions
built on the same parent before the first was validated — a sibling."

Tracing the CI logs shows the real mechanism: the first height-3 block was
*published* (consuming a budget slot), then failed prevalidation with
`DuplicateTransaction` because it re-included a transaction already confirmed in
a recent block (the producer's mempool view hadn't caught up under fast mining),
and was rebuilt at the same height. The parent-selection tracker is not at
fault — it correctly reverts to the prior tip when a published block is rejected.

Comments and test names only; no behaviour change.
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1b5b9538-69bc-4eaa-a708-64533d194c22

📥 Commits

Reviewing files that changed from the base of the PR and between ae7263c and 314a172.

📒 Files selected for processing (1)
  • crates/actors/src/block_producer.rs

📝 Walkthrough

Walkthrough

This PR updates documentation comments and test descriptions in the block producer to clarify that the test-mode block production budget counts canonical height increments and does not consume slots for same-height block replacements (rebuilds after prevalidation rejection). All changes are to documentation; no runtime logic or public API signatures were modified.

Changes

Test block production budget documentation

Layer / File(s) Summary
Block production budget and same-height replacement documentation
crates/actors/src/block_producer.rs
Field documentation for blocks_remaining_for_test, inline comments in the block publication path, function docstrings for apply_test_budget_after_production, and test descriptions are clarified to describe same-height block replacement (rebuilds after prevalidation rejection) and confirm that such replacements do not consume an additional budget slot.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • Irys-xyz/irys#1436: Directly related main PR that updates block_producer.rs test comments and names to describe same-height "replacement/replay" semantics, matching the test-mode budget accounting changes by height rather than produced blocks.

Suggested reviewers

  • glottologist
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately describes the main change: correcting the documentation narrative for the test-budget mechanism in the block producer.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this 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 fix/block-producer-budget-narrative

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/actors/src/block_producer.rs (1)

1962-1993: 🧹 Nitpick | 🔵 Trivial | 💤 Low value

Minor terminology note in assertion message.

Line 1989's assertion message uses "despite the sibling," while the test description and other documentation refer to this as a "replacement" or "rejected-then-replaced block." While the intent is clear in context, "despite the same-height replacement" would align better with the updated narrative throughout this PR.

Suggested terminology alignment
         assert_eq!(
             max_height_reached_while_budget_positive, 7,
-            "must reach the target height (1 + 6) despite the sibling"
+            "must reach the target height (1 + 6) despite the same-height replacement"
         );
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/actors/src/block_producer.rs` around lines 1962 - 1993, Update the
assertion message in the test
rejected_and_replaced_block_still_reaches_target_height to use the preferred
terminology; replace "despite the sibling" with "despite the same-height
replacement" (the assertion that checks max_height_reached_while_budget_positive
equals 7) so the message aligns with the test description and PR narrative.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/actors/src/block_producer.rs`:
- Around line 410-418: Update the inline comment in block_producer.rs that
currently says "sibling that was published... but then rejected at
prevalidation" to use the consistent "replacement" or "same-height replacement"
terminology used elsewhere (e.g., lines referenced as 157, 164, 857, 947, 1958)
so the narrative matches other comments; edit the phrase in the comment block
beginning "The test budget counts canonical height increments..." to replace
"sibling" with "replacement" and ensure the sentence still reads clearly about a
published block failing its own prevalidation.

---

Outside diff comments:
In `@crates/actors/src/block_producer.rs`:
- Around line 1962-1993: Update the assertion message in the test
rejected_and_replaced_block_still_reaches_target_height to use the preferred
terminology; replace "despite the sibling" with "despite the same-height
replacement" (the assertion that checks max_height_reached_while_budget_positive
equals 7) so the message aligns with the test description and PR narrative.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5f7a2e56-2dcc-45f6-a711-9829738cbcdc

📥 Commits

Reviewing files that changed from the base of the PR and between 4773009 and ae7263c.

📒 Files selected for processing (1)
  • crates/actors/src/block_producer.rs

Comment thread crates/actors/src/block_producer.rs
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

…get comment

Address review on #1438: the inline comment in the SolutionFound handler still
called the rejected block a 'sibling', inconsistent with the 'same-height
replacement' wording used in the surrounding doc comments and tests. Reword it
(and the lone remaining 'sibling' in a regression-test assertion) so the
narrative is consistent; still describes a published block failing its own
prevalidation. Comments/test-message only; no behaviour change.
@JesseTheRobot JesseTheRobot merged commit b6b5133 into master Jun 2, 2026
18 checks passed
@JesseTheRobot JesseTheRobot deleted the fix/block-producer-budget-narrative branch June 2, 2026 17:24
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