@aztec/archiver 0.0.1-commit.d3ec352c → 0.0.1-commit.d58ff9d0
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/README.md +164 -22
- package/dest/archiver.d.ts +194 -0
- package/dest/archiver.d.ts.map +1 -0
- package/dest/archiver.js +949 -0
- package/dest/config.d.ts +34 -0
- package/dest/config.d.ts.map +1 -0
- package/dest/config.js +95 -0
- package/dest/errors.d.ts +87 -0
- package/dest/errors.d.ts.map +1 -0
- package/dest/errors.js +129 -0
- package/dest/factory.d.ts +16 -10
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +117 -20
- package/dest/index.d.ts +19 -4
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +17 -3
- package/dest/interfaces.d.ts +9 -0
- package/dest/interfaces.d.ts.map +1 -0
- package/dest/interfaces.js +3 -0
- package/dest/l1/bin/retrieve-calldata.d.ts +3 -0
- package/dest/l1/bin/retrieve-calldata.d.ts.map +1 -0
- package/dest/l1/bin/retrieve-calldata.js +152 -0
- package/dest/l1/calldata_retriever.d.ts +143 -0
- package/dest/l1/calldata_retriever.d.ts.map +1 -0
- package/dest/l1/calldata_retriever.js +413 -0
- package/dest/l1/data_retrieval.d.ts +102 -0
- package/dest/l1/data_retrieval.d.ts.map +1 -0
- package/dest/{archiver → l1}/data_retrieval.js +85 -165
- package/dest/l1/debug_tx.d.ts +19 -0
- package/dest/l1/debug_tx.d.ts.map +1 -0
- package/dest/l1/debug_tx.js +73 -0
- package/dest/l1/spire_proposer.d.ts +70 -0
- package/dest/l1/spire_proposer.d.ts.map +1 -0
- package/dest/l1/spire_proposer.js +149 -0
- package/dest/l1/trace_tx.d.ts +43 -0
- package/dest/l1/trace_tx.d.ts.map +1 -0
- package/dest/l1/trace_tx.js +91 -0
- package/dest/l1/types.d.ts +12 -0
- package/dest/l1/types.d.ts.map +1 -0
- package/dest/l1/types.js +3 -0
- package/dest/l1/validate_historical_logs.d.ts +23 -0
- package/dest/l1/validate_historical_logs.d.ts.map +1 -0
- package/dest/l1/validate_historical_logs.js +108 -0
- package/dest/l1/validate_trace.d.ts +32 -0
- package/dest/l1/validate_trace.d.ts.map +1 -0
- package/dest/l1/validate_trace.js +154 -0
- package/dest/modules/contract_data_source_adapter.d.ts +25 -0
- package/dest/modules/contract_data_source_adapter.d.ts.map +1 -0
- package/dest/modules/contract_data_source_adapter.js +32 -0
- package/dest/modules/data_source_base.d.ts +112 -0
- package/dest/modules/data_source_base.d.ts.map +1 -0
- package/dest/modules/data_source_base.js +322 -0
- package/dest/modules/data_store_updater.d.ts +105 -0
- package/dest/modules/data_store_updater.d.ts.map +1 -0
- package/dest/modules/data_store_updater.js +393 -0
- package/dest/modules/instrumentation.d.ts +63 -0
- package/dest/modules/instrumentation.d.ts.map +1 -0
- package/dest/modules/instrumentation.js +166 -0
- package/dest/modules/l1_synchronizer.d.ts +77 -0
- package/dest/modules/l1_synchronizer.d.ts.map +1 -0
- package/dest/modules/l1_synchronizer.js +1381 -0
- package/dest/modules/outbox_trees_resolver.d.ts +62 -0
- package/dest/modules/outbox_trees_resolver.d.ts.map +1 -0
- package/dest/modules/outbox_trees_resolver.js +162 -0
- package/dest/modules/validation.d.ts +40 -0
- package/dest/modules/validation.d.ts.map +1 -0
- package/dest/{archiver → modules}/validation.js +41 -17
- package/dest/store/block_store.d.ts +303 -0
- package/dest/store/block_store.d.ts.map +1 -0
- package/dest/store/block_store.js +1206 -0
- package/dest/store/contract_class_store.d.ts +31 -0
- package/dest/store/contract_class_store.d.ts.map +1 -0
- package/dest/store/contract_class_store.js +98 -0
- package/dest/store/contract_instance_store.d.ts +51 -0
- package/dest/store/contract_instance_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/contract_instance_store.js +55 -3
- package/dest/store/data_stores.d.ts +68 -0
- package/dest/store/data_stores.d.ts.map +1 -0
- package/dest/store/data_stores.js +54 -0
- package/dest/store/function_names_cache.d.ts +17 -0
- package/dest/store/function_names_cache.d.ts.map +1 -0
- package/dest/store/function_names_cache.js +30 -0
- package/dest/store/l2_tips_cache.d.ts +25 -0
- package/dest/store/l2_tips_cache.d.ts.map +1 -0
- package/dest/store/l2_tips_cache.js +26 -0
- package/dest/store/log_store.d.ts +59 -0
- package/dest/store/log_store.d.ts.map +1 -0
- package/dest/store/log_store.js +310 -0
- package/dest/store/log_store_codec.d.ts +78 -0
- package/dest/store/log_store_codec.d.ts.map +1 -0
- package/dest/store/log_store_codec.js +110 -0
- package/dest/store/message_store.d.ts +50 -0
- package/dest/store/message_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/message_store.js +66 -23
- package/dest/{archiver/structs → structs}/data_retrieval.d.ts +1 -1
- package/dest/structs/data_retrieval.d.ts.map +1 -0
- package/dest/structs/inbox_message.d.ts +15 -0
- package/dest/structs/inbox_message.d.ts.map +1 -0
- package/dest/{archiver/structs → structs}/inbox_message.js +6 -6
- package/dest/structs/published.d.ts +2 -0
- package/dest/structs/published.d.ts.map +1 -0
- package/dest/test/fake_l1_state.d.ts +214 -0
- package/dest/test/fake_l1_state.d.ts.map +1 -0
- package/dest/test/fake_l1_state.js +517 -0
- package/dest/test/index.d.ts +2 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +4 -1
- package/dest/test/mock_archiver.d.ts +5 -6
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +8 -12
- package/dest/test/mock_l1_to_l2_message_source.d.ts +6 -7
- package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.js +19 -14
- package/dest/test/mock_l2_block_source.d.ts +68 -40
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +347 -145
- package/dest/test/mock_structs.d.ts +83 -4
- package/dest/test/mock_structs.d.ts.map +1 -1
- package/dest/test/mock_structs.js +157 -12
- package/dest/test/noop_l1_archiver.d.ts +34 -0
- package/dest/test/noop_l1_archiver.d.ts.map +1 -0
- package/dest/test/noop_l1_archiver.js +88 -0
- package/package.json +18 -18
- package/src/archiver.ts +785 -0
- package/src/config.ts +125 -0
- package/src/errors.ts +203 -0
- package/src/factory.ts +185 -22
- package/src/index.ts +27 -3
- package/src/interfaces.ts +9 -0
- package/src/l1/README.md +55 -0
- package/src/l1/bin/retrieve-calldata.ts +194 -0
- package/src/l1/calldata_retriever.ts +529 -0
- package/src/{archiver → l1}/data_retrieval.ts +157 -243
- package/src/l1/debug_tx.ts +99 -0
- package/src/l1/spire_proposer.ts +152 -0
- package/src/l1/trace_tx.ts +128 -0
- package/src/l1/types.ts +13 -0
- package/src/l1/validate_historical_logs.ts +140 -0
- package/src/l1/validate_trace.ts +229 -0
- package/src/modules/contract_data_source_adapter.ts +46 -0
- package/src/modules/data_source_base.ts +466 -0
- package/src/modules/data_store_updater.ts +519 -0
- package/src/modules/instrumentation.ts +217 -0
- package/src/modules/l1_synchronizer.ts +1320 -0
- package/src/modules/outbox_trees_resolver.ts +199 -0
- package/src/modules/validation.ts +186 -0
- package/src/store/block_store.ts +1551 -0
- package/src/store/contract_class_store.ts +126 -0
- package/src/{archiver/kv_archiver_store → store}/contract_instance_store.ts +70 -7
- package/src/store/data_stores.ts +104 -0
- package/src/store/function_names_cache.ts +37 -0
- package/src/store/l2_tips_cache.ts +35 -0
- package/src/store/log_store.ts +380 -0
- package/src/store/log_store_codec.ts +143 -0
- package/src/{archiver/kv_archiver_store → store}/message_store.ts +81 -28
- package/src/{archiver/structs → structs}/inbox_message.ts +8 -9
- package/src/{archiver/structs → structs}/published.ts +0 -1
- package/src/test/fake_l1_state.ts +770 -0
- package/src/test/fixtures/debug_traceTransaction-multicall3.json +88 -0
- package/src/test/fixtures/debug_traceTransaction-multiplePropose.json +153 -0
- package/src/test/fixtures/debug_traceTransaction-proxied.json +122 -0
- package/src/test/fixtures/trace_transaction-multicall3.json +65 -0
- package/src/test/fixtures/trace_transaction-multiplePropose.json +319 -0
- package/src/test/fixtures/trace_transaction-proxied.json +128 -0
- package/src/test/fixtures/trace_transaction-randomRevert.json +216 -0
- package/src/test/index.ts +4 -0
- package/src/test/mock_archiver.ts +10 -14
- package/src/test/mock_l1_to_l2_message_source.ts +16 -15
- package/src/test/mock_l2_block_source.ts +416 -161
- package/src/test/mock_structs.ts +292 -14
- package/src/test/noop_l1_archiver.ts +158 -0
- package/dest/archiver/archiver.d.ts +0 -290
- package/dest/archiver/archiver.d.ts.map +0 -1
- package/dest/archiver/archiver.js +0 -1434
- package/dest/archiver/archiver_store.d.ts +0 -256
- package/dest/archiver/archiver_store.d.ts.map +0 -1
- package/dest/archiver/archiver_store.js +0 -4
- package/dest/archiver/archiver_store_test_suite.d.ts +0 -8
- package/dest/archiver/archiver_store_test_suite.d.ts.map +0 -1
- package/dest/archiver/archiver_store_test_suite.js +0 -1289
- package/dest/archiver/config.d.ts +0 -21
- package/dest/archiver/config.d.ts.map +0 -1
- package/dest/archiver/config.js +0 -55
- package/dest/archiver/data_retrieval.d.ts +0 -80
- package/dest/archiver/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/errors.d.ts +0 -12
- package/dest/archiver/errors.d.ts.map +0 -1
- package/dest/archiver/errors.js +0 -17
- package/dest/archiver/index.d.ts +0 -7
- package/dest/archiver/index.d.ts.map +0 -1
- package/dest/archiver/index.js +0 -4
- package/dest/archiver/instrumentation.d.ts +0 -35
- package/dest/archiver/instrumentation.d.ts.map +0 -1
- package/dest/archiver/instrumentation.js +0 -140
- package/dest/archiver/kv_archiver_store/block_store.d.ts +0 -125
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/block_store.js +0 -371
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +0 -18
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/contract_class_store.js +0 -120
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +0 -24
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +0 -169
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +0 -296
- package/dest/archiver/kv_archiver_store/log_store.d.ts +0 -49
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/log_store.js +0 -337
- package/dest/archiver/kv_archiver_store/message_store.d.ts +0 -39
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +0 -1
- package/dest/archiver/structs/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/structs/inbox_message.d.ts +0 -15
- package/dest/archiver/structs/inbox_message.d.ts.map +0 -1
- package/dest/archiver/structs/published.d.ts +0 -3
- package/dest/archiver/structs/published.d.ts.map +0 -1
- package/dest/archiver/validation.d.ts +0 -17
- package/dest/archiver/validation.d.ts.map +0 -1
- package/dest/rpc/index.d.ts +0 -9
- package/dest/rpc/index.d.ts.map +0 -1
- package/dest/rpc/index.js +0 -15
- package/src/archiver/archiver.ts +0 -1880
- package/src/archiver/archiver_store.ts +0 -310
- package/src/archiver/archiver_store_test_suite.ts +0 -1295
- package/src/archiver/config.ts +0 -79
- package/src/archiver/errors.ts +0 -26
- package/src/archiver/index.ts +0 -6
- package/src/archiver/instrumentation.ts +0 -187
- package/src/archiver/kv_archiver_store/block_store.ts +0 -482
- package/src/archiver/kv_archiver_store/contract_class_store.ts +0 -176
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +0 -423
- package/src/archiver/kv_archiver_store/log_store.ts +0 -407
- package/src/archiver/validation.ts +0 -124
- package/src/rpc/index.ts +0 -16
- /package/dest/{archiver/structs → structs}/data_retrieval.js +0 -0
- /package/dest/{archiver/structs → structs}/published.js +0 -0
- /package/src/{archiver/structs → structs}/data_retrieval.ts +0 -0
|
@@ -1,34 +1,104 @@
|
|
|
1
1
|
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
2
|
-
import { DefaultL1ContractsConfig } from '@aztec/ethereum';
|
|
3
|
-
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { DefaultL1ContractsConfig } from '@aztec/ethereum/config';
|
|
3
|
+
import { BlockNumber, CheckpointNumber, IndexWithinCheckpoint, SlotNumber } from '@aztec/foundation/branded-types';
|
|
4
4
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
5
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
6
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
7
7
|
import { createLogger } from '@aztec/foundation/log';
|
|
8
|
-
import {
|
|
8
|
+
import { Body, GENESIS_BLOCK_HEADER_HASH, GENESIS_CHECKPOINT_HEADER_HASH, L2Block } from '@aztec/stdlib/block';
|
|
9
|
+
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
9
10
|
import { EmptyL1RollupConstants, getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
10
|
-
import {
|
|
11
|
+
import { computeCheckpointOutHash } from '@aztec/stdlib/messaging';
|
|
12
|
+
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
13
|
+
import { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
|
|
14
|
+
import { BlockHeader } from '@aztec/stdlib/tx';
|
|
11
15
|
/**
|
|
12
16
|
* A mocked implementation of L2BlockSource to be used in tests.
|
|
13
17
|
*/ export class MockL2BlockSource {
|
|
14
18
|
l2Blocks = [];
|
|
19
|
+
checkpointList = [];
|
|
15
20
|
provenBlockNumber = 0;
|
|
16
21
|
finalizedBlockNumber = 0;
|
|
22
|
+
checkpointedBlockNumber = 0;
|
|
23
|
+
initialHeader = BlockHeader.empty();
|
|
24
|
+
initialHeaderHash = GENESIS_BLOCK_HEADER_HASH;
|
|
25
|
+
genesisArchiveRoot;
|
|
26
|
+
genesisBlock;
|
|
17
27
|
log = createLogger('archiver:mock_l2_block_source');
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
/** Returns the initial header used to synthesize block 0. */ getInitialHeader() {
|
|
29
|
+
return this.initialHeader;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Sets the initial header used to synthesize block 0. Tests that wire up a real
|
|
33
|
+
* world-state should call this with `worldState.getInitialHeader()` so the L2BlockStream
|
|
34
|
+
* agrees on the genesis hash on both sides. Precomputes and caches the header hash so
|
|
35
|
+
* `getGenesisBlockHash()` can return synchronously.
|
|
36
|
+
*/ async setInitialHeader(header) {
|
|
37
|
+
this.initialHeader = header;
|
|
38
|
+
this.initialHeaderHash = await header.hash();
|
|
39
|
+
this.genesisBlock = undefined;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns the precomputed hash of the genesis block header. Defaults to the static
|
|
43
|
+
* {@link GENESIS_BLOCK_HEADER_HASH} unless {@link setInitialHeader} has been called with a
|
|
44
|
+
* custom header.
|
|
45
|
+
*/ getGenesisBlockHash() {
|
|
46
|
+
return this.initialHeaderHash;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Sets the post-genesis archive root used to synthesize block 0. Mirrors the real archiver,
|
|
50
|
+
* whose synthetic block 0 carries `new AppendOnlyTreeSnapshot(genesisArchiveRoot, 1)` rather
|
|
51
|
+
* than `AppendOnlyTreeSnapshot.empty()`. Tests wiring up a real world-state should set this so
|
|
52
|
+
* archive-based block lookups against the mock match production semantics.
|
|
53
|
+
*/ setGenesisArchiveRoot(root) {
|
|
54
|
+
this.genesisArchiveRoot = root;
|
|
55
|
+
this.genesisBlock = undefined;
|
|
56
|
+
}
|
|
57
|
+
getGenesisBlock() {
|
|
58
|
+
if (this.genesisBlock) {
|
|
59
|
+
return this.genesisBlock;
|
|
23
60
|
}
|
|
24
|
-
this.
|
|
61
|
+
const archive = this.genesisArchiveRoot ? new AppendOnlyTreeSnapshot(this.genesisArchiveRoot, 1) : AppendOnlyTreeSnapshot.empty();
|
|
62
|
+
return this.genesisBlock = new L2Block(archive, this.initialHeader, Body.empty(), CheckpointNumber.ZERO, IndexWithinCheckpoint(0));
|
|
63
|
+
}
|
|
64
|
+
/** Creates blocks grouped into single-block checkpoints. */ async createBlocks(numBlocks) {
|
|
65
|
+
await this.createCheckpoints(numBlocks, 1);
|
|
66
|
+
}
|
|
67
|
+
getCheckpointNumber() {
|
|
68
|
+
return Promise.resolve(this.checkpointList.length === 0 ? CheckpointNumber.ZERO : CheckpointNumber(this.checkpointList.length));
|
|
69
|
+
}
|
|
70
|
+
/** Creates checkpoints, each containing `blocksPerCheckpoint` blocks. */ async createCheckpoints(numCheckpoints, blocksPerCheckpoint = 1) {
|
|
71
|
+
for(let c = 0; c < numCheckpoints; c++){
|
|
72
|
+
const checkpointNum = CheckpointNumber(this.checkpointList.length + 1);
|
|
73
|
+
const startBlockNum = this.l2Blocks.length + 1;
|
|
74
|
+
const slotNumber = SlotNumber(Number(checkpointNum));
|
|
75
|
+
const checkpoint = await Checkpoint.random(checkpointNum, {
|
|
76
|
+
numBlocks: blocksPerCheckpoint,
|
|
77
|
+
startBlockNumber: startBlockNum,
|
|
78
|
+
slotNumber,
|
|
79
|
+
checkpointNumber: checkpointNum
|
|
80
|
+
});
|
|
81
|
+
this.checkpointList.push(checkpoint);
|
|
82
|
+
this.l2Blocks.push(...checkpoint.blocks);
|
|
83
|
+
}
|
|
84
|
+
this.log.verbose(`Created ${numCheckpoints} checkpoints with ${blocksPerCheckpoint} blocks each in the mock L2 block source`);
|
|
25
85
|
}
|
|
26
|
-
|
|
86
|
+
addProposedBlocks(blocks) {
|
|
27
87
|
this.l2Blocks.push(...blocks);
|
|
28
|
-
this.log.verbose(`Added ${blocks.length} blocks to the mock L2 block source`);
|
|
88
|
+
this.log.verbose(`Added ${blocks.length} proposed blocks to the mock L2 block source`);
|
|
29
89
|
}
|
|
30
90
|
removeBlocks(numBlocks) {
|
|
31
91
|
this.l2Blocks = this.l2Blocks.slice(0, -numBlocks);
|
|
92
|
+
const maxBlockNum = this.l2Blocks.length;
|
|
93
|
+
// Remove any checkpoint whose last block is beyond the remaining blocks.
|
|
94
|
+
this.checkpointList = this.checkpointList.filter((c)=>{
|
|
95
|
+
const lastBlockNum = c.blocks[0].number + c.blocks.length - 1;
|
|
96
|
+
return lastBlockNum <= maxBlockNum;
|
|
97
|
+
});
|
|
98
|
+
// Keep tip numbers consistent with remaining blocks.
|
|
99
|
+
this.checkpointedBlockNumber = Math.min(this.checkpointedBlockNumber, maxBlockNum);
|
|
100
|
+
this.provenBlockNumber = Math.min(this.provenBlockNumber, maxBlockNum);
|
|
101
|
+
this.finalizedBlockNumber = Math.min(this.finalizedBlockNumber, maxBlockNum);
|
|
32
102
|
this.log.verbose(`Removed ${numBlocks} blocks from the mock L2 block source`);
|
|
33
103
|
}
|
|
34
104
|
setProvenBlockNumber(provenBlockNumber) {
|
|
@@ -40,6 +110,34 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
40
110
|
}
|
|
41
111
|
this.finalizedBlockNumber = finalizedBlockNumber;
|
|
42
112
|
}
|
|
113
|
+
setCheckpointedBlockNumber(checkpointedBlockNumber) {
|
|
114
|
+
const prevCheckpointed = this.checkpointedBlockNumber;
|
|
115
|
+
this.checkpointedBlockNumber = checkpointedBlockNumber;
|
|
116
|
+
// Auto-create single-block checkpoints for newly checkpointed blocks that don't have one yet.
|
|
117
|
+
// This handles blocks added via addProposedBlocks that are now being marked as checkpointed.
|
|
118
|
+
const newCheckpoints = [];
|
|
119
|
+
for(let blockNum = prevCheckpointed + 1; blockNum <= checkpointedBlockNumber; blockNum++){
|
|
120
|
+
const block = this.l2Blocks[blockNum - 1];
|
|
121
|
+
if (!block) {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (this.checkpointList.some((c)=>c.blocks.some((b)=>b.number === block.number))) {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const checkpointNum = CheckpointNumber(this.checkpointList.length + newCheckpoints.length + 1);
|
|
128
|
+
const checkpoint = new Checkpoint(block.archive, CheckpointHeader.random({
|
|
129
|
+
slotNumber: block.header.globalVariables.slotNumber
|
|
130
|
+
}), [
|
|
131
|
+
block
|
|
132
|
+
], checkpointNum);
|
|
133
|
+
newCheckpoints.push(checkpoint);
|
|
134
|
+
}
|
|
135
|
+
// Insert new checkpoints in order by number.
|
|
136
|
+
if (newCheckpoints.length > 0) {
|
|
137
|
+
this.checkpointList.push(...newCheckpoints);
|
|
138
|
+
this.checkpointList.sort((a, b)=>a.number - b.number);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
43
141
|
/**
|
|
44
142
|
* Method to fetch the rollup contract address at the base-layer.
|
|
45
143
|
* @returns The rollup address.
|
|
@@ -52,117 +150,95 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
52
150
|
*/ getRegistryAddress() {
|
|
53
151
|
return Promise.resolve(EthAddress.random());
|
|
54
152
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
153
|
+
async getBlockNumber(query) {
|
|
154
|
+
if (!query) {
|
|
155
|
+
return BlockNumber(this.l2Blocks.length);
|
|
156
|
+
}
|
|
157
|
+
if ('number' in query) {
|
|
158
|
+
return query.number;
|
|
159
|
+
}
|
|
160
|
+
if ('tag' in query) {
|
|
161
|
+
return BlockNumber(this.resolveBlockTag(query.tag));
|
|
162
|
+
}
|
|
163
|
+
const block = await this.getBlock(query);
|
|
164
|
+
return block ? block.header.globalVariables.blockNumber : undefined;
|
|
60
165
|
}
|
|
61
|
-
|
|
62
|
-
|
|
166
|
+
getCheckpoint(query) {
|
|
167
|
+
const checkpoint = this.resolveCheckpointQuery(query);
|
|
168
|
+
if (!checkpoint) {
|
|
169
|
+
return Promise.resolve(undefined);
|
|
170
|
+
}
|
|
171
|
+
return Promise.resolve(new PublishedCheckpoint(checkpoint, this.mockL1DataForCheckpoint(checkpoint), []));
|
|
63
172
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
* @returns The requested L2 block.
|
|
68
|
-
*/ getBlock(number) {
|
|
69
|
-
return Promise.resolve(this.l2Blocks[number - 1]);
|
|
173
|
+
getCheckpoints(query) {
|
|
174
|
+
const checkpoints = this.resolveCheckpointsQuery(query);
|
|
175
|
+
return Promise.resolve(checkpoints.map((checkpoint)=>new PublishedCheckpoint(checkpoint, this.mockL1DataForCheckpoint(checkpoint), [])));
|
|
70
176
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
* @param limit - The maximum number of blocks to return.
|
|
75
|
-
* @returns The requested mocked L2 blocks.
|
|
76
|
-
*/ getBlocks(from, limit, proven) {
|
|
77
|
-
return Promise.resolve(this.l2Blocks.slice(from - 1, from - 1 + limit).filter((b)=>!proven || this.provenBlockNumber === undefined || b.number <= this.provenBlockNumber));
|
|
78
|
-
}
|
|
79
|
-
async getPublishedCheckpoints(from, limit) {
|
|
80
|
-
// TODO: Implement this properly. This only works when we have one block per checkpoint.
|
|
81
|
-
return (await this.getPublishedBlocks(from, limit)).map((block)=>block.toPublishedCheckpoint());
|
|
82
|
-
}
|
|
83
|
-
async getCheckpointByArchive(archive) {
|
|
84
|
-
// TODO: Implement this properly. This only works when we have one block per checkpoint.
|
|
85
|
-
return (await this.getPublishedBlockByArchive(archive))?.block.toCheckpoint();
|
|
86
|
-
}
|
|
87
|
-
async getPublishedBlocks(from, limit, proven) {
|
|
88
|
-
const blocks = await this.getBlocks(from, limit, proven);
|
|
89
|
-
return blocks.map((block)=>PublishedL2Block.fromFields({
|
|
90
|
-
block,
|
|
91
|
-
l1: {
|
|
92
|
-
blockNumber: BigInt(block.number),
|
|
93
|
-
blockHash: Buffer32.random().toString(),
|
|
94
|
-
timestamp: BigInt(block.number)
|
|
95
|
-
},
|
|
96
|
-
attestations: []
|
|
97
|
-
}));
|
|
98
|
-
}
|
|
99
|
-
async getPublishedBlockByHash(blockHash) {
|
|
100
|
-
for (const block of this.l2Blocks){
|
|
101
|
-
const hash = await block.hash();
|
|
102
|
-
if (hash.equals(blockHash)) {
|
|
103
|
-
return PublishedL2Block.fromFields({
|
|
104
|
-
block,
|
|
105
|
-
l1: {
|
|
106
|
-
blockNumber: BigInt(block.number),
|
|
107
|
-
blockHash: Buffer32.random().toString(),
|
|
108
|
-
timestamp: BigInt(block.number)
|
|
109
|
-
},
|
|
110
|
-
attestations: []
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return undefined;
|
|
177
|
+
getCheckpointByArchive(archive) {
|
|
178
|
+
const checkpoint = this.checkpointList.find((c)=>c.archive.root.equals(archive));
|
|
179
|
+
return Promise.resolve(checkpoint);
|
|
115
180
|
}
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
if (!
|
|
181
|
+
getCheckpointData(query) {
|
|
182
|
+
const checkpoint = this.resolveCheckpointQuery(query);
|
|
183
|
+
if (!checkpoint) {
|
|
119
184
|
return Promise.resolve(undefined);
|
|
120
185
|
}
|
|
121
|
-
return Promise.resolve(
|
|
122
|
-
block,
|
|
123
|
-
l1: {
|
|
124
|
-
blockNumber: BigInt(block.number),
|
|
125
|
-
blockHash: Buffer32.random().toString(),
|
|
126
|
-
timestamp: BigInt(block.number)
|
|
127
|
-
},
|
|
128
|
-
attestations: []
|
|
129
|
-
}));
|
|
130
|
-
}
|
|
131
|
-
async getBlockHeaderByHash(blockHash) {
|
|
132
|
-
for (const block of this.l2Blocks){
|
|
133
|
-
const hash = await block.hash();
|
|
134
|
-
if (hash.equals(blockHash)) {
|
|
135
|
-
return block.getBlockHeader();
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return undefined;
|
|
186
|
+
return Promise.resolve(this.checkpointToData(checkpoint));
|
|
139
187
|
}
|
|
140
|
-
|
|
141
|
-
const
|
|
142
|
-
return Promise.resolve(
|
|
188
|
+
getCheckpointsData(query) {
|
|
189
|
+
const checkpoints = this.resolveCheckpointsQuery(query);
|
|
190
|
+
return Promise.resolve(checkpoints.map((c)=>this.checkpointToData(c)));
|
|
143
191
|
}
|
|
144
|
-
|
|
145
|
-
return
|
|
192
|
+
checkpointToData(checkpoint) {
|
|
193
|
+
return {
|
|
194
|
+
checkpointNumber: checkpoint.number,
|
|
195
|
+
header: checkpoint.header,
|
|
196
|
+
archive: checkpoint.archive,
|
|
197
|
+
checkpointOutHash: computeCheckpointOutHash(checkpoint.blocks.map((b)=>b.body.txEffects.map((tx)=>tx.l2ToL1Msgs))),
|
|
198
|
+
startBlock: checkpoint.blocks[0].number,
|
|
199
|
+
blockCount: checkpoint.blocks.length,
|
|
200
|
+
feeAssetPriceModifier: checkpoint.feeAssetPriceModifier,
|
|
201
|
+
attestations: [],
|
|
202
|
+
l1: this.mockL1DataForCheckpoint(checkpoint)
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
resolveCheckpointQuery(query) {
|
|
206
|
+
if ('number' in query) {
|
|
207
|
+
return this.checkpointList[query.number - 1];
|
|
208
|
+
}
|
|
209
|
+
if ('slot' in query) {
|
|
210
|
+
return this.checkpointList.find((c)=>c.header.slotNumber === query.slot);
|
|
211
|
+
}
|
|
212
|
+
switch(query.tag){
|
|
213
|
+
case 'checkpointed':
|
|
214
|
+
return this.checkpointList[this.checkpointList.length - 1];
|
|
215
|
+
case 'proven':
|
|
216
|
+
{
|
|
217
|
+
const provenCheckpoint = this.checkpointList.filter((c)=>c.blocks.some((b)=>b.number <= this.provenBlockNumber));
|
|
218
|
+
return provenCheckpoint.at(-1);
|
|
219
|
+
}
|
|
220
|
+
case 'finalized':
|
|
221
|
+
{
|
|
222
|
+
const finalizedCheckpoint = this.checkpointList.filter((c)=>c.blocks.some((b)=>b.number <= this.finalizedBlockNumber));
|
|
223
|
+
return finalizedCheckpoint.at(-1);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
146
226
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
227
|
+
resolveCheckpointsQuery(query) {
|
|
228
|
+
if ('from' in query) {
|
|
229
|
+
return this.checkpointList.slice(query.from - 1, query.from - 1 + query.limit);
|
|
230
|
+
}
|
|
231
|
+
if ('fromSlot' in query) {
|
|
232
|
+
const matching = this.checkpointList.filter((c)=>query.reverse ? c.header.slotNumber <= query.fromSlot : c.header.slotNumber >= query.fromSlot);
|
|
233
|
+
const nearestFirst = query.reverse ? matching.reverse() : matching;
|
|
234
|
+
return nearestFirst.slice(0, query.limit);
|
|
235
|
+
}
|
|
236
|
+
return this.getCheckpointsInEpoch(query.epoch);
|
|
150
237
|
}
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
const [start, end] = getSlotRangeForEpoch(epochNumber, {
|
|
154
|
-
epochDuration
|
|
155
|
-
});
|
|
156
|
-
const blocks = this.l2Blocks.filter((b)=>{
|
|
157
|
-
const slot = b.header.globalVariables.slotNumber;
|
|
158
|
-
return slot >= start && slot <= end;
|
|
159
|
-
});
|
|
238
|
+
getBlocksForSlot(slotNumber) {
|
|
239
|
+
const blocks = this.l2Blocks.filter((b)=>b.header.globalVariables.slotNumber === slotNumber);
|
|
160
240
|
return Promise.resolve(blocks);
|
|
161
241
|
}
|
|
162
|
-
async getBlockHeadersForEpoch(epochNumber) {
|
|
163
|
-
const blocks = await this.getBlocksForEpoch(epochNumber);
|
|
164
|
-
return blocks.map((b)=>b.getBlockHeader());
|
|
165
|
-
}
|
|
166
242
|
/**
|
|
167
243
|
* Gets a tx effect.
|
|
168
244
|
* @param txHash - The hash of the tx corresponding to the tx effect.
|
|
@@ -179,52 +255,76 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
179
255
|
return {
|
|
180
256
|
data: txEffect,
|
|
181
257
|
l2BlockNumber: block.number,
|
|
182
|
-
l2BlockHash:
|
|
183
|
-
txIndexInBlock: block.body.txEffects.
|
|
258
|
+
l2BlockHash: await block.hash(),
|
|
259
|
+
txIndexInBlock: block.body.txEffects.findIndex((t)=>t.txHash.equals(txHash)),
|
|
260
|
+
slotNumber: block.header.globalVariables.slotNumber
|
|
184
261
|
};
|
|
185
262
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
* @returns The requested tx receipt (or undefined if not found).
|
|
190
|
-
*/ async getSettledTxReceipt(txHash) {
|
|
191
|
-
for (const block of this.l2Blocks){
|
|
192
|
-
for (const txEffect of block.body.txEffects){
|
|
193
|
-
if (txEffect.txHash.equals(txHash)) {
|
|
194
|
-
return new TxReceipt(txHash, TxStatus.SUCCESS, '', txEffect.transactionFee.toBigInt(), L2BlockHash.fromField(await block.hash()), block.number);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
return undefined;
|
|
263
|
+
getL2ToL1MembershipWitness() {
|
|
264
|
+
// Mock does not back the L2-to-L1 message witness flow.
|
|
265
|
+
return Promise.resolve(undefined);
|
|
199
266
|
}
|
|
200
267
|
async getL2Tips() {
|
|
201
|
-
const [latest, proven, finalized] = [
|
|
268
|
+
const [latest, proven, finalized, checkpointed] = [
|
|
202
269
|
await this.getBlockNumber(),
|
|
203
|
-
|
|
204
|
-
this.finalizedBlockNumber
|
|
270
|
+
this.provenBlockNumber,
|
|
271
|
+
this.finalizedBlockNumber,
|
|
272
|
+
this.checkpointedBlockNumber
|
|
205
273
|
];
|
|
206
274
|
const latestBlock = this.l2Blocks[latest - 1];
|
|
207
275
|
const provenBlock = this.l2Blocks[proven - 1];
|
|
208
276
|
const finalizedBlock = this.l2Blocks[finalized - 1];
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
hash: (await provenBlock?.hash())?.toString()
|
|
217
|
-
},
|
|
218
|
-
finalized: {
|
|
219
|
-
number: BlockNumber(finalized),
|
|
220
|
-
hash: (await finalizedBlock?.hash())?.toString()
|
|
277
|
+
const checkpointedBlock = this.l2Blocks[checkpointed - 1];
|
|
278
|
+
// For genesis tips (block number 0) report the dynamic initial header hash so consumers
|
|
279
|
+
// running L2BlockStream against this mock agree at block 0 with their local tip store.
|
|
280
|
+
const genesisHash = (await this.initialHeader.hash()).toString();
|
|
281
|
+
const tipHash = async (block, number)=>{
|
|
282
|
+
if (block) {
|
|
283
|
+
return (await block.hash()).toString();
|
|
221
284
|
}
|
|
285
|
+
return number === 0 ? genesisHash : '';
|
|
286
|
+
};
|
|
287
|
+
const latestBlockId = {
|
|
288
|
+
number: BlockNumber(latest),
|
|
289
|
+
hash: await tipHash(latestBlock, latest)
|
|
290
|
+
};
|
|
291
|
+
const provenBlockId = {
|
|
292
|
+
number: BlockNumber(proven),
|
|
293
|
+
hash: await tipHash(provenBlock, proven)
|
|
294
|
+
};
|
|
295
|
+
const finalizedBlockId = {
|
|
296
|
+
number: BlockNumber(finalized),
|
|
297
|
+
hash: await tipHash(finalizedBlock, finalized)
|
|
298
|
+
};
|
|
299
|
+
const checkpointedBlockId = {
|
|
300
|
+
number: BlockNumber(checkpointed),
|
|
301
|
+
hash: await tipHash(checkpointedBlock, checkpointed)
|
|
302
|
+
};
|
|
303
|
+
const makeTipId = (blockId)=>{
|
|
304
|
+
const checkpointNumber = this.findCheckpointNumberForBlock(blockId.number) ?? CheckpointNumber(0);
|
|
305
|
+
// Match production semantics: checkpoint 0 is fully synthetic (no real checkpoint header
|
|
306
|
+
// exists at 0), so its hash stays at the protocol constant `GENESIS_CHECKPOINT_HEADER_HASH`
|
|
307
|
+
// even though the block-0 hash is dynamic. See L2TipsCache for the production path.
|
|
308
|
+
const hash = checkpointNumber === 0 ? GENESIS_CHECKPOINT_HEADER_HASH.toString() : blockId.hash;
|
|
309
|
+
return {
|
|
310
|
+
block: blockId,
|
|
311
|
+
checkpoint: {
|
|
312
|
+
number: checkpointNumber,
|
|
313
|
+
hash
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
};
|
|
317
|
+
return {
|
|
318
|
+
proposed: latestBlockId,
|
|
319
|
+
checkpointed: makeTipId(checkpointedBlockId),
|
|
320
|
+
proven: makeTipId(provenBlockId),
|
|
321
|
+
finalized: makeTipId(finalizedBlockId)
|
|
222
322
|
};
|
|
223
323
|
}
|
|
224
|
-
|
|
324
|
+
getSyncedL2EpochNumber() {
|
|
225
325
|
throw new Error('Method not implemented.');
|
|
226
326
|
}
|
|
227
|
-
|
|
327
|
+
getSyncedL2SlotNumber() {
|
|
228
328
|
throw new Error('Method not implemented.');
|
|
229
329
|
}
|
|
230
330
|
isEpochComplete(_epochNumber) {
|
|
@@ -233,9 +333,12 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
233
333
|
getL1Constants() {
|
|
234
334
|
return Promise.resolve(EmptyL1RollupConstants);
|
|
235
335
|
}
|
|
336
|
+
isPruneDueAtSlot(_slot) {
|
|
337
|
+
return Promise.resolve(false);
|
|
338
|
+
}
|
|
236
339
|
getGenesisValues() {
|
|
237
340
|
return Promise.resolve({
|
|
238
|
-
genesisArchiveRoot: new Fr(GENESIS_ARCHIVE_ROOT)
|
|
341
|
+
genesisArchiveRoot: this.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT)
|
|
239
342
|
});
|
|
240
343
|
}
|
|
241
344
|
getL1Timestamp() {
|
|
@@ -276,6 +379,88 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
276
379
|
syncImmediate() {
|
|
277
380
|
return Promise.resolve();
|
|
278
381
|
}
|
|
382
|
+
async getBlock(query) {
|
|
383
|
+
if ('number' in query) {
|
|
384
|
+
if (query.number === 0) {
|
|
385
|
+
return this.getGenesisBlock();
|
|
386
|
+
}
|
|
387
|
+
return this.l2Blocks[query.number - 1];
|
|
388
|
+
}
|
|
389
|
+
if ('hash' in query) {
|
|
390
|
+
const genesis = this.getGenesisBlock();
|
|
391
|
+
if ((await genesis.hash()).equals(query.hash)) {
|
|
392
|
+
return genesis;
|
|
393
|
+
}
|
|
394
|
+
for (const b of this.l2Blocks){
|
|
395
|
+
const hash = await b.hash();
|
|
396
|
+
if (hash.equals(query.hash)) {
|
|
397
|
+
return b;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return undefined;
|
|
401
|
+
}
|
|
402
|
+
if ('archive' in query) {
|
|
403
|
+
const genesis = this.getGenesisBlock();
|
|
404
|
+
if (genesis.archive.root.equals(query.archive)) {
|
|
405
|
+
return genesis;
|
|
406
|
+
}
|
|
407
|
+
return this.l2Blocks.find((b)=>b.archive.root.equals(query.archive));
|
|
408
|
+
}
|
|
409
|
+
const number = this.resolveBlockTag(query.tag);
|
|
410
|
+
if (number === 0) {
|
|
411
|
+
return this.getGenesisBlock();
|
|
412
|
+
}
|
|
413
|
+
return this.l2Blocks[number - 1];
|
|
414
|
+
}
|
|
415
|
+
resolveBlockTag(tag) {
|
|
416
|
+
switch(tag){
|
|
417
|
+
case 'latest':
|
|
418
|
+
case 'proposed':
|
|
419
|
+
return this.l2Blocks.length;
|
|
420
|
+
case 'checkpointed':
|
|
421
|
+
return this.checkpointedBlockNumber;
|
|
422
|
+
case 'proven':
|
|
423
|
+
return this.provenBlockNumber;
|
|
424
|
+
case 'finalized':
|
|
425
|
+
return this.finalizedBlockNumber;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
getBlocks(query) {
|
|
429
|
+
let blocks;
|
|
430
|
+
if ('from' in query) {
|
|
431
|
+
blocks = this.l2Blocks.slice(query.from - 1, query.from - 1 + query.limit);
|
|
432
|
+
} else {
|
|
433
|
+
const epochCheckpoints = this.getCheckpointsInEpoch(query.epoch);
|
|
434
|
+
blocks = epochCheckpoints.flatMap((c)=>c.blocks);
|
|
435
|
+
}
|
|
436
|
+
if (query.onlyCheckpointed) {
|
|
437
|
+
blocks = blocks.filter((b)=>b.header.globalVariables.blockNumber <= this.checkpointedBlockNumber);
|
|
438
|
+
}
|
|
439
|
+
return Promise.resolve(blocks);
|
|
440
|
+
}
|
|
441
|
+
async getBlockData(query) {
|
|
442
|
+
const block = await this.getBlock(query);
|
|
443
|
+
if (!block) {
|
|
444
|
+
return undefined;
|
|
445
|
+
}
|
|
446
|
+
return {
|
|
447
|
+
header: block.header,
|
|
448
|
+
archive: block.archive,
|
|
449
|
+
blockHash: await block.hash(),
|
|
450
|
+
checkpointNumber: block.checkpointNumber,
|
|
451
|
+
indexWithinCheckpoint: block.indexWithinCheckpoint
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
async getBlocksData(query) {
|
|
455
|
+
const blocks = await this.getBlocks(query);
|
|
456
|
+
return Promise.all(blocks.map(async (block)=>({
|
|
457
|
+
header: block.header,
|
|
458
|
+
archive: block.archive,
|
|
459
|
+
blockHash: await block.hash(),
|
|
460
|
+
checkpointNumber: block.checkpointNumber,
|
|
461
|
+
indexWithinCheckpoint: block.indexWithinCheckpoint
|
|
462
|
+
})));
|
|
463
|
+
}
|
|
279
464
|
isPendingChainInvalid() {
|
|
280
465
|
return Promise.resolve(false);
|
|
281
466
|
}
|
|
@@ -284,4 +469,21 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
284
469
|
valid: true
|
|
285
470
|
});
|
|
286
471
|
}
|
|
472
|
+
getProposedCheckpointData(_query) {
|
|
473
|
+
return Promise.resolve(undefined);
|
|
474
|
+
}
|
|
475
|
+
/** Returns checkpoints whose slot falls within the given epoch. */ getCheckpointsInEpoch(epochNumber) {
|
|
476
|
+
const epochDuration = DefaultL1ContractsConfig.aztecEpochDuration;
|
|
477
|
+
const [start, end] = getSlotRangeForEpoch(epochNumber, {
|
|
478
|
+
epochDuration
|
|
479
|
+
});
|
|
480
|
+
return this.checkpointList.filter((c)=>c.header.slotNumber >= start && c.header.slotNumber <= end);
|
|
481
|
+
}
|
|
482
|
+
/** Creates a mock L1PublishedData for a checkpoint. */ mockL1DataForCheckpoint(checkpoint) {
|
|
483
|
+
return new L1PublishedData(BigInt(checkpoint.number), BigInt(checkpoint.number), Buffer32.random().toString());
|
|
484
|
+
}
|
|
485
|
+
/** Finds the checkpoint number for a block, or undefined if the block is not in any checkpoint. */ findCheckpointNumberForBlock(blockNumber) {
|
|
486
|
+
const checkpoint = this.checkpointList.find((c)=>c.blocks.some((b)=>b.number === blockNumber));
|
|
487
|
+
return checkpoint?.number;
|
|
488
|
+
}
|
|
287
489
|
}
|