hardhat 2.21.0-dev.0 → 2.21.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/cli/constants.d.ts.map +1 -1
- package/internal/cli/constants.js +1 -1
- package/internal/cli/constants.js.map +1 -1
- package/internal/cli/project-creation.js +1 -1
- package/internal/hardhat-network/provider/provider.d.ts +2 -0
- package/internal/hardhat-network/provider/provider.d.ts.map +1 -1
- package/internal/hardhat-network/provider/provider.js +21 -8
- package/internal/hardhat-network/provider/provider.js.map +1 -1
- package/internal/hardhat-network/provider/utils/convertToEdr.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/convertToEdr.js +3 -0
- package/internal/hardhat-network/provider/utils/convertToEdr.js.map +1 -1
- package/internal/hardhat-network/provider/vm/minimal-vm.d.ts.map +1 -1
- package/internal/hardhat-network/provider/vm/minimal-vm.js +3 -6
- package/internal/hardhat-network/provider/vm/minimal-vm.js.map +1 -1
- package/internal/hardhat-network/provider/vm/types.d.ts +1 -0
- package/internal/hardhat-network/provider/vm/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/internal/cli/constants.ts +1 -1
- package/src/internal/cli/project-creation.ts +1 -1
- package/src/internal/hardhat-network/provider/provider.ts +45 -19
- package/src/internal/hardhat-network/provider/utils/convertToEdr.ts +4 -0
- package/src/internal/hardhat-network/provider/vm/minimal-vm.ts +3 -6
- package/src/internal/hardhat-network/provider/vm/types.ts +1 -0
- package/internal/hardhat-network/provider/BlockchainBase.d.ts +0 -29
- package/internal/hardhat-network/provider/BlockchainBase.d.ts.map +0 -1
- package/internal/hardhat-network/provider/BlockchainBase.js +0 -144
- package/internal/hardhat-network/provider/BlockchainBase.js.map +0 -1
- package/internal/hardhat-network/provider/BlockchainData.d.ts +0 -58
- package/internal/hardhat-network/provider/BlockchainData.d.ts.map +0 -1
- package/internal/hardhat-network/provider/BlockchainData.js +0 -178
- package/internal/hardhat-network/provider/BlockchainData.js.map +0 -1
- package/internal/hardhat-network/provider/HardhatBlockchain.d.ts +0 -24
- package/internal/hardhat-network/provider/HardhatBlockchain.d.ts.map +0 -1
- package/internal/hardhat-network/provider/HardhatBlockchain.js +0 -73
- package/internal/hardhat-network/provider/HardhatBlockchain.js.map +0 -1
- package/internal/hardhat-network/provider/PoolState.d.ts +0 -26
- package/internal/hardhat-network/provider/PoolState.d.ts.map +0 -1
- package/internal/hardhat-network/provider/PoolState.js +0 -41
- package/internal/hardhat-network/provider/PoolState.js.map +0 -1
- package/internal/hardhat-network/provider/TransactionQueue.d.ts +0 -32
- package/internal/hardhat-network/provider/TransactionQueue.d.ts.map +0 -1
- package/internal/hardhat-network/provider/TransactionQueue.js +0 -130
- package/internal/hardhat-network/provider/TransactionQueue.js.map +0 -1
- package/internal/hardhat-network/provider/TxPool.d.ts +0 -83
- package/internal/hardhat-network/provider/TxPool.d.ts.map +0 -1
- package/internal/hardhat-network/provider/TxPool.js +0 -470
- package/internal/hardhat-network/provider/TxPool.js.map +0 -1
- package/internal/hardhat-network/provider/ethereumjs-workarounds.d.ts +0 -2
- package/internal/hardhat-network/provider/ethereumjs-workarounds.d.ts.map +0 -1
- package/internal/hardhat-network/provider/ethereumjs-workarounds.js +0 -15
- package/internal/hardhat-network/provider/ethereumjs-workarounds.js.map +0 -1
- package/internal/hardhat-network/provider/filter.d.ts +0 -29
- package/internal/hardhat-network/provider/filter.d.ts.map +0 -1
- package/internal/hardhat-network/provider/filter.js +0 -97
- package/internal/hardhat-network/provider/filter.js.map +0 -1
- package/internal/hardhat-network/provider/fork/ForkBlockchain.d.ts +0 -33
- package/internal/hardhat-network/provider/fork/ForkBlockchain.d.ts.map +0 -1
- package/internal/hardhat-network/provider/fork/ForkBlockchain.js +0 -272
- package/internal/hardhat-network/provider/fork/ForkBlockchain.js.map +0 -1
- package/internal/hardhat-network/provider/fork/ForkStateManager.d.ts +0 -52
- package/internal/hardhat-network/provider/fork/ForkStateManager.d.ts.map +0 -1
- package/internal/hardhat-network/provider/fork/ForkStateManager.js +0 -319
- package/internal/hardhat-network/provider/fork/ForkStateManager.js.map +0 -1
- package/internal/hardhat-network/provider/fork/rpcToBlockData.d.ts +0 -4
- package/internal/hardhat-network/provider/fork/rpcToBlockData.d.ts.map +0 -1
- package/internal/hardhat-network/provider/fork/rpcToBlockData.js +0 -32
- package/internal/hardhat-network/provider/fork/rpcToBlockData.js.map +0 -1
- package/internal/hardhat-network/provider/fork/rpcToTxData.d.ts +0 -10
- package/internal/hardhat-network/provider/fork/rpcToTxData.d.ts.map +0 -1
- package/internal/hardhat-network/provider/fork/rpcToTxData.js +0 -29
- package/internal/hardhat-network/provider/fork/rpcToTxData.js.map +0 -1
- package/internal/hardhat-network/provider/modules/base.d.ts +0 -17
- package/internal/hardhat-network/provider/modules/base.d.ts.map +0 -1
- package/internal/hardhat-network/provider/modules/base.js +0 -127
- package/internal/hardhat-network/provider/modules/base.js.map +0 -1
- package/internal/hardhat-network/provider/modules/debug.d.ts +0 -12
- package/internal/hardhat-network/provider/modules/debug.d.ts.map +0 -1
- package/internal/hardhat-network/provider/modules/debug.js +0 -52
- package/internal/hardhat-network/provider/modules/debug.js.map +0 -1
- package/internal/hardhat-network/provider/modules/eth.d.ts +0 -107
- package/internal/hardhat-network/provider/modules/eth.d.ts.map +0 -1
- package/internal/hardhat-network/provider/modules/eth.js +0 -1034
- package/internal/hardhat-network/provider/modules/eth.js.map +0 -1
- package/internal/hardhat-network/provider/modules/evm.d.ts +0 -32
- package/internal/hardhat-network/provider/modules/evm.d.ts.map +0 -1
- package/internal/hardhat-network/provider/modules/evm.js +0 -180
- package/internal/hardhat-network/provider/modules/evm.js.map +0 -1
- package/internal/hardhat-network/provider/modules/hardhat.d.ts +0 -54
- package/internal/hardhat-network/provider/modules/hardhat.d.ts.map +0 -1
- package/internal/hardhat-network/provider/modules/hardhat.js +0 -309
- package/internal/hardhat-network/provider/modules/hardhat.js.map +0 -1
- package/internal/hardhat-network/provider/modules/net.d.ts +0 -13
- package/internal/hardhat-network/provider/modules/net.d.ts.map +0 -1
- package/internal/hardhat-network/provider/modules/net.js +0 -47
- package/internal/hardhat-network/provider/modules/net.js.map +0 -1
- package/internal/hardhat-network/provider/modules/personal.d.ts +0 -9
- package/internal/hardhat-network/provider/modules/personal.d.ts.map +0 -1
- package/internal/hardhat-network/provider/modules/personal.js +0 -31
- package/internal/hardhat-network/provider/modules/personal.js.map +0 -1
- package/internal/hardhat-network/provider/modules/web3.d.ts +0 -11
- package/internal/hardhat-network/provider/modules/web3.d.ts.map +0 -1
- package/internal/hardhat-network/provider/modules/web3.js +0 -38
- package/internal/hardhat-network/provider/modules/web3.js.map +0 -1
- package/internal/hardhat-network/provider/node.d.ts +0 -197
- package/internal/hardhat-network/provider/node.d.ts.map +0 -1
- package/internal/hardhat-network/provider/node.js +0 -1866
- package/internal/hardhat-network/provider/node.js.map +0 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.d.ts +0 -29
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.d.ts.map +0 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js +0 -137
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js.map +0 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.d.ts +0 -27
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.d.ts.map +0 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js +0 -137
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js.map +0 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.d.ts +0 -33
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.d.ts.map +0 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js +0 -141
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js.map +0 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.d.ts +0 -30
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.d.ts.map +0 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.js +0 -97
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.js.map +0 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.d.ts +0 -30
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.d.ts.map +0 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.js +0 -98
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.js.map +0 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.d.ts +0 -40
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.d.ts.map +0 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.js +0 -91
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.js.map +0 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.d.ts +0 -32
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.d.ts.map +0 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.js +0 -87
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.js.map +0 -1
- package/internal/hardhat-network/provider/types/HardhatBlockchainInterface.d.ts +0 -17
- package/internal/hardhat-network/provider/types/HardhatBlockchainInterface.d.ts.map +0 -1
- package/internal/hardhat-network/provider/types/HardhatBlockchainInterface.js +0 -3
- package/internal/hardhat-network/provider/types/HardhatBlockchainInterface.js.map +0 -1
- package/internal/hardhat-network/provider/utils/makeFakeSignature.d.ts +0 -7
- package/internal/hardhat-network/provider/utils/makeFakeSignature.d.ts.map +0 -1
- package/internal/hardhat-network/provider/utils/makeFakeSignature.js +0 -31
- package/internal/hardhat-network/provider/utils/makeFakeSignature.js.map +0 -1
- package/internal/hardhat-network/provider/utils/makeStateTrie.d.ts +0 -4
- package/internal/hardhat-network/provider/utils/makeStateTrie.d.ts.map +0 -1
- package/internal/hardhat-network/provider/utils/makeStateTrie.js +0 -20
- package/internal/hardhat-network/provider/utils/makeStateTrie.js.map +0 -1
- package/internal/hardhat-network/provider/utils/putGenesisBlock.d.ts +0 -8
- package/internal/hardhat-network/provider/utils/putGenesisBlock.d.ts.map +0 -1
- package/internal/hardhat-network/provider/utils/putGenesisBlock.js +0 -37
- package/internal/hardhat-network/provider/utils/putGenesisBlock.js.map +0 -1
- package/internal/hardhat-network/provider/utils/reorganizeTransactionsLists.d.ts +0 -12
- package/internal/hardhat-network/provider/utils/reorganizeTransactionsLists.d.ts.map +0 -1
- package/internal/hardhat-network/provider/utils/reorganizeTransactionsLists.js +0 -62
- package/internal/hardhat-network/provider/utils/reorganizeTransactionsLists.js.map +0 -1
- package/internal/hardhat-network/provider/utils/txMapToArray.d.ts +0 -3
- package/internal/hardhat-network/provider/utils/txMapToArray.d.ts.map +0 -1
- package/internal/hardhat-network/provider/utils/txMapToArray.js +0 -12
- package/internal/hardhat-network/provider/utils/txMapToArray.js.map +0 -1
- package/internal/hardhat-network/provider/vm/proxy-vm.d.ts +0 -36
- package/internal/hardhat-network/provider/vm/proxy-vm.d.ts.map +0 -1
- package/internal/hardhat-network/provider/vm/proxy-vm.js +0 -73
- package/internal/hardhat-network/provider/vm/proxy-vm.js.map +0 -1
- package/internal/hardhat-network/stack-traces/vm-debug-tracer.d.ts +0 -46
- package/internal/hardhat-network/stack-traces/vm-debug-tracer.d.ts.map +0 -1
- package/internal/hardhat-network/stack-traces/vm-debug-tracer.js +0 -421
- package/internal/hardhat-network/stack-traces/vm-debug-tracer.js.map +0 -1
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.BlockchainBase = void 0;
|
|
27
|
-
const ethereumjs_blockchain_1 = require("@nomicfoundation/ethereumjs-blockchain");
|
|
28
|
-
const ethereumjs_common_1 = require("@nomicfoundation/ethereumjs-common");
|
|
29
|
-
const errors_1 = require("../../core/errors");
|
|
30
|
-
const BigIntUtils = __importStar(require("../../util/bigint"));
|
|
31
|
-
const BlockchainData_1 = require("./BlockchainData");
|
|
32
|
-
/* eslint-disable @nomicfoundation/hardhat-internal-rules/only-hardhat-error */
|
|
33
|
-
class BlockchainBase {
|
|
34
|
-
constructor(_common) {
|
|
35
|
-
this._common = _common;
|
|
36
|
-
this._data = new BlockchainData_1.BlockchainData(_common);
|
|
37
|
-
// copied from blockchain.ts in @nomicfoundation/ethereumjs-blockchain
|
|
38
|
-
switch (this._common.consensusAlgorithm()) {
|
|
39
|
-
case ethereumjs_common_1.ConsensusAlgorithm.Casper:
|
|
40
|
-
this.consensus = new ethereumjs_blockchain_1.CasperConsensus();
|
|
41
|
-
break;
|
|
42
|
-
case ethereumjs_common_1.ConsensusAlgorithm.Clique:
|
|
43
|
-
this.consensus = new ethereumjs_blockchain_1.CliqueConsensus();
|
|
44
|
-
break;
|
|
45
|
-
case ethereumjs_common_1.ConsensusAlgorithm.Ethash:
|
|
46
|
-
this.consensus = new ethereumjs_blockchain_1.EthashConsensus();
|
|
47
|
-
break;
|
|
48
|
-
default:
|
|
49
|
-
throw new Error(`consensus algorithm ${this._common.consensusAlgorithm()} not supported`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
addTransactionReceipts(receipts) {
|
|
53
|
-
for (const receipt of receipts) {
|
|
54
|
-
this._data.addTransactionReceipt(receipt);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
async delBlock(blockHash) {
|
|
58
|
-
this.deleteBlock(blockHash);
|
|
59
|
-
}
|
|
60
|
-
deleteBlock(blockHash) {
|
|
61
|
-
const block = this._data.getBlockByHash(blockHash);
|
|
62
|
-
if (block === undefined) {
|
|
63
|
-
throw new Error("Block not found");
|
|
64
|
-
}
|
|
65
|
-
this._delBlock(block.header.number);
|
|
66
|
-
}
|
|
67
|
-
async getBlock(blockHashOrNumber) {
|
|
68
|
-
if ((typeof blockHashOrNumber === "number" ||
|
|
69
|
-
BigIntUtils.isBigInt(blockHashOrNumber)) &&
|
|
70
|
-
this._data.isReservedBlock(BigInt(blockHashOrNumber))) {
|
|
71
|
-
this._data.fulfillBlockReservation(BigInt(blockHashOrNumber));
|
|
72
|
-
}
|
|
73
|
-
if (typeof blockHashOrNumber === "number") {
|
|
74
|
-
const blockByNumber = this._data.getBlockByNumber(BigInt(blockHashOrNumber));
|
|
75
|
-
if (blockByNumber === undefined) {
|
|
76
|
-
throw new Error("Block not found");
|
|
77
|
-
}
|
|
78
|
-
return blockByNumber;
|
|
79
|
-
}
|
|
80
|
-
if (BigIntUtils.isBigInt(blockHashOrNumber)) {
|
|
81
|
-
const blockByNumber = this._data.getBlockByNumber(blockHashOrNumber);
|
|
82
|
-
if (blockByNumber === undefined) {
|
|
83
|
-
throw new Error("Block not found");
|
|
84
|
-
}
|
|
85
|
-
return blockByNumber;
|
|
86
|
-
}
|
|
87
|
-
const blockByHash = this._data.getBlockByHash(blockHashOrNumber);
|
|
88
|
-
if (blockByHash === undefined) {
|
|
89
|
-
throw new Error("Block not found");
|
|
90
|
-
}
|
|
91
|
-
return blockByHash;
|
|
92
|
-
}
|
|
93
|
-
async getLatestBlock() {
|
|
94
|
-
return this.getBlock(this.getLatestBlockNumber());
|
|
95
|
-
}
|
|
96
|
-
getLocalTransaction(transactionHash) {
|
|
97
|
-
return this._data.getTransaction(transactionHash);
|
|
98
|
-
}
|
|
99
|
-
iterator(_name, _onBlock) {
|
|
100
|
-
throw new Error("Method not implemented.");
|
|
101
|
-
}
|
|
102
|
-
async putBlock(block) {
|
|
103
|
-
await this.addBlock(block);
|
|
104
|
-
}
|
|
105
|
-
reserveBlocks(count, interval, previousBlockStateRoot, previousBlockTotalDifficulty, previousBlockBaseFeePerGas) {
|
|
106
|
-
this._data.reserveBlocks(this.getLatestBlockNumber() + 1n, count, interval, previousBlockStateRoot, previousBlockTotalDifficulty, previousBlockBaseFeePerGas);
|
|
107
|
-
}
|
|
108
|
-
copy() {
|
|
109
|
-
throw new Error("Method not implemented.");
|
|
110
|
-
}
|
|
111
|
-
validateHeader(_header, _height) {
|
|
112
|
-
throw new Error("Method not implemented.");
|
|
113
|
-
}
|
|
114
|
-
_delBlock(blockNumber) {
|
|
115
|
-
let i = blockNumber;
|
|
116
|
-
while (i <= this.getLatestBlockNumber()) {
|
|
117
|
-
if (this._data.isReservedBlock(i)) {
|
|
118
|
-
const reservation = this._data.cancelReservationWithBlock(i);
|
|
119
|
-
i = reservation.last + 1n;
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
const current = this._data.getBlockByNumber(i);
|
|
123
|
-
if (current !== undefined) {
|
|
124
|
-
this._data.removeBlock(current);
|
|
125
|
-
}
|
|
126
|
-
i++;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
async _computeTotalDifficulty(block) {
|
|
131
|
-
const difficulty = block.header.difficulty;
|
|
132
|
-
const blockNumber = block.header.number;
|
|
133
|
-
if (blockNumber === 0n) {
|
|
134
|
-
return difficulty;
|
|
135
|
-
}
|
|
136
|
-
const parentBlock = await this.getBlock(blockNumber - 1n);
|
|
137
|
-
const parentHash = parentBlock.hash();
|
|
138
|
-
const parentTD = this._data.getTotalDifficulty(parentHash);
|
|
139
|
-
(0, errors_1.assertHardhatInvariant)(parentTD !== undefined, "Parent block should have total difficulty");
|
|
140
|
-
return parentTD + difficulty;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
exports.BlockchainBase = BlockchainBase;
|
|
144
|
-
//# sourceMappingURL=BlockchainBase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BlockchainBase.js","sourceRoot":"","sources":["../../../src/internal/hardhat-network/provider/BlockchainBase.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kFAMgD;AAChD,0EAAgF;AAGhF,8CAA2D;AAC3D,+DAAiD;AACjD,qDAAkD;AAGlD,+EAA+E;AAE/E,MAAsB,cAAc;IAIlC,YAAsB,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;QACnC,IAAI,CAAC,KAAK,GAAG,IAAI,+BAAc,CAAC,OAAO,CAAC,CAAC;QAEzC,sEAAsE;QACtE,QAAQ,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE;YACzC,KAAK,sCAAkB,CAAC,MAAM;gBAC5B,IAAI,CAAC,SAAS,GAAG,IAAI,uCAAe,EAAE,CAAC;gBACvC,MAAM;YACR,KAAK,sCAA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AQ,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QAC3D,IAAA,+BAAsB,EACpB,QAAQ,KAAK,SAAS,EACtB,2CAA2C,CAC5C,CAAC;QAEF,OAAO,QAAQ,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AAtKD,wCAsKC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Block } from "@nomicfoundation/ethereumjs-block";
|
|
3
|
-
import { Common } from "@nomicfoundation/ethereumjs-common";
|
|
4
|
-
import { TypedTransaction } from "@nomicfoundation/ethereumjs-tx";
|
|
5
|
-
import { FilterParams } from "./node-types";
|
|
6
|
-
import { RpcLogOutput, RpcReceiptOutput } from "./output";
|
|
7
|
-
interface Reservation {
|
|
8
|
-
first: bigint;
|
|
9
|
-
last: bigint;
|
|
10
|
-
interval: bigint;
|
|
11
|
-
previousBlockStateRoot: Buffer;
|
|
12
|
-
previousBlockTotalDifficulty: bigint;
|
|
13
|
-
previousBlockBaseFeePerGas: bigint | undefined;
|
|
14
|
-
}
|
|
15
|
-
export declare class BlockchainData {
|
|
16
|
-
private _common;
|
|
17
|
-
private _blocksByNumber;
|
|
18
|
-
private _blocksByHash;
|
|
19
|
-
private _blocksByTransactions;
|
|
20
|
-
private _transactions;
|
|
21
|
-
private _transactionReceipts;
|
|
22
|
-
private _totalDifficulty;
|
|
23
|
-
private _blockReservations;
|
|
24
|
-
constructor(_common: Common);
|
|
25
|
-
reserveBlocks(first: bigint, count: bigint, interval: bigint, previousBlockStateRoot: Buffer, previousBlockTotalDifficulty: bigint, previousBlockBaseFeePerGas: bigint | undefined): void;
|
|
26
|
-
getBlockByNumber(blockNumber: bigint): Block | undefined;
|
|
27
|
-
getBlockByHash(blockHash: Buffer): Block | undefined;
|
|
28
|
-
getBlockByTransactionHash(transactionHash: Buffer): Block | undefined;
|
|
29
|
-
getTransaction(transactionHash: Buffer): TypedTransaction | undefined;
|
|
30
|
-
getTransactionReceipt(transactionHash: Buffer): RpcReceiptOutput | undefined;
|
|
31
|
-
getTotalDifficulty(blockHash: Buffer): bigint | undefined;
|
|
32
|
-
getLogs(filterParams: FilterParams): RpcLogOutput[];
|
|
33
|
-
addBlock(block: Block, totalDifficulty: bigint): void;
|
|
34
|
-
/**
|
|
35
|
-
* WARNING: this method can leave the blockchain in an invalid state where
|
|
36
|
-
* there are gaps between blocks. Ideally we should have a method that removes
|
|
37
|
-
* the given block and all the following blocks.
|
|
38
|
-
*/
|
|
39
|
-
removeBlock(block: Block): void;
|
|
40
|
-
addTransaction(transaction: TypedTransaction): void;
|
|
41
|
-
addTransactionReceipt(receipt: RpcReceiptOutput): void;
|
|
42
|
-
isReservedBlock(blockNumber: bigint): boolean;
|
|
43
|
-
private _findBlockReservation;
|
|
44
|
-
/**
|
|
45
|
-
* WARNING: this method only removes the given reservation and can result in
|
|
46
|
-
* gaps in the reservations array. Ideally we should have a method that
|
|
47
|
-
* removes the given reservation and all the following reservations.
|
|
48
|
-
*/
|
|
49
|
-
private _removeReservation;
|
|
50
|
-
/**
|
|
51
|
-
* Cancel and return the reservation that has block `blockNumber`
|
|
52
|
-
*/
|
|
53
|
-
cancelReservationWithBlock(blockNumber: bigint): Reservation;
|
|
54
|
-
fulfillBlockReservation(blockNumber: bigint): void;
|
|
55
|
-
private _calculateTimestampForReservedBlock;
|
|
56
|
-
}
|
|
57
|
-
export {};
|
|
58
|
-
//# sourceMappingURL=BlockchainData.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BlockchainData.d.ts","sourceRoot":"","sources":["../../../src/internal/hardhat-network/provider/BlockchainData.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAMlE,OAAO,EAAE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B,CAAC,OAAO,EAAE,gBAAgB;IAI/C,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAIpD,OAAO,CAAC,qBAAqB;IAO7B;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAY1B;;OAEG;IACI,0BAA0B,CAAC,WAAW,EAAE,MAAM,GAAG,WAAW;IAI5D,uBAAuB,CAAC,WAAW,EAAE,MAAM;IAiDlD,OAAO,CAAC,mCAAmC;CA6B5C"}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BlockchainData = void 0;
|
|
4
|
-
const ethereumjs_block_1 = require("@nomicfoundation/ethereumjs-block");
|
|
5
|
-
const ethereumjs_util_1 = require("@nomicfoundation/ethereumjs-util");
|
|
6
|
-
const ethereumjs_vm_1 = require("@nomicfoundation/ethereumjs-vm");
|
|
7
|
-
const errors_1 = require("../../core/errors");
|
|
8
|
-
const filter_1 = require("./filter");
|
|
9
|
-
class BlockchainData {
|
|
10
|
-
constructor(_common) {
|
|
11
|
-
this._common = _common;
|
|
12
|
-
this._blocksByNumber = new Map();
|
|
13
|
-
this._blocksByHash = new Map();
|
|
14
|
-
this._blocksByTransactions = new Map();
|
|
15
|
-
this._transactions = new Map();
|
|
16
|
-
this._transactionReceipts = new Map();
|
|
17
|
-
this._totalDifficulty = new Map();
|
|
18
|
-
this._blockReservations = new Array();
|
|
19
|
-
}
|
|
20
|
-
reserveBlocks(first, count, interval, previousBlockStateRoot, previousBlockTotalDifficulty, previousBlockBaseFeePerGas) {
|
|
21
|
-
const reservation = {
|
|
22
|
-
first,
|
|
23
|
-
last: first + count - 1n,
|
|
24
|
-
interval,
|
|
25
|
-
previousBlockStateRoot,
|
|
26
|
-
previousBlockTotalDifficulty,
|
|
27
|
-
previousBlockBaseFeePerGas,
|
|
28
|
-
};
|
|
29
|
-
this._blockReservations.push(reservation);
|
|
30
|
-
}
|
|
31
|
-
getBlockByNumber(blockNumber) {
|
|
32
|
-
return this._blocksByNumber.get(blockNumber);
|
|
33
|
-
}
|
|
34
|
-
getBlockByHash(blockHash) {
|
|
35
|
-
return this._blocksByHash.get((0, ethereumjs_util_1.bufferToHex)(blockHash));
|
|
36
|
-
}
|
|
37
|
-
getBlockByTransactionHash(transactionHash) {
|
|
38
|
-
return this._blocksByTransactions.get((0, ethereumjs_util_1.bufferToHex)(transactionHash));
|
|
39
|
-
}
|
|
40
|
-
getTransaction(transactionHash) {
|
|
41
|
-
return this._transactions.get((0, ethereumjs_util_1.bufferToHex)(transactionHash));
|
|
42
|
-
}
|
|
43
|
-
getTransactionReceipt(transactionHash) {
|
|
44
|
-
return this._transactionReceipts.get((0, ethereumjs_util_1.bufferToHex)(transactionHash));
|
|
45
|
-
}
|
|
46
|
-
getTotalDifficulty(blockHash) {
|
|
47
|
-
return this._totalDifficulty.get((0, ethereumjs_util_1.bufferToHex)(blockHash));
|
|
48
|
-
}
|
|
49
|
-
getLogs(filterParams) {
|
|
50
|
-
const logs = [];
|
|
51
|
-
for (let i = filterParams.fromBlock; i <= filterParams.toBlock; i++) {
|
|
52
|
-
const block = this.getBlockByNumber(i);
|
|
53
|
-
if (block === undefined ||
|
|
54
|
-
!(0, filter_1.bloomFilter)(new ethereumjs_vm_1.Bloom(block.header.logsBloom), filterParams.addresses, filterParams.normalizedTopics)) {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
for (const transaction of block.transactions) {
|
|
58
|
-
const receipt = this.getTransactionReceipt(transaction.hash());
|
|
59
|
-
if (receipt !== undefined) {
|
|
60
|
-
logs.push(...(0, filter_1.filterLogs)(receipt.logs, {
|
|
61
|
-
fromBlock: filterParams.fromBlock,
|
|
62
|
-
toBlock: filterParams.toBlock,
|
|
63
|
-
addresses: filterParams.addresses,
|
|
64
|
-
normalizedTopics: filterParams.normalizedTopics,
|
|
65
|
-
}));
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return logs;
|
|
70
|
-
}
|
|
71
|
-
addBlock(block, totalDifficulty) {
|
|
72
|
-
const blockHash = (0, ethereumjs_util_1.bufferToHex)(block.hash());
|
|
73
|
-
const blockNumber = block.header.number;
|
|
74
|
-
this._blocksByNumber.set(blockNumber, block);
|
|
75
|
-
this._blocksByHash.set(blockHash, block);
|
|
76
|
-
this._totalDifficulty.set(blockHash, totalDifficulty);
|
|
77
|
-
for (const transaction of block.transactions) {
|
|
78
|
-
const transactionHash = (0, ethereumjs_util_1.bufferToHex)(transaction.hash());
|
|
79
|
-
this._transactions.set(transactionHash, transaction);
|
|
80
|
-
this._blocksByTransactions.set(transactionHash, block);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* WARNING: this method can leave the blockchain in an invalid state where
|
|
85
|
-
* there are gaps between blocks. Ideally we should have a method that removes
|
|
86
|
-
* the given block and all the following blocks.
|
|
87
|
-
*/
|
|
88
|
-
removeBlock(block) {
|
|
89
|
-
const blockHash = (0, ethereumjs_util_1.bufferToHex)(block.hash());
|
|
90
|
-
const blockNumber = block.header.number;
|
|
91
|
-
this._blocksByNumber.delete(blockNumber);
|
|
92
|
-
this._blocksByHash.delete(blockHash);
|
|
93
|
-
this._totalDifficulty.delete(blockHash);
|
|
94
|
-
for (const transaction of block.transactions) {
|
|
95
|
-
const transactionHash = (0, ethereumjs_util_1.bufferToHex)(transaction.hash());
|
|
96
|
-
this._transactions.delete(transactionHash);
|
|
97
|
-
this._transactionReceipts.delete(transactionHash);
|
|
98
|
-
this._blocksByTransactions.delete(transactionHash);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
addTransaction(transaction) {
|
|
102
|
-
this._transactions.set((0, ethereumjs_util_1.bufferToHex)(transaction.hash()), transaction);
|
|
103
|
-
}
|
|
104
|
-
addTransactionReceipt(receipt) {
|
|
105
|
-
this._transactionReceipts.set(receipt.transactionHash, receipt);
|
|
106
|
-
}
|
|
107
|
-
isReservedBlock(blockNumber) {
|
|
108
|
-
return this._findBlockReservation(blockNumber) !== -1;
|
|
109
|
-
}
|
|
110
|
-
_findBlockReservation(blockNumber) {
|
|
111
|
-
return this._blockReservations.findIndex((reservation) => reservation.first <= blockNumber && blockNumber <= reservation.last);
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* WARNING: this method only removes the given reservation and can result in
|
|
115
|
-
* gaps in the reservations array. Ideally we should have a method that
|
|
116
|
-
* removes the given reservation and all the following reservations.
|
|
117
|
-
*/
|
|
118
|
-
_removeReservation(index) {
|
|
119
|
-
(0, errors_1.assertHardhatInvariant)(index in this._blockReservations, `Reservation ${index} does not exist`);
|
|
120
|
-
const reservation = this._blockReservations[index];
|
|
121
|
-
this._blockReservations.splice(index, 1);
|
|
122
|
-
return reservation;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Cancel and return the reservation that has block `blockNumber`
|
|
126
|
-
*/
|
|
127
|
-
cancelReservationWithBlock(blockNumber) {
|
|
128
|
-
return this._removeReservation(this._findBlockReservation(blockNumber));
|
|
129
|
-
}
|
|
130
|
-
fulfillBlockReservation(blockNumber) {
|
|
131
|
-
// in addition to adding the given block, the reservation needs to be split
|
|
132
|
-
// in two in order to accomodate access to the given block.
|
|
133
|
-
const reservationIndex = this._findBlockReservation(blockNumber);
|
|
134
|
-
(0, errors_1.assertHardhatInvariant)(reservationIndex !== -1, `No reservation to fill for block number ${blockNumber.toString()}`);
|
|
135
|
-
// capture the timestamp before removing the reservation:
|
|
136
|
-
const timestamp = this._calculateTimestampForReservedBlock(blockNumber);
|
|
137
|
-
// split the block reservation:
|
|
138
|
-
const oldReservation = this._removeReservation(reservationIndex);
|
|
139
|
-
if (blockNumber !== oldReservation.first) {
|
|
140
|
-
this._blockReservations.push({
|
|
141
|
-
...oldReservation,
|
|
142
|
-
last: blockNumber - 1n,
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
if (blockNumber !== oldReservation.last) {
|
|
146
|
-
this._blockReservations.push({
|
|
147
|
-
...oldReservation,
|
|
148
|
-
first: blockNumber + 1n,
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
this.addBlock(ethereumjs_block_1.Block.fromBlockData({
|
|
152
|
-
header: {
|
|
153
|
-
number: blockNumber,
|
|
154
|
-
stateRoot: oldReservation.previousBlockStateRoot,
|
|
155
|
-
baseFeePerGas: oldReservation.previousBlockBaseFeePerGas,
|
|
156
|
-
timestamp,
|
|
157
|
-
},
|
|
158
|
-
}, {
|
|
159
|
-
common: this._common,
|
|
160
|
-
skipConsensusFormatValidation: true,
|
|
161
|
-
}), oldReservation.previousBlockTotalDifficulty);
|
|
162
|
-
}
|
|
163
|
-
_calculateTimestampForReservedBlock(blockNumber) {
|
|
164
|
-
const reservationIndex = this._findBlockReservation(blockNumber);
|
|
165
|
-
(0, errors_1.assertHardhatInvariant)(reservationIndex !== -1, `Block ${blockNumber.toString()} does not lie within any of the reservations.`);
|
|
166
|
-
const reservation = this._blockReservations[reservationIndex];
|
|
167
|
-
const blockNumberBeforeReservation = reservation.first - 1n;
|
|
168
|
-
const blockBeforeReservation = this.getBlockByNumber(blockNumberBeforeReservation);
|
|
169
|
-
(0, errors_1.assertHardhatInvariant)(blockBeforeReservation !== undefined, `Reservation after block ${blockNumberBeforeReservation.toString()} cannot be created because that block does not exist`);
|
|
170
|
-
const previousTimestamp = this.isReservedBlock(blockNumberBeforeReservation)
|
|
171
|
-
? this._calculateTimestampForReservedBlock(blockNumberBeforeReservation)
|
|
172
|
-
: blockBeforeReservation.header.timestamp;
|
|
173
|
-
return (previousTimestamp +
|
|
174
|
-
reservation.interval * (blockNumber - reservation.first + 1n));
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
exports.BlockchainData = BlockchainData;
|
|
178
|
-
//# sourceMappingURL=BlockchainData.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BlockchainData.js","sourceRoot":"","sources":["../../../src/internal/hardhat-network/provider/B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AAA,+BAAsB,EACpB,gBAAgB,KAAK,CAAC,CAAC,EACvB,SAAS,WAAW,CAAC,QAAQ,EAAE,+CAA+C,CAC/E,CAAC;QAEF,MAAM,WAAW,GAAG,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;QAE9D,MAAM,4BAA4B,GAAG,WAAW,CAAC,KAAK,GAAG,EAAE,CAAC;QAE5D,MAAM,sBAAsB,GAAG,IAAI,CAAC,gBAAgB,CAClD,4BAA4B,CAC7B,CAAC;QACF,IAAA,+BAAsB,EACpB,sBAAsB,KAAK,SAAS,EACpC,2BAA2B,4BAA4B,CAAC,QAAQ,EAAE,sDAAsD,CACzH,CAAC;QAEF,MAAM,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAC,4BAA4B,CAAC;YAC1E,CAAC,CAAC,IAAI,CAAC,mCAAmC,CAAC,4BAA4B,CAAC;YACxE,CAAC,CAAC,sBAAsB,CAAC,MAAM,CAAC,SAAS,CAAC;QAE5C,OAAO,CACL,iBAAiB;YACjB,WAAW,CAAC,QAAQ,GAAG,CAAC,WAAW,GAAG,WAAW,CAAC,KAAK,GAAG,EAAE,CAAC,CAC9D,CAAC;IACJ,CAAC;CACF;AAhPD,wCAgPC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Block } from "@nomicfoundation/ethereumjs-block";
|
|
3
|
-
import { Common } from "@nomicfoundation/ethereumjs-common";
|
|
4
|
-
import { TypedTransaction } from "@nomicfoundation/ethereumjs-tx";
|
|
5
|
-
import { BlockchainBase } from "./BlockchainBase";
|
|
6
|
-
import { FilterParams } from "./node-types";
|
|
7
|
-
import { RpcLogOutput } from "./output";
|
|
8
|
-
import { HardhatBlockchainInterface } from "./types/HardhatBlockchainInterface";
|
|
9
|
-
export declare class HardhatBlockchain extends BlockchainBase implements HardhatBlockchainInterface {
|
|
10
|
-
private _length;
|
|
11
|
-
constructor(common: Common);
|
|
12
|
-
getLatestBlockNumber(): bigint;
|
|
13
|
-
addBlock(block: Block): Promise<Block>;
|
|
14
|
-
reserveBlocks(count: bigint, interval: bigint, previousBlockStateRoot: Buffer, previousBlockTotalDifficulty: bigint, previousBlockBaseFeePerGas: bigint | undefined): void;
|
|
15
|
-
deleteLaterBlocks(block: Block): void;
|
|
16
|
-
getTotalDifficulty(blockHash: Buffer): Promise<bigint>;
|
|
17
|
-
getTransaction(transactionHash: Buffer): Promise<TypedTransaction | undefined>;
|
|
18
|
-
getBlockByTransactionHash(transactionHash: Buffer): Promise<Block | null>;
|
|
19
|
-
getTransactionReceipt(transactionHash: Buffer): Promise<import("./output").RpcReceiptOutput | null>;
|
|
20
|
-
getLogs(filterParams: FilterParams): Promise<RpcLogOutput[]>;
|
|
21
|
-
private _validateBlock;
|
|
22
|
-
protected _delBlock(blockNumber: bigint): void;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=HardhatBlockchain.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HardhatBlockchain.d.ts","sourceRoot":"","sources":["../../../src/internal/hardhat-network/provider/HardhatBlockchain.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAGlE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAIhF,qBAAa,iBACX,SAAQ,cACR,YAAW,0BAA0B;IAErC,OAAO,CAAC,OAAO,CAAM;gBAET,MAAM,EAAE,MAAM;IAInB,oBAAoB,IAAI,MAAM;IAIxB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAQ5C,aAAa,CAClB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,sBAAsB,EAAE,MAAM,EAC9B,4BAA4B,EAAE,MAAM,EACpC,0BAA0B,EAAE,MAAM,GAAG,SAAS;IAYzC,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAS/B,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQtD,cAAc,CACzB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAI3B,yBAAyB,CACpC,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAKX,qBAAqB,CAAC,eAAe,EAAE,MAAM;IAI7C,OAAO,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAIzE,OAAO,CAAC,cAAc;IAqBtB,SAAS,CAAC,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;CAI/C"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HardhatBlockchain = void 0;
|
|
4
|
-
const ethereumjs_util_1 = require("@nomicfoundation/ethereumjs-util");
|
|
5
|
-
const BlockchainBase_1 = require("./BlockchainBase");
|
|
6
|
-
/* eslint-disable @nomicfoundation/hardhat-internal-rules/only-hardhat-error */
|
|
7
|
-
class HardhatBlockchain extends BlockchainBase_1.BlockchainBase {
|
|
8
|
-
constructor(common) {
|
|
9
|
-
super(common);
|
|
10
|
-
this._length = 0n;
|
|
11
|
-
}
|
|
12
|
-
getLatestBlockNumber() {
|
|
13
|
-
return BigInt(this._length - 1n);
|
|
14
|
-
}
|
|
15
|
-
async addBlock(block) {
|
|
16
|
-
this._validateBlock(block);
|
|
17
|
-
const totalDifficulty = await this._computeTotalDifficulty(block);
|
|
18
|
-
this._data.addBlock(block, totalDifficulty);
|
|
19
|
-
this._length += 1n;
|
|
20
|
-
return block;
|
|
21
|
-
}
|
|
22
|
-
reserveBlocks(count, interval, previousBlockStateRoot, previousBlockTotalDifficulty, previousBlockBaseFeePerGas) {
|
|
23
|
-
super.reserveBlocks(count, interval, previousBlockStateRoot, previousBlockTotalDifficulty, previousBlockBaseFeePerGas);
|
|
24
|
-
this._length += count;
|
|
25
|
-
}
|
|
26
|
-
deleteLaterBlocks(block) {
|
|
27
|
-
const actual = this._data.getBlockByHash(block.hash());
|
|
28
|
-
if (actual === undefined) {
|
|
29
|
-
throw new Error("Invalid block");
|
|
30
|
-
}
|
|
31
|
-
this._delBlock(actual.header.number + 1n);
|
|
32
|
-
}
|
|
33
|
-
async getTotalDifficulty(blockHash) {
|
|
34
|
-
const totalDifficulty = this._data.getTotalDifficulty(blockHash);
|
|
35
|
-
if (totalDifficulty === undefined) {
|
|
36
|
-
throw new Error("Block not found");
|
|
37
|
-
}
|
|
38
|
-
return totalDifficulty;
|
|
39
|
-
}
|
|
40
|
-
async getTransaction(transactionHash) {
|
|
41
|
-
return this.getLocalTransaction(transactionHash);
|
|
42
|
-
}
|
|
43
|
-
async getBlockByTransactionHash(transactionHash) {
|
|
44
|
-
const block = this._data.getBlockByTransactionHash(transactionHash);
|
|
45
|
-
return block ?? null;
|
|
46
|
-
}
|
|
47
|
-
async getTransactionReceipt(transactionHash) {
|
|
48
|
-
return this._data.getTransactionReceipt(transactionHash) ?? null;
|
|
49
|
-
}
|
|
50
|
-
async getLogs(filterParams) {
|
|
51
|
-
return this._data.getLogs(filterParams);
|
|
52
|
-
}
|
|
53
|
-
_validateBlock(block) {
|
|
54
|
-
const blockNumber = block.header.number;
|
|
55
|
-
const parentHash = block.header.parentHash;
|
|
56
|
-
const parent = this._data.getBlockByNumber(BigInt(blockNumber - 1n));
|
|
57
|
-
if (BigInt(this._length) !== blockNumber) {
|
|
58
|
-
throw new Error(`Invalid block number ${blockNumber}. Expected ${this._length}.`);
|
|
59
|
-
}
|
|
60
|
-
if ((blockNumber === 0n && !parentHash.equals((0, ethereumjs_util_1.zeros)(32))) ||
|
|
61
|
-
(blockNumber > 0 &&
|
|
62
|
-
parent !== undefined &&
|
|
63
|
-
!parentHash.equals(parent.hash()))) {
|
|
64
|
-
throw new Error("Invalid parent hash");
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
_delBlock(blockNumber) {
|
|
68
|
-
super._delBlock(blockNumber);
|
|
69
|
-
this._length = blockNumber;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
exports.HardhatBlockchain = HardhatBlockchain;
|
|
73
|
-
//# sourceMappingURL=HardhatBlockchain.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HardhatBlockchain.js","sourceRoot":"","sources":["../../../src/internal/hardhat-network/provider/HardhatBlockchain.ts"],"names":[],"mappings":";;;AAGA,sEAAyD;AAEzD,qDAAkD;AAKlD,+EAA+E;AAE/E,MAAa,iBACX,SAAQ,+BAAc;IAKtB,YAAY,MAAc;QACxB,KAAK,CAAC,MAAM,CAAC,CAAC;QAHR,YAAO,GAAG,EAAE,CAAC;IAIrB,CAAC;IAEM,oBAAoB;QACzB,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;IACnC,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,KAAY;QAChC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QAC3B,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC;QAClE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;QAC5C,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;QACnB,OAAO,KAAK,CAAC;IACf,CAAC;IAEM,aAAa,CAClB,KAAa,EACb,QAAgB,EAChB,sBAA8B,EAC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,CAAC,YAAY,CAAC,CAAC;IAC1C,CAAC;IAEO,cAAc,CAAC,KAAY;QACjC,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;QACxC,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC;QAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,WAAW,GAAG,EAAE,CAAC,CAAC,CAAC;QAErE,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,WAAW,EAAE;YACxC,MAAM,IAAI,KAAK,CACb,wBAAwB,WAAW,cAAc,IAAI,CAAC,OAAO,GAAG,CACjE,CAAC;SACH;QAED,IACE,CAAC,WAAW,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAA,uBAAK,EAAC,EAAE,CAAC,CAAC,CAAC;YACrD,CAAC,WAAW,GAAG,CAAC;gBACd,MAAM,KAAK,SAAS;gBACpB,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,EACpC;YACA,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;SACxC;IACH,CAAC;IAES,SAAS,CAAC,WAAmB;QACrC,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,WAAW,CAAC;IAC7B,CAAC;CACF;AAtGD,8CAsGC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { TypedTransaction } from "@nomicfoundation/ethereumjs-tx";
|
|
2
|
-
import { List as ImmutableList, Map as ImmutableMap, Record as ImmutableRecord } from "immutable";
|
|
3
|
-
export interface OrderedTransaction {
|
|
4
|
-
orderId: number;
|
|
5
|
-
data: TypedTransaction;
|
|
6
|
-
}
|
|
7
|
-
interface ImmutableOrderedTransaction {
|
|
8
|
-
orderId: number;
|
|
9
|
-
fakeFrom: string | undefined;
|
|
10
|
-
data: string;
|
|
11
|
-
txType: number;
|
|
12
|
-
}
|
|
13
|
-
export declare const makeSerializedTransaction: ImmutableRecord.Factory<ImmutableOrderedTransaction>;
|
|
14
|
-
export type SerializedTransaction = ImmutableRecord<ImmutableOrderedTransaction>;
|
|
15
|
-
export type SenderTransactions = ImmutableList<SerializedTransaction>;
|
|
16
|
-
export type AddressToTransactions = ImmutableMap<string, SenderTransactions>;
|
|
17
|
-
export type HashToTransaction = ImmutableMap<string, SerializedTransaction>;
|
|
18
|
-
export interface PoolState {
|
|
19
|
-
pendingTransactions: AddressToTransactions;
|
|
20
|
-
queuedTransactions: AddressToTransactions;
|
|
21
|
-
hashToTransaction: HashToTransaction;
|
|
22
|
-
blockGasLimit: string;
|
|
23
|
-
}
|
|
24
|
-
export declare const makePoolState: ImmutableRecord.Factory<PoolState>;
|
|
25
|
-
export {};
|
|
26
|
-
//# sourceMappingURL=PoolState.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PoolState.d.ts","sourceRoot":"","sources":["../../../src/internal/hardhat-network/provider/PoolState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EACL,IAAI,IAAI,aAAa,EACrB,GAAG,IAAI,YAAY,EACnB,MAAM,IAAI,eAAe,EAC1B,MAAM,WAAW,CAAC;AAInB,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,gBAAgB,CAAC;CACxB;AAED,UAAU,2BAA2B;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,yBAAyB,sDAMlC,CAAC;AAEL,MAAM,MAAM,qBAAqB,GAC/B,eAAe,CAAC,2BAA2B,CAAC,CAAC;AAC/C,MAAM,MAAM,kBAAkB,GAAG,aAAa,CAAC,qBAAqB,CAAC,CAAC;AACtE,MAAM,MAAM,qBAAqB,GAAG,YAAY,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AAC7E,MAAM,MAAM,iBAAiB,GAAG,YAAY,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;AAE5E,MAAM,WAAW,SAAS;IACxB,mBAAmB,EAAE,qBAAqB,CAAC;IAC3C,kBAAkB,EAAE,qBAAqB,CAAC;IAC1C,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,aAAa,oCAKxB,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.makePoolState = exports.makeSerializedTransaction = void 0;
|
|
27
|
-
const immutable_1 = require("immutable");
|
|
28
|
-
const BigIntUtils = __importStar(require("../../util/bigint"));
|
|
29
|
-
exports.makeSerializedTransaction = (0, immutable_1.Record)({
|
|
30
|
-
orderId: 0,
|
|
31
|
-
fakeFrom: undefined,
|
|
32
|
-
data: "",
|
|
33
|
-
txType: 0,
|
|
34
|
-
});
|
|
35
|
-
exports.makePoolState = (0, immutable_1.Record)({
|
|
36
|
-
pendingTransactions: (0, immutable_1.Map)(),
|
|
37
|
-
queuedTransactions: (0, immutable_1.Map)(),
|
|
38
|
-
hashToTransaction: (0, immutable_1.Map)(),
|
|
39
|
-
blockGasLimit: BigIntUtils.toHex(9500000),
|
|
40
|
-
});
|
|
41
|
-
//# sourceMappingURL=PoolState.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PoolState.js","sourceRoot":"","sources":["../../../src/internal/hardhat-network/provider/PoolState.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAImB;AAEnB,+DAAiD;AAcpC,QAAA,yBAAyB,GACpC,IAAA,kBAAe,EAA8B;IAC3C,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,SAAS;IACnB,IAAI,EAAE,EAAE;IACR,MAAM,EAAE,CAAC;CACV,CAAC,CAAC;AAeQ,QAAA,aAAa,GAAG,IAAA,kBAAe,EAAY;IACtD,mBAAmB,EAAE,IAAA,eAAY,GAA8B;IAC/D,kBAAkB,EAAE,IAAA,eAAY,GAA8B;IAC9D,iBAAiB,EAAE,IAAA,eAAY,GAAiC;IAChE,aAAa,EAAE,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC;CAC1C,CAAC,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { TypedTransaction } from "@nomicfoundation/ethereumjs-tx";
|
|
2
|
-
import { MempoolOrder } from "./node-types";
|
|
3
|
-
import { OrderedTransaction } from "./PoolState";
|
|
4
|
-
/**
|
|
5
|
-
* A queue of transactions in the order that they could be mined in the next
|
|
6
|
-
* block.
|
|
7
|
-
*
|
|
8
|
-
* A transaction being part of this queue doesn't mean that it will be mined in
|
|
9
|
-
* the next block, as it may not meet the required criteria to be included or
|
|
10
|
-
* may not fit within the block.
|
|
11
|
-
*
|
|
12
|
-
* If after getting the next transaction in the queue you decided not to mine
|
|
13
|
-
* it, the other transactions that belong to that sender MUST be removed from
|
|
14
|
-
* the queue by calling the #removeLastSenderTransactions() method.
|
|
15
|
-
**/
|
|
16
|
-
export declare class TransactionQueue {
|
|
17
|
-
private readonly _queuedTransactions;
|
|
18
|
-
private readonly _heap;
|
|
19
|
-
private _lastTransactionSender?;
|
|
20
|
-
/**
|
|
21
|
-
* Creates a TransactionQueue.
|
|
22
|
-
*
|
|
23
|
-
* @param pendingTransactions A map of sender to a list of their transactions,
|
|
24
|
-
* sorted by nonce and without nonce gaps.
|
|
25
|
-
* @param baseFee The base fee of the next block, if it's going to use EIP-1559
|
|
26
|
-
*/
|
|
27
|
-
constructor(pendingTransactions: Map<string, OrderedTransaction[]>, mempoolOrder: MempoolOrder, baseFee?: bigint);
|
|
28
|
-
getNextTransaction(): TypedTransaction | undefined;
|
|
29
|
-
removeLastSenderTransactions(): void;
|
|
30
|
-
private _moveFirstEnqueuedTransactionToHeap;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=TransactionQueue.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionQueue.d.ts","sourceRoot":"","sources":["../../../src/internal/hardhat-network/provider/TransactionQueue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAKlE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAmEjD;;;;;;;;;;;IAWI;AACJ,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CACxB;IAEZ,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA2B;IAEjD,OAAO,CAAC,sBAAsB,CAAC,CAAS;IAExC;;;;;;OAMG;gBAED,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,CAAC,EACtD,YAAY,EAAE,YAAY,EAC1B,OAAO,CAAC,EAAE,MAAM;IAkBX,kBAAkB,IAAI,gBAAgB,GAAG,SAAS;IAclD,4BAA4B;IAYnC,OAAO,CAAC,mCAAmC;CAU5C"}
|