Skip to content

test(runtime): Extend Deterministic Batcher Coverage#2518

Draft
refcell wants to merge 3 commits intomainfrom
rf/test/runtime-coverage-phase2
Draft

test(runtime): Extend Deterministic Batcher Coverage#2518
refcell wants to merge 3 commits intomainfrom
rf/test/runtime-coverage-phase2

Conversation

@refcell
Copy link
Copy Markdown
Contributor

@refcell refcell commented May 4, 2026

Summary

This stacks on the initial deterministic runtime coverage PR and completes the tx-manager and batcher runtime testing pass. It moves additional tx-manager, L1 head source, and safe-head poller timer paths behind base-runtime, then adds virtual-time tests for event ordering, polling, cancellation, duplicate suppression, and timeout behavior.

@refcell refcell added the tooling Area: tooling label May 4, 2026
@refcell refcell self-assigned this May 4, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented May 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
base Ignored Ignored May 4, 2026 9:17pm

Request Review

Comment on lines +88 to 92
/// Spawn the polling loop on an injected runtime.
pub fn spawn_with_runtime<R: Runtime>(self, runtime: R) {
let task_runtime = runtime.clone();
std::mem::drop(runtime.spawn(self.run(task_runtime)));
}
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.

nit: spawn_with_runtime is declared pub but has no callers. If it's intended for future use in deterministic tests, consider adding a #[cfg(test)] gate or an #[allow(dead_code)] comment explaining the intent. Otherwise clippy (or cargo-udeps equivalent) may flag it.

Comment on lines 146 to +154
#[must_use]
pub fn critical_error(&self) -> Option<TxManagerError> {
let now = Instant::now();
self.critical_error_with(None)
}

/// Returns the critical error using a runtime-relative timestamp.
#[must_use]
pub fn critical_error_at(&self, now: Duration) -> Option<TxManagerError> {
self.critical_error_with(Some(now))
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.

The no-arg critical_error() will silently miss an expired MempoolDeadline::Runtime deadline because runtime_now is None. Currently safe since all production call sites use critical_error_at(), but this is a latent footgun — a future caller using the simpler method would get silent deadline misses.

Consider either:

  • Documenting on critical_error() that it only checks WallClock deadlines, or
  • Deprecating critical_error() and requiring all callers to pass a timestamp, or
  • Having critical_error() panic/warn if a Runtime deadline is set (fail-fast rather than silent miss).

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

Review Summary

The PR correctly abstracts tokio::time and CancellationToken usage behind base-runtime traits across the tx-manager, safe-head poller, and L1 hybrid source, enabling deterministic virtual-time testing. The new tests cover priority ordering, cancellation, timeout, and polling behaviors well.

Findings

  1. spawn_with_runtime is unused (safe_head_poller.rs:88-92) — declared pub but never called. Should be gated or documented.

  2. critical_error() silently ignores Runtime deadlines (send_state.rs:146-154) — The MempoolDeadline enum split into Runtime(Duration) / WallClock(Instant) creates a latent correctness risk: the no-arg critical_error() passes None as runtime_now, so a Runtime deadline will never fire through that path. Currently safe since production uses critical_error_at(), but this is a footgun for future callers.

No blocking issues found. The runtime abstraction is well-structured, the delegation pattern (wait_minedwait_mined_with_runtime, query_receiptquery_receipt_with_runtime) preserves backward compatibility, and the tokio::select! { biased; } patterns correctly prioritize cancellation and completion over timers.

Base automatically changed from rf/test/add-deterministic-runtime-coverage to main May 5, 2026 01:53
@cb-heimdall
Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

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

Labels

tooling Area: tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants