@aztec/archiver 0.0.1-commit.b655e406 → 0.0.1-commit.b8a057fa
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 +120 -22
- 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/l1/data_retrieval.js +307 -0
- 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/modules/validation.js +122 -0
- 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/structs/data_retrieval.d.ts +27 -0
- 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 -5
- 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 +16 -8
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +19 -14
- package/dest/test/mock_l1_to_l2_message_source.d.ts +7 -6
- package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.js +21 -11
- package/dest/test/mock_l2_block_source.d.ts +73 -40
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +348 -133
- 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 -11
- 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 +20 -20
- package/src/archiver.ts +785 -0
- package/src/config.ts +125 -0
- package/src/errors.ts +203 -0
- package/src/factory.ts +186 -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/l1/data_retrieval.ts +491 -0
- 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 +7 -7
- package/src/structs/published.ts +1 -0
- 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 +23 -16
- package/src/test/mock_l1_to_l2_message_source.ts +18 -11
- package/src/test/mock_l2_block_source.ts +419 -147
- package/src/test/mock_structs.ts +292 -13
- package/src/test/noop_l1_archiver.ts +158 -0
- package/dest/archiver/archiver.d.ts +0 -277
- package/dest/archiver/archiver.d.ts.map +0 -1
- package/dest/archiver/archiver.js +0 -1322
- package/dest/archiver/archiver_store.d.ts +0 -255
- 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 -1288
- package/dest/archiver/config.d.ts +0 -21
- package/dest/archiver/config.d.ts.map +0 -1
- package/dest/archiver/config.js +0 -50
- package/dest/archiver/data_retrieval.d.ts +0 -79
- package/dest/archiver/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/data_retrieval.js +0 -362
- 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 -124
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/block_store.js +0 -370
- 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 -168
- 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 -336
- 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 +0 -27
- 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 -2
- package/dest/archiver/structs/published.d.ts.map +0 -1
- package/dest/archiver/validation.d.ts +0 -11
- package/dest/archiver/validation.d.ts.map +0 -1
- package/dest/archiver/validation.js +0 -90
- 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 -1722
- package/src/archiver/archiver_store.ts +0 -305
- package/src/archiver/archiver_store_test_suite.ts +0 -1263
- package/src/archiver/config.ts +0 -74
- package/src/archiver/data_retrieval.ts +0 -545
- 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 -481
- package/src/archiver/kv_archiver_store/contract_class_store.ts +0 -176
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +0 -422
- package/src/archiver/kv_archiver_store/log_store.ts +0 -406
- package/src/archiver/structs/published.ts +0 -1
- package/src/archiver/validation.ts +0 -99
- 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,33 +1,104 @@
|
|
|
1
1
|
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
2
|
-
import { DefaultL1ContractsConfig } from '@aztec/ethereum';
|
|
2
|
+
import { DefaultL1ContractsConfig } from '@aztec/ethereum/config';
|
|
3
|
+
import { BlockNumber, CheckpointNumber, IndexWithinCheckpoint, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
4
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
5
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
6
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
6
7
|
import { createLogger } from '@aztec/foundation/log';
|
|
7
|
-
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';
|
|
8
10
|
import { EmptyL1RollupConstants, getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
9
|
-
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';
|
|
10
15
|
/**
|
|
11
16
|
* A mocked implementation of L2BlockSource to be used in tests.
|
|
12
17
|
*/ export class MockL2BlockSource {
|
|
13
18
|
l2Blocks = [];
|
|
19
|
+
checkpointList = [];
|
|
14
20
|
provenBlockNumber = 0;
|
|
15
21
|
finalizedBlockNumber = 0;
|
|
22
|
+
checkpointedBlockNumber = 0;
|
|
23
|
+
initialHeader = BlockHeader.empty();
|
|
24
|
+
initialHeaderHash = GENESIS_BLOCK_HEADER_HASH;
|
|
25
|
+
genesisArchiveRoot;
|
|
26
|
+
genesisBlock;
|
|
16
27
|
log = createLogger('archiver:mock_l2_block_source');
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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;
|
|
22
60
|
}
|
|
23
|
-
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`);
|
|
24
85
|
}
|
|
25
|
-
|
|
86
|
+
addProposedBlocks(blocks) {
|
|
26
87
|
this.l2Blocks.push(...blocks);
|
|
27
|
-
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`);
|
|
28
89
|
}
|
|
29
90
|
removeBlocks(numBlocks) {
|
|
30
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);
|
|
31
102
|
this.log.verbose(`Removed ${numBlocks} blocks from the mock L2 block source`);
|
|
32
103
|
}
|
|
33
104
|
setProvenBlockNumber(provenBlockNumber) {
|
|
@@ -39,6 +110,34 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
39
110
|
}
|
|
40
111
|
this.finalizedBlockNumber = finalizedBlockNumber;
|
|
41
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
|
+
}
|
|
42
141
|
/**
|
|
43
142
|
* Method to fetch the rollup contract address at the base-layer.
|
|
44
143
|
* @returns The rollup address.
|
|
@@ -51,104 +150,94 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
51
150
|
*/ getRegistryAddress() {
|
|
52
151
|
return Promise.resolve(EthAddress.random());
|
|
53
152
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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;
|
|
59
165
|
}
|
|
60
|
-
|
|
61
|
-
|
|
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), []));
|
|
62
172
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
* @returns The requested L2 block.
|
|
67
|
-
*/ getBlock(number) {
|
|
68
|
-
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), [])));
|
|
69
176
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
* @param limit - The maximum number of blocks to return.
|
|
74
|
-
* @returns The requested mocked L2 blocks.
|
|
75
|
-
*/ getBlocks(from, limit, proven) {
|
|
76
|
-
return Promise.resolve(this.l2Blocks.slice(from - 1, from - 1 + limit).filter((b)=>!proven || this.provenBlockNumber === undefined || b.number <= this.provenBlockNumber));
|
|
77
|
-
}
|
|
78
|
-
async getPublishedBlocks(from, limit, proven) {
|
|
79
|
-
const blocks = await this.getBlocks(from, limit, proven);
|
|
80
|
-
return blocks.map((block)=>PublishedL2Block.fromFields({
|
|
81
|
-
block,
|
|
82
|
-
l1: {
|
|
83
|
-
blockNumber: BigInt(block.number),
|
|
84
|
-
blockHash: Buffer32.random().toString(),
|
|
85
|
-
timestamp: BigInt(block.number)
|
|
86
|
-
},
|
|
87
|
-
attestations: []
|
|
88
|
-
}));
|
|
89
|
-
}
|
|
90
|
-
async getPublishedBlockByHash(blockHash) {
|
|
91
|
-
for (const block of this.l2Blocks){
|
|
92
|
-
const hash = await block.hash();
|
|
93
|
-
if (hash.equals(blockHash)) {
|
|
94
|
-
return PublishedL2Block.fromFields({
|
|
95
|
-
block,
|
|
96
|
-
l1: {
|
|
97
|
-
blockNumber: BigInt(block.number),
|
|
98
|
-
blockHash: Buffer32.random().toString(),
|
|
99
|
-
timestamp: BigInt(block.number)
|
|
100
|
-
},
|
|
101
|
-
attestations: []
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return undefined;
|
|
177
|
+
getCheckpointByArchive(archive) {
|
|
178
|
+
const checkpoint = this.checkpointList.find((c)=>c.archive.root.equals(archive));
|
|
179
|
+
return Promise.resolve(checkpoint);
|
|
106
180
|
}
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
if (!
|
|
181
|
+
getCheckpointData(query) {
|
|
182
|
+
const checkpoint = this.resolveCheckpointQuery(query);
|
|
183
|
+
if (!checkpoint) {
|
|
110
184
|
return Promise.resolve(undefined);
|
|
111
185
|
}
|
|
112
|
-
return Promise.resolve(
|
|
113
|
-
block,
|
|
114
|
-
l1: {
|
|
115
|
-
blockNumber: BigInt(block.number),
|
|
116
|
-
blockHash: Buffer32.random().toString(),
|
|
117
|
-
timestamp: BigInt(block.number)
|
|
118
|
-
},
|
|
119
|
-
attestations: []
|
|
120
|
-
}));
|
|
121
|
-
}
|
|
122
|
-
async getBlockHeaderByHash(blockHash) {
|
|
123
|
-
for (const block of this.l2Blocks){
|
|
124
|
-
const hash = await block.hash();
|
|
125
|
-
if (hash.equals(blockHash)) {
|
|
126
|
-
return block.getBlockHeader();
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return undefined;
|
|
186
|
+
return Promise.resolve(this.checkpointToData(checkpoint));
|
|
130
187
|
}
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
return Promise.resolve(
|
|
188
|
+
getCheckpointsData(query) {
|
|
189
|
+
const checkpoints = this.resolveCheckpointsQuery(query);
|
|
190
|
+
return Promise.resolve(checkpoints.map((c)=>this.checkpointToData(c)));
|
|
134
191
|
}
|
|
135
|
-
|
|
136
|
-
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
|
+
};
|
|
137
204
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
+
}
|
|
148
226
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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);
|
|
237
|
+
}
|
|
238
|
+
getBlocksForSlot(slotNumber) {
|
|
239
|
+
const blocks = this.l2Blocks.filter((b)=>b.header.globalVariables.slotNumber === slotNumber);
|
|
240
|
+
return Promise.resolve(blocks);
|
|
152
241
|
}
|
|
153
242
|
/**
|
|
154
243
|
* Gets a tx effect.
|
|
@@ -166,52 +255,76 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
166
255
|
return {
|
|
167
256
|
data: txEffect,
|
|
168
257
|
l2BlockNumber: block.number,
|
|
169
|
-
l2BlockHash:
|
|
170
|
-
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
|
|
171
261
|
};
|
|
172
262
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
* @returns The requested tx receipt (or undefined if not found).
|
|
177
|
-
*/ async getSettledTxReceipt(txHash) {
|
|
178
|
-
for (const block of this.l2Blocks){
|
|
179
|
-
for (const txEffect of block.body.txEffects){
|
|
180
|
-
if (txEffect.txHash.equals(txHash)) {
|
|
181
|
-
return new TxReceipt(txHash, TxStatus.SUCCESS, '', txEffect.transactionFee.toBigInt(), L2BlockHash.fromField(await block.hash()), block.number);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
return undefined;
|
|
263
|
+
getL2ToL1MembershipWitness() {
|
|
264
|
+
// Mock does not back the L2-to-L1 message witness flow.
|
|
265
|
+
return Promise.resolve(undefined);
|
|
186
266
|
}
|
|
187
267
|
async getL2Tips() {
|
|
188
|
-
const [latest, proven, finalized] = [
|
|
268
|
+
const [latest, proven, finalized, checkpointed] = [
|
|
189
269
|
await this.getBlockNumber(),
|
|
190
|
-
|
|
191
|
-
this.finalizedBlockNumber
|
|
270
|
+
this.provenBlockNumber,
|
|
271
|
+
this.finalizedBlockNumber,
|
|
272
|
+
this.checkpointedBlockNumber
|
|
192
273
|
];
|
|
193
274
|
const latestBlock = this.l2Blocks[latest - 1];
|
|
194
275
|
const provenBlock = this.l2Blocks[proven - 1];
|
|
195
276
|
const finalizedBlock = this.l2Blocks[finalized - 1];
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
hash: (await provenBlock?.hash())?.toString()
|
|
204
|
-
},
|
|
205
|
-
finalized: {
|
|
206
|
-
number: finalized,
|
|
207
|
-
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();
|
|
208
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)
|
|
209
322
|
};
|
|
210
323
|
}
|
|
211
|
-
|
|
324
|
+
getSyncedL2EpochNumber() {
|
|
212
325
|
throw new Error('Method not implemented.');
|
|
213
326
|
}
|
|
214
|
-
|
|
327
|
+
getSyncedL2SlotNumber() {
|
|
215
328
|
throw new Error('Method not implemented.');
|
|
216
329
|
}
|
|
217
330
|
isEpochComplete(_epochNumber) {
|
|
@@ -220,9 +333,12 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
220
333
|
getL1Constants() {
|
|
221
334
|
return Promise.resolve(EmptyL1RollupConstants);
|
|
222
335
|
}
|
|
336
|
+
isPruneDueAtSlot(_slot) {
|
|
337
|
+
return Promise.resolve(false);
|
|
338
|
+
}
|
|
223
339
|
getGenesisValues() {
|
|
224
340
|
return Promise.resolve({
|
|
225
|
-
genesisArchiveRoot: new Fr(GENESIS_ARCHIVE_ROOT)
|
|
341
|
+
genesisArchiveRoot: this.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT)
|
|
226
342
|
});
|
|
227
343
|
}
|
|
228
344
|
getL1Timestamp() {
|
|
@@ -263,6 +379,88 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
263
379
|
syncImmediate() {
|
|
264
380
|
return Promise.resolve();
|
|
265
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
|
+
}
|
|
266
464
|
isPendingChainInvalid() {
|
|
267
465
|
return Promise.resolve(false);
|
|
268
466
|
}
|
|
@@ -271,4 +469,21 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
271
469
|
valid: true
|
|
272
470
|
});
|
|
273
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
|
+
}
|
|
274
489
|
}
|
|
@@ -1,9 +1,88 @@
|
|
|
1
|
+
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { Buffer16 } from '@aztec/foundation/buffer';
|
|
2
|
-
import {
|
|
3
|
+
import type { Secp256k1Signer } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
4
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
+
import { L2Block } from '@aztec/stdlib/block';
|
|
7
|
+
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
8
|
+
import { PrivateLog, PublicLog, SiloedTag, Tag } from '@aztec/stdlib/logs';
|
|
9
|
+
import { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
|
|
10
|
+
import { StateReference } from '@aztec/stdlib/tx';
|
|
11
|
+
import { type InboxMessage } from '../structs/inbox_message.js';
|
|
3
12
|
export declare function makeInboxMessage(previousRollingHash?: Buffer16, overrides?: Partial<InboxMessage>): InboxMessage;
|
|
4
|
-
export declare function makeInboxMessages(
|
|
13
|
+
export declare function makeInboxMessages(totalCount: number, opts?: {
|
|
5
14
|
initialHash?: Buffer16;
|
|
6
|
-
|
|
15
|
+
initialCheckpointNumber?: CheckpointNumber;
|
|
16
|
+
messagesPerCheckpoint?: number;
|
|
7
17
|
overrideFn?: (msg: InboxMessage, index: number) => InboxMessage;
|
|
8
18
|
}): InboxMessage[];
|
|
9
|
-
|
|
19
|
+
/** Creates inbox messages distributed across multiple blocks with proper checkpoint numbering. */
|
|
20
|
+
export declare function makeInboxMessagesWithFullBlocks(blockCount: number, opts?: {
|
|
21
|
+
initialCheckpointNumber?: CheckpointNumber;
|
|
22
|
+
}): InboxMessage[];
|
|
23
|
+
/** Creates a deterministic block hash from a block number. */
|
|
24
|
+
export declare function makeBlockHash(blockNumber: number): `0x${string}`;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a StateReference with properly calculated noteHashTree.nextAvailableLeafIndex.
|
|
27
|
+
* This ensures LogStore's dataStartIndexForBlock calculation doesn't produce negative values.
|
|
28
|
+
*/
|
|
29
|
+
export declare function makeStateForBlock(blockNumber: number, txsPerBlock: number): StateReference;
|
|
30
|
+
/** Creates L1PublishedData with deterministic values based on l1BlockNumber. */
|
|
31
|
+
export declare function makeL1PublishedData(l1BlockNumber: number): L1PublishedData;
|
|
32
|
+
/** Creates a Checkpoint from a list of blocks with a header that matches the blocks' structure. */
|
|
33
|
+
export declare function makeCheckpoint(blocks: L2Block[], checkpointNumber?: CheckpointNumber): Checkpoint;
|
|
34
|
+
/** Wraps a Checkpoint with L1 published data and random attestations. */
|
|
35
|
+
export declare function makePublishedCheckpoint(checkpoint: Checkpoint, l1BlockNumber: number, attestationCount?: number): PublishedCheckpoint;
|
|
36
|
+
export interface MakeChainedCheckpointsOptions {
|
|
37
|
+
/** Number of L2 blocks per checkpoint. Default: 1 */
|
|
38
|
+
blocksPerCheckpoint?: number;
|
|
39
|
+
/** Number of transactions per block. Default: 4 */
|
|
40
|
+
txsPerBlock?: number;
|
|
41
|
+
/** Starting checkpoint number. Default: CheckpointNumber(1) */
|
|
42
|
+
startCheckpointNumber?: CheckpointNumber;
|
|
43
|
+
/** Starting block number. Default: 1 */
|
|
44
|
+
startBlockNumber?: number;
|
|
45
|
+
/** Starting L1 block number. Default: 10 */
|
|
46
|
+
startL1BlockNumber?: number;
|
|
47
|
+
/** Previous archive to chain from. Default: undefined */
|
|
48
|
+
previousArchive?: AppendOnlyTreeSnapshot;
|
|
49
|
+
/** Optional function to provide per-checkpoint overrides */
|
|
50
|
+
makeCheckpointOptions?: (cpNumber: CheckpointNumber) => Partial<Parameters<typeof Checkpoint.random>[1]>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Creates multiple checkpoints with properly chained archives.
|
|
54
|
+
* Each checkpoint's blocks have their lastArchive set to the previous block's archive,
|
|
55
|
+
* ensuring archive chain continuity for testing.
|
|
56
|
+
*/
|
|
57
|
+
export declare function makeChainedCheckpoints(count: number, options?: MakeChainedCheckpointsOptions): Promise<PublishedCheckpoint[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Creates a PublishedCheckpoint with attestations signed by the provided signers.
|
|
60
|
+
* Useful for testing attestation validation.
|
|
61
|
+
*/
|
|
62
|
+
export declare function makeSignedPublishedCheckpoint(checkpoint: Checkpoint, signers: Secp256k1Signer[], committee: EthAddress[], l1BlockNumber?: number): PublishedCheckpoint;
|
|
63
|
+
/** Creates a deterministic SiloedTag for private log testing. */
|
|
64
|
+
export declare function makePrivateLogTag(blockNumber: number, txIndex: number, logIndex: number): SiloedTag;
|
|
65
|
+
/** Creates a PrivateLog with fields derived from the tag. */
|
|
66
|
+
export declare function makePrivateLog(tag: SiloedTag): PrivateLog;
|
|
67
|
+
/** Creates multiple private logs for a transaction. */
|
|
68
|
+
export declare function mockPrivateLogs(blockNumber: number, txIndex: number, numLogsPerTx: number): PrivateLog[];
|
|
69
|
+
/** Creates a deterministic Tag for public log testing. */
|
|
70
|
+
export declare function makePublicLogTag(blockNumber: number, txIndex: number, logIndex: number): Tag;
|
|
71
|
+
/** Creates a PublicLog with fields derived from the tag. */
|
|
72
|
+
export declare function makePublicLog(tag: Tag, contractAddress?: AztecAddress): PublicLog;
|
|
73
|
+
/** Creates multiple public logs for a transaction. */
|
|
74
|
+
export declare function makePublicLogs(blockNumber: number, txIndex: number, numLogsPerTx: number, contractAddress?: AztecAddress): PublicLog[];
|
|
75
|
+
export interface MockCheckpointWithLogsOptions {
|
|
76
|
+
previousArchive?: AppendOnlyTreeSnapshot;
|
|
77
|
+
numTxsPerBlock?: number;
|
|
78
|
+
privateLogs?: {
|
|
79
|
+
numLogsPerTx: number;
|
|
80
|
+
};
|
|
81
|
+
publicLogs?: {
|
|
82
|
+
numLogsPerTx: number;
|
|
83
|
+
contractAddress?: AztecAddress;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/** Creates a checkpoint with specified logs on each tx effect. */
|
|
87
|
+
export declare function makeCheckpointWithLogs(blockNumber: number, options?: MockCheckpointWithLogsOptions): Promise<PublishedCheckpoint>;
|
|
88
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9ja19zdHJ1Y3RzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdGVzdC9tb2NrX3N0cnVjdHMudHMiXSwibmFtZXMi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