solidity-coverage: Overridden gas price does not work in London fork

https://github.com/sc-forks/solidity-coverage/blob/3c0f3a5c7db26e82974873bbf61cf462072a7c6d/lib/api.js#L55

Solidity-coverage overrides gasPrice and sets it to 1 wei. This behaviour was acceptable before London hardfork but now coverage fails with Transaction gasPrice (1) is too low for the next block, which has a baseFeePerGas of 73433802882

I understand the reasoning behind overriding gas and blockGasLimit, but I think gasPrice should not be overridden anymore.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 20
  • Comments: 17 (8 by maintainers)

Commits related to this issue

Most upvoted comments

One possible workaround would be to use set the initial base fee per gas to 0.

networks: {
    hardhat: {
      initialBaseFeePerGas: 0
    }
  }

There’s a small chance of this not working, but I think it’d work in most of the cases.

Hey @cgewecke! Sorry to tag you, but this seems to be an urgent issue. Any chance you could remove the this.gasPrice = 0x01 line and ship a fixed version of solidity-coverage?

We’d all be very grateful.

This is patched with @alcuadrado’s initialBaseFee fix (comment above) in 0.7.17. (Thank you!!!)

(Closing for the moment … might need to revisit this I guess)

There’s a small chance of this not working, but I think it’d work in most of the cases.

I should have given more info here. This may not work because sendings txs that use more than 50% of the block gas limit would result in the next block having a larger base fee. Most the time, given the math of eip1559, this would still result in the next base fee being 0 or 1. But if this happens for a few blocks in a row, it may result in base fees greater than 1, and the og problem will happen.

Actually, I’m going to leave this open for a bit so it’s easy to find because it’s so gnarly.

Another workaround is to set an environment variable as a flag and regress to the berlin hardfork in your Hardhat Network configuration when that flag is set. E.g. how I do it in my solidity-template:

hardhat: {
  hardfork: process.env.CODE_COVERAGE ? "berlin" : "london",
}

Of course, this is not great, because running test coverage on different EVMs might produce different results. But it’s good enough as a temporary solution.

@pedroyan Still need to investigate this a bit - have opened it as a separate issue and will track in #707. Thanks for the repro, perfect!

@pedroyan I see OpenZeppelin’s coverage passing in CI (they are on 2.9.1) and aren’t setting the base fee in their config: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/3fb25b604bda2af48bab75b8d9179b8ed3b7b87c/hardhat.config.js#L70

And our tests are passing on 2.9.3 in #706. If you have a way to repro this will reopen though.

@pedroyan To be clear you seeing an error that specifically mentions the gas price and the baseFeePerGas? Something like:

Transaction gasPrice (1) is too low for the next block, which has a baseFeePerGas

@pedroyan This is now being done automatically as well and the tool works with the London HF without additional config. Is it possible it’s being reset somewhere else in your code?