Skip to content

Mining semantics contract drift: interval empty blocks and explicit intervalSeconds handling #40

Description

@roninjin10

Summary

Trusted mining behavior diverges from the contract in three places:

  1. Interval mining does not produce empty blocks when no tx is pending.
  2. Explicit mine calls ignore the second intervalSeconds argument.
  3. Interval-mining setter treats input as milliseconds and rounds, while contract defines seconds.

Why this matters

Mining cadence and timestamp progression semantics are part of the public contract and directly affect tests, replay determinism, and tooling behavior.

Normative contract

  • docs/specs/json-rpc-contract.md:866-868 interval mode should produce empty blocks when idle.
  • docs/specs/json-rpc-contract.md:876-879 explicit mine supports [count, intervalSeconds].
  • docs/specs/json-rpc-contract.md:749 zevm_setIntervalMining parameter is seconds.

Evidence

Interval loop exits when pool is empty:

  • src/rpc/node_handler.zig:1148-1150
if (self.node_runtime.pool.pendingCount() == 0) {
    return;
}

Explicit mine only parses first arg (count) and ignores second arg:

  • src/rpc/node_handler.zig:439-443
const count = parseOptionalFirstU64(params, 1) ...
while (i < count) {
    ...
}

Interval setter converts provided value as milliseconds to seconds:

  • src/rpc/node_handler.zig:402-410
const interval_millis = parseOptionalFirstU64(params, 0) ...
const interval_seconds = @max(@as(u64, 1), (interval_millis + 999) / 1000);

Suggested scope

  • Remove pending-pool gate in interval loop so empty ticks can seal empty blocks.
  • Parse and apply explicit mine second arg (intervalSeconds) for per-call timestamp stepping.
  • Align interval setter units with contract seconds semantics.
  • Add end-to-end tests for:
    • interval mode empty-block production,
    • multi-block explicit mine with timestamp increments,
    • unit-correct interval configuration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions