@aztec/archiver 0.0.1-commit.96bb3f7 → 0.0.1-commit.993d240
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/{archiver/config.js → config.js} +31 -14
- 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 +13 -9
- 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/{archiver → modules}/instrumentation.js +61 -19
- 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 +12 -6
- 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 +1 -1
- package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.js +2 -1
- package/dest/test/mock_l2_block_source.d.ts +65 -41
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +330 -151
- 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} +43 -12
- 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 +24 -6
- 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/{archiver → modules}/instrumentation.ts +72 -20
- package/src/modules/l1_synchronizer.ts +1257 -0
- package/src/{archiver → modules}/validation.ts +15 -9
- 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 +1 -0
- package/src/test/mock_l2_block_source.ts +403 -171
- package/src/test/mock_structs.ts +283 -8
- package/src/test/noop_l1_archiver.ts +139 -0
- package/dest/archiver/archiver.d.ts +0 -307
- package/dest/archiver/archiver.d.ts.map +0 -1
- package/dest/archiver/archiver.js +0 -2102
- package/dest/archiver/archiver_store.d.ts +0 -315
- 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 -2770
- package/dest/archiver/config.d.ts +0 -22
- package/dest/archiver/config.d.ts.map +0 -1
- 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/kv_archiver_store/block_store.d.ts +0 -164
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/block_store.js +0 -626
- 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 -159
- 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 -316
- 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 -401
- 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 -2265
- package/src/archiver/archiver_store.ts +0 -380
- package/src/archiver/archiver_store_test_suite.ts +0 -2842
- package/src/archiver/errors.ts +0 -90
- package/src/archiver/index.ts +0 -6
- package/src/archiver/kv_archiver_store/block_store.ts +0 -850
- package/src/archiver/kv_archiver_store/contract_class_store.ts +0 -176
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +0 -442
- package/src/archiver/kv_archiver_store/log_store.ts +0 -516
- 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,36 +1,106 @@
|
|
|
1
1
|
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
2
2
|
import { DefaultL1ContractsConfig } from '@aztec/ethereum/config';
|
|
3
|
-
import { BlockNumber, CheckpointNumber } 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;
|
|
18
22
|
checkpointedBlockNumber = 0;
|
|
23
|
+
proposedCheckpointBlockNumber = 0;
|
|
24
|
+
initialHeader = BlockHeader.empty();
|
|
25
|
+
initialHeaderHash = GENESIS_BLOCK_HEADER_HASH;
|
|
26
|
+
genesisArchiveRoot;
|
|
27
|
+
genesisBlock;
|
|
19
28
|
log = createLogger('archiver:mock_l2_block_source');
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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;
|
|
25
61
|
}
|
|
26
|
-
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`);
|
|
27
86
|
}
|
|
28
|
-
|
|
87
|
+
addProposedBlocks(blocks) {
|
|
29
88
|
this.l2Blocks.push(...blocks);
|
|
30
|
-
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`);
|
|
31
90
|
}
|
|
32
91
|
removeBlocks(numBlocks) {
|
|
33
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);
|
|
34
104
|
this.log.verbose(`Removed ${numBlocks} blocks from the mock L2 block source`);
|
|
35
105
|
}
|
|
36
106
|
setProvenBlockNumber(provenBlockNumber) {
|
|
@@ -42,8 +112,40 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
42
112
|
}
|
|
43
113
|
this.finalizedBlockNumber = finalizedBlockNumber;
|
|
44
114
|
}
|
|
115
|
+
setProposedCheckpointBlockNumber(blockNumber) {
|
|
116
|
+
this.proposedCheckpointBlockNumber = blockNumber;
|
|
117
|
+
}
|
|
45
118
|
setCheckpointedBlockNumber(checkpointedBlockNumber) {
|
|
119
|
+
const prevCheckpointed = this.checkpointedBlockNumber;
|
|
46
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
|
+
}
|
|
47
149
|
}
|
|
48
150
|
/**
|
|
49
151
|
* Method to fetch the rollup contract address at the base-layer.
|
|
@@ -57,142 +159,93 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
57
159
|
*/ getRegistryAddress() {
|
|
58
160
|
return Promise.resolve(EthAddress.random());
|
|
59
161
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
*/ getBlockNumber() {
|
|
64
|
-
return Promise.resolve(BlockNumber(this.l2Blocks.length));
|
|
65
|
-
}
|
|
66
|
-
getProvenBlockNumber() {
|
|
67
|
-
return Promise.resolve(BlockNumber(this.provenBlockNumber));
|
|
68
|
-
}
|
|
69
|
-
getCheckpointedBlock(number) {
|
|
70
|
-
if (number > this.checkpointedBlockNumber) {
|
|
71
|
-
return Promise.resolve(undefined);
|
|
162
|
+
async getBlockNumber(query) {
|
|
163
|
+
if (!query) {
|
|
164
|
+
return BlockNumber(this.l2Blocks.length);
|
|
72
165
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return Promise.resolve(undefined);
|
|
166
|
+
if ('number' in query) {
|
|
167
|
+
return query.number;
|
|
76
168
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
async getCheckpointedBlocks(from, limit, _proven) {
|
|
81
|
-
const result = [];
|
|
82
|
-
for(let i = 0; i < limit; i++){
|
|
83
|
-
const blockNum = from + i;
|
|
84
|
-
if (blockNum > this.checkpointedBlockNumber) {
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
const block = await this.getCheckpointedBlock(BlockNumber(blockNum));
|
|
88
|
-
if (block) {
|
|
89
|
-
result.push(block);
|
|
90
|
-
}
|
|
169
|
+
if ('tag' in query) {
|
|
170
|
+
return BlockNumber(this.resolveBlockTag(query.tag));
|
|
91
171
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Gets an l2 block.
|
|
96
|
-
* @param number - The block number to return (inclusive).
|
|
97
|
-
* @returns The requested L2 block.
|
|
98
|
-
*/ getBlock(number) {
|
|
99
|
-
return Promise.resolve(this.l2Blocks[number - 1]);
|
|
172
|
+
const block = await this.getBlock(query);
|
|
173
|
+
return block ? block.header.globalVariables.blockNumber : undefined;
|
|
100
174
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
* @param number - The block number to return.
|
|
104
|
-
* @returns The requested L2 block.
|
|
105
|
-
*/ getL2BlockNew(number) {
|
|
106
|
-
const block = this.l2Blocks[number - 1];
|
|
107
|
-
return Promise.resolve(block?.toL2Block());
|
|
175
|
+
getProposedCheckpointL2BlockNumber() {
|
|
176
|
+
return Promise.resolve(BlockNumber(this.proposedCheckpointBlockNumber));
|
|
108
177
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
* @returns The requested mocked L2 blocks.
|
|
114
|
-
*/ getBlocks(from, limit, proven) {
|
|
115
|
-
return Promise.resolve(this.l2Blocks.slice(from - 1, from - 1 + limit).filter((b)=>!proven || this.provenBlockNumber === undefined || b.number <= this.provenBlockNumber));
|
|
116
|
-
}
|
|
117
|
-
async getPublishedCheckpoints(from, limit) {
|
|
118
|
-
// TODO: Implement this properly. This only works when we have one block per checkpoint.
|
|
119
|
-
return (await this.getPublishedBlocks(from, limit)).map((block)=>block.toPublishedCheckpoint());
|
|
120
|
-
}
|
|
121
|
-
async getCheckpointByArchive(archive) {
|
|
122
|
-
// TODO: Implement this properly. This only works when we have one block per checkpoint.
|
|
123
|
-
return (await this.getPublishedBlockByArchive(archive))?.block.toCheckpoint();
|
|
124
|
-
}
|
|
125
|
-
async getPublishedBlocks(from, limit, proven) {
|
|
126
|
-
const blocks = await this.getBlocks(from, limit, proven);
|
|
127
|
-
return blocks.map((block)=>PublishedL2Block.fromFields({
|
|
128
|
-
block,
|
|
129
|
-
l1: new L1PublishedData(BigInt(block.number), BigInt(block.number), Buffer32.random().toString()),
|
|
130
|
-
attestations: []
|
|
131
|
-
}));
|
|
132
|
-
}
|
|
133
|
-
async getL2BlocksNew(from, limit, proven) {
|
|
134
|
-
const blocks = await this.getBlocks(from, limit, proven);
|
|
135
|
-
return blocks.map((x)=>x.toL2Block());
|
|
136
|
-
}
|
|
137
|
-
async getPublishedBlockByHash(blockHash) {
|
|
138
|
-
for (const block of this.l2Blocks){
|
|
139
|
-
const hash = await block.hash();
|
|
140
|
-
if (hash.equals(blockHash)) {
|
|
141
|
-
return PublishedL2Block.fromFields({
|
|
142
|
-
block,
|
|
143
|
-
l1: new L1PublishedData(BigInt(block.number), BigInt(block.number), Buffer32.random().toString()),
|
|
144
|
-
attestations: []
|
|
145
|
-
});
|
|
146
|
-
}
|
|
178
|
+
getCheckpoint(query) {
|
|
179
|
+
const checkpoint = this.resolveCheckpointQuery(query);
|
|
180
|
+
if (!checkpoint) {
|
|
181
|
+
return Promise.resolve(undefined);
|
|
147
182
|
}
|
|
148
|
-
return
|
|
183
|
+
return Promise.resolve(new PublishedCheckpoint(checkpoint, this.mockL1DataForCheckpoint(checkpoint), []));
|
|
149
184
|
}
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
|
|
185
|
+
getCheckpoints(query) {
|
|
186
|
+
const checkpoints = this.resolveCheckpointsQuery(query);
|
|
187
|
+
return Promise.resolve(checkpoints.map((checkpoint)=>new PublishedCheckpoint(checkpoint, this.mockL1DataForCheckpoint(checkpoint), [])));
|
|
188
|
+
}
|
|
189
|
+
getCheckpointByArchive(archive) {
|
|
190
|
+
const checkpoint = this.checkpointList.find((c)=>c.archive.root.equals(archive));
|
|
191
|
+
return Promise.resolve(checkpoint);
|
|
192
|
+
}
|
|
193
|
+
getCheckpointData(query) {
|
|
194
|
+
const checkpoint = this.resolveCheckpointQuery(query);
|
|
195
|
+
if (!checkpoint) {
|
|
153
196
|
return Promise.resolve(undefined);
|
|
154
197
|
}
|
|
155
|
-
return Promise.resolve(
|
|
156
|
-
block,
|
|
157
|
-
l1: new L1PublishedData(BigInt(block.number), BigInt(block.number), Buffer32.random().toString()),
|
|
158
|
-
attestations: []
|
|
159
|
-
}));
|
|
198
|
+
return Promise.resolve(this.checkpointToData(checkpoint));
|
|
160
199
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
if (hash.equals(blockHash)) {
|
|
165
|
-
return block.getBlockHeader();
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return undefined;
|
|
200
|
+
getCheckpointsData(query) {
|
|
201
|
+
const checkpoints = this.resolveCheckpointsQuery(query);
|
|
202
|
+
return Promise.resolve(checkpoints.map((c)=>this.checkpointToData(c)));
|
|
169
203
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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
|
+
};
|
|
173
216
|
}
|
|
174
|
-
|
|
175
|
-
|
|
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
|
+
}
|
|
176
238
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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);
|
|
180
244
|
}
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
const [start, end] = getSlotRangeForEpoch(epochNumber, {
|
|
184
|
-
epochDuration
|
|
185
|
-
});
|
|
186
|
-
const blocks = this.l2Blocks.filter((b)=>{
|
|
187
|
-
const slot = b.header.globalVariables.slotNumber;
|
|
188
|
-
return slot >= start && slot <= end;
|
|
189
|
-
});
|
|
245
|
+
getBlocksForSlot(slotNumber) {
|
|
246
|
+
const blocks = this.l2Blocks.filter((b)=>b.header.globalVariables.slotNumber === slotNumber);
|
|
190
247
|
return Promise.resolve(blocks);
|
|
191
248
|
}
|
|
192
|
-
async getBlockHeadersForEpoch(epochNumber) {
|
|
193
|
-
const blocks = await this.getBlocksForEpoch(epochNumber);
|
|
194
|
-
return blocks.map((b)=>b.getBlockHeader());
|
|
195
|
-
}
|
|
196
249
|
/**
|
|
197
250
|
* Gets a tx effect.
|
|
198
251
|
* @param txHash - The hash of the tx corresponding to the tx effect.
|
|
@@ -209,8 +262,8 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
209
262
|
return {
|
|
210
263
|
data: txEffect,
|
|
211
264
|
l2BlockNumber: block.number,
|
|
212
|
-
l2BlockHash:
|
|
213
|
-
txIndexInBlock: block.body.txEffects.
|
|
265
|
+
l2BlockHash: await block.hash(),
|
|
266
|
+
txIndexInBlock: block.body.txEffects.findIndex((t)=>t.txHash.equals(txHash))
|
|
214
267
|
};
|
|
215
268
|
}
|
|
216
269
|
/**
|
|
@@ -221,57 +274,81 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
221
274
|
for (const block of this.l2Blocks){
|
|
222
275
|
for (const txEffect of block.body.txEffects){
|
|
223
276
|
if (txEffect.txHash.equals(txHash)) {
|
|
224
|
-
|
|
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));
|
|
225
279
|
}
|
|
226
280
|
}
|
|
227
281
|
}
|
|
228
282
|
return undefined;
|
|
229
283
|
}
|
|
230
284
|
async getL2Tips() {
|
|
231
|
-
const [latest, proven, finalized, checkpointed] = [
|
|
285
|
+
const [latest, proven, finalized, checkpointed, proposedCheckpoint] = [
|
|
232
286
|
await this.getBlockNumber(),
|
|
233
|
-
|
|
287
|
+
this.provenBlockNumber,
|
|
234
288
|
this.finalizedBlockNumber,
|
|
235
|
-
this.checkpointedBlockNumber
|
|
289
|
+
this.checkpointedBlockNumber,
|
|
290
|
+
await this.getProposedCheckpointL2BlockNumber()
|
|
236
291
|
];
|
|
237
292
|
const latestBlock = this.l2Blocks[latest - 1];
|
|
238
293
|
const provenBlock = this.l2Blocks[proven - 1];
|
|
239
294
|
const finalizedBlock = this.l2Blocks[finalized - 1];
|
|
240
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();
|
|
303
|
+
}
|
|
304
|
+
return number === 0 ? genesisHash : '';
|
|
305
|
+
};
|
|
241
306
|
const latestBlockId = {
|
|
242
307
|
number: BlockNumber(latest),
|
|
243
|
-
hash:
|
|
308
|
+
hash: await tipHash(latestBlock, latest)
|
|
244
309
|
};
|
|
245
310
|
const provenBlockId = {
|
|
246
311
|
number: BlockNumber(proven),
|
|
247
|
-
hash:
|
|
312
|
+
hash: await tipHash(provenBlock, proven)
|
|
248
313
|
};
|
|
249
314
|
const finalizedBlockId = {
|
|
250
315
|
number: BlockNumber(finalized),
|
|
251
|
-
hash:
|
|
316
|
+
hash: await tipHash(finalizedBlock, finalized)
|
|
252
317
|
};
|
|
253
318
|
const checkpointedBlockId = {
|
|
254
319
|
number: BlockNumber(checkpointed),
|
|
255
|
-
hash:
|
|
320
|
+
hash: await tipHash(checkpointedBlock, checkpointed)
|
|
321
|
+
};
|
|
322
|
+
const proposedCheckpointBlockId = {
|
|
323
|
+
number: BlockNumber(proposedCheckpoint),
|
|
324
|
+
hash: await tipHash(proposedCheckpointBlock, proposedCheckpoint)
|
|
256
325
|
};
|
|
257
|
-
const makeTipId = (blockId)=>
|
|
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 {
|
|
258
333
|
block: blockId,
|
|
259
334
|
checkpoint: {
|
|
260
|
-
number:
|
|
261
|
-
hash
|
|
335
|
+
number: checkpointNumber,
|
|
336
|
+
hash
|
|
262
337
|
}
|
|
263
|
-
}
|
|
338
|
+
};
|
|
339
|
+
};
|
|
264
340
|
return {
|
|
265
341
|
proposed: latestBlockId,
|
|
266
342
|
checkpointed: makeTipId(checkpointedBlockId),
|
|
267
343
|
proven: makeTipId(provenBlockId),
|
|
268
|
-
finalized: makeTipId(finalizedBlockId)
|
|
344
|
+
finalized: makeTipId(finalizedBlockId),
|
|
345
|
+
proposedCheckpoint: makeTipId(proposedCheckpointBlockId)
|
|
269
346
|
};
|
|
270
347
|
}
|
|
271
|
-
|
|
348
|
+
getSyncedL2EpochNumber() {
|
|
272
349
|
throw new Error('Method not implemented.');
|
|
273
350
|
}
|
|
274
|
-
|
|
351
|
+
getSyncedL2SlotNumber() {
|
|
275
352
|
throw new Error('Method not implemented.');
|
|
276
353
|
}
|
|
277
354
|
isEpochComplete(_epochNumber) {
|
|
@@ -280,9 +357,12 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
280
357
|
getL1Constants() {
|
|
281
358
|
return Promise.resolve(EmptyL1RollupConstants);
|
|
282
359
|
}
|
|
360
|
+
isPruneDueAtSlot(_slot) {
|
|
361
|
+
return Promise.resolve(false);
|
|
362
|
+
}
|
|
283
363
|
getGenesisValues() {
|
|
284
364
|
return Promise.resolve({
|
|
285
|
-
genesisArchiveRoot: new Fr(GENESIS_ARCHIVE_ROOT)
|
|
365
|
+
genesisArchiveRoot: this.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT)
|
|
286
366
|
});
|
|
287
367
|
}
|
|
288
368
|
getL1Timestamp() {
|
|
@@ -323,6 +403,88 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
323
403
|
syncImmediate() {
|
|
324
404
|
return Promise.resolve();
|
|
325
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
|
+
}
|
|
326
488
|
isPendingChainInvalid() {
|
|
327
489
|
return Promise.resolve(false);
|
|
328
490
|
}
|
|
@@ -331,4 +493,21 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
331
493
|
valid: true
|
|
332
494
|
});
|
|
333
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
|
+
}
|
|
334
513
|
}
|