Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run gas report and coverage in e2e #4961

Merged
merged 2 commits into from
Apr 8, 2024
Merged

Run gas report and coverage in e2e #4961

merged 2 commits into from
Apr 8, 2024

Conversation

fvictorio
Copy link
Member

The e2e workflow should fail with this change. For some reason, npx hardhat coverage doesn't work with the viem-based sample project. As part of this PR, we should fix that.

Copy link

changeset-bot bot commented Mar 5, 2024

⚠️ No Changeset found

Latest commit: aab0a48

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Mar 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hardhat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 8, 2024 1:35pm

@github-actions github-actions bot added the status:ready This issue is ready to be worked on label Mar 5, 2024
@fvictorio fvictorio requested a review from schaable March 5, 2024 15:03
@cgewecke
Copy link
Contributor

cgewecke commented Mar 5, 2024

Hi @schaable, @ChristopherDedominici

Just leaving a few notes b/c I looked at this recently. The gas reporter is also broken for viem but that problem will be resolved in the next major version which is adding necessary logic and migrating to the new extendProvider hook. (Should be published soon).

I'm not certain but for coverage I think the issue might come from a conflict caused by:

Coverage needs to initialize the VM to certain values - would like to do this in an extendConfig hook to minimize conflicts but that should only happen for the coverage task and it doesn't look like there's a way to know what command has been called from there. Would it be possible to pass TASK context info to the hook? e.g

extendConfig((config: HardhatConfig, userConfig: Readonly<HardhatUserConfig>, [...here...])

cf: solidity-coverage issue 819

@cgewecke
Copy link
Contributor

Update: The gas reporter issues with viem are fixed in the latest release there:

https://github.com/cgewecke/hardhat-gas-reporter/releases/tag/v2.0.0

The problems with solidity-coverage will require some kind of fix here I think....or possibly both places. Just lmk.

@cgewecke
Copy link
Contributor

Another note...I think if the viem plugin followed the same strategy as the ethers plugin and passed hre instead of provider the conflict with solidity-coverage would be resolved

See...

return {
...ethers,
provider,
getSigner: (address: string) => getSigner(hre, address),
getSigners: () => getSigners(hre),
getImpersonatedSigner: (address: string) =>
getImpersonatedSigner(hre, address),
// We cast to any here as we hit a limitation of Function#bind and
// overloads. See: https://github.com/microsoft/TypeScript/issues/28582
getContractFactory: getContractFactory.bind(null, hre) as any,
getContractFactoryFromArtifact: (...args) =>
getContractFactoryFromArtifact(hre, ...args),
getContractAt: (...args) => getContractAt(hre, ...args),
getContractAtFromArtifact: (...args) =>
getContractAtFromArtifact(hre, ...args),
deployContract: deployContract.bind(null, hre) as any,
};
});

@cgewecke
Copy link
Contributor

cgewecke commented Apr 5, 2024

Another update...

In the latest version of solidity-coverage (v0.8.12) there is a work-around for viem. Coverage will configure the provider via extendConfig (side-stepping the conflict describe above) if the environment variable SOLIDITY_COVERAGE is set to true, e.g

SOLIDITY_COVERAGE=true npx hardhat coverage

If coverage detects viem on the hardhat environment without this env variable set, it now throws the advisory error below:

Screen Shot 2024-04-05 at 1 41 43 PM

@ChristopherDedominici ChristopherDedominici added the no changeset needed This PR doesn't require a changeset label Apr 8, 2024
@kanej kanej merged commit 279764a into main Apr 8, 2024
30 checks passed
@kanej kanej deleted the e2e-coverage-and-gas-report branch April 8, 2024 15:53
fritx added a commit to fritx/mixed-playground that referenced this pull request Apr 10, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
no changeset needed This PR doesn't require a changeset status:ready This issue is ready to be worked on
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants