Skip to content

Commit 4ac1707

Browse files
authored
Fix default tx gas limit after osaka (#916)
1 parent 485fb69 commit 4ac1707

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

lib/api.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const path = require('path');
55
const istanbul = require('sc-istanbul');
66
const assert = require('assert');
77
const _ = require('lodash/lang');
8+
const { hardforkGte, HardforkName } = require('hardhat/internal/util/hardforks');
89

910
const ConfigValidator = require('./validator');
1011
const Instrumenter = require('./instrumenter');
@@ -17,7 +18,7 @@ const AbiUtils = require('./abi');
1718
* Coverage Runner
1819
*/
1920
class API {
20-
constructor(config={}) {
21+
constructor(config={}, hardfork) {
2122
this.validator = new ConfigValidator();
2223
this.abiUtils = new AbiUtils();
2324
this.config = config || {};
@@ -47,8 +48,11 @@ class API {
4748
this.skipFiles = config.skipFiles || [];
4849

4950
this.log = config.log || console.log;
50-
this.gasLimit = 0xffffffffff // default "gas sent" with transactions
51-
this.gasLimitNumber = 0x1fffffffffffff; // block gas limit for Hardhat
51+
const isEip7825Enabled = hardfork !== undefined && HardforkName.OSAKA !== undefined
52+
? hardforkGte(hardfork, HardforkName.OSAKA)
53+
: false;
54+
this.gasLimit = isEip7825Enabled ? 2 ** 24 : 0xffffffffff // default "gas sent" with transactions
55+
this.gasLimitNumber = 0x1fffffffffffff; // block gas limit for Hardhat
5256
this.gasPrice = 0x01;
5357

5458
this.istanbulFolder = config.istanbulFolder || false;

plugins/hardhat.plugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extendConfig((config, userConfig) => {
2727
if (Boolean(process.env.SOLIDITY_COVERAGE)) {
2828
const { configureHardhatEVMGas } = require('./resources/nomiclabs.utils');
2929
const API = require('./../lib/api');
30-
const api = new API({});
30+
const api = new API({}, config.networks.hardhat.hardfork);
3131

3232
const hardhatNetworkForCoverage = {};
3333
configureHardhatEVMGas(hardhatNetworkForCoverage, api);
@@ -150,7 +150,7 @@ task("coverage", "Generates a code coverage report for tests")
150150
try {
151151
config = nomiclabsUtils.normalizeConfig(env.config, args);
152152
ui = new PluginUI(config.logger.log);
153-
api = new API(utils.loadSolcoverJS(config));
153+
api = new API(utils.loadSolcoverJS(config), config.networks.hardhat.hardfork);
154154

155155
optimizerDetails = api.solcOptimizerDetails;
156156
irMinimum = api.irMinimum;

0 commit comments

Comments
 (0)