Given a modifier:
modifier yetNotCalculated() {
require(calculated == false);
_;
}
and then using it in my function:
function calculateResult() public yetNotCalculated {
calculate();
calculated = true;
}
When the modifier rejects further processing (calculated
is set to true
), it consumes all my gas :( ! is this a desired behaviour ?
Here I am invoking that function using web3 library, and that what I get as receipt:
{ blockHash: '0xc8219ac506e4020f61e199126d8b578c8d8219222286d684661415593c251495',
blockNumber: 12476,
contractAddress: null,
cumulativeGasUsed: 2100000,
from: '0xe6cb4d38ae1f3458f5095652a68b304b3aa7f82c',
gasUsed: 2100000,
logs: [],
logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
root: '0x6047a5fe941496e089cf73e0c2cbd7db1608794bac0a73368fcfcd34833a1aef',
to: '0xf8b8741024621ee0936bafac55ff544421d7924b',
transactionHash: '0xf8b40eeb956b425fc4cfadec1c1cc2a479addbc635c74fb6000945fedd41696a',
transactionIndex: 0 }
as you can see 2100000 gas was used which is my gas limit. why is that :) ? Thanks
require(false);
. See stackoverflow.com/a/48085107/2318492 – Lauri Peltonen Mar 14 '18 at 10:40