Skip to content

Add verbosity for all hh tasks#7983

Merged
ChristopherDedominici merged 15 commits intomainfrom
edr-upgrade-25
Mar 30, 2026
Merged

Add verbosity for all hh tasks#7983
ChristopherDedominici merged 15 commits intomainfrom
edr-upgrade-25

Conversation

@ChristopherDedominici
Copy link
Copy Markdown
Contributor

@ChristopherDedominici ChristopherDedominici commented Feb 20, 2026

This PR implements part of the changes of this PR. See the PR for more details on the changes related to EDR.

Changes

It also implements this issue, as verbosity is now a global flag covering all Hardhat logic, and the scope is no longer limited to Solidity tests, but to all tasks that interact with EDR.

Links to website docs

PR: NomicFoundation/hardhat-website#225

How to use

Use -v to control the level of detail in Hardhat's output. Stack multiple vs to increase verbosity.

Levels

Flag Level Effect
(none) 0-2 No call traces (level 2 is the default: shows logs)
-vvv 3 Execution traces for failing tests only
-vvvv 4 Execution traces for all tests + setUp traces for failing tests
-vvvvv 5 All traces (execution + setUp) for all tests

For non-test tasks (hardhat run, hardhat ignition deploy, etc.):

Flag Level Effect
(none) 0-2 No call traces
-vvv 3 Call traces for failing transactions only
-vvvv / -vvvvv 4-5 All call traces

Usage

The flag works with any Hardhat command:

# Tests
pnpm hardhat test -vvv
pnpm hardhat test solidity -vvvvv
pnpm hardhat test mocha -vvv

# Scripts
pnpm hardhat run scripts/deploy.ts -vvvvv

# Ignition
pnpm hardhat ignition deploy ignition/modules/MyModule.ts -vvv

You can also use the long form: --verbosity 3.

Output examples

Examples for the same solidity tests:

  • no verbosity:
image
  • verbosity 3 (failing traces only):
image
  • verbosity 4 (traces for all tests + setUp for failures):
image
  • verbosity 5 (all traces including setUp):
image

Verbosity Manual Tests Scenarios

All commands run from v-next/example-project/.

Solidity tests

pnpm hardhat test solidity
pnpm hardhat test solidity -vvv
pnpm hardhat test solidity -vvvv
pnpm hardhat test solidity -vvvvv
pnpm hardhat test solidity contracts/Counter.t.sol
pnpm hardhat test solidity contracts/Counter.t.sol -vvv
pnpm hardhat test solidity contracts/Counter.t.sol -vvvv
pnpm hardhat test solidity contracts/Counter.t.sol -vvvvv

Mocha tests

pnpm hardhat test mocha
pnpm hardhat test mocha -vvv
pnpm hardhat test mocha -vvvv
pnpm hardhat test mocha -vvvvv
pnpm hardhat test mocha test/mocha/mocha-test.ts -vvv
pnpm hardhat test mocha test/mocha/mocha-test.ts -vvvvv

Node.js tests

pnpm hardhat test nodejs
pnpm hardhat test nodejs -vvv
pnpm hardhat test nodejs -vvvv
pnpm hardhat test nodejs -vvvvv
pnpm hardhat test nodejs test/node/example-test.ts -vvv
pnpm hardhat test nodejs test/node/example-test.ts -vvvvv

All runners combined

pnpm hardhat test
pnpm hardhat test -vvv
pnpm hardhat test -vvvv
pnpm hardhat test -vvvvv
pnpm hardhat test test/node/other-example-test.js -vvv

Non-test: scripts

pnpm hardhat run scripts/deploy-rocket-from-script.ts
pnpm hardhat run scripts/deploy-rocket-from-script.ts -vvv
pnpm hardhat run scripts/deploy-rocket-from-script.ts -vvvv
pnpm hardhat run scripts/deploy-rocket-from-script.ts -vvvvv

Non-test: ignition deploy

pnpm hardhat ignition deploy ignition/modules/Apollo.ts
pnpm hardhat ignition deploy ignition/modules/Apollo.ts -vvv
pnpm hardhat ignition deploy ignition/modules/Apollo.ts -vvvvv

Non-test: tasks

pnpm hardhat accounts
pnpm hardhat accounts -vvv

@ChristopherDedominici ChristopherDedominici self-assigned this Feb 20, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 20, 2026

🦋 Changeset detected

Latest commit: 96b785c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@nomicfoundation/hardhat-utils Patch
hardhat Patch

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 20, 2026

hardhat

Total size of the bundle: 246M
Total number of dependencies (including transitive): 48

List of dependencies (sorted by size)
239M	total
37M	@nomicfoundation/edr-linux-x64-musl
37M	@nomicfoundation/edr-linux-x64-gnu
34M	@nomicfoundation/edr-linux-arm64-musl
34M	@nomicfoundation/edr-linux-arm64-gnu
25M	@nomicfoundation/edr-win32-x64-msvc
25M	@nomicfoundation/edr-darwin-x64
21M	@nomicfoundation/edr-darwin-arm64
7.3M	@sentry/core
5.2M	zod
2.7M	micro-eth-signer
1.9M	@noble/curves
1.7M	undici
1.2M	@noble/hashes
1.1M	@nomicfoundation/hardhat-utils
884K	@nomicfoundation/hardhat-vendored
864K	@streamparser/json
624K	micro-packed
592K	tsx
556K	@nomicfoundation/hardhat-errors
492K	@scure/bip39
476K	@nomicfoundation/edr
408K	json-stream-stringify
368K	ethereum-cryptography
344K	fast-equals
332K	@streamparser/json-node
320K	enquirer
320K	@nomicfoundation/hardhat-zod-utils
288K	semver
200K	ws
180K	chokidar
176K	get-tsconfig
168K	@scure/base
160K	esbuild
136K	adm-zip
96K	@scure/bip32
92K	chalk
72K	@nomicfoundation/solidity-analyzer
68K	debug
60K	readdirp
56K	rfdc
48K	ansi-colors
44K	resolve.exports
40K	resolve-pkg-maps
36K	p-map
24K	strip-ansi
24K	env-paths
24K	ansi-regex
20K	ms

@@ -0,0 +1,203 @@
import type { Colorizer } from "../../../../utils/colorizer.js";
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These functions have been moved from hardhat/src/internal/builtin-plugins/solidity-test/formatters.ts, except for verbosityToIncludeTraces, which is a newly added function.

);
}

function formatInputs(
Copy link
Copy Markdown
Contributor Author

@ChristopherDedominici ChristopherDedominici Feb 20, 2026

Choose a reason for hiding this comment

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

These functions starting from this one have been moved to v-next/hardhat/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.ts because this logic is no longer limited to solidity tests

return `${sourceName}:${artifactId.name}`;
}

export function formatLogs(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed as it is not used anywhere

import { bytesToHexString } from "@nomicfoundation/hardhat-utils/hex";
import chalk from "chalk";

export interface Colorizer {
Copy link
Copy Markdown
Contributor Author

@ChristopherDedominici ChristopherDedominici Feb 20, 2026

Choose a reason for hiding this comment

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

moved to file v-next/hardhat/src/internal/utils/colorizer.ts because this logic is no longer limited to solidity tests

task(["task4"]).addLevel({
name: "verbosity",
shortName: "v",
name: "logLevel",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

verbosity custom param used in these tests clashes with the ne added global flag verbosity, so I replaced the custom param with logLevel

failed: false,
gas: 21000,
returnValue: "",
returnValue: "0x",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Before hardhat used edrRpcDebugTraceToHardhat that was converting to "", now we use EDR response directly

@ChristopherDedominici ChristopherDedominici linked an issue Feb 20, 2026 that may be closed by this pull request
1 task
@alcuadrado
Copy link
Copy Markdown
Member

@ChristopherDedominici can you add an explanation about how this works from the user POV? When are the traces printed? How? Some screenshots would also help. Thanks!

Copilot AI review requested due to automatic review settings March 12, 2026 09:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new global --verbosity/-v level that controls trace output across Hardhat tasks that interact with EDR, and wires that verbosity into both Solidity test output and the EDR-backed network provider (including upgrading to EDR’s new call trace plumbing).

Changes:

  • Add verbosity as a built-in global option and propagate it through HRE/network initialization.
  • Centralize trace formatting + verbosity→trace-inclusion mapping under the network-manager EDR utilities, and update Solidity test reporter/helpers accordingly.
  • Enable provider-side call trace collection/printing by passing includeCallTraces into EDR provider config based on global verbosity.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
v-next/hardhat/src/internal/builtin-global-options.ts Adds global verbosity level option (-v/--verbosity) with default.
v-next/hardhat/src/types/global-options.ts Extends GlobalOptions with verbosity: number.
v-next/hardhat/src/internal/utils/colorizer.ts Introduces shared Colorizer interface for trace formatting/reporting.
v-next/hardhat/src/internal/builtin-plugins/network-manager/network-manager.ts Threads verbosity into network manager and maps it to includeCallTraces.
v-next/hardhat/src/internal/builtin-plugins/network-manager/hook-handlers/hre.ts Passes hre.globalOptions.verbosity into NetworkManagerImplementation.
v-next/hardhat/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.ts New shared formatTraces + verbosityToIncludeTraces.
v-next/hardhat/src/internal/builtin-plugins/network-manager/edr/edr-provider.ts Adds includeCallTraces to provider config and prints call traces from responses.
v-next/hardhat/src/internal/builtin-plugins/solidity-test/helpers.ts Uses shared verbosity→IncludeTraces mapping.
v-next/hardhat/src/internal/builtin-plugins/solidity-test/reporter.ts Imports shared formatTraces and updates trace printing thresholds.
v-next/hardhat/src/internal/builtin-plugins/solidity-test/task-action.ts Reads verbosity from hre.globalOptions instead of task args.
v-next/hardhat/src/internal/builtin-plugins/test/index.ts Removes per-task verbosity level (now global).
v-next/hardhat/src/internal/builtin-plugins/test/task-action.ts Stops forwarding task-level verbosity option (now global).
v-next/hardhat-utils/src/env.ts Allows numeric global options to be set as env vars.
v-next/hardhat/test/internal/hre-initialization.ts Updates expected resolved global options to include verbosity.
v-next/hardhat/test/internal/cli/main.ts Updates CLI help expectations + avoids name collision by renaming a test level arg.
v-next/hardhat/test/internal/cli/help/get-global-help-string.ts Updates global help string expectations to include verbosity.
v-next/hardhat/test/internal/builtin-plugins/solidity-test/helpers.ts Updates IncludeTraces expectations for new verbosity thresholds.
v-next/hardhat/test/internal/builtin-plugins/network-manager/network-manager.ts Updates NetworkManager tests for the new verbosity constructor param.
v-next/hardhat/test/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.ts Updates/extends tests for shared trace utilities.
.changeset/cyan-drinks-beg.md Changeset entry announcing global verbosity support.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +326 to +338
#outputCallTraces(edrResponse: Response): void {
try {
const callTraces = edrResponse.callTraces();

if (callTraces.length > 0) {
const formatted = formatTraces(callTraces, " ", chalk);
this.#printLineFn(" Call Traces:");
this.#printLineFn(formatted);
}
} catch (e) {
log("Failed to get call traces: %O", e);
}
}
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

#handleEdrResponse calls #outputCallTraces for every JSON-RPC response, and #outputCallTraces always calls edrResponse.callTraces(). Consider storing the configured includeCallTraces on the provider instance and returning early when it’s IncludeTraces.None/undefined to avoid unnecessary per-request work (and potential debug spam if callTraces() throws when disabled).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This piece of feedback is valuable, for performance reasons. So that we don't call callTraces if not needed, which goes through the FFI barrier.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ChristopherDedominici ChristopherDedominici changed the title Add verbosity for all hh tasks + upgrade to edr v0.12.0-next.25 Add verbosity for all hh tasks Mar 16, 2026
Copy link
Copy Markdown
Member

@alcuadrado alcuadrado left a comment

Choose a reason for hiding this comment

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

"hardhat": patch
---

Added `-v` verbosity support for all tasks ([7983](https://github.com/NomicFoundation/hardhat/pull/7983)), ([7963](https://github.com/NomicFoundation/hardhat/issues/7963)).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Added `-v` verbosity support for all tasks ([7983](https://github.com/NomicFoundation/hardhat/pull/7983)), ([7963](https://github.com/NomicFoundation/hardhat/issues/7963)).
Added `--verbosity` (and `-v`, `-vv`, and the other shorthands) to all tasks, including TypeScript tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done here (I kept the links): 7a9a64c

@alcuadrado
Copy link
Copy Markdown
Member

Actually, this comment can be better address in the second PR

Copilot AI review requested due to automatic review settings March 30, 2026 10:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings March 30, 2026 11:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated no new comments.

@ChristopherDedominici ChristopherDedominici added this pull request to the merge queue Mar 30, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 30, 2026
@ChristopherDedominici ChristopherDedominici added this pull request to the merge queue Mar 30, 2026
Merged via the queue into main with commit d5f59f7 Mar 30, 2026
258 checks passed
@ChristopherDedominici ChristopherDedominici deleted the edr-upgrade-25 branch March 30, 2026 16:26
@github-project-automation github-project-automation bot moved this from In Review to Done in Hardhat Mar 30, 2026
@github-actions github-actions bot mentioned this pull request Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add support for -vvvv in JS/TS tests

4 participants