@feelyourprotocol/blockchain 8141.0.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.
Files changed (132) hide show
  1. package/README.md +269 -0
  2. package/dist/cjs/blockchain.d.ts +372 -0
  3. package/dist/cjs/blockchain.d.ts.map +1 -0
  4. package/dist/cjs/blockchain.js +1105 -0
  5. package/dist/cjs/blockchain.js.map +1 -0
  6. package/dist/cjs/consensus/casper.d.ts +16 -0
  7. package/dist/cjs/consensus/casper.d.ts.map +1 -0
  8. package/dist/cjs/consensus/casper.js +28 -0
  9. package/dist/cjs/consensus/casper.js.map +1 -0
  10. package/dist/cjs/consensus/clique.d.ts +164 -0
  11. package/dist/cjs/consensus/clique.d.ts.map +1 -0
  12. package/dist/cjs/consensus/clique.js +520 -0
  13. package/dist/cjs/consensus/clique.js.map +1 -0
  14. package/dist/cjs/consensus/ethash.d.ts +29 -0
  15. package/dist/cjs/consensus/ethash.d.ts.map +1 -0
  16. package/dist/cjs/consensus/ethash.js +48 -0
  17. package/dist/cjs/consensus/ethash.js.map +1 -0
  18. package/dist/cjs/consensus/index.d.ts +5 -0
  19. package/dist/cjs/consensus/index.d.ts.map +1 -0
  20. package/dist/cjs/consensus/index.js +10 -0
  21. package/dist/cjs/consensus/index.js.map +1 -0
  22. package/dist/cjs/constructors.d.ts +13 -0
  23. package/dist/cjs/constructors.d.ts.map +1 -0
  24. package/dist/cjs/constructors.js +80 -0
  25. package/dist/cjs/constructors.js.map +1 -0
  26. package/dist/cjs/db/cache.d.ts +17 -0
  27. package/dist/cjs/db/cache.d.ts.map +1 -0
  28. package/dist/cjs/db/cache.js +38 -0
  29. package/dist/cjs/db/cache.js.map +1 -0
  30. package/dist/cjs/db/constants.d.ts +23 -0
  31. package/dist/cjs/db/constants.d.ts.map +1 -0
  32. package/dist/cjs/db/constants.js +54 -0
  33. package/dist/cjs/db/constants.js.map +1 -0
  34. package/dist/cjs/db/helpers.d.ts +9 -0
  35. package/dist/cjs/db/helpers.d.ts.map +1 -0
  36. package/dist/cjs/db/helpers.js +68 -0
  37. package/dist/cjs/db/helpers.js.map +1 -0
  38. package/dist/cjs/db/manager.d.ts +78 -0
  39. package/dist/cjs/db/manager.d.ts.map +1 -0
  40. package/dist/cjs/db/manager.js +203 -0
  41. package/dist/cjs/db/manager.js.map +1 -0
  42. package/dist/cjs/db/operation.d.ts +45 -0
  43. package/dist/cjs/db/operation.d.ts.map +1 -0
  44. package/dist/cjs/db/operation.js +110 -0
  45. package/dist/cjs/db/operation.js.map +1 -0
  46. package/dist/cjs/helpers.d.ts +19 -0
  47. package/dist/cjs/helpers.d.ts.map +1 -0
  48. package/dist/cjs/helpers.js +34 -0
  49. package/dist/cjs/helpers.js.map +1 -0
  50. package/dist/cjs/index.d.ts +7 -0
  51. package/dist/cjs/index.d.ts.map +1 -0
  52. package/dist/cjs/index.js +33 -0
  53. package/dist/cjs/index.js.map +1 -0
  54. package/dist/cjs/package.json +3 -0
  55. package/dist/cjs/types.d.ts +219 -0
  56. package/dist/cjs/types.d.ts.map +1 -0
  57. package/dist/cjs/types.js +3 -0
  58. package/dist/cjs/types.js.map +1 -0
  59. package/dist/esm/blockchain.d.ts +372 -0
  60. package/dist/esm/blockchain.d.ts.map +1 -0
  61. package/dist/esm/blockchain.js +1101 -0
  62. package/dist/esm/blockchain.js.map +1 -0
  63. package/dist/esm/consensus/casper.d.ts +16 -0
  64. package/dist/esm/consensus/casper.d.ts.map +1 -0
  65. package/dist/esm/consensus/casper.js +24 -0
  66. package/dist/esm/consensus/casper.js.map +1 -0
  67. package/dist/esm/consensus/clique.d.ts +164 -0
  68. package/dist/esm/consensus/clique.d.ts.map +1 -0
  69. package/dist/esm/consensus/clique.js +516 -0
  70. package/dist/esm/consensus/clique.js.map +1 -0
  71. package/dist/esm/consensus/ethash.d.ts +29 -0
  72. package/dist/esm/consensus/ethash.d.ts.map +1 -0
  73. package/dist/esm/consensus/ethash.js +44 -0
  74. package/dist/esm/consensus/ethash.js.map +1 -0
  75. package/dist/esm/consensus/index.d.ts +5 -0
  76. package/dist/esm/consensus/index.d.ts.map +1 -0
  77. package/dist/esm/consensus/index.js +5 -0
  78. package/dist/esm/consensus/index.js.map +1 -0
  79. package/dist/esm/constructors.d.ts +13 -0
  80. package/dist/esm/constructors.d.ts.map +1 -0
  81. package/dist/esm/constructors.js +76 -0
  82. package/dist/esm/constructors.js.map +1 -0
  83. package/dist/esm/db/cache.d.ts +17 -0
  84. package/dist/esm/db/cache.d.ts.map +1 -0
  85. package/dist/esm/db/cache.js +34 -0
  86. package/dist/esm/db/cache.js.map +1 -0
  87. package/dist/esm/db/constants.d.ts +23 -0
  88. package/dist/esm/db/constants.d.ts.map +1 -0
  89. package/dist/esm/db/constants.js +46 -0
  90. package/dist/esm/db/constants.js.map +1 -0
  91. package/dist/esm/db/helpers.d.ts +9 -0
  92. package/dist/esm/db/helpers.d.ts.map +1 -0
  93. package/dist/esm/db/helpers.js +61 -0
  94. package/dist/esm/db/helpers.js.map +1 -0
  95. package/dist/esm/db/manager.d.ts +78 -0
  96. package/dist/esm/db/manager.d.ts.map +1 -0
  97. package/dist/esm/db/manager.js +199 -0
  98. package/dist/esm/db/manager.js.map +1 -0
  99. package/dist/esm/db/operation.d.ts +45 -0
  100. package/dist/esm/db/operation.d.ts.map +1 -0
  101. package/dist/esm/db/operation.js +106 -0
  102. package/dist/esm/db/operation.js.map +1 -0
  103. package/dist/esm/helpers.d.ts +19 -0
  104. package/dist/esm/helpers.d.ts.map +1 -0
  105. package/dist/esm/helpers.js +30 -0
  106. package/dist/esm/helpers.js.map +1 -0
  107. package/dist/esm/index.d.ts +7 -0
  108. package/dist/esm/index.d.ts.map +1 -0
  109. package/dist/esm/index.js +7 -0
  110. package/dist/esm/index.js.map +1 -0
  111. package/dist/esm/package.json +3 -0
  112. package/dist/esm/types.d.ts +219 -0
  113. package/dist/esm/types.d.ts.map +1 -0
  114. package/dist/esm/types.js +2 -0
  115. package/dist/esm/types.js.map +1 -0
  116. package/dist/tsconfig.prod.cjs.tsbuildinfo +1 -0
  117. package/dist/tsconfig.prod.esm.tsbuildinfo +1 -0
  118. package/package.json +75 -0
  119. package/src/blockchain.ts +1353 -0
  120. package/src/consensus/casper.ts +33 -0
  121. package/src/consensus/clique.ts +633 -0
  122. package/src/consensus/ethash.ts +69 -0
  123. package/src/consensus/index.ts +5 -0
  124. package/src/constructors.ts +119 -0
  125. package/src/db/cache.ts +39 -0
  126. package/src/db/constants.ts +73 -0
  127. package/src/db/helpers.ts +81 -0
  128. package/src/db/manager.ts +243 -0
  129. package/src/db/operation.ts +152 -0
  130. package/src/helpers.ts +37 -0
  131. package/src/index.ts +12 -0
  132. package/src/types.ts +256 -0
@@ -0,0 +1,372 @@
1
+ import { Block, BlockHeader } from '@feelyourprotocol/block';
2
+ import { Common } from '@feelyourprotocol/common';
3
+ import { EventEmitter } from 'eventemitter3';
4
+ import { DBManager } from './db/manager.ts';
5
+ import type { BigIntLike, DB, DBObject } from '@feelyourprotocol/util';
6
+ import type { BlockchainEvent, BlockchainInterface, BlockchainOptions, Consensus, OnBlock } from './types.ts';
7
+ /**
8
+ * Blockchain implementation to create and maintain a valid canonical chain
9
+ * of block headers or blocks with support for reorgs and the ability to provide
10
+ * custom DB backends.
11
+ *
12
+ * By default consensus validation is not provided since with the switch to
13
+ * Proof-of-Stake consensus is validated by the Ethereum consensus layer.
14
+ * If consensus validation is desired for Ethash or Clique blockchains the
15
+ * optional `consensusDict` option can be used to pass in validation objects.
16
+ *
17
+ * A Blockchain object can be created with the constructor method:
18
+ *
19
+ * - {@link createBlockchain}
20
+ */
21
+ export declare class Blockchain implements BlockchainInterface {
22
+ db: DB<Uint8Array | string, Uint8Array | string | DBObject>;
23
+ dbManager: DBManager;
24
+ events: EventEmitter<BlockchainEvent>;
25
+ private _genesisBlock?; /** The genesis block of this blockchain */
26
+ private _customGenesisState?; /** Custom genesis state */
27
+ /**
28
+ * The following two heads and the heads stored within the `_heads` always point
29
+ * to a hash in the canonical chain and never to a stale hash.
30
+ * With the exception of `_headHeaderHash` this does not necessarily need to be
31
+ * the hash with the highest total difficulty.
32
+ */
33
+ /** The hash of the current head block */
34
+ private _headBlockHash?;
35
+ /** The hash of the current head header */
36
+ private _headHeaderHash?;
37
+ /**
38
+ * A Map which stores the head of each key (for instance the "vm" key) which is
39
+ * updated along a {@link Blockchain.iterator} method run and can be used to (re)run
40
+ * non-verified blocks (for instance in the VM).
41
+ */
42
+ private _heads;
43
+ private _lock;
44
+ readonly common: Common;
45
+ private _hardforkByHeadBlockNumber;
46
+ private readonly _validateBlocks;
47
+ private readonly _validateConsensus;
48
+ private _consensusDict;
49
+ /**
50
+ * This is used to track which canonical blocks are deleted. After a method calls
51
+ * `_deleteCanonicalChainReferences`, if this array has any items, the
52
+ * `deletedCanonicalBlocks` event is emitted with the array as argument.
53
+ */
54
+ private _deletedBlocks;
55
+ private DEBUG;
56
+ private _debug;
57
+ /**
58
+ * Creates new Blockchain object.
59
+ *
60
+ * @deprecated The direct usage of this constructor is discouraged since
61
+ * non-finalized async initialization might lead to side effects. Please
62
+ * use the async {@link createBlockchain} constructor instead (same API).
63
+ *
64
+ * @param opts An object with the options that this constructor takes. See
65
+ * {@link BlockchainOptions}.
66
+ */
67
+ constructor(opts?: BlockchainOptions);
68
+ private _consensusCheck;
69
+ /**
70
+ * Returns an eventual consensus object matching the current consensus algorithm from Common
71
+ * or undefined if non available
72
+ */
73
+ get consensus(): Consensus | undefined;
74
+ /**
75
+ * Returns a deep copy of this {@link Blockchain} instance.
76
+ *
77
+ * Note: this does not make a copy of the underlying db
78
+ * since it is unknown if the source is on disk or in memory.
79
+ * This should not be a significant issue in most usage since
80
+ * the queries will only reflect the instance's known data.
81
+ * If you would like this copied blockchain to use another db
82
+ * set the {@link db} of this returned instance to a copy of
83
+ * the original.
84
+ */
85
+ shallowCopy(): Blockchain;
86
+ /**
87
+ * Run a function after acquiring a lock. It is implied that we have already
88
+ * initialized the module (or we are calling this from the init function, like
89
+ * `_setCanonicalGenesisBlock`)
90
+ * @param action - function to run after acquiring a lock
91
+ * @hidden
92
+ */
93
+ private runWithLock;
94
+ /**
95
+ * Returns the specified iterator head.
96
+ *
97
+ * This function replaces the old Blockchain.getHead() method. Note that
98
+ * the function deviates from the old behavior and returns the
99
+ * genesis hash instead of the current head block if an iterator
100
+ * has not been run. This matches the behavior of {@link Blockchain.iterator}.
101
+ *
102
+ * @param name - Optional name of the iterator head (default: 'vm')
103
+ */
104
+ getIteratorHead(name?: string): Promise<Block>;
105
+ /**
106
+ * This method differs from `getIteratorHead`. If the head is not found, it returns `undefined`.
107
+ * @param name - Optional name of the iterator head (default: 'vm')
108
+ * @returns
109
+ */
110
+ getIteratorHeadSafe(name?: string): Promise<Block | undefined>;
111
+ private getHead;
112
+ /**
113
+ * Returns the latest header in the canonical chain.
114
+ */
115
+ getCanonicalHeadHeader(): Promise<BlockHeader>;
116
+ /**
117
+ * Returns the latest full block in the canonical chain.
118
+ */
119
+ getCanonicalHeadBlock(): Promise<Block>;
120
+ /**
121
+ * Adds blocks to the blockchain.
122
+ *
123
+ * If an invalid block is met the function will throw, blocks before will
124
+ * nevertheless remain in the DB. If any of the saved blocks has a higher
125
+ * total difficulty than the current max total difficulty the canonical
126
+ * chain is rebuilt and any stale heads/hashes are overwritten.
127
+ * @param blocks - The blocks to be added to the blockchain
128
+ */
129
+ putBlocks(blocks: Block[]): Promise<void>;
130
+ /**
131
+ * Adds a block to the blockchain.
132
+ *
133
+ * If the block is valid and has a higher total difficulty than the current
134
+ * max total difficulty, the canonical chain is rebuilt and any stale
135
+ * heads/hashes are overwritten.
136
+ * @param block - The block to be added to the blockchain
137
+ */
138
+ putBlock(block: Block): Promise<void>;
139
+ /**
140
+ * Adds many headers to the blockchain.
141
+ *
142
+ * If an invalid header is met the function will throw, headers before will
143
+ * nevertheless remain in the DB. If any of the saved headers has a higher
144
+ * total difficulty than the current max total difficulty the canonical
145
+ * chain is rebuilt and any stale heads/hashes are overwritten.
146
+ * @param headers - The headers to be added to the blockchain
147
+ */
148
+ putHeaders(headers: Array<any>): Promise<void>;
149
+ /**
150
+ * Adds a header to the blockchain.
151
+ *
152
+ * If this header is valid and it has a higher total difficulty than the current
153
+ * max total difficulty, the canonical chain is rebuilt and any stale
154
+ * heads/hashes are overwritten.
155
+ * @param header - The header to be added to the blockchain
156
+ */
157
+ putHeader(header: BlockHeader): Promise<void>;
158
+ /**
159
+ * Resets the canonical chain to canonicalHead number
160
+ *
161
+ * This updates the head hashes (if affected) to the hash corresponding to
162
+ * canonicalHead and cleans up canonical references greater than canonicalHead
163
+ * @param canonicalHead - The number to which chain should be reset to
164
+ */
165
+ resetCanonicalHead(canonicalHead: bigint): Promise<void>;
166
+ /**
167
+ * Entrypoint for putting any block or block header. Verifies this block,
168
+ * checks the total TD: if this TD is higher than the current highest TD, we
169
+ * have thus found a new canonical block and have to rewrite the canonical
170
+ * chain. This also updates the head block hashes. If any of the older known
171
+ * canonical chains just became stale, then we also reset every _heads header
172
+ * which points to a stale header to the last verified header which was in the
173
+ * old canonical chain, but also in the new canonical chain. This thus rolls
174
+ * back these headers so that these can be updated to the "new" canonical
175
+ * header using the iterator method.
176
+ * @hidden
177
+ */
178
+ private _putBlockOrHeader;
179
+ /**
180
+ * Validates a block header, throwing if invalid. It is being validated against the reported `parentHash`.
181
+ * It verifies the current block against the `parentHash`:
182
+ * - The `parentHash` is part of the blockchain (it is a valid header)
183
+ * - Current block number is parent block number + 1
184
+ * - Current block has a strictly higher timestamp
185
+ * - Additional PoW checks ->
186
+ * - Current block has valid difficulty and gas limit
187
+ * - In case that the header is an uncle header, it should not be too old or young in the chain.
188
+ * - Additional PoA clique checks ->
189
+ * - Checks on coinbase and mixHash
190
+ * - Current block has a timestamp diff greater or equal to PERIOD
191
+ * - Current block has difficulty correctly marked as INTURN or NOTURN
192
+ * @param header - header to be validated
193
+ * @param height - If this is an uncle header, this is the height of the block that is including it
194
+ */
195
+ validateHeader(header: BlockHeader, height?: bigint): Promise<void>;
196
+ /**
197
+ * Validates a block, by validating the header against the current chain, any uncle headers, and then
198
+ * whether the block is internally consistent
199
+ * @param block block to be validated
200
+ */
201
+ validateBlock(block: Block): Promise<void>;
202
+ /**
203
+ * The following rules are checked in this method:
204
+ * Uncle Header is a valid header.
205
+ * Uncle Header is an orphan, i.e. it is not one of the headers of the canonical chain.
206
+ * Uncle Header has a parentHash which points to the canonical chain. This parentHash is within the last 7 blocks.
207
+ * Uncle Header is not already included as uncle in another block.
208
+ * @param block - block for which uncles are being validated
209
+ */
210
+ private _validateUncleHeaders;
211
+ /**
212
+ * Gets a block by its hash or number. If a number is provided, the returned
213
+ * block will be the canonical block at that number in the chain
214
+ *
215
+ * @param blockId - The block's hash or number. If a hash is provided, then
216
+ * this will be immediately looked up, otherwise it will wait until we have
217
+ * unlocked the DB
218
+ */
219
+ getBlock(blockId: Uint8Array | number | bigint): Promise<Block>;
220
+ /**
221
+ * Gets total difficulty for a block specified by hash and number
222
+ */
223
+ getTotalDifficulty(hash: Uint8Array, number?: bigint): Promise<bigint>;
224
+ /**
225
+ * Gets total difficulty for a header's parent, helpful for determining terminal block
226
+ * @param header - Block header whose parent td is desired
227
+ */
228
+ getParentTD(header: BlockHeader): Promise<bigint>;
229
+ /**
230
+ * Looks up many blocks relative to blockId Note: due to `GetBlockHeaders
231
+ * (0x03)` (ETH wire protocol) we have to support skip/reverse as well.
232
+ * @param blockId - The block's hash or number
233
+ * @param maxBlocks - Max number of blocks to return
234
+ * @param skip - Number of blocks to skip apart
235
+ * @param reverse - Fetch blocks in reverse
236
+ */
237
+ getBlocks(blockId: Uint8Array | bigint | number, maxBlocks: number, skip: number, reverse: boolean): Promise<Block[]>;
238
+ /**
239
+ * Given an ordered array, returns an array of hashes that are not in the
240
+ * blockchain yet. Uses binary search to find out what hashes are missing.
241
+ * Therefore, the array needs to be ordered upon number.
242
+ * @param hashes - Ordered array of hashes (ordered on `number`).
243
+ */
244
+ selectNeededHashes(hashes: Array<Uint8Array>): Promise<Uint8Array[]>;
245
+ /**
246
+ * Completely deletes a block from the blockchain including any references to
247
+ * this block. If this block was in the canonical chain, then also each child
248
+ * block of this block is deleted Also, if this was a canonical block, each
249
+ * head header which is part of this now stale chain will be set to the
250
+ * parentHeader of this block An example reason to execute is when running the
251
+ * block in the VM invalidates this block: this will then reset the canonical
252
+ * head to the past block (which has been validated in the past by the VM, so
253
+ * we can be sure it is correct).
254
+ * @param blockHash - The hash of the block to be deleted
255
+ */
256
+ delBlock(blockHash: Uint8Array): Promise<void>;
257
+ /**
258
+ * @hidden
259
+ */
260
+ private _delBlock;
261
+ /**
262
+ * Updates the `DatabaseOperation` list to delete a block from the DB,
263
+ * identified by `blockHash` and `blockNumber`. Deletes fields from `Header`,
264
+ * `Body`, `HashToNumber` and `TotalDifficulty` tables. If child blocks of
265
+ * this current block are in the canonical chain, delete these as well. Does
266
+ * not actually commit these changes to the DB. Sets `_headHeaderHash` and
267
+ * `_headBlockHash` to `headHash` if any of these matches the current child to
268
+ * be deleted.
269
+ * @param blockHash - the block hash to delete
270
+ * @param blockNumber - the number corresponding to the block hash
271
+ * @param headHash - the current head of the chain (if null, do not update
272
+ * `_headHeaderHash` and `_headBlockHash`)
273
+ * @param ops - the `DatabaseOperation` list to add the delete operations to
274
+ * @hidden
275
+ */
276
+ private _delChild;
277
+ /**
278
+ * Iterates through blocks starting at the specified iterator head and calls
279
+ * the onBlock function on each block. The current location of an iterator
280
+ * head can be retrieved using {@link Blockchain.getIteratorHead}.
281
+ *
282
+ * @param name - Name of the state root head
283
+ * @param onBlock - Function called on each block with params (block, reorg)
284
+ * @param maxBlocks - How many blocks to run. By default, run all unprocessed blocks in the canonical chain.
285
+ * @param releaseLockOnCallback - Do not lock the blockchain for running the callback (default: `false`)
286
+ * @returns number of blocks actually iterated
287
+ */
288
+ iterator(name: string, onBlock: OnBlock, maxBlocks?: number, releaseLockOnCallback?: boolean): Promise<number>;
289
+ /**
290
+ * Set header hash of a certain `tag`.
291
+ * When calling the iterator, the iterator will start running the first child block after the header hash currently stored.
292
+ * @param tag - The tag to save the headHash to
293
+ * @param headHash - The head hash to save
294
+ */
295
+ setIteratorHead(tag: string, headHash: Uint8Array): Promise<void>;
296
+ /**
297
+ * Find the common ancestor of the new block and the old block.
298
+ * @param newHeader - the new block header
299
+ */
300
+ private findCommonAncestor;
301
+ /**
302
+ * Pushes DB operations to delete canonical number assignments for specified
303
+ * block number and above. This only deletes `NumberToHash` references and not
304
+ * the blocks themselves. Note: this does not write to the DB but only pushes
305
+ * to a DB operations list.
306
+ * @param blockNumber - the block number from which we start deleting
307
+ * canonical chain assignments (including this block)
308
+ * @param headHash - the hash of the current canonical chain head. The _heads
309
+ * reference matching any hash of any of the deleted blocks will be set to
310
+ * this
311
+ * @param ops - the DatabaseOperation list to write DatabaseOperations to
312
+ * @hidden
313
+ */
314
+ private _deleteCanonicalChainReferences;
315
+ /**
316
+ * Given a `header`, put all operations to change the canonical chain directly
317
+ * into `ops`. This walks the supplied `header` backwards. It is thus assumed
318
+ * that this header should be canonical header. For each header the
319
+ * corresponding hash corresponding to the current canonical chain in the DB
320
+ * is checked. If the number => hash reference does not correspond to the
321
+ * reference in the DB, we overwrite this reference with the implied number =>
322
+ * hash reference Also, each `_heads` member is checked; if these point to a
323
+ * stale hash, then the hash which we terminate the loop (i.e. the first hash
324
+ * which matches the number => hash of the implied chain) is put as this stale
325
+ * head hash. The same happens to _headBlockHash.
326
+ * @param header - The canonical header.
327
+ * @param ops - The database operations list.
328
+ * @hidden
329
+ */
330
+ private _rebuildCanonical;
331
+ /**
332
+ * Builds the `DatabaseOperation[]` list which describes the DB operations to
333
+ * write the heads, head header hash and the head header block to the DB
334
+ * @hidden
335
+ */
336
+ private _saveHeadOps;
337
+ /**
338
+ * Gets the `DatabaseOperation[]` list to save `_heads`, `_headHeaderHash` and
339
+ * `_headBlockHash` and writes these to the DB
340
+ * @hidden
341
+ */
342
+ private _saveHeads;
343
+ /**
344
+ * Gets a header by hash and number. Header can exist outside the canonical
345
+ * chain
346
+ *
347
+ * @hidden
348
+ */
349
+ private _getHeader;
350
+ checkAndTransitionHardForkByNumber(number: BigIntLike, timestamp?: BigIntLike): Promise<void>;
351
+ /**
352
+ * Gets a header by number. Header must be in the canonical chain
353
+ */
354
+ getCanonicalHeader(number: bigint): Promise<BlockHeader>;
355
+ /**
356
+ * This method either returns a Uint8Array if there exists one in the DB or if it
357
+ * does not exist then return false If DB throws
358
+ * any other error, this function throws.
359
+ * @param number
360
+ */
361
+ safeNumberToHash(number: bigint): Promise<Uint8Array | false>;
362
+ /**
363
+ * The genesis {@link Block} for the blockchain.
364
+ */
365
+ get genesisBlock(): Block;
366
+ /**
367
+ * Creates a genesis {@link Block} for the blockchain with params from {@link Common.genesis}
368
+ * @param stateRoot The genesis stateRoot
369
+ */
370
+ createGenesisBlock(stateRoot: Uint8Array): Block;
371
+ }
372
+ //# sourceMappingURL=blockchain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blockchain.d.ts","sourceRoot":"","sources":["../../src/blockchain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAe,MAAM,mBAAmB,CAAA;AACnE,OAAO,EAAE,MAAM,EAAwD,MAAM,oBAAoB,CAAA;AAkBjG,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAU5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAK3C,OAAO,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEhE,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,SAAS,EAET,OAAO,EACR,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;GAaG;AACH,qBAAa,UAAW,YAAW,mBAAmB;IACpD,EAAE,EAAE,EAAE,CAAC,UAAU,GAAG,MAAM,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,CAAC,CAAA;IAC3D,SAA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