hardhat 2.20.0 → 2.21.0-dev.0
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/internal/core/jsonrpc/types/input/blockTag.d.ts +3 -3
- package/internal/core/jsonrpc/types/input/filterRequest.d.ts +6 -6
- package/internal/core/providers/construction.d.ts.map +1 -1
- package/internal/core/providers/construction.js +28 -4
- package/internal/core/providers/construction.js.map +1 -1
- package/internal/core/providers/http.d.ts +2 -0
- package/internal/core/providers/http.d.ts.map +1 -1
- package/internal/core/providers/http.js +2 -1
- package/internal/core/providers/http.js.map +1 -1
- package/internal/core/runtime-environment.d.ts.map +1 -1
- package/internal/core/runtime-environment.js.map +1 -1
- package/internal/hardhat-network/jsonrpc/client.d.ts +0 -2
- package/internal/hardhat-network/jsonrpc/client.d.ts.map +1 -1
- package/internal/hardhat-network/jsonrpc/client.js +0 -16
- package/internal/hardhat-network/jsonrpc/client.js.map +1 -1
- package/internal/hardhat-network/jsonrpc/handler.js +9 -1
- package/internal/hardhat-network/jsonrpc/handler.js.map +1 -1
- package/internal/hardhat-network/provider/BlockchainData.d.ts +5 -5
- package/internal/hardhat-network/provider/BlockchainData.d.ts.map +1 -1
- package/internal/hardhat-network/provider/BlockchainData.js +10 -10
- package/internal/hardhat-network/provider/BlockchainData.js.map +1 -1
- package/internal/hardhat-network/provider/HardhatBlockchain.d.ts +0 -7
- package/internal/hardhat-network/provider/HardhatBlockchain.d.ts.map +1 -1
- package/internal/hardhat-network/provider/HardhatBlockchain.js +2 -14
- package/internal/hardhat-network/provider/HardhatBlockchain.js.map +1 -1
- package/internal/hardhat-network/provider/TxPool.d.ts +3 -2
- package/internal/hardhat-network/provider/TxPool.d.ts.map +1 -1
- package/internal/hardhat-network/provider/TxPool.js +16 -16
- package/internal/hardhat-network/provider/TxPool.js.map +1 -1
- package/internal/hardhat-network/provider/ethereumjs-workarounds.js +1 -1
- package/internal/hardhat-network/provider/ethereumjs-workarounds.js.map +1 -1
- package/internal/hardhat-network/provider/filter.d.ts +6 -5
- package/internal/hardhat-network/provider/filter.d.ts.map +1 -1
- package/internal/hardhat-network/provider/filter.js +2 -2
- package/internal/hardhat-network/provider/filter.js.map +1 -1
- package/internal/hardhat-network/provider/fork/ForkBlockchain.d.ts +0 -7
- package/internal/hardhat-network/provider/fork/ForkBlockchain.d.ts.map +1 -1
- package/internal/hardhat-network/provider/fork/ForkBlockchain.js +4 -21
- package/internal/hardhat-network/provider/fork/ForkBlockchain.js.map +1 -1
- package/internal/hardhat-network/provider/fork/ForkStateManager.d.ts +13 -19
- package/internal/hardhat-network/provider/fork/ForkStateManager.d.ts.map +1 -1
- package/internal/hardhat-network/provider/fork/ForkStateManager.js +61 -59
- package/internal/hardhat-network/provider/fork/ForkStateManager.js.map +1 -1
- package/internal/hardhat-network/provider/fork/rpcToBlockData.d.ts.map +1 -1
- package/internal/hardhat-network/provider/fork/rpcToBlockData.js +0 -3
- package/internal/hardhat-network/provider/fork/rpcToBlockData.js.map +1 -1
- package/internal/hardhat-network/provider/fork/rpcToTxData.d.ts +2 -2
- package/internal/hardhat-network/provider/fork/rpcToTxData.d.ts.map +1 -1
- package/internal/hardhat-network/provider/fork/rpcToTxData.js +1 -1
- package/internal/hardhat-network/provider/fork/rpcToTxData.js.map +1 -1
- package/internal/hardhat-network/provider/modules/base.js +4 -4
- package/internal/hardhat-network/provider/modules/base.js.map +1 -1
- package/internal/hardhat-network/provider/modules/eth.d.ts.map +1 -1
- package/internal/hardhat-network/provider/modules/eth.js +9 -16
- package/internal/hardhat-network/provider/modules/eth.js.map +1 -1
- package/internal/hardhat-network/provider/modules/logger.d.ts +6 -84
- package/internal/hardhat-network/provider/modules/logger.d.ts.map +1 -1
- package/internal/hardhat-network/provider/modules/logger.js +3 -530
- package/internal/hardhat-network/provider/modules/logger.js.map +1 -1
- package/internal/hardhat-network/provider/node-types.d.ts +2 -65
- package/internal/hardhat-network/provider/node-types.d.ts.map +1 -1
- package/internal/hardhat-network/provider/node-types.js +0 -5
- package/internal/hardhat-network/provider/node-types.js.map +1 -1
- package/internal/hardhat-network/provider/node.d.ts +2 -6
- package/internal/hardhat-network/provider/node.d.ts.map +1 -1
- package/internal/hardhat-network/provider/node.js +79 -148
- package/internal/hardhat-network/provider/node.js.map +1 -1
- package/internal/hardhat-network/provider/output.d.ts +0 -14
- package/internal/hardhat-network/provider/output.d.ts.map +1 -1
- package/internal/hardhat-network/provider/output.js +0 -264
- package/internal/hardhat-network/provider/output.js.map +1 -1
- package/internal/hardhat-network/provider/provider.d.ts +26 -25
- package/internal/hardhat-network/provider/provider.d.ts.map +1 -1
- package/internal/hardhat-network/provider/provider.js +342 -186
- package/internal/hardhat-network/provider/provider.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.d.ts +10 -8
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js +9 -9
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.d.ts +10 -8
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js +9 -9
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.d.ts +10 -9
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js +7 -6
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.d.ts +6 -5
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.js +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.d.ts +5 -4
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.js +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.d.ts +8 -7
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.js +2 -2
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.d.ts +8 -7
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.js +2 -2
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.js.map +1 -1
- package/internal/hardhat-network/provider/types/HardhatBlockchainInterface.d.ts +5 -4
- package/internal/hardhat-network/provider/types/HardhatBlockchainInterface.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/convertToEdr.d.ts +14 -0
- package/internal/hardhat-network/provider/utils/convertToEdr.d.ts.map +1 -0
- package/internal/hardhat-network/provider/utils/convertToEdr.js +191 -0
- package/internal/hardhat-network/provider/utils/convertToEdr.js.map +1 -0
- package/internal/hardhat-network/provider/utils/getCurrentTimestamp.d.ts +0 -1
- package/internal/hardhat-network/provider/utils/getCurrentTimestamp.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/getCurrentTimestamp.js +1 -5
- package/internal/hardhat-network/provider/utils/getCurrentTimestamp.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 +1 -3
- package/internal/hardhat-network/provider/utils/makeCommon.js.map +1 -1
- package/internal/hardhat-network/provider/utils/makeFakeSignature.d.ts +2 -2
- package/internal/hardhat-network/provider/utils/makeFakeSignature.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/makeFakeSignature.js +1 -15
- package/internal/hardhat-network/provider/utils/makeFakeSignature.js.map +1 -1
- package/internal/hardhat-network/provider/utils/makeForkClient.d.ts +10 -1
- package/internal/hardhat-network/provider/utils/makeForkClient.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/makeForkClient.js +38 -18
- package/internal/hardhat-network/provider/utils/makeForkClient.js.map +1 -1
- package/internal/hardhat-network/provider/utils/makeStateTrie.js +2 -2
- package/internal/hardhat-network/provider/utils/makeStateTrie.js.map +1 -1
- package/internal/hardhat-network/provider/utils/putGenesisBlock.d.ts +3 -1
- package/internal/hardhat-network/provider/utils/putGenesisBlock.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/putGenesisBlock.js +2 -6
- package/internal/hardhat-network/provider/utils/putGenesisBlock.js.map +1 -1
- package/internal/hardhat-network/provider/utils/random.d.ts +1 -0
- package/internal/hardhat-network/provider/utils/random.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/random.js +7 -1
- package/internal/hardhat-network/provider/utils/random.js.map +1 -1
- package/internal/hardhat-network/provider/utils/reorgs-protection.d.ts +1 -1
- package/internal/hardhat-network/provider/utils/reorgs-protection.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/reorgs-protection.js +5 -5
- package/internal/hardhat-network/provider/utils/reorgs-protection.js.map +1 -1
- package/internal/hardhat-network/provider/vm/exit.d.ts +22 -0
- package/internal/hardhat-network/provider/vm/exit.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/exit.js +93 -0
- package/internal/hardhat-network/provider/vm/exit.js.map +1 -0
- package/internal/hardhat-network/provider/vm/minimal-vm.d.ts +29 -0
- package/internal/hardhat-network/provider/vm/minimal-vm.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/minimal-vm.js +46 -0
- package/internal/hardhat-network/provider/vm/minimal-vm.js.map +1 -0
- package/internal/hardhat-network/provider/vm/proxy-vm.d.ts +36 -0
- package/internal/hardhat-network/provider/vm/proxy-vm.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/proxy-vm.js +73 -0
- package/internal/hardhat-network/provider/vm/proxy-vm.js.map +1 -0
- package/internal/hardhat-network/provider/vm/types.d.ts +27 -0
- package/internal/hardhat-network/provider/vm/types.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/types.js +3 -0
- package/internal/hardhat-network/provider/vm/types.js.map +1 -0
- package/internal/hardhat-network/stack-traces/consoleLogger.d.ts +6 -0
- package/internal/hardhat-network/stack-traces/consoleLogger.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/consoleLogger.js +33 -16
- package/internal/hardhat-network/stack-traces/consoleLogger.js.map +1 -1
- package/internal/hardhat-network/stack-traces/contracts-identifier.d.ts +1 -2
- package/internal/hardhat-network/stack-traces/contracts-identifier.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/contracts-identifier.js +6 -7
- package/internal/hardhat-network/stack-traces/contracts-identifier.js.map +1 -1
- package/internal/hardhat-network/stack-traces/debug.js +6 -6
- package/internal/hardhat-network/stack-traces/debug.js.map +1 -1
- package/internal/hardhat-network/stack-traces/error-inferrer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/error-inferrer.js +13 -7
- package/internal/hardhat-network/stack-traces/error-inferrer.js.map +1 -1
- package/internal/hardhat-network/stack-traces/message-trace.d.ts +8 -3
- package/internal/hardhat-network/stack-traces/message-trace.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/message-trace.js +22 -1
- package/internal/hardhat-network/stack-traces/message-trace.js.map +1 -1
- package/internal/hardhat-network/stack-traces/model.d.ts +8 -0
- package/internal/hardhat-network/stack-traces/model.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/model.js +52 -0
- package/internal/hardhat-network/stack-traces/model.js.map +1 -1
- package/internal/hardhat-network/stack-traces/opcodes.d.ts +1 -0
- package/internal/hardhat-network/stack-traces/opcodes.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/opcodes.js +5 -1
- package/internal/hardhat-network/stack-traces/opcodes.js.map +1 -1
- package/internal/hardhat-network/stack-traces/solidity-errors.js +2 -2
- package/internal/hardhat-network/stack-traces/solidity-errors.js.map +1 -1
- package/internal/hardhat-network/stack-traces/solidityTracer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/solidityTracer.js +5 -5
- package/internal/hardhat-network/stack-traces/solidityTracer.js.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 +28 -34
- package/internal/hardhat-network/stack-traces/vm-debug-tracer.js.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-trace-decoder.d.ts +7 -0
- package/internal/hardhat-network/stack-traces/vm-trace-decoder.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-trace-decoder.js +69 -2
- package/internal/hardhat-network/stack-traces/vm-trace-decoder.js.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-tracer.d.ts +7 -12
- package/internal/hardhat-network/stack-traces/vm-tracer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-tracer.js +46 -65
- package/internal/hardhat-network/stack-traces/vm-tracer.js.map +1 -1
- package/internal/util/date.d.ts +1 -0
- package/internal/util/date.d.ts.map +1 -1
- package/internal/util/date.js +5 -1
- package/internal/util/date.js.map +1 -1
- package/internal/util/hardforks.d.ts +2 -0
- package/internal/util/hardforks.d.ts.map +1 -1
- package/internal/util/hardforks.js +27 -1
- package/internal/util/hardforks.js.map +1 -1
- package/package.json +18 -16
- package/src/internal/core/providers/construction.ts +7 -9
- package/src/internal/core/providers/http.ts +3 -1
- package/src/internal/core/runtime-environment.ts +2 -1
- package/src/internal/hardhat-network/jsonrpc/client.ts +1 -28
- package/src/internal/hardhat-network/jsonrpc/handler.ts +9 -1
- package/src/internal/hardhat-network/provider/modules/logger.ts +6 -801
- package/src/internal/hardhat-network/provider/node-types.ts +2 -89
- package/src/internal/hardhat-network/provider/output.ts +0 -352
- package/src/internal/hardhat-network/provider/provider.ts +482 -263
- package/src/internal/hardhat-network/provider/utils/convertToEdr.ts +228 -0
- package/src/internal/hardhat-network/provider/utils/getCurrentTimestamp.ts +0 -4
- package/src/internal/hardhat-network/provider/utils/makeCommon.ts +1 -12
- package/src/internal/hardhat-network/provider/utils/makeForkClient.ts +63 -24
- package/src/internal/hardhat-network/provider/utils/random.ts +8 -1
- package/src/internal/hardhat-network/provider/utils/reorgs-protection.ts +5 -5
- package/src/internal/hardhat-network/provider/vm/exit.ts +101 -0
- package/src/internal/hardhat-network/provider/vm/minimal-vm.ts +101 -0
- package/src/internal/hardhat-network/provider/vm/types.ts +31 -0
- package/src/internal/hardhat-network/stack-traces/consoleLogger.ts +40 -21
- package/src/internal/hardhat-network/stack-traces/contracts-identifier.ts +10 -12
- package/src/internal/hardhat-network/stack-traces/debug.ts +6 -6
- package/src/internal/hardhat-network/stack-traces/error-inferrer.ts +15 -8
- package/src/internal/hardhat-network/stack-traces/message-trace.ts +40 -4
- package/src/internal/hardhat-network/stack-traces/model.ts +61 -0
- package/src/internal/hardhat-network/stack-traces/opcodes.ts +4 -0
- package/src/internal/hardhat-network/stack-traces/solidity-errors.ts +2 -2
- package/src/internal/hardhat-network/stack-traces/solidityTracer.ts +6 -5
- package/src/internal/hardhat-network/stack-traces/vm-trace-decoder.ts +113 -4
- package/src/internal/hardhat-network/stack-traces/vm-tracer.ts +67 -95
- package/src/internal/util/date.ts +4 -0
- package/src/internal/util/hardforks.ts +52 -0
- package/src/internal/hardhat-network/provider/BlockchainBase.ts +0 -185
- package/src/internal/hardhat-network/provider/BlockchainData.ts +0 -261
- package/src/internal/hardhat-network/provider/HardhatBlockchain.ts +0 -140
- package/src/internal/hardhat-network/provider/PoolState.ts +0 -48
- package/src/internal/hardhat-network/provider/TransactionQueue.ts +0 -158
- package/src/internal/hardhat-network/provider/TxPool.ts +0 -715
- package/src/internal/hardhat-network/provider/ethereumjs-workarounds.ts +0 -21
- package/src/internal/hardhat-network/provider/filter.ts +0 -142
- package/src/internal/hardhat-network/provider/fork/ForkBlockchain.ts +0 -433
- package/src/internal/hardhat-network/provider/fork/ForkStateManager.ts +0 -480
- package/src/internal/hardhat-network/provider/fork/rpcToBlockData.ts +0 -35
- package/src/internal/hardhat-network/provider/fork/rpcToTxData.ts +0 -44
- package/src/internal/hardhat-network/provider/modules/base.ts +0 -156
- package/src/internal/hardhat-network/provider/modules/debug.ts +0 -104
- package/src/internal/hardhat-network/provider/modules/eth.ts +0 -1781
- package/src/internal/hardhat-network/provider/modules/evm.ts +0 -249
- package/src/internal/hardhat-network/provider/modules/hardhat.ts +0 -481
- package/src/internal/hardhat-network/provider/modules/net.ts +0 -60
- package/src/internal/hardhat-network/provider/modules/personal.ts +0 -40
- package/src/internal/hardhat-network/provider/modules/web3.ts +0 -49
- package/src/internal/hardhat-network/provider/node.ts +0 -2993
- package/src/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.ts +0 -226
- package/src/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.ts +0 -224
- package/src/internal/hardhat-network/provider/transactions/FakeSenderTransaction.ts +0 -216
- package/src/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.ts +0 -143
- package/src/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.ts +0 -144
- package/src/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.ts +0 -171
- package/src/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.ts +0 -169
- package/src/internal/hardhat-network/provider/types/HardhatBlockchainInterface.ts +0 -25
- package/src/internal/hardhat-network/provider/utils/makeFakeSignature.ts +0 -60
- package/src/internal/hardhat-network/provider/utils/makeStateTrie.ts +0 -29
- package/src/internal/hardhat-network/provider/utils/putGenesisBlock.ts +0 -61
- package/src/internal/hardhat-network/provider/utils/reorganizeTransactionsLists.ts +0 -45
- package/src/internal/hardhat-network/provider/utils/txMapToArray.ts +0 -7
- package/src/internal/hardhat-network/stack-traces/vm-debug-tracer.ts +0 -630
|
@@ -26,14 +26,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.HardhatNode = void 0;
|
|
30
30
|
const ethereumjs_block_1 = require("@nomicfoundation/ethereumjs-block");
|
|
31
31
|
const ethereumjs_common_1 = require("@nomicfoundation/ethereumjs-common");
|
|
32
|
-
const exceptions_1 = require("@nomicfoundation/ethereumjs-evm/dist/cjs/exceptions");
|
|
33
32
|
const ethereumjs_tx_1 = require("@nomicfoundation/ethereumjs-tx");
|
|
34
33
|
const ethereumjs_util_1 = require("@nomicfoundation/ethereumjs-util");
|
|
35
34
|
const ethereumjs_vm_1 = require("@nomicfoundation/ethereumjs-vm");
|
|
36
35
|
const ethereumjs_evm_1 = require("@nomicfoundation/ethereumjs-evm");
|
|
36
|
+
const exceptions_1 = require("@nomicfoundation/ethereumjs-evm/dist/exceptions");
|
|
37
37
|
const ethereumjs_statemanager_1 = require("@nomicfoundation/ethereumjs-statemanager");
|
|
38
38
|
const eth_sig_util_1 = require("@metamask/eth-sig-util");
|
|
39
39
|
const chalk_1 = __importDefault(require("chalk"));
|
|
@@ -79,8 +79,6 @@ const makeStateTrie_1 = require("./utils/makeStateTrie");
|
|
|
79
79
|
const putGenesisBlock_1 = require("./utils/putGenesisBlock");
|
|
80
80
|
const txMapToArray_1 = require("./utils/txMapToArray");
|
|
81
81
|
const random_1 = require("./utils/random");
|
|
82
|
-
const BEACON_ROOT_ADDRESS = "0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02";
|
|
83
|
-
const BEACON_ROOT_BYTECODE = "0x3373fffffffffffffffffffffffffffffffffffffffe14604d57602036146024575f5ffd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f5260205ff35b5f5ffd5b62001fff42064281555f359062001fff015500";
|
|
84
82
|
const log = (0, debug_1.default)("hardhat:core:hardhat-network:node");
|
|
85
83
|
/* eslint-disable @nomicfoundation/hardhat-internal-rules/only-hardhat-error */
|
|
86
84
|
class HardhatNode extends events_1.default {
|
|
@@ -100,7 +98,6 @@ class HardhatNode extends events_1.default {
|
|
|
100
98
|
: undefined;
|
|
101
99
|
const hardfork = (0, hardforks_1.getHardforkName)(config.hardfork);
|
|
102
100
|
const mixHashGenerator = random_1.RandomBufferGenerator.create("randomMixHashSeed");
|
|
103
|
-
const parentBeaconBlockRootGenerator = random_1.RandomBufferGenerator.create("randomParentBeaconBlockRootSeed");
|
|
104
101
|
let forkClient;
|
|
105
102
|
const common = (0, makeCommon_1.makeCommon)(config);
|
|
106
103
|
if ((0, node_types_1.isForkedNodeConfig)(config)) {
|
|
@@ -112,9 +109,6 @@ class HardhatNode extends events_1.default {
|
|
|
112
109
|
this._validateHardforks(config.forkConfig.blockNumber, common, forkNetworkId);
|
|
113
110
|
const forkStateManager = new ForkStateManager_1.ForkStateManager(forkClient, forkBlockNumber);
|
|
114
111
|
await forkStateManager.initializeGenesisAccounts(genesisAccounts);
|
|
115
|
-
if ((0, hardforks_1.hardforkGte)(hardfork, hardforks_1.HardforkName.CANCUN)) {
|
|
116
|
-
await forkStateManager.putContractCode(ethereumjs_util_1.Address.fromString(BEACON_ROOT_ADDRESS), Buffer.from((0, ethereumjs_util_1.toBytes)(BEACON_ROOT_BYTECODE)));
|
|
117
|
-
}
|
|
118
112
|
stateManager = forkStateManager;
|
|
119
113
|
blockchain = new ForkBlockchain_1.ForkBlockchain(forkClient, forkBlockNumber, common);
|
|
120
114
|
initialBlockTimeOffset = BigInt((0, date_1.getDifferenceInSeconds)(new Date(forkBlockTimestamp), new Date()));
|
|
@@ -143,27 +137,23 @@ class HardhatNode extends events_1.default {
|
|
|
143
137
|
stateManager = new ethereumjs_statemanager_1.DefaultStateManager({
|
|
144
138
|
trie: stateTrie,
|
|
145
139
|
});
|
|
146
|
-
if ((0, hardforks_1.hardforkGte)(hardfork, hardforks_1.HardforkName.CANCUN)) {
|
|
147
|
-
await stateManager.putContractCode(ethereumjs_util_1.Address.fromString(BEACON_ROOT_ADDRESS), Buffer.from((0, ethereumjs_util_1.toBytes)(BEACON_ROOT_BYTECODE)));
|
|
148
|
-
}
|
|
149
140
|
const hardhatBlockchain = new HardhatBlockchain_1.HardhatBlockchain(common);
|
|
150
141
|
const genesisBlockBaseFeePerGas = (0, hardforks_1.hardforkGte)(hardfork, hardforks_1.HardforkName.LONDON)
|
|
151
142
|
? initialBaseFeePerGasConfig ??
|
|
152
143
|
BigInt(default_config_1.HARDHAT_NETWORK_DEFAULT_INITIAL_BASE_FEE_PER_GAS)
|
|
153
144
|
: undefined;
|
|
154
|
-
await (0, putGenesisBlock_1.putGenesisBlock)(hardhatBlockchain, common, config,
|
|
145
|
+
await (0, putGenesisBlock_1.putGenesisBlock)(hardhatBlockchain, common, config, stateTrie, hardfork, mixHashGenerator.next(), genesisBlockBaseFeePerGas);
|
|
155
146
|
if (config.initialDate !== undefined) {
|
|
156
147
|
initialBlockTimeOffset = BigInt((0, date_1.getDifferenceInSeconds)(config.initialDate, new Date()));
|
|
157
148
|
}
|
|
158
149
|
blockchain = hardhatBlockchain;
|
|
159
150
|
}
|
|
160
151
|
const txPool = new TxPool_1.TxPool(stateManager, BigInt(blockGasLimit), common);
|
|
161
|
-
const
|
|
152
|
+
const eei = new ethereumjs_vm_1.EEI(stateManager, common, blockchain);
|
|
153
|
+
const evm = await ethereumjs_evm_1.EVM.create({
|
|
154
|
+
eei,
|
|
162
155
|
allowUnlimitedContractSize,
|
|
163
|
-
allowUnlimitedInitCodeSize: allowUnlimitedContractSize,
|
|
164
|
-
blockchain,
|
|
165
156
|
common,
|
|
166
|
-
stateManager,
|
|
167
157
|
});
|
|
168
158
|
const vm = await ethereumjs_vm_1.VM.create({
|
|
169
159
|
evm,
|
|
@@ -172,8 +162,8 @@ class HardhatNode extends events_1.default {
|
|
|
172
162
|
stateManager,
|
|
173
163
|
blockchain,
|
|
174
164
|
});
|
|
175
|
-
const instanceId = (0, ethereumjs_util_1.
|
|
176
|
-
const node = new HardhatNode(vm, instanceId, stateManager, blockchain, txPool, automine, minGasPrice, initialBlockTimeOffset, mempoolOrder, config.coinbase, genesisAccounts, networkId, chainId, hardfork, hardforkActivations, mixHashGenerator,
|
|
165
|
+
const instanceId = (0, ethereumjs_util_1.bufferToBigInt)((0, crypto_1.randomBytes)(32));
|
|
166
|
+
const node = new HardhatNode(vm, instanceId, stateManager, blockchain, txPool, automine, minGasPrice, initialBlockTimeOffset, mempoolOrder, config.coinbase, genesisAccounts, networkId, chainId, hardfork, hardforkActivations, mixHashGenerator, allowUnlimitedContractSize, allowBlocksWithSameTimestamp, tracingConfig, forkNetworkId, forkBlockNum, forkBlockHash, nextBlockBaseFeePerGas, forkClient, enableTransientStorage);
|
|
177
167
|
return [common, node];
|
|
178
168
|
}
|
|
179
169
|
static _validateHardforks(forkBlockNumber, common, remoteChainId) {
|
|
@@ -193,7 +183,7 @@ The hardfork must be at least spuriousDragon, but ${common.hardfork()} was given
|
|
|
193
183
|
// this validation.
|
|
194
184
|
return;
|
|
195
185
|
}
|
|
196
|
-
upstreamCommon.
|
|
186
|
+
upstreamCommon.setHardforkByBlockNumber(forkBlockNumber);
|
|
197
187
|
if (!upstreamCommon.gteHardfork("spuriousDragon")) {
|
|
198
188
|
throw new errors_2.InternalError(`Cannot fork ${upstreamCommon.chainName()} from block ${forkBlockNumber}.
|
|
199
189
|
|
|
@@ -201,7 +191,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
201
191
|
}
|
|
202
192
|
}
|
|
203
193
|
}
|
|
204
|
-
constructor(_vm, _instanceId, _stateManager, _blockchain, _txPool, _automine, _minGasPrice, _blockTimeOffsetSeconds = 0n, _mempoolOrder, _coinbase, genesisAccounts, _configNetworkId, _configChainId, hardfork, _hardforkActivations, _mixHashGenerator,
|
|
194
|
+
constructor(_vm, _instanceId, _stateManager, _blockchain, _txPool, _automine, _minGasPrice, _blockTimeOffsetSeconds = 0n, _mempoolOrder, _coinbase, genesisAccounts, _configNetworkId, _configChainId, hardfork, _hardforkActivations, _mixHashGenerator, allowUnlimitedContractSize, _allowBlocksWithSameTimestamp, tracingConfig, _forkNetworkId, _forkBlockNumber, _forkBlockHash, nextBlockBaseFee, _forkClient, _enableTransientStorage = false) {
|
|
205
195
|
super();
|
|
206
196
|
this._vm = _vm;
|
|
207
197
|
this._instanceId = _instanceId;
|
|
@@ -218,7 +208,6 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
218
208
|
this.hardfork = hardfork;
|
|
219
209
|
this._hardforkActivations = _hardforkActivations;
|
|
220
210
|
this._mixHashGenerator = _mixHashGenerator;
|
|
221
|
-
this._parentBeaconBlockRootGenerator = _parentBeaconBlockRootGenerator;
|
|
222
211
|
this.allowUnlimitedContractSize = allowUnlimitedContractSize;
|
|
223
212
|
this._allowBlocksWithSameTimestamp = _allowBlocksWithSameTimestamp;
|
|
224
213
|
this._forkNetworkId = _forkNetworkId;
|
|
@@ -266,32 +255,26 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
266
255
|
}
|
|
267
256
|
}
|
|
268
257
|
async getSignedTransaction(txParams) {
|
|
269
|
-
const senderAddress = (0, ethereumjs_util_1.
|
|
258
|
+
const senderAddress = (0, ethereumjs_util_1.bufferToHex)(txParams.from);
|
|
270
259
|
const pk = this._localAccounts.get(senderAddress);
|
|
271
260
|
if (pk !== undefined) {
|
|
272
261
|
let tx;
|
|
273
|
-
if ("
|
|
274
|
-
tx = ethereumjs_tx_1.BlobEIP4844Transaction.fromTxData(txParams, {
|
|
275
|
-
common: this._vm.common,
|
|
276
|
-
allowUnlimitedInitCodeSize: true,
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
else if ("maxFeePerGas" in txParams) {
|
|
262
|
+
if ("maxFeePerGas" in txParams) {
|
|
280
263
|
tx = ethereumjs_tx_1.FeeMarketEIP1559Transaction.fromTxData(txParams, {
|
|
281
|
-
common: this._vm.
|
|
282
|
-
|
|
264
|
+
common: this._vm._common,
|
|
265
|
+
disableMaxInitCodeSizeCheck: true,
|
|
283
266
|
});
|
|
284
267
|
}
|
|
285
268
|
else if ("accessList" in txParams) {
|
|
286
269
|
tx = ethereumjs_tx_1.AccessListEIP2930Transaction.fromTxData(txParams, {
|
|
287
|
-
common: this._vm.
|
|
288
|
-
|
|
270
|
+
common: this._vm._common,
|
|
271
|
+
disableMaxInitCodeSizeCheck: true,
|
|
289
272
|
});
|
|
290
273
|
}
|
|
291
274
|
else {
|
|
292
|
-
tx = ethereumjs_tx_1.
|
|
293
|
-
common: this._vm.
|
|
294
|
-
|
|
275
|
+
tx = ethereumjs_tx_1.Transaction.fromTxData(txParams, {
|
|
276
|
+
common: this._vm._common,
|
|
277
|
+
disableMaxInitCodeSizeCheck: true,
|
|
295
278
|
});
|
|
296
279
|
}
|
|
297
280
|
return tx.sign(pk);
|
|
@@ -434,11 +417,11 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
434
417
|
blockNumberOrPending = this.getLatestBlockNumber();
|
|
435
418
|
}
|
|
436
419
|
const account = await this._runInBlockContext(blockNumberOrPending, () => this._stateManager.getAccount(address));
|
|
437
|
-
return account
|
|
420
|
+
return account.balance;
|
|
438
421
|
}
|
|
439
422
|
async getNextConfirmedNonce(address, blockNumberOrPending) {
|
|
440
423
|
const account = await this._runInBlockContext(blockNumberOrPending, () => this._stateManager.getAccount(address));
|
|
441
|
-
return account
|
|
424
|
+
return account.nonce;
|
|
442
425
|
}
|
|
443
426
|
async getAccountNextPendingNonce(address) {
|
|
444
427
|
return this._txPool.getNextPendingNonce(address);
|
|
@@ -553,19 +536,13 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
553
536
|
return ethereumjs_util_1.Address.fromString(this._coinbase);
|
|
554
537
|
}
|
|
555
538
|
async getStorageAt(address, positionIndex, blockNumberOrPending) {
|
|
556
|
-
const key = (0, ethereumjs_util_1.setLengthLeft)((0, ethereumjs_util_1.
|
|
557
|
-
const data = await this._runInBlockContext(blockNumberOrPending,
|
|
558
|
-
const account = await this._stateManager.getAccount(address);
|
|
559
|
-
if (account === undefined) {
|
|
560
|
-
return Uint8Array.from([]);
|
|
561
|
-
}
|
|
562
|
-
return this._stateManager.getContractStorage(address, key);
|
|
563
|
-
});
|
|
539
|
+
const key = (0, ethereumjs_util_1.setLengthLeft)((0, ethereumjs_util_1.bigIntToBuffer)(positionIndex), 32);
|
|
540
|
+
const data = await this._runInBlockContext(blockNumberOrPending, () => this._stateManager.getContractStorage(address, key));
|
|
564
541
|
const EXPECTED_DATA_SIZE = 32;
|
|
565
542
|
if (data.length < EXPECTED_DATA_SIZE) {
|
|
566
543
|
return Buffer.concat([Buffer.alloc(EXPECTED_DATA_SIZE - data.length, 0), data], EXPECTED_DATA_SIZE);
|
|
567
544
|
}
|
|
568
|
-
return
|
|
545
|
+
return data;
|
|
569
546
|
}
|
|
570
547
|
async getBlockByNumber(blockNumberOrPending) {
|
|
571
548
|
if (blockNumberOrPending === "pending") {
|
|
@@ -596,7 +573,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
596
573
|
return this._blockchain.getTotalDifficulty(block.hash());
|
|
597
574
|
}
|
|
598
575
|
async getCode(address, blockNumberOrPending) {
|
|
599
|
-
return this._runInBlockContext(blockNumberOrPending, () => this._stateManager.getContractCode(address)
|
|
576
|
+
return this._runInBlockContext(blockNumberOrPending, () => this._stateManager.getContractCode(address));
|
|
600
577
|
}
|
|
601
578
|
getNextBlockTimestamp() {
|
|
602
579
|
return this._nextBlockTimestamp;
|
|
@@ -637,7 +614,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
637
614
|
return this._txPool.getTransactionByHash(hash)?.data;
|
|
638
615
|
}
|
|
639
616
|
async getTransactionReceipt(hash) {
|
|
640
|
-
const hashBuffer = hash instanceof Buffer ? hash : (0, ethereumjs_util_1.
|
|
617
|
+
const hashBuffer = hash instanceof Buffer ? hash : (0, ethereumjs_util_1.toBuffer)(hash);
|
|
641
618
|
const receipt = await this._blockchain.getTransactionReceipt(hashBuffer);
|
|
642
619
|
return receipt ?? undefined;
|
|
643
620
|
}
|
|
@@ -654,7 +631,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
654
631
|
async signTypedDataV4(address, typedData) {
|
|
655
632
|
const privateKey = this._getLocalAccountPrivateKey(address);
|
|
656
633
|
return (0, eth_sig_util_1.signTypedData)({
|
|
657
|
-
privateKey
|
|
634
|
+
privateKey,
|
|
658
635
|
version: eth_sig_util_1.SignTypedDataVersion.V4,
|
|
659
636
|
data: typedData,
|
|
660
637
|
});
|
|
@@ -676,7 +653,6 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
676
653
|
userProvidedNextBlockBaseFeePerGas: this.getUserProvidedNextBlockBaseFeePerGas(),
|
|
677
654
|
coinbase: this.getCoinbaseAddress().toString(),
|
|
678
655
|
mixHashGenerator: this._mixHashGenerator.clone(),
|
|
679
|
-
parentBeaconBlockRootGenerator: this._parentBeaconBlockRootGenerator.clone(),
|
|
680
656
|
};
|
|
681
657
|
this._irregularStatesByBlockNumber = new Map(this._irregularStatesByBlockNumber);
|
|
682
658
|
this._snapshots.push(snapshot);
|
|
@@ -715,8 +691,6 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
715
691
|
}
|
|
716
692
|
this._coinbase = snapshot.coinbase;
|
|
717
693
|
this._mixHashGenerator = snapshot.mixHashGenerator;
|
|
718
|
-
this._parentBeaconBlockRootGenerator =
|
|
719
|
-
snapshot.parentBeaconBlockRootGenerator;
|
|
720
694
|
// We delete this and the following snapshots, as they can only be used
|
|
721
695
|
// once in Ganache
|
|
722
696
|
this._snapshots.splice(snapshotIndex);
|
|
@@ -748,7 +722,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
748
722
|
id: filterId,
|
|
749
723
|
type: filter_1.Type.BLOCK_SUBSCRIPTION,
|
|
750
724
|
deadline: this._newDeadline(),
|
|
751
|
-
hashes: [(0, ethereumjs_util_1.
|
|
725
|
+
hashes: [(0, ethereumjs_util_1.bufferToHex)(block.header.hash())],
|
|
752
726
|
logs: [],
|
|
753
727
|
subscription: isSubscription,
|
|
754
728
|
});
|
|
@@ -830,11 +804,11 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
830
804
|
return true;
|
|
831
805
|
}
|
|
832
806
|
addImpersonatedAccount(address) {
|
|
833
|
-
this._impersonatedAccounts.add((0, ethereumjs_util_1.
|
|
807
|
+
this._impersonatedAccounts.add((0, ethereumjs_util_1.bufferToHex)(address));
|
|
834
808
|
return true;
|
|
835
809
|
}
|
|
836
810
|
removeImpersonatedAccount(address) {
|
|
837
|
-
return this._impersonatedAccounts.delete((0, ethereumjs_util_1.
|
|
811
|
+
return this._impersonatedAccounts.delete((0, ethereumjs_util_1.bufferToHex)(address));
|
|
838
812
|
}
|
|
839
813
|
setAutomine(automine) {
|
|
840
814
|
this._automine = automine;
|
|
@@ -856,18 +830,14 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
856
830
|
}
|
|
857
831
|
const isTransactionMined = await this._isTransactionMined(hash);
|
|
858
832
|
if (isTransactionMined) {
|
|
859
|
-
throw new errors_2.InvalidArgumentsError(`Transaction ${(0, ethereumjs_util_1.
|
|
833
|
+
throw new errors_2.InvalidArgumentsError(`Transaction ${(0, ethereumjs_util_1.bufferToHex)(hash)} cannot be dropped because it's already mined`);
|
|
860
834
|
}
|
|
861
835
|
return false;
|
|
862
836
|
}
|
|
863
837
|
async setAccountBalance(address, newBalance) {
|
|
864
838
|
const account = await this._stateManager.getAccount(address);
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
balance: newBalance,
|
|
868
|
-
storageRoot: account?.storageRoot,
|
|
869
|
-
codeHash: account?.codeHash,
|
|
870
|
-
}));
|
|
839
|
+
account.balance = newBalance;
|
|
840
|
+
await this._stateManager.putAccount(address, account);
|
|
871
841
|
await this._persistIrregularWorldState();
|
|
872
842
|
}
|
|
873
843
|
async setAccountCode(address, newCode) {
|
|
@@ -879,20 +849,15 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
879
849
|
throw new errors_2.InternalError("Cannot set account nonce when the transaction pool is not empty");
|
|
880
850
|
}
|
|
881
851
|
const account = await this._stateManager.getAccount(address);
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
await this._stateManager.putAccount(address,
|
|
887
|
-
nonce: newNonce,
|
|
888
|
-
balance: account?.balance,
|
|
889
|
-
storageRoot: account?.storageRoot,
|
|
890
|
-
codeHash: account?.codeHash,
|
|
891
|
-
}));
|
|
852
|
+
if (newNonce < account.nonce) {
|
|
853
|
+
throw new errors_2.InvalidInputError(`New nonce (${newNonce.toString()}) must not be smaller than the existing nonce (${account.nonce.toString()})`);
|
|
854
|
+
}
|
|
855
|
+
account.nonce = newNonce;
|
|
856
|
+
await this._stateManager.putAccount(address, account);
|
|
892
857
|
await this._persistIrregularWorldState();
|
|
893
858
|
}
|
|
894
859
|
async setStorageAt(address, positionIndex, value) {
|
|
895
|
-
await this._stateManager.putContractStorage(address, (0, ethereumjs_util_1.setLengthLeft)((0, ethereumjs_util_1.
|
|
860
|
+
await this._stateManager.putContractStorage(address, (0, ethereumjs_util_1.setLengthLeft)((0, ethereumjs_util_1.bigIntToBuffer)(positionIndex), 32), value);
|
|
896
861
|
await this._persistIrregularWorldState();
|
|
897
862
|
}
|
|
898
863
|
async traceCall(callParams, block, traceConfig) {
|
|
@@ -904,7 +869,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
904
869
|
async traceTransaction(hash, config) {
|
|
905
870
|
const block = await this.getBlockByTransactionHash(hash);
|
|
906
871
|
if (block === undefined) {
|
|
907
|
-
throw new errors_2.InvalidInputError(`Unable to find a block containing transaction ${(0, ethereumjs_util_1.
|
|
872
|
+
throw new errors_2.InvalidInputError(`Unable to find a block containing transaction ${(0, ethereumjs_util_1.bufferToHex)(hash)}`);
|
|
908
873
|
}
|
|
909
874
|
return this._runInBlockContext(block.header.number - 1n, async () => {
|
|
910
875
|
const blockNumber = block.header.number;
|
|
@@ -925,7 +890,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
925
890
|
// to avoid having to distinguish between empty and non-existing accounts.
|
|
926
891
|
// We *could* do it during the non-forked mode, but for simplicity we just
|
|
927
892
|
// don't support it at all.
|
|
928
|
-
const isPreSpuriousDragon = !vm.
|
|
893
|
+
const isPreSpuriousDragon = !vm._common.gteHardfork("spuriousDragon");
|
|
929
894
|
if (isPreSpuriousDragon) {
|
|
930
895
|
throw new errors_2.InvalidInputError("Tracing is not supported for transactions using hardforks older than Spurious Dragon. ");
|
|
931
896
|
}
|
|
@@ -934,20 +899,20 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
934
899
|
const sender = tx.getSenderAddress();
|
|
935
900
|
if (tx.type === 0) {
|
|
936
901
|
txWithCommon = new FakeSenderTransaction_1.FakeSenderTransaction(sender, tx, {
|
|
937
|
-
common: vm.
|
|
902
|
+
common: vm._common,
|
|
938
903
|
});
|
|
939
904
|
}
|
|
940
905
|
else if (tx.type === 1) {
|
|
941
|
-
txWithCommon = new FakeSenderAccessListEIP2930Transaction_1.FakeSenderAccessListEIP2930Transaction(sender, tx, { common: vm.
|
|
906
|
+
txWithCommon = new FakeSenderAccessListEIP2930Transaction_1.FakeSenderAccessListEIP2930Transaction(sender, tx, { common: vm._common });
|
|
942
907
|
}
|
|
943
908
|
else if (tx.type === 2) {
|
|
944
|
-
txWithCommon = new FakeSenderEIP1559Transaction_1.FakeSenderEIP1559Transaction(sender, { ...tx, gasPrice: undefined }, { common: vm.
|
|
909
|
+
txWithCommon = new FakeSenderEIP1559Transaction_1.FakeSenderEIP1559Transaction(sender, { ...tx, gasPrice: undefined }, { common: vm._common });
|
|
945
910
|
}
|
|
946
911
|
else {
|
|
947
912
|
throw new errors_2.InternalError("Only legacy, EIP2930, and EIP1559 txs are supported");
|
|
948
913
|
}
|
|
949
914
|
const txHash = txWithCommon.hash();
|
|
950
|
-
if (
|
|
915
|
+
if (txHash.equals(hash)) {
|
|
951
916
|
const vmDebugTracer = new vm_debug_tracer_1.VMDebugTracer(vm);
|
|
952
917
|
return vmDebugTracer.trace(async () => {
|
|
953
918
|
await vm.runTx({
|
|
@@ -1098,7 +1063,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1098
1063
|
async _addPendingTransaction(tx) {
|
|
1099
1064
|
await this._txPool.addTransaction(tx);
|
|
1100
1065
|
await this._notifyPendingTransaction(tx);
|
|
1101
|
-
return (0, ethereumjs_util_1.
|
|
1066
|
+
return (0, ethereumjs_util_1.bufferToHex)(tx.hash());
|
|
1102
1067
|
}
|
|
1103
1068
|
async _mineTransaction(tx) {
|
|
1104
1069
|
await this._addPendingTransaction(tx);
|
|
@@ -1209,9 +1174,6 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1209
1174
|
if (this.isPostMergeHardfork()) {
|
|
1210
1175
|
headerData.mixHash = this._getNextMixHash();
|
|
1211
1176
|
}
|
|
1212
|
-
if (this.isPostCancunHardfork()) {
|
|
1213
|
-
headerData.parentBeaconBlockRoot = this._getNextParentBeaconBlockRoot();
|
|
1214
|
-
}
|
|
1215
1177
|
headerData.baseFeePerGas = await this.getNextBlockBaseFeePerGas();
|
|
1216
1178
|
const blockBuilder = await this._vm.buildBlock({
|
|
1217
1179
|
parentBlock,
|
|
@@ -1263,22 +1225,22 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1263
1225
|
}
|
|
1264
1226
|
_getMinimalTransactionFee() {
|
|
1265
1227
|
// Typically 21_000 gas
|
|
1266
|
-
return this._vm.
|
|
1228
|
+
return this._vm._common.param("gasPrices", "tx");
|
|
1267
1229
|
}
|
|
1268
1230
|
async _getFakeTransaction(txParams) {
|
|
1269
1231
|
const sender = new ethereumjs_util_1.Address(txParams.from);
|
|
1270
1232
|
if ("maxFeePerGas" in txParams && txParams.maxFeePerGas !== undefined) {
|
|
1271
1233
|
return new FakeSenderEIP1559Transaction_1.FakeSenderEIP1559Transaction(sender, txParams, {
|
|
1272
|
-
common: this._vm.
|
|
1234
|
+
common: this._vm._common,
|
|
1273
1235
|
});
|
|
1274
1236
|
}
|
|
1275
1237
|
if ("accessList" in txParams && txParams.accessList !== undefined) {
|
|
1276
1238
|
return new FakeSenderAccessListEIP2930Transaction_1.FakeSenderAccessListEIP2930Transaction(sender, txParams, {
|
|
1277
|
-
common: this._vm.
|
|
1239
|
+
common: this._vm._common,
|
|
1278
1240
|
});
|
|
1279
1241
|
}
|
|
1280
1242
|
return new FakeSenderTransaction_1.FakeSenderTransaction(sender, txParams, {
|
|
1281
|
-
common: this._vm.
|
|
1243
|
+
common: this._vm._common,
|
|
1282
1244
|
});
|
|
1283
1245
|
}
|
|
1284
1246
|
_getSnapshotIndex(id) {
|
|
@@ -1301,9 +1263,9 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1301
1263
|
this._snapshots.splice(snapshotIndex);
|
|
1302
1264
|
}
|
|
1303
1265
|
_initLocalAccounts(genesisAccounts) {
|
|
1304
|
-
const privateKeys = genesisAccounts.map((acc) => (0, ethereumjs_util_1.
|
|
1266
|
+
const privateKeys = genesisAccounts.map((acc) => (0, ethereumjs_util_1.toBuffer)(acc.privateKey));
|
|
1305
1267
|
for (const pk of privateKeys) {
|
|
1306
|
-
this._localAccounts.set((0, ethereumjs_util_1.
|
|
1268
|
+
this._localAccounts.set((0, ethereumjs_util_1.bufferToHex)((0, ethereumjs_util_1.privateToAddress)(pk)), pk);
|
|
1307
1269
|
}
|
|
1308
1270
|
}
|
|
1309
1271
|
async _getConsoleLogMessages(vmTrace, vmTracerError) {
|
|
@@ -1409,7 +1371,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1409
1371
|
async _notifyPendingTransaction(tx) {
|
|
1410
1372
|
this._filters.forEach((filter) => {
|
|
1411
1373
|
if (filter.type === filter_1.Type.PENDING_TRANSACTION_SUBSCRIPTION) {
|
|
1412
|
-
const hash = (0, ethereumjs_util_1.
|
|
1374
|
+
const hash = (0, ethereumjs_util_1.bufferToHex)(tx.hash());
|
|
1413
1375
|
if (filter.subscription) {
|
|
1414
1376
|
this._emitEthEvent(filter.id, hash);
|
|
1415
1377
|
return;
|
|
@@ -1430,7 +1392,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1430
1392
|
* was added to the blockchain.
|
|
1431
1393
|
*/
|
|
1432
1394
|
async _saveBlockAsSuccessfullyRun(block, runBlockResult) {
|
|
1433
|
-
const receipts = (0, output_1.getRpcReceiptOutputsFromLocalBlockExecution)(block, runBlockResult, (0, output_1.shouldShowTransactionTypeForHardfork)(this._vm.
|
|
1395
|
+
const receipts = (0, output_1.getRpcReceiptOutputsFromLocalBlockExecution)(block, runBlockResult, (0, output_1.shouldShowTransactionTypeForHardfork)(this._vm._common));
|
|
1434
1396
|
this._blockchain.addTransactionReceipts(receipts);
|
|
1435
1397
|
const td = await this.getBlockTotalDifficulty(block);
|
|
1436
1398
|
const rpcLogs = [];
|
|
@@ -1445,10 +1407,10 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1445
1407
|
case filter_1.Type.BLOCK_SUBSCRIPTION:
|
|
1446
1408
|
const hash = block.hash();
|
|
1447
1409
|
if (filter.subscription) {
|
|
1448
|
-
this._emitEthEvent(filter.id, (0, output_1.getRpcBlock)(block, td, (0, output_1.shouldShowTransactionTypeForHardfork)(this._vm.
|
|
1410
|
+
this._emitEthEvent(filter.id, (0, output_1.getRpcBlock)(block, td, (0, output_1.shouldShowTransactionTypeForHardfork)(this._vm._common), false));
|
|
1449
1411
|
return;
|
|
1450
1412
|
}
|
|
1451
|
-
filter.hashes.push((0, ethereumjs_util_1.
|
|
1413
|
+
filter.hashes.push((0, ethereumjs_util_1.bufferToHex)(hash));
|
|
1452
1414
|
break;
|
|
1453
1415
|
case filter_1.Type.LOGS_SUBSCRIPTION:
|
|
1454
1416
|
if ((0, filter_1.bloomFilter)(new ethereumjs_vm_1.Bloom(block.header.logsBloom), filter.criteria.addresses, filter.criteria.normalizedTopics)) {
|
|
@@ -1582,7 +1544,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1582
1544
|
async _applyStateOverrideSet(stateOverrideSet) {
|
|
1583
1545
|
// Multiple state override set can be configured for different addresses, hence the loop
|
|
1584
1546
|
for (const [addrToOverride, stateOverrideOptions] of Object.entries(stateOverrideSet)) {
|
|
1585
|
-
const address = new ethereumjs_util_1.Address((0, ethereumjs_util_1.
|
|
1547
|
+
const address = new ethereumjs_util_1.Address((0, ethereumjs_util_1.toBuffer)(addrToOverride));
|
|
1586
1548
|
const { balance, nonce, code, state, stateDiff } = stateOverrideOptions;
|
|
1587
1549
|
await this._overrideBalanceAndNonce(address, balance, nonce);
|
|
1588
1550
|
await this._overrideCode(address, code);
|
|
@@ -1625,7 +1587,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1625
1587
|
throw new errors_2.InvalidInputError("The properties 'state' and 'stateDiff' cannot be used simultaneously when configuring the state override set passed to the eth_call method.");
|
|
1626
1588
|
}
|
|
1627
1589
|
for (const [storageKey, value] of Object.entries(newState)) {
|
|
1628
|
-
await this._stateManager.putContractStorage(address, (0, ethereumjs_util_1.
|
|
1590
|
+
await this._stateManager.putContractStorage(address, (0, ethereumjs_util_1.toBuffer)(storageKey), (0, ethereumjs_util_1.setLengthLeft)((0, ethereumjs_util_1.bigIntToBuffer)(value), 32));
|
|
1629
1591
|
}
|
|
1630
1592
|
}
|
|
1631
1593
|
/**
|
|
@@ -1651,9 +1613,8 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1651
1613
|
// we don't need to add the tx to the block because runTx doesn't
|
|
1652
1614
|
// know anything about the txs in the current block
|
|
1653
1615
|
}
|
|
1654
|
-
originalCommon = this._vm.
|
|
1655
|
-
|
|
1656
|
-
this._vm.common = ethereumjs_common_1.Common.custom({
|
|
1616
|
+
originalCommon = this._vm._common;
|
|
1617
|
+
this._vm._common = ethereumjs_common_1.Common.custom({
|
|
1657
1618
|
chainId: this._forkBlockNumber === undefined ||
|
|
1658
1619
|
blockContext.header.number >= this._forkBlockNumber
|
|
1659
1620
|
? this._configChainId
|
|
@@ -1661,6 +1622,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1661
1622
|
networkId: this._forkNetworkId ?? this._configNetworkId,
|
|
1662
1623
|
}, {
|
|
1663
1624
|
hardfork: this._selectHardfork(blockContext.header.number),
|
|
1625
|
+
...this._getTransientStorageSettings(),
|
|
1664
1626
|
});
|
|
1665
1627
|
// If this VM is running without EIP4895, but the block has withdrawals,
|
|
1666
1628
|
// we remove them and the withdrawal root from the block
|
|
@@ -1675,25 +1637,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1675
1637
|
},
|
|
1676
1638
|
}, {
|
|
1677
1639
|
freeze: false,
|
|
1678
|
-
common: this._vm.
|
|
1679
|
-
skipConsensusFormatValidation: true,
|
|
1680
|
-
});
|
|
1681
|
-
}
|
|
1682
|
-
// If this VM is running without cancun, but the block has cancun fields,
|
|
1683
|
-
// we remove them from the block
|
|
1684
|
-
if (!this.isCancunBlock(blockNumberOrPending) &&
|
|
1685
|
-
blockContext.header.blobGasUsed !== undefined) {
|
|
1686
|
-
blockContext = ethereumjs_block_1.Block.fromBlockData({
|
|
1687
|
-
...blockContext,
|
|
1688
|
-
header: {
|
|
1689
|
-
...blockContext.header,
|
|
1690
|
-
blobGasUsed: undefined,
|
|
1691
|
-
excessBlobGas: undefined,
|
|
1692
|
-
parentBeaconBlockRoot: undefined,
|
|
1693
|
-
},
|
|
1694
|
-
}, {
|
|
1695
|
-
freeze: false,
|
|
1696
|
-
common: this._vm.common,
|
|
1640
|
+
common: this._vm._common,
|
|
1697
1641
|
skipConsensusFormatValidation: true,
|
|
1698
1642
|
});
|
|
1699
1643
|
}
|
|
@@ -1714,7 +1658,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1714
1658
|
(blockContext.header.baseFeePerGas === undefined || forceBaseFeeZero)) {
|
|
1715
1659
|
blockContext = ethereumjs_block_1.Block.fromBlockData(blockContext, {
|
|
1716
1660
|
freeze: false,
|
|
1717
|
-
common: this._vm.
|
|
1661
|
+
common: this._vm._common,
|
|
1718
1662
|
skipConsensusFormatValidation: true,
|
|
1719
1663
|
});
|
|
1720
1664
|
blockContext.header.baseFeePerGas = 0n;
|
|
@@ -1730,7 +1674,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1730
1674
|
}
|
|
1731
1675
|
finally {
|
|
1732
1676
|
if (originalCommon !== undefined) {
|
|
1733
|
-
this._vm.
|
|
1677
|
+
this._vm._common = originalCommon;
|
|
1734
1678
|
}
|
|
1735
1679
|
await this._stateManager.setStateRoot(initialStateRoot);
|
|
1736
1680
|
}
|
|
@@ -1776,7 +1720,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1776
1720
|
}
|
|
1777
1721
|
return this._runInBlockContext(blockNumberOrPending, async () => {
|
|
1778
1722
|
const account = await this._stateManager.getAccount(address);
|
|
1779
|
-
return account
|
|
1723
|
+
return account.nonce;
|
|
1780
1724
|
});
|
|
1781
1725
|
}
|
|
1782
1726
|
async _isTransactionMined(hash) {
|
|
@@ -1797,30 +1741,20 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1797
1741
|
isEip1559Active(blockNumberOrPending) {
|
|
1798
1742
|
if (blockNumberOrPending !== undefined &&
|
|
1799
1743
|
blockNumberOrPending !== "pending") {
|
|
1800
|
-
return this._vm.
|
|
1744
|
+
return this._vm._common.hardforkGteHardfork(this._selectHardfork(blockNumberOrPending), "london");
|
|
1801
1745
|
}
|
|
1802
|
-
return this._vm.
|
|
1746
|
+
return this._vm._common.gteHardfork("london");
|
|
1803
1747
|
}
|
|
1804
1748
|
isEip4895Active(blockNumberOrPending) {
|
|
1805
1749
|
if (blockNumberOrPending !== undefined &&
|
|
1806
1750
|
blockNumberOrPending !== "pending") {
|
|
1807
|
-
return this._vm.
|
|
1751
|
+
return this._vm._common.hardforkGteHardfork(this._selectHardfork(blockNumberOrPending), "shanghai");
|
|
1808
1752
|
}
|
|
1809
|
-
return this._vm.
|
|
1810
|
-
}
|
|
1811
|
-
isCancunBlock(blockNumberOrPending) {
|
|
1812
|
-
if (blockNumberOrPending !== undefined &&
|
|
1813
|
-
blockNumberOrPending !== "pending") {
|
|
1814
|
-
return this._vm.common.hardforkGteHardfork(this._selectHardfork(blockNumberOrPending), "cancun");
|
|
1815
|
-
}
|
|
1816
|
-
return this._vm.common.gteHardfork("cancun");
|
|
1753
|
+
return this._vm._common.gteHardfork("shanghai");
|
|
1817
1754
|
}
|
|
1818
1755
|
isPostMergeHardfork() {
|
|
1819
1756
|
return (0, hardforks_1.hardforkGte)(this.hardfork, hardforks_1.HardforkName.MERGE);
|
|
1820
1757
|
}
|
|
1821
|
-
isPostCancunHardfork() {
|
|
1822
|
-
return (0, hardforks_1.hardforkGte)(this.hardfork, hardforks_1.HardforkName.CANCUN);
|
|
1823
|
-
}
|
|
1824
1758
|
setPrevRandao(prevRandao) {
|
|
1825
1759
|
this._mixHashGenerator.setNext(prevRandao);
|
|
1826
1760
|
}
|
|
@@ -1834,7 +1768,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1834
1768
|
const instanceIdHex = BigIntUtils.toEvmWord(this._instanceId);
|
|
1835
1769
|
const instanceId = `0x${instanceIdHex}`;
|
|
1836
1770
|
const latestBlock = await this.getLatestBlock();
|
|
1837
|
-
const latestBlockHashHex =
|
|
1771
|
+
const latestBlockHashHex = latestBlock.header.hash().toString("hex");
|
|
1838
1772
|
const latestBlockHash = `0x${latestBlockHashHex}`;
|
|
1839
1773
|
const metadata = {
|
|
1840
1774
|
clientVersion,
|
|
@@ -1857,9 +1791,6 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1857
1791
|
_getNextMixHash() {
|
|
1858
1792
|
return this._mixHashGenerator.next();
|
|
1859
1793
|
}
|
|
1860
|
-
_getNextParentBeaconBlockRoot() {
|
|
1861
|
-
return this._parentBeaconBlockRootGenerator.next();
|
|
1862
|
-
}
|
|
1863
1794
|
async _getEstimateGasFeePriceFields(callParams, blockNumberOrPending) {
|
|
1864
1795
|
if (!this.isEip1559Active(blockNumberOrPending) ||
|
|
1865
1796
|
callParams.gasPrice !== undefined) {
|
|
@@ -1889,7 +1820,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1889
1820
|
_selectHardfork(blockNumber) {
|
|
1890
1821
|
if (this._forkBlockNumber === undefined ||
|
|
1891
1822
|
blockNumber >= this._forkBlockNumber) {
|
|
1892
|
-
return this._vm.
|
|
1823
|
+
return this._vm._common.hardfork();
|
|
1893
1824
|
}
|
|
1894
1825
|
if (this._hardforkActivations.size === 0) {
|
|
1895
1826
|
throw new errors_2.InternalError(`No known hardfork for execution on historical block ${blockNumber.toString()} (relative to fork block number ${this._forkBlockNumber}). The node was not configured with a hardfork activation history. See http://hardhat.org/custom-hardfork-history`);
|
|
@@ -1907,16 +1838,16 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1907
1838
|
if (!constants_1.HARDHAT_NETWORK_SUPPORTED_HARDFORKS.includes(hardfork)) {
|
|
1908
1839
|
throw new errors_2.InternalError(`Tried to run a call or transaction in the context of a block whose hardfork is "${hardfork}", but Hardhat Network only supports the following hardforks: ${constants_1.HARDHAT_NETWORK_SUPPORTED_HARDFORKS.join(", ")}`);
|
|
1909
1840
|
}
|
|
1910
|
-
return hardfork
|
|
1841
|
+
return hardfork;
|
|
1911
1842
|
}
|
|
1912
1843
|
_getCommonForTracing(networkId, blockNumber) {
|
|
1913
|
-
assertTransientStorageCompatibility(this._enableTransientStorage, this._vm.common.hardfork());
|
|
1914
1844
|
try {
|
|
1915
1845
|
const common = ethereumjs_common_1.Common.custom({
|
|
1916
1846
|
chainId: networkId,
|
|
1917
1847
|
networkId,
|
|
1918
1848
|
}, {
|
|
1919
1849
|
hardfork: this._selectHardfork(BigInt(blockNumber)),
|
|
1850
|
+
...this._getTransientStorageSettings(),
|
|
1920
1851
|
});
|
|
1921
1852
|
return common;
|
|
1922
1853
|
}
|
|
@@ -1924,12 +1855,12 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1924
1855
|
throw new errors_2.InternalError(`Network id ${networkId} does not correspond to a network that Hardhat can trace`);
|
|
1925
1856
|
}
|
|
1926
1857
|
}
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1858
|
+
_getTransientStorageSettings() {
|
|
1859
|
+
if (this._enableTransientStorage) {
|
|
1860
|
+
return { eips: [1153] };
|
|
1861
|
+
}
|
|
1862
|
+
return {};
|
|
1932
1863
|
}
|
|
1933
1864
|
}
|
|
1934
|
-
exports.
|
|
1865
|
+
exports.HardhatNode = HardhatNode;
|
|
1935
1866
|
//# sourceMappingURL=node.js.map
|