hardhat 2.17.0 → 2.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/builtin-tasks/compile.js +28 -4
- package/builtin-tasks/compile.js.map +1 -1
- package/builtin-tasks/flatten.js +131 -5
- package/builtin-tasks/flatten.js.map +1 -1
- package/builtin-tasks/task-names.d.ts +2 -0
- package/builtin-tasks/task-names.d.ts.map +1 -1
- package/builtin-tasks/task-names.js +4 -2
- package/builtin-tasks/task-names.js.map +1 -1
- package/builtin-tasks/utils/solidity-files-cache.js +3 -3
- package/builtin-tasks/utils/solidity-files-cache.js.map +1 -1
- package/builtin-tasks/utils/watch.d.ts +1 -1
- package/builtin-tasks/utils/watch.d.ts.map +1 -1
- package/console.sol +1192 -1171
- package/internal/artifacts.d.ts +28 -0
- package/internal/artifacts.d.ts.map +1 -1
- package/internal/artifacts.js +39 -1
- package/internal/artifacts.js.map +1 -1
- package/internal/cli/ArgumentsParser.js +1 -1
- package/internal/cli/ArgumentsParser.js.map +1 -1
- package/internal/cli/analytics.d.ts +1 -1
- package/internal/cli/analytics.d.ts.map +1 -1
- package/internal/cli/analytics.js +4 -5
- package/internal/cli/analytics.js.map +1 -1
- package/internal/cli/project-creation.js +1 -1
- package/internal/cli/types.d.ts +1 -1
- package/internal/cli/types.d.ts.map +1 -1
- package/internal/context.d.ts +1 -1
- package/internal/context.d.ts.map +1 -1
- package/internal/core/errors-list.d.ts +28 -0
- package/internal/core/errors-list.d.ts.map +1 -1
- package/internal/core/errors-list.js +34 -0
- package/internal/core/errors-list.js.map +1 -1
- package/internal/core/errors.js +17 -17
- package/internal/core/errors.js.map +1 -1
- package/internal/core/jsonrpc/types/access-list.d.ts +2 -2
- package/internal/core/jsonrpc/types/access-list.d.ts.map +1 -1
- package/internal/core/jsonrpc/types/base-types.d.ts +1 -0
- package/internal/core/jsonrpc/types/base-types.d.ts.map +1 -1
- package/internal/core/jsonrpc/types/base-types.js +8 -1
- package/internal/core/jsonrpc/types/base-types.js.map +1 -1
- package/internal/core/jsonrpc/types/input/blockTag.d.ts +4 -4
- package/internal/core/jsonrpc/types/input/blockTag.d.ts.map +1 -1
- package/internal/core/jsonrpc/types/input/callRequest.d.ts +61 -1
- package/internal/core/jsonrpc/types/input/callRequest.d.ts.map +1 -1
- package/internal/core/jsonrpc/types/input/callRequest.js +13 -1
- package/internal/core/jsonrpc/types/input/callRequest.js.map +1 -1
- package/internal/core/jsonrpc/types/input/debugTraceTransaction.d.ts +3 -1
- package/internal/core/jsonrpc/types/input/debugTraceTransaction.d.ts.map +1 -1
- package/internal/core/jsonrpc/types/input/debugTraceTransaction.js +1 -0
- package/internal/core/jsonrpc/types/input/debugTraceTransaction.js.map +1 -1
- package/internal/core/jsonrpc/types/input/filterRequest.d.ts +2 -2
- package/internal/core/jsonrpc/types/input/filterRequest.d.ts.map +1 -1
- package/internal/core/jsonrpc/types/input/hardhat-network.d.ts +3 -3
- package/internal/core/jsonrpc/types/input/hardhat-network.d.ts.map +1 -1
- package/internal/core/jsonrpc/types/input/logAddress.d.ts +2 -2
- package/internal/core/jsonrpc/types/input/logAddress.d.ts.map +1 -1
- package/internal/core/jsonrpc/types/input/logTopics.d.ts +2 -2
- package/internal/core/jsonrpc/types/input/logTopics.d.ts.map +1 -1
- package/internal/core/jsonrpc/types/input/solc.d.ts +2 -2
- package/internal/core/jsonrpc/types/input/solc.d.ts.map +1 -1
- package/internal/core/jsonrpc/types/input/subscribeRequest.d.ts +1 -1
- package/internal/core/jsonrpc/types/input/subscribeRequest.d.ts.map +1 -1
- package/internal/core/jsonrpc/types/input/transactionRequest.d.ts +1 -1
- package/internal/core/jsonrpc/types/input/transactionRequest.d.ts.map +1 -1
- package/internal/core/jsonrpc/types/output/block.d.ts +2 -2
- package/internal/core/jsonrpc/types/output/block.d.ts.map +1 -1
- package/internal/core/jsonrpc/types/output/log.d.ts +1 -1
- package/internal/core/jsonrpc/types/output/log.d.ts.map +1 -1
- package/internal/core/jsonrpc/types/output/receipt.d.ts +1 -1
- package/internal/core/jsonrpc/types/output/receipt.d.ts.map +1 -1
- package/internal/core/jsonrpc/types/output/transaction.d.ts +1 -1
- package/internal/core/jsonrpc/types/output/transaction.d.ts.map +1 -1
- package/internal/core/providers/construction.d.ts.map +1 -1
- package/internal/core/providers/construction.js +1 -0
- package/internal/core/providers/construction.js.map +1 -1
- package/internal/core/providers/errors.js +12 -12
- package/internal/core/providers/errors.js.map +1 -1
- package/internal/core/providers/gas-providers.js +1 -1
- package/internal/core/providers/gas-providers.js.map +1 -1
- package/internal/core/providers/http.d.ts.map +1 -1
- package/internal/core/providers/http.js +5 -3
- package/internal/core/providers/http.js.map +1 -1
- package/internal/core/providers/lazy-initialization.d.ts +2 -2
- package/internal/core/providers/lazy-initialization.d.ts.map +1 -1
- package/internal/core/runtime-environment.js +1 -1
- package/internal/core/runtime-environment.js.map +1 -1
- package/internal/core/tasks/task-definitions.js +3 -3
- package/internal/core/tasks/task-definitions.js.map +1 -1
- package/internal/hardhat-network/provider/PoolState.d.ts +4 -4
- package/internal/hardhat-network/provider/PoolState.d.ts.map +1 -1
- package/internal/hardhat-network/provider/fork/ForkBlockchain.d.ts.map +1 -1
- package/internal/hardhat-network/provider/fork/ForkBlockchain.js +13 -1
- package/internal/hardhat-network/provider/fork/ForkBlockchain.js.map +1 -1
- package/internal/hardhat-network/provider/fork/rpcToTxData.d.ts +6 -1
- package/internal/hardhat-network/provider/fork/rpcToTxData.d.ts.map +1 -1
- package/internal/hardhat-network/provider/fork/rpcToTxData.js.map +1 -1
- package/internal/hardhat-network/provider/modules/debug.d.ts +1 -0
- package/internal/hardhat-network/provider/modules/debug.d.ts.map +1 -1
- package/internal/hardhat-network/provider/modules/debug.js +8 -1
- package/internal/hardhat-network/provider/modules/debug.js.map +1 -1
- package/internal/hardhat-network/provider/modules/eth.d.ts.map +1 -1
- package/internal/hardhat-network/provider/modules/eth.js +3 -3
- package/internal/hardhat-network/provider/modules/eth.js.map +1 -1
- package/internal/hardhat-network/provider/node-types.d.ts +8 -7
- package/internal/hardhat-network/provider/node-types.d.ts.map +1 -1
- package/internal/hardhat-network/provider/node.d.ts +8 -1
- package/internal/hardhat-network/provider/node.d.ts.map +1 -1
- package/internal/hardhat-network/provider/node.js +126 -67
- package/internal/hardhat-network/provider/node.js.map +1 -1
- package/internal/hardhat-network/provider/output.d.ts +2 -2
- package/internal/hardhat-network/provider/output.d.ts.map +1 -1
- package/internal/hardhat-network/provider/provider.d.ts +1 -0
- package/internal/hardhat-network/provider/provider.d.ts.map +1 -1
- package/internal/hardhat-network/provider/provider.js +1 -0
- package/internal/hardhat-network/provider/provider.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js +11 -11
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js +10 -10
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js +11 -11
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.js +12 -12
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.js +12 -12
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.js +5 -5
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.js +6 -6
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.js.map +1 -1
- package/internal/hardhat-network/provider/utils/makeCommon.d.ts +1 -1
- package/internal/hardhat-network/provider/utils/makeCommon.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/makeCommon.js +3 -1
- package/internal/hardhat-network/provider/utils/makeCommon.js.map +1 -1
- package/internal/hardhat-network/stack-traces/consoleLogger.d.ts +2 -2
- package/internal/hardhat-network/stack-traces/consoleLogger.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/constants.d.ts +1 -1
- package/internal/hardhat-network/stack-traces/constants.js +1 -1
- package/internal/hardhat-network/stack-traces/contracts-identifier.js +5 -5
- package/internal/hardhat-network/stack-traces/contracts-identifier.js.map +1 -1
- package/internal/hardhat-network/stack-traces/message-trace.d.ts +4 -4
- package/internal/hardhat-network/stack-traces/message-trace.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/model.js +5 -5
- package/internal/hardhat-network/stack-traces/model.js.map +1 -1
- package/internal/hardhat-network/stack-traces/solidity-stack-trace.d.ts +2 -2
- package/internal/hardhat-network/stack-traces/solidity-stack-trace.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-debug-tracer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-debug-tracer.js +8 -8
- package/internal/hardhat-network/stack-traces/vm-debug-tracer.js.map +1 -1
- package/internal/sentry/reporter.js +12 -12
- package/internal/sentry/reporter.js.map +1 -1
- package/internal/solidity/compiler/downloader.js +11 -11
- package/internal/solidity/compiler/downloader.js.map +1 -1
- package/internal/solidity/dependencyGraph.d.ts.map +1 -1
- package/internal/solidity/dependencyGraph.js +17 -7
- package/internal/solidity/dependencyGraph.js.map +1 -1
- package/internal/solidity/resolver.d.ts +2 -1
- package/internal/solidity/resolver.d.ts.map +1 -1
- package/internal/solidity/resolver.js +31 -17
- package/internal/solidity/resolver.js.map +1 -1
- package/internal/util/jsonrpc.d.ts +1 -1
- package/internal/util/jsonrpc.d.ts.map +1 -1
- package/internal/util/unsafe.d.ts +1 -1
- package/internal/util/unsafe.d.ts.map +1 -1
- package/internal/util/unsafe.js.map +1 -1
- package/package.json +13 -16
- package/src/builtin-tasks/compile.ts +33 -4
- package/src/builtin-tasks/flatten.ts +228 -19
- package/src/builtin-tasks/task-names.ts +3 -0
- package/src/internal/artifacts.ts +40 -1
- package/src/internal/cli/analytics.ts +0 -3
- package/src/internal/cli/project-creation.ts +1 -1
- package/src/internal/core/errors-list.ts +38 -0
- package/src/internal/core/jsonrpc/types/base-types.ts +15 -0
- package/src/internal/core/jsonrpc/types/input/callRequest.ts +35 -1
- package/src/internal/core/jsonrpc/types/input/debugTraceTransaction.ts +1 -0
- package/src/internal/core/providers/construction.ts +2 -0
- package/src/internal/core/providers/http.ts +6 -3
- package/src/internal/hardhat-network/provider/fork/ForkBlockchain.ts +24 -4
- package/src/internal/hardhat-network/provider/fork/rpcToTxData.ts +10 -1
- package/src/internal/hardhat-network/provider/modules/debug.ts +21 -2
- package/src/internal/hardhat-network/provider/modules/eth.ts +18 -4
- package/src/internal/hardhat-network/provider/node-types.ts +1 -0
- package/src/internal/hardhat-network/provider/node.ts +110 -6
- package/src/internal/hardhat-network/provider/provider.ts +2 -0
- package/src/internal/hardhat-network/provider/utils/makeCommon.ts +9 -1
- package/src/internal/hardhat-network/stack-traces/constants.ts +1 -1
- package/src/internal/hardhat-network/stack-traces/vm-debug-tracer.ts +12 -10
- package/src/internal/solidity/dependencyGraph.ts +15 -3
- package/src/internal/solidity/resolver.ts +58 -16
- package/src/internal/util/unsafe.ts +1 -1
- package/src/types/config.ts +2 -0
- package/src/utils/contract-names.ts +1 -0
- package/src/utils/remappings.ts +17 -0
- package/types/config.d.ts +12 -10
- package/types/config.d.ts.map +1 -1
- package/types/experimental.d.ts +2 -2
- package/types/experimental.d.ts.map +1 -1
- package/types/runtime.d.ts +6 -6
- package/types/runtime.d.ts.map +1 -1
- package/utils/contract-names.d.ts +1 -0
- package/utils/contract-names.d.ts.map +1 -1
- package/utils/contract-names.js +1 -0
- package/utils/contract-names.js.map +1 -1
- package/utils/remappings.d.ts +2 -0
- package/utils/remappings.d.ts.map +1 -0
- package/utils/remappings.js +15 -0
- package/utils/remappings.js.map +1 -0
|
@@ -4,7 +4,10 @@ import {
|
|
|
4
4
|
RpcDebugTracingConfig,
|
|
5
5
|
} from "../../../core/jsonrpc/types/input/debugTraceTransaction";
|
|
6
6
|
import { validateParams } from "../../../core/jsonrpc/types/input/validation";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
InvalidArgumentsError,
|
|
9
|
+
MethodNotFoundError,
|
|
10
|
+
} from "../../../core/providers/errors";
|
|
8
11
|
import { HardhatNode } from "../node";
|
|
9
12
|
import { RpcDebugTraceOutput } from "../output";
|
|
10
13
|
|
|
@@ -32,7 +35,23 @@ export class DebugModule {
|
|
|
32
35
|
private _traceTransactionParams(
|
|
33
36
|
params: any[]
|
|
34
37
|
): [Buffer, RpcDebugTracingConfig] {
|
|
35
|
-
|
|
38
|
+
const validatedParams = validateParams(
|
|
39
|
+
params,
|
|
40
|
+
rpcHash,
|
|
41
|
+
rpcDebugTracingConfig
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
this._validateTracerParam(validatedParams[1]);
|
|
45
|
+
|
|
46
|
+
return validatedParams;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private _validateTracerParam(config: RpcDebugTracingConfig) {
|
|
50
|
+
if (config?.tracer !== undefined) {
|
|
51
|
+
throw new InvalidArgumentsError(
|
|
52
|
+
"Hardhat currently only supports the default tracer, so no tracer parameter should be passed."
|
|
53
|
+
);
|
|
54
|
+
}
|
|
36
55
|
}
|
|
37
56
|
|
|
38
57
|
private async _traceTransactionAction(
|
|
@@ -37,6 +37,8 @@ import {
|
|
|
37
37
|
RpcOldBlockTag,
|
|
38
38
|
} from "../../../core/jsonrpc/types/input/blockTag";
|
|
39
39
|
import {
|
|
40
|
+
optionalStateOverrideSet,
|
|
41
|
+
OptionalStateOverrideSet,
|
|
40
42
|
rpcCallRequest,
|
|
41
43
|
RpcCallRequest,
|
|
42
44
|
} from "../../../core/jsonrpc/types/input/callRequest";
|
|
@@ -334,13 +336,21 @@ export class EthModule {
|
|
|
334
336
|
|
|
335
337
|
// eth_call
|
|
336
338
|
|
|
337
|
-
private _callParams(
|
|
338
|
-
|
|
339
|
+
private _callParams(
|
|
340
|
+
params: any[]
|
|
341
|
+
): [RpcCallRequest, OptionalRpcNewBlockTag, OptionalStateOverrideSet] {
|
|
342
|
+
return validateParams(
|
|
343
|
+
params,
|
|
344
|
+
rpcCallRequest,
|
|
345
|
+
optionalRpcNewBlockTag,
|
|
346
|
+
optionalStateOverrideSet
|
|
347
|
+
);
|
|
339
348
|
}
|
|
340
349
|
|
|
341
350
|
private async _callAction(
|
|
342
351
|
rpcCall: RpcCallRequest,
|
|
343
|
-
blockTag: OptionalRpcNewBlockTag
|
|
352
|
+
blockTag: OptionalRpcNewBlockTag,
|
|
353
|
+
stateOverrideSet: OptionalStateOverrideSet
|
|
344
354
|
): Promise<string> {
|
|
345
355
|
this._validateTransactionAndCallRequest(rpcCall);
|
|
346
356
|
|
|
@@ -353,7 +363,11 @@ export class EthModule {
|
|
|
353
363
|
trace,
|
|
354
364
|
error,
|
|
355
365
|
consoleLogMessages,
|
|
356
|
-
} = await this._node.runCall(
|
|
366
|
+
} = await this._node.runCall(
|
|
367
|
+
callParams,
|
|
368
|
+
blockNumberOrPending,
|
|
369
|
+
stateOverrideSet
|
|
370
|
+
);
|
|
357
371
|
|
|
358
372
|
const code = await this._node.getCodeFromTrace(trace, blockNumberOrPending);
|
|
359
373
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Block, HeaderData } from "@nomicfoundation/ethereumjs-block";
|
|
2
|
-
import { Common } from "@nomicfoundation/ethereumjs-common";
|
|
2
|
+
import { Common, CustomCommonOpts } from "@nomicfoundation/ethereumjs-common";
|
|
3
3
|
import {
|
|
4
4
|
AccessListEIP2930Transaction,
|
|
5
5
|
FeeMarketEIP1559Transaction,
|
|
@@ -83,6 +83,10 @@ import { VMTracer } from "../stack-traces/vm-tracer";
|
|
|
83
83
|
import "./ethereumjs-workarounds";
|
|
84
84
|
import { rpcQuantityToBigInt } from "../../core/jsonrpc/types/base-types";
|
|
85
85
|
import { JsonRpcClient } from "../jsonrpc/client";
|
|
86
|
+
import {
|
|
87
|
+
StateOverrideSet,
|
|
88
|
+
StateProperties,
|
|
89
|
+
} from "../../core/jsonrpc/types/input/callRequest";
|
|
86
90
|
import { bloomFilter, Filter, filterLogs, LATEST_BLOCK, Type } from "./filter";
|
|
87
91
|
import { ForkBlockchain } from "./fork/ForkBlockchain";
|
|
88
92
|
import { ForkStateManager } from "./fork/ForkStateManager";
|
|
@@ -146,6 +150,7 @@ export class HardhatNode extends EventEmitter {
|
|
|
146
150
|
networkId,
|
|
147
151
|
chainId,
|
|
148
152
|
allowBlocksWithSameTimestamp,
|
|
153
|
+
enableTransientStorage,
|
|
149
154
|
} = config;
|
|
150
155
|
|
|
151
156
|
const allowUnlimitedContractSize =
|
|
@@ -303,7 +308,8 @@ export class HardhatNode extends EventEmitter {
|
|
|
303
308
|
forkBlockNum,
|
|
304
309
|
forkBlockHash,
|
|
305
310
|
nextBlockBaseFeePerGas,
|
|
306
|
-
forkClient
|
|
311
|
+
forkClient,
|
|
312
|
+
enableTransientStorage
|
|
307
313
|
);
|
|
308
314
|
|
|
309
315
|
return [common, node];
|
|
@@ -390,7 +396,8 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
390
396
|
private _forkBlockNumber?: bigint,
|
|
391
397
|
private _forkBlockHash?: string,
|
|
392
398
|
nextBlockBaseFee?: bigint,
|
|
393
|
-
private _forkClient?: JsonRpcClient
|
|
399
|
+
private _forkClient?: JsonRpcClient,
|
|
400
|
+
private readonly _enableTransientStorage: boolean = false
|
|
394
401
|
) {
|
|
395
402
|
super();
|
|
396
403
|
|
|
@@ -624,7 +631,8 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
624
631
|
|
|
625
632
|
public async runCall(
|
|
626
633
|
call: CallParams,
|
|
627
|
-
blockNumberOrPending: bigint | "pending"
|
|
634
|
+
blockNumberOrPending: bigint | "pending",
|
|
635
|
+
stateOverrideSet: StateOverrideSet = {}
|
|
628
636
|
): Promise<RunCallResult> {
|
|
629
637
|
let txParams: TransactionParams;
|
|
630
638
|
|
|
@@ -659,7 +667,13 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
659
667
|
|
|
660
668
|
const result = await this._runInBlockContext(
|
|
661
669
|
blockNumberOrPending,
|
|
662
|
-
async () =>
|
|
670
|
+
async () =>
|
|
671
|
+
this._runTxAndRevertMutations(
|
|
672
|
+
tx,
|
|
673
|
+
blockNumberOrPending,
|
|
674
|
+
true,
|
|
675
|
+
stateOverrideSet
|
|
676
|
+
)
|
|
663
677
|
);
|
|
664
678
|
|
|
665
679
|
const traces = await this._gatherTraces(result.execResult);
|
|
@@ -2354,6 +2368,83 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
2354
2368
|
);
|
|
2355
2369
|
}
|
|
2356
2370
|
|
|
2371
|
+
private async _applyStateOverrideSet(stateOverrideSet: StateOverrideSet) {
|
|
2372
|
+
// Multiple state override set can be configured for different addresses, hence the loop
|
|
2373
|
+
for (const [addrToOverride, stateOverrideOptions] of Object.entries(
|
|
2374
|
+
stateOverrideSet
|
|
2375
|
+
)) {
|
|
2376
|
+
const address = new Address(toBuffer(addrToOverride));
|
|
2377
|
+
|
|
2378
|
+
const { balance, nonce, code, state, stateDiff } = stateOverrideOptions;
|
|
2379
|
+
|
|
2380
|
+
await this._overrideBalanceAndNonce(address, balance, nonce);
|
|
2381
|
+
await this._overrideCode(address, code);
|
|
2382
|
+
await this._overrideStateAndStateDiff(address, state, stateDiff);
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2386
|
+
private async _overrideBalanceAndNonce(
|
|
2387
|
+
address: Address,
|
|
2388
|
+
balance: bigint | undefined,
|
|
2389
|
+
nonce: bigint | undefined
|
|
2390
|
+
) {
|
|
2391
|
+
const MAX_NONCE = 2n ** 64n - 1n;
|
|
2392
|
+
const MAX_BALANCE = 2n ** 256n - 1n;
|
|
2393
|
+
|
|
2394
|
+
if (nonce !== undefined && nonce > MAX_NONCE) {
|
|
2395
|
+
throw new InvalidInputError(
|
|
2396
|
+
`The 'nonce' property should occupy a maximum of 8 bytes (nonce=${nonce}).`
|
|
2397
|
+
);
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2400
|
+
if (balance !== undefined && balance > MAX_BALANCE) {
|
|
2401
|
+
throw new InvalidInputError(
|
|
2402
|
+
`The 'balance' property should occupy a maximum of 32 bytes (balance=${balance}).`
|
|
2403
|
+
);
|
|
2404
|
+
}
|
|
2405
|
+
|
|
2406
|
+
await this._stateManager.modifyAccountFields(address, {
|
|
2407
|
+
balance,
|
|
2408
|
+
nonce,
|
|
2409
|
+
});
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2412
|
+
private async _overrideCode(address: Address, code: Buffer | undefined) {
|
|
2413
|
+
if (code === undefined) return;
|
|
2414
|
+
|
|
2415
|
+
await this._stateManager.putContractCode(address, code);
|
|
2416
|
+
}
|
|
2417
|
+
|
|
2418
|
+
private async _overrideStateAndStateDiff(
|
|
2419
|
+
address: Address,
|
|
2420
|
+
state: StateProperties | undefined,
|
|
2421
|
+
stateDiff: StateProperties | undefined
|
|
2422
|
+
) {
|
|
2423
|
+
let newState;
|
|
2424
|
+
|
|
2425
|
+
if (state !== undefined && stateDiff === undefined) {
|
|
2426
|
+
await this._stateManager.clearContractStorage(address);
|
|
2427
|
+
newState = state;
|
|
2428
|
+
} else if (state === undefined && stateDiff !== undefined) {
|
|
2429
|
+
newState = stateDiff;
|
|
2430
|
+
} else if (state === undefined && stateDiff === undefined) {
|
|
2431
|
+
// nothing to do
|
|
2432
|
+
return;
|
|
2433
|
+
} else {
|
|
2434
|
+
throw new InvalidInputError(
|
|
2435
|
+
"The properties 'state' and 'stateDiff' cannot be used simultaneously when configuring the state override set passed to the eth_call method."
|
|
2436
|
+
);
|
|
2437
|
+
}
|
|
2438
|
+
|
|
2439
|
+
for (const [storageKey, value] of Object.entries(newState)) {
|
|
2440
|
+
await this._stateManager.putContractStorage(
|
|
2441
|
+
address,
|
|
2442
|
+
toBuffer(storageKey),
|
|
2443
|
+
setLengthLeft(bigIntToBuffer(value), 32)
|
|
2444
|
+
);
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
2447
|
+
|
|
2357
2448
|
/**
|
|
2358
2449
|
* This function runs a transaction and reverts all the modifications that it
|
|
2359
2450
|
* makes.
|
|
@@ -2361,10 +2452,13 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
2361
2452
|
private async _runTxAndRevertMutations(
|
|
2362
2453
|
tx: TypedTransaction,
|
|
2363
2454
|
blockNumberOrPending: bigint | "pending",
|
|
2364
|
-
forceBaseFeeZero = false
|
|
2455
|
+
forceBaseFeeZero = false,
|
|
2456
|
+
stateOverrideSet: StateOverrideSet = {}
|
|
2365
2457
|
): Promise<RunTxResult> {
|
|
2366
2458
|
const initialStateRoot = await this._stateManager.getStateRoot();
|
|
2367
2459
|
|
|
2460
|
+
await this._applyStateOverrideSet(stateOverrideSet);
|
|
2461
|
+
|
|
2368
2462
|
let blockContext: Block | undefined;
|
|
2369
2463
|
let originalCommon: Common | undefined;
|
|
2370
2464
|
|
|
@@ -2400,6 +2494,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
2400
2494
|
},
|
|
2401
2495
|
{
|
|
2402
2496
|
hardfork: this._selectHardfork(blockContext.header.number),
|
|
2497
|
+
...this._getTransientStorageSettings(),
|
|
2403
2498
|
}
|
|
2404
2499
|
);
|
|
2405
2500
|
|
|
@@ -2740,6 +2835,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
2740
2835
|
},
|
|
2741
2836
|
{
|
|
2742
2837
|
hardfork: this._selectHardfork(BigInt(blockNumber)),
|
|
2838
|
+
...this._getTransientStorageSettings(),
|
|
2743
2839
|
}
|
|
2744
2840
|
);
|
|
2745
2841
|
|
|
@@ -2750,4 +2846,12 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
2750
2846
|
);
|
|
2751
2847
|
}
|
|
2752
2848
|
}
|
|
2849
|
+
|
|
2850
|
+
private _getTransientStorageSettings(): Partial<CustomCommonOpts> {
|
|
2851
|
+
if (this._enableTransientStorage) {
|
|
2852
|
+
return { eips: [1153] };
|
|
2853
|
+
}
|
|
2854
|
+
|
|
2855
|
+
return {};
|
|
2856
|
+
}
|
|
2753
2857
|
}
|
|
@@ -80,6 +80,7 @@ interface HardhatNetworkProviderConfig {
|
|
|
80
80
|
experimentalHardhatNetworkMessageTraceHooks?: BoundExperimentalHardhatNetworkMessageTraceHook[];
|
|
81
81
|
forkConfig?: ForkConfig;
|
|
82
82
|
forkCachePath?: string;
|
|
83
|
+
enableTransientStorage: boolean;
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
export class HardhatNetworkProvider
|
|
@@ -253,6 +254,7 @@ export class HardhatNetworkProvider
|
|
|
253
254
|
coinbase: this._config.coinbase ?? DEFAULT_COINBASE,
|
|
254
255
|
chains: this._config.chains,
|
|
255
256
|
allowBlocksWithSameTimestamp: this._config.allowBlocksWithSameTimestamp,
|
|
257
|
+
enableTransientStorage: this._config.enableTransientStorage,
|
|
256
258
|
};
|
|
257
259
|
|
|
258
260
|
const [common, node] = await HardhatNode.create(config);
|
|
@@ -2,7 +2,14 @@ import { Common } from "@nomicfoundation/ethereumjs-common";
|
|
|
2
2
|
|
|
3
3
|
import { LocalNodeConfig } from "../node-types";
|
|
4
4
|
|
|
5
|
-
export function makeCommon({
|
|
5
|
+
export function makeCommon({
|
|
6
|
+
chainId,
|
|
7
|
+
networkId,
|
|
8
|
+
hardfork,
|
|
9
|
+
enableTransientStorage,
|
|
10
|
+
}: LocalNodeConfig) {
|
|
11
|
+
const otherSettings = enableTransientStorage ? { eips: [1153] } : {};
|
|
12
|
+
|
|
6
13
|
const common = Common.custom(
|
|
7
14
|
{
|
|
8
15
|
chainId,
|
|
@@ -10,6 +17,7 @@ export function makeCommon({ chainId, networkId, hardfork }: LocalNodeConfig) {
|
|
|
10
17
|
},
|
|
11
18
|
{
|
|
12
19
|
hardfork,
|
|
20
|
+
...otherSettings,
|
|
13
21
|
}
|
|
14
22
|
);
|
|
15
23
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const SUPPORTED_SOLIDITY_VERSION_RANGE = "<=0.8.
|
|
1
|
+
export const SUPPORTED_SOLIDITY_VERSION_RANGE = "<=0.8.21";
|
|
2
2
|
export const FIRST_SOLC_VERSION_SUPPORTED = "0.5.1";
|
|
@@ -280,10 +280,12 @@ export class VMDebugTracer {
|
|
|
280
280
|
"There shouldn't be two messages one after another"
|
|
281
281
|
);
|
|
282
282
|
|
|
283
|
-
//
|
|
284
|
-
//
|
|
285
|
-
|
|
286
|
-
|
|
283
|
+
// memory opcodes reflect the expanded memory in that step,
|
|
284
|
+
// so we correct them
|
|
285
|
+
if (
|
|
286
|
+
previousStructLog.op === "MSTORE" ||
|
|
287
|
+
previousStructLog.op === "MLOAD"
|
|
288
|
+
) {
|
|
287
289
|
const memoryLengthDifference =
|
|
288
290
|
structLog.memory.length - previousStructLog.memory.length;
|
|
289
291
|
for (let k = 0; k < memoryLengthDifference; k++) {
|
|
@@ -315,13 +317,13 @@ export class VMDebugTracer {
|
|
|
315
317
|
}
|
|
316
318
|
|
|
317
319
|
private _getMemory(step: InterpreterStep): string[] {
|
|
318
|
-
const
|
|
319
|
-
.
|
|
320
|
-
|
|
320
|
+
const rawMemory =
|
|
321
|
+
Buffer.from(step.memory)
|
|
322
|
+
.toString("hex")
|
|
323
|
+
.match(/.{1,64}/g) ?? [];
|
|
321
324
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
return result;
|
|
325
|
+
// Remove the additional non allocated memory
|
|
326
|
+
return rawMemory.slice(0, Number(step.memoryWordCount));
|
|
325
327
|
}
|
|
326
328
|
|
|
327
329
|
private _getStack(step: InterpreterStep): string[] {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as taskTypes from "../../types/builtin-tasks";
|
|
2
|
+
import { HardhatError } from "../core/errors";
|
|
3
|
+
import { ERRORS } from "../core/errors-list";
|
|
2
4
|
|
|
3
5
|
import { ResolvedFile, Resolver } from "./resolver";
|
|
4
6
|
|
|
@@ -22,7 +24,8 @@ export class DependencyGraph implements taskTypes.DependencyGraph {
|
|
|
22
24
|
private _resolvedFiles = new Map<string, ResolvedFile>();
|
|
23
25
|
private _dependenciesPerFile = new Map<string, Set<ResolvedFile>>();
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
// map absolute paths to source names
|
|
28
|
+
private readonly _visitedFiles = new Map<string, string>();
|
|
26
29
|
|
|
27
30
|
private constructor() {}
|
|
28
31
|
|
|
@@ -160,11 +163,20 @@ export class DependencyGraph implements taskTypes.DependencyGraph {
|
|
|
160
163
|
resolver: Resolver,
|
|
161
164
|
file: ResolvedFile
|
|
162
165
|
): Promise<void> {
|
|
163
|
-
|
|
166
|
+
const sourceName = this._visitedFiles.get(file.absolutePath);
|
|
167
|
+
|
|
168
|
+
if (sourceName !== undefined) {
|
|
169
|
+
if (sourceName !== file.sourceName) {
|
|
170
|
+
throw new HardhatError(ERRORS.RESOLVER.AMBIGUOUS_SOURCE_NAMES, {
|
|
171
|
+
sourcenames: `'${sourceName}' and '${file.sourceName}'`,
|
|
172
|
+
file: file.absolutePath,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
164
176
|
return;
|
|
165
177
|
}
|
|
166
178
|
|
|
167
|
-
this._visitedFiles.
|
|
179
|
+
this._visitedFiles.set(file.absolutePath, file.sourceName);
|
|
168
180
|
|
|
169
181
|
const dependencies = new Set<ResolvedFile>();
|
|
170
182
|
this._resolvedFiles.set(file.sourceName, file);
|
|
@@ -21,6 +21,7 @@ import { ERRORS } from "../core/errors-list";
|
|
|
21
21
|
import { createNonCryptographicHashBasedIdentifier } from "../util/hash";
|
|
22
22
|
|
|
23
23
|
import { getRealPath } from "../util/fs-utils";
|
|
24
|
+
import { applyRemappings } from "../../utils/remappings";
|
|
24
25
|
import { Parser } from "./parse";
|
|
25
26
|
|
|
26
27
|
export interface ResolvedFilesMap {
|
|
@@ -69,6 +70,7 @@ export class Resolver {
|
|
|
69
70
|
constructor(
|
|
70
71
|
private readonly _projectRoot: string,
|
|
71
72
|
private readonly _parser: Parser,
|
|
73
|
+
private readonly _remappings: Record<string, string>,
|
|
72
74
|
private readonly _readFile: (absolutePath: string) => Promise<string>,
|
|
73
75
|
private readonly _transformImportName: (
|
|
74
76
|
importName: string
|
|
@@ -86,14 +88,22 @@ export class Resolver {
|
|
|
86
88
|
return cached;
|
|
87
89
|
}
|
|
88
90
|
|
|
89
|
-
|
|
91
|
+
const remappedSourceName = applyRemappings(this._remappings, sourceName);
|
|
92
|
+
|
|
93
|
+
validateSourceNameFormat(remappedSourceName);
|
|
90
94
|
|
|
91
95
|
let resolvedFile: ResolvedFile;
|
|
92
96
|
|
|
93
|
-
if (await isLocalSourceName(this._projectRoot,
|
|
94
|
-
resolvedFile = await this._resolveLocalSourceName(
|
|
97
|
+
if (await isLocalSourceName(this._projectRoot, remappedSourceName)) {
|
|
98
|
+
resolvedFile = await this._resolveLocalSourceName(
|
|
99
|
+
sourceName,
|
|
100
|
+
remappedSourceName
|
|
101
|
+
);
|
|
95
102
|
} else {
|
|
96
|
-
resolvedFile = await this._resolveLibrarySourceName(
|
|
103
|
+
resolvedFile = await this._resolveLibrarySourceName(
|
|
104
|
+
sourceName,
|
|
105
|
+
remappedSourceName
|
|
106
|
+
);
|
|
97
107
|
}
|
|
98
108
|
|
|
99
109
|
this._cache.set(sourceName, resolvedFile);
|
|
@@ -109,7 +119,14 @@ export class Resolver {
|
|
|
109
119
|
from: ResolvedFile,
|
|
110
120
|
importName: string
|
|
111
121
|
): Promise<ResolvedFile> {
|
|
112
|
-
|
|
122
|
+
// sanity check for deprecated task
|
|
123
|
+
if (importName !== (await this._transformImportName(importName))) {
|
|
124
|
+
throw new HardhatError(
|
|
125
|
+
ERRORS.TASK_DEFINITIONS.DEPRECATED_TRANSFORM_IMPORT_TASK
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const imported = applyRemappings(this._remappings, importName);
|
|
113
130
|
|
|
114
131
|
const scheme = this._getUriScheme(imported);
|
|
115
132
|
if (scheme !== undefined) {
|
|
@@ -151,7 +168,7 @@ export class Resolver {
|
|
|
151
168
|
if (isRelativeImport) {
|
|
152
169
|
sourceName = await this._relativeImportToSourceName(from, imported);
|
|
153
170
|
} else {
|
|
154
|
-
sourceName = normalizeSourceName(
|
|
171
|
+
sourceName = normalizeSourceName(importName); // The sourceName of the imported file is not transformed
|
|
155
172
|
}
|
|
156
173
|
|
|
157
174
|
const cached = this._cache.get(sourceName);
|
|
@@ -169,7 +186,10 @@ export class Resolver {
|
|
|
169
186
|
isRelativeImport &&
|
|
170
187
|
!this._isRelativeImportToLibrary(from, imported)
|
|
171
188
|
) {
|
|
172
|
-
resolvedFile = await this._resolveLocalSourceName(
|
|
189
|
+
resolvedFile = await this._resolveLocalSourceName(
|
|
190
|
+
sourceName,
|
|
191
|
+
applyRemappings(this._remappings, sourceName)
|
|
192
|
+
);
|
|
173
193
|
} else {
|
|
174
194
|
resolvedFile = await this.resolveSourceName(sourceName);
|
|
175
195
|
}
|
|
@@ -241,28 +261,50 @@ export class Resolver {
|
|
|
241
261
|
);
|
|
242
262
|
}
|
|
243
263
|
|
|
264
|
+
if (
|
|
265
|
+
HardhatError.isHardhatErrorType(
|
|
266
|
+
error,
|
|
267
|
+
ERRORS.GENERAL.INVALID_READ_OF_DIRECTORY
|
|
268
|
+
)
|
|
269
|
+
) {
|
|
270
|
+
throw new HardhatError(
|
|
271
|
+
ERRORS.RESOLVER.INVALID_IMPORT_OF_DIRECTORY,
|
|
272
|
+
{
|
|
273
|
+
imported,
|
|
274
|
+
from: from.sourceName,
|
|
275
|
+
},
|
|
276
|
+
error
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
|
|
244
280
|
// eslint-disable-next-line @nomicfoundation/hardhat-internal-rules/only-hardhat-error
|
|
245
281
|
throw error;
|
|
246
282
|
}
|
|
247
283
|
}
|
|
248
284
|
|
|
249
285
|
private async _resolveLocalSourceName(
|
|
250
|
-
sourceName: string
|
|
286
|
+
sourceName: string,
|
|
287
|
+
remappedSourceName: string
|
|
251
288
|
): Promise<ResolvedFile> {
|
|
252
289
|
await this._validateSourceNameExistenceAndCasing(
|
|
253
290
|
this._projectRoot,
|
|
254
|
-
|
|
291
|
+
remappedSourceName,
|
|
255
292
|
false
|
|
256
293
|
);
|
|
257
294
|
|
|
258
|
-
const absolutePath = path.join(this._projectRoot,
|
|
295
|
+
const absolutePath = path.join(this._projectRoot, remappedSourceName);
|
|
259
296
|
return this._resolveFile(sourceName, absolutePath);
|
|
260
297
|
}
|
|
261
298
|
|
|
262
299
|
private async _resolveLibrarySourceName(
|
|
263
|
-
sourceName: string
|
|
300
|
+
sourceName: string,
|
|
301
|
+
remappedSourceName: string
|
|
264
302
|
): Promise<ResolvedFile> {
|
|
265
|
-
const
|
|
303
|
+
const normalizedSourceName = remappedSourceName.replace(
|
|
304
|
+
/^node_modules\//,
|
|
305
|
+
""
|
|
306
|
+
);
|
|
307
|
+
const libraryName = this._getLibraryName(normalizedSourceName);
|
|
266
308
|
|
|
267
309
|
let packageJsonPath;
|
|
268
310
|
try {
|
|
@@ -288,7 +330,7 @@ export class Resolver {
|
|
|
288
330
|
}
|
|
289
331
|
|
|
290
332
|
let nodeModulesPath = path.dirname(path.dirname(packageJsonPath));
|
|
291
|
-
if (this._isScopedPackage(
|
|
333
|
+
if (this._isScopedPackage(normalizedSourceName)) {
|
|
292
334
|
nodeModulesPath = path.dirname(nodeModulesPath);
|
|
293
335
|
}
|
|
294
336
|
|
|
@@ -298,7 +340,7 @@ export class Resolver {
|
|
|
298
340
|
// cases we handle resolution differently
|
|
299
341
|
const packageRoot = path.dirname(packageJsonPath);
|
|
300
342
|
const pattern = new RegExp(`^${libraryName}/?`);
|
|
301
|
-
const fileName =
|
|
343
|
+
const fileName = normalizedSourceName.replace(pattern, "");
|
|
302
344
|
|
|
303
345
|
await this._validateSourceNameExistenceAndCasing(
|
|
304
346
|
packageRoot,
|
|
@@ -311,10 +353,10 @@ export class Resolver {
|
|
|
311
353
|
} else {
|
|
312
354
|
await this._validateSourceNameExistenceAndCasing(
|
|
313
355
|
nodeModulesPath,
|
|
314
|
-
|
|
356
|
+
normalizedSourceName,
|
|
315
357
|
true
|
|
316
358
|
);
|
|
317
|
-
absolutePath = path.join(nodeModulesPath,
|
|
359
|
+
absolutePath = path.join(nodeModulesPath, normalizedSourceName);
|
|
318
360
|
}
|
|
319
361
|
|
|
320
362
|
const packageInfo: {
|
|
@@ -10,6 +10,6 @@ export const unsafeObjectKeys = Object.keys as <T>(
|
|
|
10
10
|
* This function is a typed version of `Object.entries`. Note that it's type
|
|
11
11
|
* unsafe. You have to be sure that `o` has exactly the same keys as `T`.
|
|
12
12
|
*/
|
|
13
|
-
export function unsafeObjectEntries<T>(o: T) {
|
|
13
|
+
export function unsafeObjectEntries<T extends object>(o: T) {
|
|
14
14
|
return Object.entries(o) as Array<[keyof T, T[keyof T]]>;
|
|
15
15
|
}
|
package/src/types/config.ts
CHANGED
|
@@ -57,6 +57,7 @@ export interface HardhatNetworkUserConfig {
|
|
|
57
57
|
forking?: HardhatNetworkForkingUserConfig;
|
|
58
58
|
coinbase?: string;
|
|
59
59
|
chains?: HardhatNetworkChainsUserConfig;
|
|
60
|
+
enableTransientStorage?: boolean;
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
export type HardhatNetworkAccountsUserConfig =
|
|
@@ -153,6 +154,7 @@ export interface HardhatNetworkConfig {
|
|
|
153
154
|
coinbase?: string;
|
|
154
155
|
chains: HardhatNetworkChainsConfig;
|
|
155
156
|
allowBlocksWithSameTimestamp?: boolean;
|
|
157
|
+
enableTransientStorage?: boolean;
|
|
156
158
|
}
|
|
157
159
|
|
|
158
160
|
export type HardhatNetworkAccountsConfig =
|
|
@@ -22,6 +22,7 @@ export function isFullyQualifiedName(name: string): boolean {
|
|
|
22
22
|
* Parses a fully qualified name.
|
|
23
23
|
*
|
|
24
24
|
* @param fullyQualifiedName It MUST be a fully qualified name.
|
|
25
|
+
* @throws {HardhatError} If the name is not fully qualified.
|
|
25
26
|
*/
|
|
26
27
|
export function parseFullyQualifiedName(fullyQualifiedName: string): {
|
|
27
28
|
sourceName: string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function applyRemappings(
|
|
2
|
+
remappings: Record<string, string>,
|
|
3
|
+
sourceName: string
|
|
4
|
+
): string {
|
|
5
|
+
const selectedRemapping = { from: "", to: "" };
|
|
6
|
+
|
|
7
|
+
for (const [from, to] of Object.entries(remappings)) {
|
|
8
|
+
if (
|
|
9
|
+
sourceName.startsWith(from) &&
|
|
10
|
+
from.length >= selectedRemapping.from.length
|
|
11
|
+
) {
|
|
12
|
+
[selectedRemapping.from, selectedRemapping.to] = [from, to];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return sourceName.replace(selectedRemapping.from, selectedRemapping.to);
|
|
17
|
+
}
|