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