hardhat 2.20.1 → 2.21.0-dev.1
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 -153
- 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 +28 -25
- package/internal/hardhat-network/provider/provider.d.ts.map +1 -1
- package/internal/hardhat-network/provider/provider.js +349 -185
- 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 +194 -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 +43 -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 +28 -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 +16 -14
- 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 +501 -261
- package/src/internal/hardhat-network/provider/utils/convertToEdr.ts +232 -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 +98 -0
- package/src/internal/hardhat-network/provider/vm/types.ts +32 -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 -2999
- 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
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { TransactionFactory } from "@nomicfoundation/ethereumjs-tx";
|
|
2
|
-
import { BaseTransaction } from "@nomicfoundation/ethereumjs-tx/dist/cjs/baseTransaction";
|
|
3
|
-
import {
|
|
4
|
-
TxOptions,
|
|
5
|
-
TypedTxData,
|
|
6
|
-
} from "@nomicfoundation/ethereumjs-tx/dist/cjs/types";
|
|
7
|
-
|
|
8
|
-
// This is a hack to prevent Block.fromBlockData from recreating our
|
|
9
|
-
// transactions and changing their types. Note fromBlockData is used
|
|
10
|
-
// by the BlockBuilder to update block it's building.
|
|
11
|
-
const previousFromTxData = TransactionFactory.fromTxData;
|
|
12
|
-
(TransactionFactory as any).fromTxData = function (
|
|
13
|
-
txData: TypedTxData,
|
|
14
|
-
txOptions?: TxOptions
|
|
15
|
-
) {
|
|
16
|
-
if (txData instanceof BaseTransaction) {
|
|
17
|
-
return txData;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return previousFromTxData.call(this, txData, txOptions);
|
|
21
|
-
};
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
bytesToHex as bufferToHex,
|
|
3
|
-
toBytes,
|
|
4
|
-
} from "@nomicfoundation/ethereumjs-util";
|
|
5
|
-
import { Bloom } from "@nomicfoundation/ethereumjs-vm";
|
|
6
|
-
|
|
7
|
-
import { RpcLogOutput } from "./output";
|
|
8
|
-
|
|
9
|
-
export const LATEST_BLOCK = -1n;
|
|
10
|
-
|
|
11
|
-
export enum Type {
|
|
12
|
-
LOGS_SUBSCRIPTION = 0,
|
|
13
|
-
PENDING_TRANSACTION_SUBSCRIPTION = 1,
|
|
14
|
-
BLOCK_SUBSCRIPTION = 2,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface FilterCriteria {
|
|
18
|
-
fromBlock: bigint;
|
|
19
|
-
toBlock: bigint;
|
|
20
|
-
addresses: Uint8Array[];
|
|
21
|
-
normalizedTopics: Array<Array<Uint8Array | null> | null>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface Filter {
|
|
25
|
-
id: bigint;
|
|
26
|
-
type: Type;
|
|
27
|
-
criteria?: FilterCriteria;
|
|
28
|
-
deadline: Date;
|
|
29
|
-
hashes: string[];
|
|
30
|
-
logs: RpcLogOutput[];
|
|
31
|
-
subscription: boolean;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function bloomFilter(
|
|
35
|
-
bloom: Bloom,
|
|
36
|
-
addresses: Uint8Array[],
|
|
37
|
-
normalizedTopics: Array<Array<Uint8Array | null> | null>
|
|
38
|
-
): boolean {
|
|
39
|
-
if (addresses.length > 0) {
|
|
40
|
-
let included = false;
|
|
41
|
-
for (const address of addresses) {
|
|
42
|
-
if (bloom.check(address)) {
|
|
43
|
-
included = true;
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (!included) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
for (const sub of normalizedTopics) {
|
|
54
|
-
if (sub === null || sub.length === 0) {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
let included = false;
|
|
59
|
-
for (const topic of sub) {
|
|
60
|
-
if (topic !== null && bloom.check(topic)) {
|
|
61
|
-
included = true;
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (!included) {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function filterLogs(
|
|
74
|
-
logs: RpcLogOutput[],
|
|
75
|
-
criteria: FilterCriteria
|
|
76
|
-
): RpcLogOutput[] {
|
|
77
|
-
const filteredLogs: RpcLogOutput[] = [];
|
|
78
|
-
for (const log of logs) {
|
|
79
|
-
const blockNumber = BigInt(log.blockNumber!);
|
|
80
|
-
if (blockNumber < criteria.fromBlock) {
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (criteria.toBlock !== LATEST_BLOCK && blockNumber > criteria.toBlock) {
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (
|
|
89
|
-
criteria.addresses.length !== 0 &&
|
|
90
|
-
!includes(criteria.addresses, toBytes(log.address))
|
|
91
|
-
) {
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (!topicMatched(criteria.normalizedTopics, log.topics)) {
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
filteredLogs.push(log);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return filteredLogs;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export function includes(addresses: Uint8Array[], a: Uint8Array): boolean {
|
|
106
|
-
for (const address of addresses) {
|
|
107
|
-
if (Buffer.compare(address, a) === 0) {
|
|
108
|
-
return true;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export function topicMatched(
|
|
116
|
-
normalizedTopics: Array<Array<Uint8Array | null> | null>,
|
|
117
|
-
logTopics: string[]
|
|
118
|
-
): boolean {
|
|
119
|
-
for (let i = 0; i < normalizedTopics.length; i++) {
|
|
120
|
-
if (normalizedTopics.length > logTopics.length) {
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const sub = normalizedTopics[i];
|
|
125
|
-
if (sub === null || sub.length === 0) {
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
let match: boolean = false;
|
|
130
|
-
for (const topic of sub) {
|
|
131
|
-
if (topic === null || logTopics[i] === bufferToHex(topic)) {
|
|
132
|
-
match = true;
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
if (!match) {
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return true;
|
|
142
|
-
}
|
|
@@ -1,433 +0,0 @@
|
|
|
1
|
-
import { Block } from "@nomicfoundation/ethereumjs-block";
|
|
2
|
-
import {
|
|
3
|
-
BlockchainInterface,
|
|
4
|
-
BlockchainEvents,
|
|
5
|
-
} from "@nomicfoundation/ethereumjs-blockchain";
|
|
6
|
-
import { Common } from "@nomicfoundation/ethereumjs-common";
|
|
7
|
-
import {
|
|
8
|
-
FeeMarketEIP1559TxData,
|
|
9
|
-
TypedTransaction,
|
|
10
|
-
} from "@nomicfoundation/ethereumjs-tx";
|
|
11
|
-
import {
|
|
12
|
-
Address,
|
|
13
|
-
AsyncEventEmitter,
|
|
14
|
-
equalsBytes,
|
|
15
|
-
} from "@nomicfoundation/ethereumjs-util";
|
|
16
|
-
|
|
17
|
-
import { RpcBlockWithTransactions } from "../../../core/jsonrpc/types/output/block";
|
|
18
|
-
import { RpcTransactionReceipt } from "../../../core/jsonrpc/types/output/receipt";
|
|
19
|
-
import { RpcTransaction } from "../../../core/jsonrpc/types/output/transaction";
|
|
20
|
-
import { InternalError } from "../../../core/providers/errors";
|
|
21
|
-
import { JsonRpcClient } from "../../jsonrpc/client";
|
|
22
|
-
import { BlockchainBase } from "../BlockchainBase";
|
|
23
|
-
import { FilterParams } from "../node-types";
|
|
24
|
-
import {
|
|
25
|
-
remoteReceiptToRpcReceiptOutput,
|
|
26
|
-
RpcLogOutput,
|
|
27
|
-
RpcReceiptOutput,
|
|
28
|
-
shouldShowEffectiveGasPriceForHardfork,
|
|
29
|
-
shouldShowTransactionTypeForHardfork,
|
|
30
|
-
toRpcLogOutput,
|
|
31
|
-
} from "../output";
|
|
32
|
-
import { ReadOnlyValidEIP2930Transaction } from "../transactions/ReadOnlyValidEIP2930Transaction";
|
|
33
|
-
import { ReadOnlyValidTransaction } from "../transactions/ReadOnlyValidTransaction";
|
|
34
|
-
import { HardhatBlockchainInterface } from "../types/HardhatBlockchainInterface";
|
|
35
|
-
|
|
36
|
-
import { ReadOnlyValidEIP1559Transaction } from "../transactions/ReadOnlyValidEIP1559Transaction";
|
|
37
|
-
import { ReadOnlyValidUnknownTypeTransaction } from "../transactions/ReadOnlyValidUnknownTypeTransaction";
|
|
38
|
-
import { rpcToBlockData } from "./rpcToBlockData";
|
|
39
|
-
import { rpcToTxData } from "./rpcToTxData";
|
|
40
|
-
|
|
41
|
-
/* eslint-disable @nomicfoundation/hardhat-internal-rules/only-hardhat-error */
|
|
42
|
-
|
|
43
|
-
export class ForkBlockchain
|
|
44
|
-
extends BlockchainBase
|
|
45
|
-
implements HardhatBlockchainInterface
|
|
46
|
-
{
|
|
47
|
-
private _latestBlockNumber = this._forkBlockNumber;
|
|
48
|
-
public events?: AsyncEventEmitter<BlockchainEvents> | undefined;
|
|
49
|
-
|
|
50
|
-
constructor(
|
|
51
|
-
private _jsonRpcClient: JsonRpcClient,
|
|
52
|
-
private _forkBlockNumber: bigint,
|
|
53
|
-
common: Common
|
|
54
|
-
) {
|
|
55
|
-
super(common);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
public getIteratorHead(_name?: string | undefined): Promise<Block> {
|
|
59
|
-
throw new Error("Method not implemented.");
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
public setIteratorHead(_tag: string, _headHash: Uint8Array): Promise<void> {
|
|
63
|
-
throw new Error("Method not implemented.");
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
public getCanonicalHeadBlock(): Promise<Block> {
|
|
67
|
-
throw new Error("Method not implemented.");
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
public shallowCopy(): BlockchainInterface {
|
|
71
|
-
return this;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
public getLatestBlockNumber(): bigint {
|
|
75
|
-
return this._latestBlockNumber;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
public async getBlock(blockHashOrNumber: Buffer | bigint): Promise<Block> {
|
|
79
|
-
if (
|
|
80
|
-
typeof blockHashOrNumber === "bigint" &&
|
|
81
|
-
this._data.isReservedBlock(blockHashOrNumber)
|
|
82
|
-
) {
|
|
83
|
-
this._data.fulfillBlockReservation(blockHashOrNumber);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
let block: Block | undefined | null;
|
|
87
|
-
if (Buffer.isBuffer(blockHashOrNumber)) {
|
|
88
|
-
block = await this._getBlockByHash(blockHashOrNumber);
|
|
89
|
-
if (block === undefined) {
|
|
90
|
-
throw new Error("Block not found");
|
|
91
|
-
}
|
|
92
|
-
return block;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
block = await this._getBlockByNumber(BigInt(blockHashOrNumber));
|
|
96
|
-
if (block === undefined) {
|
|
97
|
-
throw new Error("Block not found");
|
|
98
|
-
}
|
|
99
|
-
return block;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
public async addBlock(block: Block): Promise<Block> {
|
|
103
|
-
const blockNumber = BigInt(block.header.number);
|
|
104
|
-
if (blockNumber !== this._latestBlockNumber + 1n) {
|
|
105
|
-
throw new Error(
|
|
106
|
-
`Invalid block number ${blockNumber}. Expected ${
|
|
107
|
-
this._latestBlockNumber + 1n
|
|
108
|
-
}`
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// When forking a network whose consensus is not the classic PoW,
|
|
113
|
-
// we can't calculate the hash correctly.
|
|
114
|
-
// Thus, we avoid this check for the first block after the fork.
|
|
115
|
-
if (blockNumber > this._forkBlockNumber + 1n) {
|
|
116
|
-
const parent = await this.getLatestBlock();
|
|
117
|
-
if (!equalsBytes(block.header.parentHash, parent.hash())) {
|
|
118
|
-
throw new Error("Invalid parent hash");
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
this._latestBlockNumber++;
|
|
123
|
-
const totalDifficulty = await this._computeTotalDifficulty(block);
|
|
124
|
-
this._data.addBlock(block, totalDifficulty);
|
|
125
|
-
return block;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
public reserveBlocks(
|
|
129
|
-
count: bigint,
|
|
130
|
-
interval: bigint,
|
|
131
|
-
previousBlockStateRoot: Buffer,
|
|
132
|
-
previousBlockTotalDifficulty: bigint,
|
|
133
|
-
previousBlockBaseFeePerGas: bigint | undefined
|
|
134
|
-
) {
|
|
135
|
-
super.reserveBlocks(
|
|
136
|
-
count,
|
|
137
|
-
interval,
|
|
138
|
-
previousBlockStateRoot,
|
|
139
|
-
previousBlockTotalDifficulty,
|
|
140
|
-
previousBlockBaseFeePerGas
|
|
141
|
-
);
|
|
142
|
-
this._latestBlockNumber += count;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
public deleteLaterBlocks(block: Block): void {
|
|
146
|
-
const blockNumber = block.header.number;
|
|
147
|
-
const savedBlock = this._data.getBlockByNumber(blockNumber);
|
|
148
|
-
if (
|
|
149
|
-
savedBlock === undefined ||
|
|
150
|
-
!equalsBytes(savedBlock.hash(), block.hash())
|
|
151
|
-
) {
|
|
152
|
-
throw new Error("Invalid block");
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const nextBlockNumber = blockNumber + 1n;
|
|
156
|
-
if (this._forkBlockNumber >= nextBlockNumber) {
|
|
157
|
-
throw new Error("Cannot delete remote block");
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
this._delBlock(nextBlockNumber);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
public async getTotalDifficulty(blockHash: Buffer): Promise<bigint> {
|
|
164
|
-
let td = this._data.getTotalDifficulty(blockHash);
|
|
165
|
-
if (td !== undefined) {
|
|
166
|
-
return td;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// fetch block to check if it exists
|
|
170
|
-
await this.getBlock(blockHash);
|
|
171
|
-
|
|
172
|
-
td = this._data.getTotalDifficulty(blockHash);
|
|
173
|
-
if (td === undefined) {
|
|
174
|
-
throw new Error("This should never happen");
|
|
175
|
-
}
|
|
176
|
-
return td;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
public async getTransaction(
|
|
180
|
-
transactionHash: Buffer
|
|
181
|
-
): Promise<TypedTransaction | undefined> {
|
|
182
|
-
const tx = this.getLocalTransaction(transactionHash);
|
|
183
|
-
if (tx === undefined) {
|
|
184
|
-
const remote = await this._jsonRpcClient.getTransactionByHash(
|
|
185
|
-
transactionHash
|
|
186
|
-
);
|
|
187
|
-
return this._processRemoteTransaction(remote);
|
|
188
|
-
}
|
|
189
|
-
return tx;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
public async getBlockByTransactionHash(
|
|
193
|
-
transactionHash: Buffer
|
|
194
|
-
): Promise<Block | null> {
|
|
195
|
-
let block = this._data.getBlockByTransactionHash(transactionHash);
|
|
196
|
-
if (block === undefined) {
|
|
197
|
-
const remote = await this._jsonRpcClient.getTransactionByHash(
|
|
198
|
-
transactionHash
|
|
199
|
-
);
|
|
200
|
-
this._processRemoteTransaction(remote);
|
|
201
|
-
if (remote !== null && remote.blockHash !== null) {
|
|
202
|
-
await this.getBlock(remote.blockHash);
|
|
203
|
-
block = this._data.getBlockByTransactionHash(transactionHash);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
return block ?? null;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
public async getTransactionReceipt(
|
|
210
|
-
transactionHash: Buffer
|
|
211
|
-
): Promise<RpcReceiptOutput | null> {
|
|
212
|
-
const local = this._data.getTransactionReceipt(transactionHash);
|
|
213
|
-
if (local !== undefined) {
|
|
214
|
-
return local;
|
|
215
|
-
}
|
|
216
|
-
const remote = await this._jsonRpcClient.getTransactionReceipt(
|
|
217
|
-
transactionHash
|
|
218
|
-
);
|
|
219
|
-
if (remote !== null) {
|
|
220
|
-
const receipt = await this._processRemoteReceipt(remote);
|
|
221
|
-
return receipt ?? null;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
return null;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
public getForkBlockNumber() {
|
|
228
|
-
return this._forkBlockNumber;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
public async getLogs(filterParams: FilterParams): Promise<RpcLogOutput[]> {
|
|
232
|
-
if (filterParams.fromBlock <= this._forkBlockNumber) {
|
|
233
|
-
let toBlock = filterParams.toBlock;
|
|
234
|
-
let localLogs: RpcLogOutput[] = [];
|
|
235
|
-
if (toBlock > this._forkBlockNumber) {
|
|
236
|
-
toBlock = this._forkBlockNumber;
|
|
237
|
-
localLogs = this._data.getLogs({
|
|
238
|
-
...filterParams,
|
|
239
|
-
fromBlock: this._forkBlockNumber + 1n,
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
const remoteLogs = await this._jsonRpcClient.getLogs({
|
|
243
|
-
fromBlock: filterParams.fromBlock,
|
|
244
|
-
toBlock,
|
|
245
|
-
address:
|
|
246
|
-
filterParams.addresses.length === 1
|
|
247
|
-
? filterParams.addresses[0]
|
|
248
|
-
: filterParams.addresses,
|
|
249
|
-
topics: filterParams.normalizedTopics,
|
|
250
|
-
});
|
|
251
|
-
return remoteLogs.map(toRpcLogOutput).concat(localLogs);
|
|
252
|
-
}
|
|
253
|
-
return this._data.getLogs(filterParams);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
private async _getBlockByHash(blockHash: Buffer) {
|
|
257
|
-
const block = this._data.getBlockByHash(blockHash);
|
|
258
|
-
if (block !== undefined) {
|
|
259
|
-
return block;
|
|
260
|
-
}
|
|
261
|
-
const rpcBlock = await this._jsonRpcClient.getBlockByHash(blockHash, true);
|
|
262
|
-
return this._processRemoteBlock(rpcBlock);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
private async _getBlockByNumber(blockNumber: bigint) {
|
|
266
|
-
if (blockNumber > this._latestBlockNumber) {
|
|
267
|
-
return undefined;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
try {
|
|
271
|
-
const block = await super.getBlock(blockNumber);
|
|
272
|
-
return block;
|
|
273
|
-
} catch {}
|
|
274
|
-
|
|
275
|
-
const rpcBlock = await this._jsonRpcClient.getBlockByNumber(
|
|
276
|
-
blockNumber,
|
|
277
|
-
true
|
|
278
|
-
);
|
|
279
|
-
return this._processRemoteBlock(rpcBlock);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
private async _processRemoteBlock(rpcBlock: RpcBlockWithTransactions | null) {
|
|
283
|
-
if (
|
|
284
|
-
rpcBlock === null ||
|
|
285
|
-
rpcBlock.hash === null ||
|
|
286
|
-
rpcBlock.number === null ||
|
|
287
|
-
rpcBlock.number > this._forkBlockNumber
|
|
288
|
-
) {
|
|
289
|
-
return undefined;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
const common = this._common.copy();
|
|
293
|
-
// We set the common's hardfork depending on the remote block fields, to
|
|
294
|
-
// prevent ethereumjs from throwing if unsupported fields are passed.
|
|
295
|
-
// We use "berlin" for pre-EIP-1559 blocks (blocks without baseFeePerGas),
|
|
296
|
-
// "merge" for blocks that have baseFeePerGas but not withdrawals,
|
|
297
|
-
// and "shanghai" for blocks with withdrawals
|
|
298
|
-
if (rpcBlock.baseFeePerGas === undefined) {
|
|
299
|
-
common.setHardfork("berlin");
|
|
300
|
-
} else if (rpcBlock.withdrawals === undefined) {
|
|
301
|
-
// ethereumjs uses this name for the merge hardfork
|
|
302
|
-
common.setHardfork("mergeForkIdTransition");
|
|
303
|
-
} else if (rpcBlock.parentBeaconBlockRoot === undefined) {
|
|
304
|
-
common.setHardfork("shanghai");
|
|
305
|
-
} else {
|
|
306
|
-
common.setHardfork("cancun");
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
// we don't include the transactions to add our own custom tx objects,
|
|
310
|
-
// otherwise they are recreated with upstream classes
|
|
311
|
-
const blockData = rpcToBlockData({
|
|
312
|
-
...rpcBlock,
|
|
313
|
-
transactions: [],
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
const block = Block.fromBlockData(blockData, {
|
|
317
|
-
common,
|
|
318
|
-
|
|
319
|
-
// We use freeze false here because we add the transactions manually
|
|
320
|
-
freeze: false,
|
|
321
|
-
|
|
322
|
-
// don't validate things like the size of `extraData` in the header
|
|
323
|
-
skipConsensusFormatValidation: true,
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
for (const transaction of rpcBlock.transactions) {
|
|
327
|
-
let tx;
|
|
328
|
-
if (transaction.type === undefined || transaction.type === 0n) {
|
|
329
|
-
tx = new ReadOnlyValidTransaction(
|
|
330
|
-
new Address(transaction.from),
|
|
331
|
-
rpcToTxData(transaction)
|
|
332
|
-
);
|
|
333
|
-
} else if (transaction.type === 1n) {
|
|
334
|
-
tx = new ReadOnlyValidEIP2930Transaction(
|
|
335
|
-
new Address(transaction.from),
|
|
336
|
-
rpcToTxData(transaction)
|
|
337
|
-
);
|
|
338
|
-
} else if (transaction.type === 2n) {
|
|
339
|
-
tx = new ReadOnlyValidEIP1559Transaction(
|
|
340
|
-
new Address(transaction.from),
|
|
341
|
-
rpcToTxData(transaction) as FeeMarketEIP1559TxData
|
|
342
|
-
);
|
|
343
|
-
} else {
|
|
344
|
-
// we try to interpret unknown txs as legacy transactions, to support
|
|
345
|
-
// networks like Arbitrum that have non-standards tx types
|
|
346
|
-
try {
|
|
347
|
-
tx = new ReadOnlyValidUnknownTypeTransaction(
|
|
348
|
-
new Address(transaction.from),
|
|
349
|
-
Number(transaction.type),
|
|
350
|
-
rpcToTxData(transaction)
|
|
351
|
-
);
|
|
352
|
-
} catch (e: any) {
|
|
353
|
-
throw new InternalError(
|
|
354
|
-
`Could not process transaction with type ${transaction.type.toString()}`,
|
|
355
|
-
e
|
|
356
|
-
);
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
block.transactions.push(tx);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
this._data.addBlock(block, rpcBlock.totalDifficulty);
|
|
364
|
-
return block;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
protected _delBlock(blockNumber: bigint): void {
|
|
368
|
-
if (blockNumber <= this._forkBlockNumber) {
|
|
369
|
-
throw new Error("Cannot delete remote block");
|
|
370
|
-
}
|
|
371
|
-
super._delBlock(blockNumber);
|
|
372
|
-
this._latestBlockNumber = blockNumber - 1n;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
private _processRemoteTransaction(rpcTransaction: RpcTransaction | null) {
|
|
376
|
-
if (
|
|
377
|
-
rpcTransaction === null ||
|
|
378
|
-
rpcTransaction.blockNumber === null ||
|
|
379
|
-
rpcTransaction.blockNumber > this._forkBlockNumber
|
|
380
|
-
) {
|
|
381
|
-
return undefined;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
let transaction: TypedTransaction;
|
|
385
|
-
|
|
386
|
-
if (rpcTransaction.type === undefined || rpcTransaction.type === 0n) {
|
|
387
|
-
transaction = new ReadOnlyValidTransaction(
|
|
388
|
-
new Address(rpcTransaction.from),
|
|
389
|
-
rpcToTxData(rpcTransaction)
|
|
390
|
-
);
|
|
391
|
-
} else if (rpcTransaction.type === 1n) {
|
|
392
|
-
transaction = new ReadOnlyValidEIP2930Transaction(
|
|
393
|
-
new Address(rpcTransaction.from),
|
|
394
|
-
rpcToTxData(rpcTransaction)
|
|
395
|
-
);
|
|
396
|
-
} else if (rpcTransaction.type === 2n) {
|
|
397
|
-
transaction = new ReadOnlyValidEIP1559Transaction(
|
|
398
|
-
new Address(rpcTransaction.from),
|
|
399
|
-
rpcToTxData(rpcTransaction) as FeeMarketEIP1559TxData
|
|
400
|
-
);
|
|
401
|
-
} else {
|
|
402
|
-
transaction = new ReadOnlyValidUnknownTypeTransaction(
|
|
403
|
-
new Address(rpcTransaction.from),
|
|
404
|
-
Number(rpcTransaction.type),
|
|
405
|
-
rpcToTxData(rpcTransaction)
|
|
406
|
-
);
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
this._data.addTransaction(transaction);
|
|
410
|
-
|
|
411
|
-
return transaction;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
private async _processRemoteReceipt(
|
|
415
|
-
txReceipt: RpcTransactionReceipt | null
|
|
416
|
-
): Promise<RpcReceiptOutput | undefined> {
|
|
417
|
-
if (txReceipt === null || txReceipt.blockNumber > this._forkBlockNumber) {
|
|
418
|
-
return undefined;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
const tx = await this.getTransaction(txReceipt.transactionHash);
|
|
422
|
-
|
|
423
|
-
const receipt = remoteReceiptToRpcReceiptOutput(
|
|
424
|
-
txReceipt,
|
|
425
|
-
tx!,
|
|
426
|
-
shouldShowTransactionTypeForHardfork(this._common),
|
|
427
|
-
shouldShowEffectiveGasPriceForHardfork(this._common)
|
|
428
|
-
);
|
|
429
|
-
|
|
430
|
-
this._data.addTransactionReceipt(receipt);
|
|
431
|
-
return receipt;
|
|
432
|
-
}
|
|
433
|
-
}
|