@aztec/archiver 0.0.1-commit.fce3e4f → 0.0.1-commit.ff7989d6c
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 +156 -22
- package/dest/archiver.d.ts +139 -0
- package/dest/archiver.d.ts.map +1 -0
- package/dest/archiver.js +699 -0
- package/dest/config.d.ts +30 -0
- package/dest/config.d.ts.map +1 -0
- package/dest/{archiver/config.js → config.js} +21 -5
- package/dest/errors.d.ts +41 -0
- package/dest/errors.d.ts.map +1 -0
- package/dest/errors.js +62 -0
- package/dest/factory.d.ts +9 -7
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +97 -13
- package/dest/index.d.ts +11 -4
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +9 -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 +148 -0
- package/dest/l1/calldata_retriever.d.ts +118 -0
- package/dest/l1/calldata_retriever.d.ts.map +1 -0
- package/dest/l1/calldata_retriever.js +484 -0
- package/dest/l1/data_retrieval.d.ts +89 -0
- package/dest/l1/data_retrieval.d.ts.map +1 -0
- package/dest/{archiver → l1}/data_retrieval.js +80 -153
- 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 +157 -0
- package/dest/l1/trace_tx.d.ts +97 -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_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/data_source_base.d.ts +89 -0
- package/dest/modules/data_source_base.d.ts.map +1 -0
- package/dest/modules/data_source_base.js +216 -0
- package/dest/modules/data_store_updater.d.ts +80 -0
- package/dest/modules/data_store_updater.d.ts.map +1 -0
- package/dest/modules/data_store_updater.js +323 -0
- package/dest/modules/instrumentation.d.ts +39 -0
- package/dest/modules/instrumentation.d.ts.map +1 -0
- package/dest/{archiver → modules}/instrumentation.js +39 -62
- package/dest/modules/l1_synchronizer.d.ts +76 -0
- package/dest/modules/l1_synchronizer.d.ts.map +1 -0
- package/dest/modules/l1_synchronizer.js +1112 -0
- package/dest/modules/validation.d.ts +17 -0
- package/dest/modules/validation.d.ts.map +1 -0
- package/dest/{archiver → modules}/validation.js +7 -1
- package/dest/store/block_store.d.ts +196 -0
- package/dest/store/block_store.d.ts.map +1 -0
- package/dest/store/block_store.js +773 -0
- package/dest/store/contract_class_store.d.ts +18 -0
- package/dest/store/contract_class_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/contract_class_store.js +13 -9
- package/dest/store/contract_instance_store.d.ts +24 -0
- package/dest/store/contract_instance_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/contract_instance_store.js +1 -1
- package/dest/store/kv_archiver_store.d.ts +354 -0
- package/dest/store/kv_archiver_store.d.ts.map +1 -0
- package/dest/store/kv_archiver_store.js +464 -0
- package/dest/store/l2_tips_cache.d.ts +19 -0
- package/dest/store/l2_tips_cache.d.ts.map +1 -0
- package/dest/store/l2_tips_cache.js +89 -0
- package/dest/store/log_store.d.ts +54 -0
- package/dest/store/log_store.d.ts.map +1 -0
- package/dest/store/log_store.js +456 -0
- package/dest/store/message_store.d.ts +40 -0
- package/dest/store/message_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/message_store.js +15 -14
- package/dest/{archiver/structs → structs}/data_retrieval.d.ts +1 -1
- package/dest/structs/data_retrieval.d.ts.map +1 -0
- package/dest/structs/inbox_message.d.ts +15 -0
- package/dest/structs/inbox_message.d.ts.map +1 -0
- package/dest/{archiver/structs → structs}/inbox_message.js +6 -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 +193 -0
- package/dest/test/fake_l1_state.d.ts.map +1 -0
- package/dest/test/fake_l1_state.js +389 -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 +51 -18
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +245 -82
- package/dest/test/mock_structs.d.ts +80 -4
- package/dest/test/mock_structs.d.ts.map +1 -1
- package/dest/test/mock_structs.js +145 -11
- package/dest/test/noop_l1_archiver.d.ts +23 -0
- package/dest/test/noop_l1_archiver.d.ts.map +1 -0
- package/dest/test/noop_l1_archiver.js +68 -0
- package/package.json +20 -20
- package/src/archiver.ts +443 -0
- package/src/{archiver/config.ts → config.ts} +28 -12
- package/src/errors.ts +102 -0
- package/src/factory.ts +143 -13
- package/src/index.ts +11 -3
- package/src/interfaces.ts +9 -0
- package/src/l1/README.md +98 -0
- package/src/l1/bin/retrieve-calldata.ts +181 -0
- package/src/l1/calldata_retriever.ts +663 -0
- package/src/{archiver → l1}/data_retrieval.ts +146 -224
- package/src/l1/debug_tx.ts +99 -0
- package/src/l1/spire_proposer.ts +160 -0
- package/src/l1/trace_tx.ts +128 -0
- package/src/l1/types.ts +13 -0
- package/src/l1/validate_trace.ts +229 -0
- package/src/modules/data_source_base.ts +328 -0
- package/src/modules/data_store_updater.ts +448 -0
- package/src/{archiver → modules}/instrumentation.ts +43 -66
- package/src/modules/l1_synchronizer.ts +932 -0
- package/src/{archiver → modules}/validation.ts +11 -6
- package/src/store/block_store.ts +1015 -0
- package/src/{archiver/kv_archiver_store → store}/contract_class_store.ts +13 -9
- package/src/{archiver/kv_archiver_store → store}/contract_instance_store.ts +2 -2
- package/src/store/kv_archiver_store.ts +671 -0
- package/src/store/l2_tips_cache.ts +89 -0
- package/src/store/log_store.ts +637 -0
- package/src/{archiver/kv_archiver_store → store}/message_store.ts +21 -18
- package/src/{archiver/structs → structs}/inbox_message.ts +8 -8
- package/src/{archiver/structs → structs}/published.ts +0 -1
- package/src/test/fake_l1_state.ts +607 -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 +296 -90
- package/src/test/mock_structs.ts +275 -13
- package/src/test/noop_l1_archiver.ts +109 -0
- package/dest/archiver/archiver.d.ts +0 -287
- package/dest/archiver/archiver.d.ts.map +0 -1
- package/dest/archiver/archiver.js +0 -1408
- 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 -1289
- package/dest/archiver/config.d.ts +0 -21
- package/dest/archiver/config.d.ts.map +0 -1
- package/dest/archiver/data_retrieval.d.ts +0 -79
- package/dest/archiver/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/errors.d.ts +0 -12
- package/dest/archiver/errors.d.ts.map +0 -1
- package/dest/archiver/errors.js +0 -17
- package/dest/archiver/index.d.ts +0 -7
- package/dest/archiver/index.d.ts.map +0 -1
- package/dest/archiver/index.js +0 -4
- package/dest/archiver/instrumentation.d.ts +0 -35
- package/dest/archiver/instrumentation.d.ts.map +0 -1
- package/dest/archiver/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_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.map +0 -1
- package/dest/archiver/structs/inbox_message.d.ts +0 -15
- package/dest/archiver/structs/inbox_message.d.ts.map +0 -1
- package/dest/archiver/structs/published.d.ts +0 -3
- package/dest/archiver/structs/published.d.ts.map +0 -1
- package/dest/archiver/validation.d.ts +0 -17
- package/dest/archiver/validation.d.ts.map +0 -1
- package/dest/rpc/index.d.ts +0 -9
- package/dest/rpc/index.d.ts.map +0 -1
- package/dest/rpc/index.js +0 -15
- package/src/archiver/archiver.ts +0 -1858
- package/src/archiver/archiver_store.ts +0 -305
- package/src/archiver/archiver_store_test_suite.ts +0 -1264
- package/src/archiver/errors.ts +0 -26
- package/src/archiver/index.ts +0 -6
- package/src/archiver/kv_archiver_store/block_store.ts +0 -481
- 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/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,37 +1,171 @@
|
|
|
1
|
+
import { MAX_NOTE_HASHES_PER_TX, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, PRIVATE_LOG_SIZE_IN_FIELDS } from '@aztec/constants';
|
|
2
|
+
import { makeTuple } from '@aztec/foundation/array';
|
|
3
|
+
import { BlockNumber, CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
1
4
|
import { Buffer16, Buffer32 } from '@aztec/foundation/buffer';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
5
|
+
import { times, timesParallel } from '@aztec/foundation/collection';
|
|
6
|
+
import { randomBigInt, randomInt } from '@aztec/foundation/crypto/random';
|
|
7
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
8
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
|
+
import { CommitteeAttestation, L2Block } from '@aztec/stdlib/block';
|
|
10
|
+
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
11
|
+
import { PrivateLog, PublicLog, SiloedTag, Tag } from '@aztec/stdlib/logs';
|
|
4
12
|
import { InboxLeaf } from '@aztec/stdlib/messaging';
|
|
5
|
-
import {
|
|
13
|
+
import { orderAttestations } from '@aztec/stdlib/p2p';
|
|
14
|
+
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
15
|
+
import { makeCheckpointAttestationFromCheckpoint } from '@aztec/stdlib/testing';
|
|
16
|
+
import { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
|
|
17
|
+
import { PartialStateReference, StateReference, TxEffect } from '@aztec/stdlib/tx';
|
|
18
|
+
import { updateRollingHash } from '../structs/inbox_message.js';
|
|
6
19
|
export function makeInboxMessage(previousRollingHash = Buffer16.ZERO, overrides = {}) {
|
|
7
|
-
const {
|
|
20
|
+
const { checkpointNumber = CheckpointNumber(randomInt(100) + 1) } = overrides;
|
|
8
21
|
const { l1BlockNumber = randomBigInt(100n) + 1n } = overrides;
|
|
9
22
|
const { l1BlockHash = Buffer32.random() } = overrides;
|
|
10
23
|
const { leaf = Fr.random() } = overrides;
|
|
11
24
|
const { rollingHash = updateRollingHash(previousRollingHash, leaf) } = overrides;
|
|
12
|
-
const { index = InboxLeaf.
|
|
25
|
+
const { index = InboxLeaf.smallestIndexForCheckpoint(checkpointNumber) } = overrides;
|
|
13
26
|
return {
|
|
14
27
|
index,
|
|
15
28
|
leaf,
|
|
16
|
-
|
|
29
|
+
checkpointNumber,
|
|
17
30
|
l1BlockNumber,
|
|
18
31
|
l1BlockHash,
|
|
19
32
|
rollingHash
|
|
20
33
|
};
|
|
21
34
|
}
|
|
22
|
-
export function makeInboxMessages(
|
|
23
|
-
const { initialHash = Buffer16.ZERO, overrideFn = (msg)=>msg,
|
|
35
|
+
export function makeInboxMessages(totalCount, opts = {}) {
|
|
36
|
+
const { initialHash = Buffer16.ZERO, overrideFn = (msg)=>msg, initialCheckpointNumber = CheckpointNumber(1), messagesPerCheckpoint = 1 } = opts;
|
|
24
37
|
const messages = [];
|
|
25
38
|
let rollingHash = initialHash;
|
|
26
|
-
for(let i = 0; i <
|
|
39
|
+
for(let i = 0; i < totalCount; i++){
|
|
40
|
+
const msgIndex = i % messagesPerCheckpoint;
|
|
41
|
+
const checkpointNumber = CheckpointNumber.fromBigInt(BigInt(initialCheckpointNumber) + BigInt(i) / BigInt(messagesPerCheckpoint));
|
|
27
42
|
const leaf = Fr.random();
|
|
28
|
-
const l2BlockNumber = i + initialL2BlockNumber;
|
|
29
43
|
const message = overrideFn(makeInboxMessage(rollingHash, {
|
|
30
44
|
leaf,
|
|
31
|
-
|
|
45
|
+
checkpointNumber,
|
|
46
|
+
index: InboxLeaf.smallestIndexForCheckpoint(checkpointNumber) + BigInt(msgIndex)
|
|
32
47
|
}), i);
|
|
33
48
|
rollingHash = message.rollingHash;
|
|
34
49
|
messages.push(message);
|
|
35
50
|
}
|
|
36
51
|
return messages;
|
|
37
52
|
}
|
|
53
|
+
/** Creates inbox messages distributed across multiple blocks with proper checkpoint numbering. */ export function makeInboxMessagesWithFullBlocks(blockCount, opts = {}) {
|
|
54
|
+
const { initialCheckpointNumber = CheckpointNumber(13) } = opts;
|
|
55
|
+
return makeInboxMessages(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP * blockCount, {
|
|
56
|
+
overrideFn: (msg, i)=>{
|
|
57
|
+
const checkpointNumber = CheckpointNumber(initialCheckpointNumber + Math.floor(i / NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP));
|
|
58
|
+
const index = InboxLeaf.smallestIndexForCheckpoint(checkpointNumber) + BigInt(i % NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
59
|
+
return {
|
|
60
|
+
...msg,
|
|
61
|
+
checkpointNumber,
|
|
62
|
+
index
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/** Creates a deterministic block hash from a block number. */ export function makeBlockHash(blockNumber) {
|
|
68
|
+
return `0x${blockNumber.toString(16).padStart(64, '0')}`;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Creates a StateReference with properly calculated noteHashTree.nextAvailableLeafIndex.
|
|
72
|
+
* This ensures LogStore's dataStartIndexForBlock calculation doesn't produce negative values.
|
|
73
|
+
*/ export function makeStateForBlock(blockNumber, txsPerBlock) {
|
|
74
|
+
const noteHashIndex = blockNumber * txsPerBlock * MAX_NOTE_HASHES_PER_TX;
|
|
75
|
+
return new StateReference(AppendOnlyTreeSnapshot.random(), new PartialStateReference(new AppendOnlyTreeSnapshot(Fr.random(), noteHashIndex), AppendOnlyTreeSnapshot.random(), AppendOnlyTreeSnapshot.random()));
|
|
76
|
+
}
|
|
77
|
+
/** Creates L1PublishedData with deterministic values based on l1BlockNumber. */ export function makeL1PublishedData(l1BlockNumber) {
|
|
78
|
+
return new L1PublishedData(BigInt(l1BlockNumber), BigInt(l1BlockNumber * 1000), makeBlockHash(l1BlockNumber));
|
|
79
|
+
}
|
|
80
|
+
/** Wraps a Checkpoint with L1 published data and random attestations. */ export function makePublishedCheckpoint(checkpoint, l1BlockNumber, attestationCount = 3) {
|
|
81
|
+
return new PublishedCheckpoint(checkpoint, makeL1PublishedData(l1BlockNumber), times(attestationCount, CommitteeAttestation.random));
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Creates multiple checkpoints with properly chained archives.
|
|
85
|
+
* Each checkpoint's blocks have their lastArchive set to the previous block's archive,
|
|
86
|
+
* ensuring archive chain continuity for testing.
|
|
87
|
+
*/ export async function makeChainedCheckpoints(count, options = {}) {
|
|
88
|
+
const { blocksPerCheckpoint = 1, txsPerBlock = 4, startCheckpointNumber = CheckpointNumber(1), startBlockNumber = 1, startL1BlockNumber = 10, makeCheckpointOptions } = options;
|
|
89
|
+
let previousArchive = options.previousArchive;
|
|
90
|
+
const checkpoints = [];
|
|
91
|
+
for(let i = 0; i < count; i++){
|
|
92
|
+
const cpNumber = CheckpointNumber(startCheckpointNumber + i);
|
|
93
|
+
const blockStart = startBlockNumber + i * blocksPerCheckpoint;
|
|
94
|
+
const customOptions = makeCheckpointOptions?.(cpNumber) ?? {};
|
|
95
|
+
const checkpoint = await Checkpoint.random(cpNumber, {
|
|
96
|
+
numBlocks: blocksPerCheckpoint,
|
|
97
|
+
startBlockNumber: blockStart,
|
|
98
|
+
previousArchive,
|
|
99
|
+
txsPerBlock,
|
|
100
|
+
state: makeStateForBlock(blockStart, txsPerBlock),
|
|
101
|
+
txOptions: {
|
|
102
|
+
numPublicCallsPerTx: 2,
|
|
103
|
+
numPublicLogsPerCall: 2
|
|
104
|
+
},
|
|
105
|
+
...customOptions
|
|
106
|
+
});
|
|
107
|
+
previousArchive = checkpoint.blocks.at(-1).archive;
|
|
108
|
+
checkpoints.push(makePublishedCheckpoint(checkpoint, startL1BlockNumber + i * 10));
|
|
109
|
+
}
|
|
110
|
+
return checkpoints;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Creates a PublishedCheckpoint with attestations signed by the provided signers.
|
|
114
|
+
* Useful for testing attestation validation.
|
|
115
|
+
*/ export function makeSignedPublishedCheckpoint(checkpoint, signers, committee, l1BlockNumber = 1) {
|
|
116
|
+
const attestations = signers.map((signer)=>makeCheckpointAttestationFromCheckpoint(checkpoint, signer));
|
|
117
|
+
const committeeAttestations = orderAttestations(attestations, committee);
|
|
118
|
+
return new PublishedCheckpoint(checkpoint, makeL1PublishedData(l1BlockNumber), committeeAttestations);
|
|
119
|
+
}
|
|
120
|
+
/** Creates a deterministic SiloedTag for private log testing. */ export function makePrivateLogTag(blockNumber, txIndex, logIndex) {
|
|
121
|
+
return new SiloedTag(blockNumber === 1 && txIndex === 0 && logIndex === 0 ? Fr.ZERO : new Fr(blockNumber * 100 + txIndex * 10 + logIndex));
|
|
122
|
+
}
|
|
123
|
+
/** Creates a PrivateLog with fields derived from the tag. */ export function makePrivateLog(tag) {
|
|
124
|
+
return PrivateLog.from({
|
|
125
|
+
fields: makeTuple(PRIVATE_LOG_SIZE_IN_FIELDS, (i)=>!i ? tag.value : new Fr(tag.value.toBigInt() + BigInt(i))),
|
|
126
|
+
emittedLength: PRIVATE_LOG_SIZE_IN_FIELDS
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/** Creates multiple private logs for a transaction. */ export function mockPrivateLogs(blockNumber, txIndex, numLogsPerTx) {
|
|
130
|
+
return times(numLogsPerTx, (logIndex)=>{
|
|
131
|
+
const tag = makePrivateLogTag(blockNumber, txIndex, logIndex);
|
|
132
|
+
return makePrivateLog(tag);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
/** Creates a deterministic Tag for public log testing. */ export function makePublicLogTag(blockNumber, txIndex, logIndex) {
|
|
136
|
+
return new Tag(blockNumber === 1 && txIndex === 0 && logIndex === 0 ? Fr.ZERO : new Fr((blockNumber * 100 + txIndex * 10 + logIndex) * 123));
|
|
137
|
+
}
|
|
138
|
+
/** Creates a PublicLog with fields derived from the tag. */ export function makePublicLog(tag, contractAddress = AztecAddress.fromNumber(543254)) {
|
|
139
|
+
return PublicLog.from({
|
|
140
|
+
contractAddress,
|
|
141
|
+
fields: new Array(10).fill(null).map((_, i)=>!i ? tag.value : new Fr(tag.value.toBigInt() + BigInt(i)))
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/** Creates multiple public logs for a transaction. */ export function makePublicLogs(blockNumber, txIndex, numLogsPerTx, contractAddress = AztecAddress.fromNumber(543254)) {
|
|
145
|
+
return times(numLogsPerTx, (logIndex)=>{
|
|
146
|
+
const tag = makePublicLogTag(blockNumber, txIndex, logIndex);
|
|
147
|
+
return makePublicLog(tag, contractAddress);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/** Creates a checkpoint with specified logs on each tx effect. */ export async function makeCheckpointWithLogs(blockNumber, options = {}) {
|
|
151
|
+
const { previousArchive, numTxsPerBlock = 4, privateLogs, publicLogs } = options;
|
|
152
|
+
const block = await L2Block.random(BlockNumber(blockNumber), {
|
|
153
|
+
checkpointNumber: CheckpointNumber.fromBlockNumber(BlockNumber(blockNumber)),
|
|
154
|
+
indexWithinCheckpoint: IndexWithinCheckpoint(0),
|
|
155
|
+
state: makeStateForBlock(blockNumber, numTxsPerBlock),
|
|
156
|
+
...previousArchive ? {
|
|
157
|
+
lastArchive: previousArchive
|
|
158
|
+
} : {}
|
|
159
|
+
});
|
|
160
|
+
block.header.globalVariables.blockNumber = BlockNumber(blockNumber);
|
|
161
|
+
block.body.txEffects = await timesParallel(numTxsPerBlock, async (txIndex)=>{
|
|
162
|
+
const txEffect = await TxEffect.random();
|
|
163
|
+
txEffect.privateLogs = privateLogs ? mockPrivateLogs(blockNumber, txIndex, privateLogs.numLogsPerTx) : [];
|
|
164
|
+
txEffect.publicLogs = publicLogs ? makePublicLogs(blockNumber, txIndex, publicLogs.numLogsPerTx, publicLogs.contractAddress) : [];
|
|
165
|
+
return txEffect;
|
|
166
|
+
});
|
|
167
|
+
const checkpoint = new Checkpoint(AppendOnlyTreeSnapshot.random(), CheckpointHeader.random(), [
|
|
168
|
+
block
|
|
169
|
+
], CheckpointNumber.fromBlockNumber(BlockNumber(blockNumber)));
|
|
170
|
+
return makePublishedCheckpoint(checkpoint, blockNumber);
|
|
171
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
3
|
+
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
4
|
+
import { Archiver } from '../archiver.js';
|
|
5
|
+
import { ArchiverInstrumentation } from '../modules/instrumentation.js';
|
|
6
|
+
import type { KVArchiverDataStore } from '../store/kv_archiver_store.js';
|
|
7
|
+
/**
|
|
8
|
+
* Archiver with mocked L1 connectivity for testing.
|
|
9
|
+
* Uses mock L1 clients and a noop synchronizer, enabling tests that
|
|
10
|
+
* don't require real Ethereum connectivity.
|
|
11
|
+
*/
|
|
12
|
+
export declare class NoopL1Archiver extends Archiver {
|
|
13
|
+
constructor(dataStore: KVArchiverDataStore, l1Constants: L1RollupConstants & {
|
|
14
|
+
genesisArchiveRoot: Fr;
|
|
15
|
+
}, instrumentation: ArchiverInstrumentation);
|
|
16
|
+
/** Override start to skip L1 validation checks. */
|
|
17
|
+
start(_blockUntilSynced?: boolean): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
/** Creates an archiver with mocked L1 connectivity for testing. */
|
|
20
|
+
export declare function createNoopL1Archiver(dataStore: KVArchiverDataStore, l1Constants: L1RollupConstants & {
|
|
21
|
+
genesisArchiveRoot: Fr;
|
|
22
|
+
}, telemetry?: TelemetryClient): Promise<NoopL1Archiver>;
|
|
23
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm9vcF9sMV9hcmNoaXZlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3Rlc3Qvbm9vcF9sMV9hcmNoaXZlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFJQSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFJcEQsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNyRSxPQUFPLEVBQUUsS0FBSyxlQUFlLEVBQW1DLE1BQU0seUJBQXlCLENBQUM7QUFLaEcsT0FBTyxFQUFFLFFBQVEsRUFBRSxNQUFNLGdCQUFnQixDQUFDO0FBQzFDLE9BQU8sRUFBRSx1QkFBdUIsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBRXhFLE9BQU8sS0FBSyxFQUFFLG1CQUFtQixFQUFFLE1BQU0sK0JBQStCLENBQUM7QUF5QnpFOzs7O0dBSUc7QUFDSCxxQkFBYSxjQUFlLFNBQVEsUUFBUTtJQUMxQyxZQUNFLFNBQVMsRUFBRSxtQkFBbUIsRUFDOUIsV0FBVyxFQUFFLGlCQUFpQixHQUFHO1FBQUUsa0JBQWtCLEVBQUUsRUFBRSxDQUFBO0tBQUUsRUFDM0QsZUFBZSxFQUFFLHVCQUF1QixFQXVDekM7SUFFRCxtREFBbUQ7SUFDbkMsS0FBSyxDQUFDLGlCQUFpQixDQUFDLEVBQUUsT0FBTyxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FJaEU7Q0FDRjtBQUVELG1FQUFtRTtBQUNuRSx3QkFBc0Isb0JBQW9CLENBQ3hDLFNBQVMsRUFBRSxtQkFBbUIsRUFDOUIsV0FBVyxFQUFFLGlCQUFpQixHQUFHO0lBQUUsa0JBQWtCLEVBQUUsRUFBRSxDQUFBO0NBQUUsRUFDM0QsU0FBUyxHQUFFLGVBQXNDLEdBQ2hELE9BQU8sQ0FBQyxjQUFjLENBQUMsQ0FHekIifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noop_l1_archiver.d.ts","sourceRoot":"","sources":["../../src/test/noop_l1_archiver.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAIpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,KAAK,eAAe,EAAmC,MAAM,yBAAyB,CAAC;AAKhG,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAyBzE;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,QAAQ;IAC1C,YACE,SAAS,EAAE,mBAAmB,EAC9B,WAAW,EAAE,iBAAiB,GAAG;QAAE,kBAAkB,EAAE,EAAE,CAAA;KAAE,EAC3D,eAAe,EAAE,uBAAuB,EAuCzC;IAED,mDAAmD;IACnC,KAAK,CAAC,iBAAiB,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAIhE;CACF;AAED,mEAAmE;AACnE,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,mBAAmB,EAC9B,WAAW,EAAE,iBAAiB,GAAG;IAAE,kBAAkB,EAAE,EAAE,CAAA;CAAE,EAC3D,SAAS,GAAE,eAAsC,GAChD,OAAO,CAAC,cAAc,CAAC,CAGzB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
4
|
+
import { mock } from 'jest-mock-extended';
|
|
5
|
+
import { EventEmitter } from 'node:events';
|
|
6
|
+
import { Archiver } from '../archiver.js';
|
|
7
|
+
import { ArchiverInstrumentation } from '../modules/instrumentation.js';
|
|
8
|
+
/** Noop L1 synchronizer for testing without L1 connectivity. */ class NoopL1Synchronizer {
|
|
9
|
+
tracer;
|
|
10
|
+
constructor(tracer){
|
|
11
|
+
this.tracer = tracer;
|
|
12
|
+
}
|
|
13
|
+
setConfig(_config) {}
|
|
14
|
+
getL1BlockNumber() {
|
|
15
|
+
return 0n;
|
|
16
|
+
}
|
|
17
|
+
getL1Timestamp() {
|
|
18
|
+
return 0n;
|
|
19
|
+
}
|
|
20
|
+
testEthereumNodeSynced() {
|
|
21
|
+
return Promise.resolve();
|
|
22
|
+
}
|
|
23
|
+
syncFromL1(_initialSyncComplete) {
|
|
24
|
+
return Promise.resolve();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Archiver with mocked L1 connectivity for testing.
|
|
29
|
+
* Uses mock L1 clients and a noop synchronizer, enabling tests that
|
|
30
|
+
* don't require real Ethereum connectivity.
|
|
31
|
+
*/ export class NoopL1Archiver extends Archiver {
|
|
32
|
+
constructor(dataStore, l1Constants, instrumentation){
|
|
33
|
+
// Create mocks for L1 clients
|
|
34
|
+
const publicClient = mock();
|
|
35
|
+
const debugClient = mock();
|
|
36
|
+
const rollup = mock();
|
|
37
|
+
const blobClient = mock();
|
|
38
|
+
// Mock methods called during start()
|
|
39
|
+
blobClient.testSources.mockResolvedValue();
|
|
40
|
+
publicClient.getBlockNumber.mockResolvedValue(1n);
|
|
41
|
+
const events = new EventEmitter();
|
|
42
|
+
const synchronizer = new NoopL1Synchronizer(instrumentation.tracer);
|
|
43
|
+
super(publicClient, debugClient, rollup, {
|
|
44
|
+
registryAddress: EthAddress.ZERO,
|
|
45
|
+
governanceProposerAddress: EthAddress.ZERO,
|
|
46
|
+
slashFactoryAddress: EthAddress.ZERO,
|
|
47
|
+
slashingProposerAddress: EthAddress.ZERO
|
|
48
|
+
}, dataStore, {
|
|
49
|
+
pollingIntervalMs: 1000,
|
|
50
|
+
batchSize: 100,
|
|
51
|
+
skipValidateCheckpointAttestations: true,
|
|
52
|
+
maxAllowedEthClientDriftSeconds: 300,
|
|
53
|
+
ethereumAllowNoDebugHosts: true
|
|
54
|
+
}, blobClient, instrumentation, {
|
|
55
|
+
...l1Constants,
|
|
56
|
+
l1StartBlockHash: Buffer32.random()
|
|
57
|
+
}, synchronizer, events);
|
|
58
|
+
}
|
|
59
|
+
/** Override start to skip L1 validation checks. */ start(_blockUntilSynced) {
|
|
60
|
+
// Just start the running promise without L1 checks
|
|
61
|
+
this.runningPromise.start();
|
|
62
|
+
return Promise.resolve();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Creates an archiver with mocked L1 connectivity for testing. */ export async function createNoopL1Archiver(dataStore, l1Constants, telemetry = getTelemetryClient()) {
|
|
66
|
+
const instrumentation = await ArchiverInstrumentation.new(telemetry, ()=>dataStore.estimateSize());
|
|
67
|
+
return new NoopL1Archiver(dataStore, l1Constants, instrumentation);
|
|
68
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/archiver",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.ff7989d6c",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
7
|
-
"./data-retrieval": "./dest/archiver/data_retrieval.js",
|
|
8
|
-
"./epoch": "./dest/archiver/epoch_helpers.js",
|
|
9
7
|
"./test": "./dest/test/index.js",
|
|
10
|
-
"./
|
|
8
|
+
"./test/noop-l1": "./dest/test/noop_l1_archiver.js",
|
|
9
|
+
"./config": "./dest/config.js"
|
|
11
10
|
},
|
|
12
11
|
"typedocOptions": {
|
|
13
12
|
"entryPoints": [
|
|
@@ -17,8 +16,8 @@
|
|
|
17
16
|
"tsconfig": "./tsconfig.json"
|
|
18
17
|
},
|
|
19
18
|
"scripts": {
|
|
20
|
-
"build": "yarn clean &&
|
|
21
|
-
"build:dev": "
|
|
19
|
+
"build": "yarn clean && ../scripts/tsc.sh",
|
|
20
|
+
"build:dev": "../scripts/tsc.sh --watch",
|
|
22
21
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
23
22
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
|
|
24
23
|
"test:integration": "concurrently -k -s first -c reset,dim -n test,anvil \"yarn test:integration:run\" \"anvil\"",
|
|
@@ -66,22 +65,23 @@
|
|
|
66
65
|
]
|
|
67
66
|
},
|
|
68
67
|
"dependencies": {
|
|
69
|
-
"@aztec/blob-
|
|
70
|
-
"@aztec/blob-
|
|
71
|
-
"@aztec/constants": "0.0.1-commit.
|
|
72
|
-
"@aztec/epoch-cache": "0.0.1-commit.
|
|
73
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
74
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
75
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
76
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
77
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
78
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
79
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
80
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
68
|
+
"@aztec/blob-client": "0.0.1-commit.ff7989d6c",
|
|
69
|
+
"@aztec/blob-lib": "0.0.1-commit.ff7989d6c",
|
|
70
|
+
"@aztec/constants": "0.0.1-commit.ff7989d6c",
|
|
71
|
+
"@aztec/epoch-cache": "0.0.1-commit.ff7989d6c",
|
|
72
|
+
"@aztec/ethereum": "0.0.1-commit.ff7989d6c",
|
|
73
|
+
"@aztec/foundation": "0.0.1-commit.ff7989d6c",
|
|
74
|
+
"@aztec/kv-store": "0.0.1-commit.ff7989d6c",
|
|
75
|
+
"@aztec/l1-artifacts": "0.0.1-commit.ff7989d6c",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.ff7989d6c",
|
|
77
|
+
"@aztec/protocol-contracts": "0.0.1-commit.ff7989d6c",
|
|
78
|
+
"@aztec/stdlib": "0.0.1-commit.ff7989d6c",
|
|
79
|
+
"@aztec/telemetry-client": "0.0.1-commit.ff7989d6c",
|
|
81
80
|
"lodash.groupby": "^4.6.0",
|
|
82
81
|
"lodash.omit": "^4.5.0",
|
|
83
82
|
"tslib": "^2.5.0",
|
|
84
|
-
"viem": "npm:@aztec/viem@2.38.2"
|
|
83
|
+
"viem": "npm:@aztec/viem@2.38.2",
|
|
84
|
+
"zod": "^3.23.8"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@jest/globals": "^30.0.0",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"@types/lodash.groupby": "^4.6.9",
|
|
90
90
|
"@types/lodash.omit": "^4.5.7",
|
|
91
91
|
"@types/node": "^22.15.17",
|
|
92
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
92
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
93
93
|
"concurrently": "^8.0.1",
|
|
94
94
|
"jest": "^30.0.0",
|
|
95
95
|
"jest-mock-extended": "^4.0.0",
|