Hi!
Based on this article at Solidity blog about Custom Errors, I’ve understood that this recent Solidity feature Custom Errors would behavior in the same way as a failed condition in require
statement, since it says:
require(condition, “error message”) should be translated to if (!condition) revert CustomError().
However, as you can see in this verified contract on Goerli: https://goerli.etherscan.io/address/0xa69ff680173d7317a2bb482b2d00ca99323e01d5, which has the following three very simular functions, the testFailRevert gas cost is systematically higher than the other two functions.
Is there any explanation about it?
Thanks a lot!
function testFailRequire() external {
for (uint256 i = 0; i < 100; i++) {
greeting = "consome gas";
}
require(false);
}
function testFailRevert() external {
for (uint256 i = 0; i < 100; i++) {
greeting = "consome gas";
}
revert UnevitactableError();
}
function testFailAssert() external {
for (uint256 i = 0; i < 100; i++) {
greeting = "consome gas";
}
assert(false);
}