fix: don't reject a mining interval of 0, which disables interval mining - #8486
Open
Kropiunig wants to merge 1 commit into
Open
fix: don't reject a mining interval of 0, which disables interval mining#8486Kropiunig wants to merge 1 commit into
Kropiunig wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 2ccd059 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes EDR simulated-network config validation so that mining.interval: 0 (the sentinel that disables interval mining and is also the resolved default) no longer triggers the “< 1000 ms” timestamp-divergence validation error.
Changes:
- Updated EDR network config refinement to skip the minimum-interval check for scalar
interval === 0while keeping interval-range validation unchanged. - Added regression tests covering
interval: 0(accepted) and[0, 5000](still rejected whenallowBlocksWithSameTimestampis false). - Added a changeset to release the fix as a patch.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/hardhat/src/internal/builtin-plugins/network-manager/type-validation.ts | Adjusts interval validation to treat scalar 0 as “interval mining disabled,” skipping the < 1000 ms guard. |
| packages/hardhat/test/internal/builtin-plugins/network-manager/hook-handlers/config.ts | Adds test coverage for interval: 0 acceptance and preserves errors for interval ranges with a minimum below 1000. |
| .changeset/edr-mining-interval-zero.md | Documents the patch release for the validation behavior change. |
Comment on lines
619
to
622
| // // Interval range with min >= 1000, allowBlocksWithSameTimestamp = false, no error | ||
| validationErrors = await validateNetworkUserConfig( | ||
| makeConfig([1000, 1000], true), | ||
| ); |
kanej
self-requested a review
August 4, 2026 09:10
The EDR network config validation rejects any `mining.interval` below 1000 ms unless `allowBlocksWithSameTimestamp` is set, to keep block timestamps from diverging from clock time (NomicFoundation#6012). A scalar `interval: 0` doesn't schedule any blocks at all though: it's how interval mining is turned off (see `hardhatMiningIntervalToEdrMiningInterval`), and it's the value the config resolution defaults to. Writing it explicitly, as in `mining: { auto: false, interval: 0 }`, made Hardhat fail to load the config with a message about timestamps that can't apply. An interval range still enables interval mining, so `[0, 5000]` remains an error.
Kropiunig
force-pushed
the
fix/edr-mining-interval-zero
branch
from
August 7, 2026 12:23
fb88891 to
2ccd059
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The EDR network config validation rejects any
mining.intervalbelow 1000 msunless
allowBlocksWithSameTimestamp: trueis also set. That check exists tostop block timestamps from running ahead of clock time (#6012).
A scalar
interval: 0does not schedule blocks at all, so it can't cause thatdivergence. It is how interval mining is turned off — and it is the value the
config resolution already defaults to. Writing it explicitly makes Hardhat
refuse to load the config:
The suggested workaround (
allowBlocksWithSameTimestamp: true) changesunrelated behaviour, and the message describes a risk that cannot occur when no
blocks are mined on a timer.
Root cause
refineEdrNetworkUserConfiginpackages/hardhat/src/internal/builtin-plugins/network-manager/type-validation.tsruns the minimum-interval check for every numeric interval, including
0:But
0is the "interval mining disabled" sentinel elsewhere in the sameplugin:
hardhatMiningIntervalToEdrMiningInterval(
edr/utils/convert-to-edr.ts) maps a scalar0toundefinedwith thecomment
// Is interval mining disabled?.resolveMiningConfig(config-resolution.ts) resolves the default tointerval: 0, and the existing default-config test assertsmining === { auto: true, interval: 0, mempool: { order: "priority" } }.So the validation rejects a value the resolver produces by default.
Fix
Skip the check only for a scalar
0. An interval range always enablesinterval mining, so
[0, 5000]is still an error.Tests
Added to
packages/hardhat/test/internal/builtin-plugins/network-manager/hook-handlers/config.ts:interval: 0withallowBlocksWithSameTimestamp: false→ no validation errors.mining: { auto: false, interval: 0 }→ no validation errors.interval: [0, 5000]→ still errors (ranges are unaffected).Both new assertions fail on
main(1 validation error where 0 is expected) andpass with this change.