Open barakman opened 1 year ago
@barakman could you please confirm with a different framework? The viaIR
in Hardhat is a bit flaky at times, especially with revert messages.
This looks like https://github.com/NomicFoundation/hardhat/issues/2453 and https://github.com/NomicFoundation/hardhat/issues/3750. See especially https://github.com/NomicFoundation/hardhat/issues/3750#issuecomment-1462483527.
The tl;dr is that you should be running your tests with optimizer disabled if you need Hardhat to properly detect revert reasons when using viaIR: true
. It's because Hardhat uses heuristics to detect those reasons and they're not reliable with optimized code generated by the the IR pipeline.
Not sure about other frameworks but I would not be suprised if they either have similar limitations or just don't support checking revert reasons. This will only really be solved properly when we get the ethdebug format specified and implemented in the compiler so that debuggers and frameworks can stop relying on heuristics.
We managed to avoid a similar problem when calling populateTransaction
: https://github.com/1inch/limit-order-protocol/blob/master/test/RangeAmountCalculator.js#L23
hardhat 2.14.0 / @nomiclabs/hardhat-ethers
Before using populateTransaction
we had received "without reason" error too.
Description
Calling a function which takes no input arguments, under a scenario in which the function should revert with a message:
viaIR = false
, the function reverts with the expected messageviaIR = true
, the function reverts with a different messageEnvironment
I have tested this problem separately with hardhat versions 2.12.7 and 2.14.0. The reproduction below uses the 'truffle5' plugin, but it also works without it.
Steps to Reproduce
Outcome:
Strangely enough, adding a
console.log
inside the contract function solves the problem.This is possibly a HardHat issue, so I shall post it there too.
Please find the project configuration below.
File package.json:
File hardhat.config.js:
Thanks :)