@aztec/sequencer-client 4.0.0-nightly.20260111 → 4.0.0-nightly.20260113

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.
Files changed (59) hide show
  1. package/dest/client/sequencer-client.d.ts +4 -5
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/config.d.ts +1 -1
  4. package/dest/config.d.ts.map +1 -1
  5. package/dest/config.js +8 -1
  6. package/dest/index.d.ts +2 -3
  7. package/dest/index.d.ts.map +1 -1
  8. package/dest/index.js +1 -2
  9. package/dest/publisher/sequencer-publisher.d.ts +15 -15
  10. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  11. package/dest/publisher/sequencer-publisher.js +44 -46
  12. package/dest/sequencer/block_builder.d.ts +1 -1
  13. package/dest/sequencer/block_builder.d.ts.map +1 -1
  14. package/dest/sequencer/block_builder.js +1 -1
  15. package/dest/sequencer/checkpoint_proposal_job.d.ts +8 -7
  16. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
  17. package/dest/sequencer/checkpoint_proposal_job.js +47 -28
  18. package/dest/sequencer/index.d.ts +1 -2
  19. package/dest/sequencer/index.d.ts.map +1 -1
  20. package/dest/sequencer/index.js +0 -1
  21. package/dest/sequencer/metrics.d.ts +3 -3
  22. package/dest/sequencer/metrics.d.ts.map +1 -1
  23. package/dest/sequencer/metrics.js +4 -4
  24. package/dest/sequencer/sequencer.d.ts +12 -11
  25. package/dest/sequencer/sequencer.d.ts.map +1 -1
  26. package/dest/sequencer/sequencer.js +28 -26
  27. package/dest/test/index.d.ts +2 -3
  28. package/dest/test/index.d.ts.map +1 -1
  29. package/dest/test/mock_checkpoint_builder.d.ts +10 -2
  30. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
  31. package/dest/test/mock_checkpoint_builder.js +23 -0
  32. package/dest/test/utils.d.ts +8 -4
  33. package/dest/test/utils.d.ts.map +1 -1
  34. package/dest/test/utils.js +18 -8
  35. package/package.json +27 -27
  36. package/src/client/sequencer-client.ts +3 -4
  37. package/src/config.ts +7 -0
  38. package/src/index.ts +0 -3
  39. package/src/publisher/sequencer-publisher.ts +75 -70
  40. package/src/sequencer/block_builder.ts +1 -2
  41. package/src/sequencer/checkpoint_proposal_job.ts +58 -38
  42. package/src/sequencer/index.ts +0 -1
  43. package/src/sequencer/metrics.ts +4 -4
  44. package/src/sequencer/sequencer.ts +41 -33
  45. package/src/test/index.ts +1 -2
  46. package/src/test/mock_checkpoint_builder.ts +34 -2
  47. package/src/test/utils.ts +35 -9
  48. package/dest/sequencer/checkpoint_builder.d.ts +0 -63
  49. package/dest/sequencer/checkpoint_builder.d.ts.map +0 -1
  50. package/dest/sequencer/checkpoint_builder.js +0 -131
  51. package/dest/tx_validator/nullifier_cache.d.ts +0 -14
  52. package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
  53. package/dest/tx_validator/nullifier_cache.js +0 -24
  54. package/dest/tx_validator/tx_validator_factory.d.ts +0 -18
  55. package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
  56. package/dest/tx_validator/tx_validator_factory.js +0 -53
  57. package/src/sequencer/checkpoint_builder.ts +0 -217
  58. package/src/tx_validator/nullifier_cache.ts +0 -30
  59. package/src/tx_validator/tx_validator_factory.ts +0 -133
@@ -1,18 +0,0 @@
1
- import { BlockNumber } from '@aztec/foundation/branded-types';
2
- import type { ContractDataSource } from '@aztec/stdlib/contract';
3
- import type { GasFees } from '@aztec/stdlib/gas';
4
- import type { AllowedElement, ClientProtocolCircuitVerifier, MerkleTreeReadOperations, PublicProcessorValidator } from '@aztec/stdlib/interfaces/server';
5
- import { GlobalVariables, type Tx, type TxValidator } from '@aztec/stdlib/tx';
6
- import type { UInt64 } from '@aztec/stdlib/types';
7
- export declare function createValidatorForAcceptingTxs(db: MerkleTreeReadOperations, contractDataSource: ContractDataSource, verifier: ClientProtocolCircuitVerifier | undefined, { l1ChainId, rollupVersion, setupAllowList, gasFees, skipFeeEnforcement, timestamp, blockNumber, txsPermitted }: {
8
- l1ChainId: number;
9
- rollupVersion: number;
10
- setupAllowList: AllowedElement[];
11
- gasFees: GasFees;
12
- skipFeeEnforcement?: boolean;
13
- timestamp: UInt64;
14
- blockNumber: BlockNumber;
15
- txsPermitted: boolean;
16
- }): TxValidator<Tx>;
17
- export declare function createValidatorForBlockBuilding(db: MerkleTreeReadOperations, contractDataSource: ContractDataSource, globalVariables: GlobalVariables, setupAllowList: AllowedElement[]): PublicProcessorValidator;
18
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhfdmFsaWRhdG9yX2ZhY3RvcnkuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90eF92YWxpZGF0b3IvdHhfdmFsaWRhdG9yX2ZhY3RvcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBaUI5RCxPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQ2pFLE9BQU8sS0FBSyxFQUFFLE9BQU8sRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ2pELE9BQU8sS0FBSyxFQUNWLGNBQWMsRUFDZCw2QkFBNkIsRUFDN0Isd0JBQXdCLEVBQ3hCLHdCQUF3QixFQUN6QixNQUFNLGlDQUFpQyxDQUFDO0FBRXpDLE9BQU8sRUFBRSxlQUFlLEVBQUUsS0FBSyxFQUFFLEVBQUUsS0FBSyxXQUFXLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUM5RSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUlsRCx3QkFBZ0IsOEJBQThCLENBQzVDLEVBQUUsRUFBRSx3QkFBd0IsRUFDNUIsa0JBQWtCLEVBQUUsa0JBQWtCLEVBQ3RDLFFBQVEsRUFBRSw2QkFBNkIsR0FBRyxTQUFTLEVBQ25ELEVBQ0UsU0FBUyxFQUNULGFBQWEsRUFDYixjQUFjLEVBQ2QsT0FBTyxFQUNQLGtCQUFrQixFQUNsQixTQUFTLEVBQ1QsV0FBVyxFQUNYLFlBQVksRUFDYixFQUFFO0lBQ0QsU0FBUyxFQUFFLE1BQU0sQ0FBQztJQUNsQixhQUFhLEVBQUUsTUFBTSxDQUFDO0lBQ3RCLGNBQWMsRUFBRSxjQUFjLEVBQUUsQ0FBQztJQUNqQyxPQUFPLEVBQUUsT0FBTyxDQUFDO0lBQ2pCLGtCQUFrQixDQUFDLEVBQUUsT0FBTyxDQUFDO0lBQzdCLFNBQVMsRUFBRSxNQUFNLENBQUM7SUFDbEIsV0FBVyxFQUFFLFdBQVcsQ0FBQztJQUN6QixZQUFZLEVBQUUsT0FBTyxDQUFDO0NBQ3ZCLEdBQ0EsV0FBVyxDQUFDLEVBQUUsQ0FBQyxDQTRCakI7QUFFRCx3QkFBZ0IsK0JBQStCLENBQzdDLEVBQUUsRUFBRSx3QkFBd0IsRUFDNUIsa0JBQWtCLEVBQUUsa0JBQWtCLEVBQ3RDLGVBQWUsRUFBRSxlQUFlLEVBQ2hDLGNBQWMsRUFBRSxjQUFjLEVBQUUsR0FDL0Isd0JBQXdCLENBZ0IxQiJ9
@@ -1 +0,0 @@
1
- {"version":3,"file":"tx_validator_factory.d.ts","sourceRoot":"","sources":["../../src/tx_validator/tx_validator_factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAiB9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EACV,cAAc,EACd,6BAA6B,EAC7B,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAIlD,wBAAgB,8BAA8B,CAC5C,EAAE,EAAE,wBAAwB,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,QAAQ,EAAE,6BAA6B,GAAG,SAAS,EACnD,EACE,SAAS,EACT,aAAa,EACb,cAAc,EACd,OAAO,EACP,kBAAkB,EAClB,SAAS,EACT,WAAW,EACX,YAAY,EACb,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,cAAc,EAAE,CAAC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,WAAW,CAAC;IACzB,YAAY,EAAE,OAAO,CAAC;CACvB,GACA,WAAW,CAAC,EAAE,CAAC,CA4BjB;AAED,wBAAgB,+BAA+B,CAC7C,EAAE,EAAE,wBAAwB,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,cAAc,EAAE,GAC/B,wBAAwB,CAgB1B"}
@@ -1,53 +0,0 @@
1
- import { Fr } from '@aztec/foundation/curves/bn254';
2
- import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
3
- import { AggregateTxValidator, ArchiveCache, BlockHeaderTxValidator, DataTxValidator, DoubleSpendTxValidator, GasTxValidator, MetadataTxValidator, PhasesTxValidator, TimestampTxValidator, TxPermittedValidator, TxProofValidator } from '@aztec/p2p';
4
- import { ProtocolContractAddress, protocolContractsHash } from '@aztec/protocol-contracts';
5
- import { DatabasePublicStateSource } from '@aztec/stdlib/trees';
6
- import { NullifierCache } from './nullifier_cache.js';
7
- export function createValidatorForAcceptingTxs(db, contractDataSource, verifier, { l1ChainId, rollupVersion, setupAllowList, gasFees, skipFeeEnforcement, timestamp, blockNumber, txsPermitted }) {
8
- const validators = [
9
- new TxPermittedValidator(txsPermitted),
10
- new DataTxValidator(),
11
- new MetadataTxValidator({
12
- l1ChainId: new Fr(l1ChainId),
13
- rollupVersion: new Fr(rollupVersion),
14
- protocolContractsHash,
15
- vkTreeRoot: getVKTreeRoot()
16
- }),
17
- new TimestampTxValidator({
18
- timestamp,
19
- blockNumber
20
- }),
21
- new DoubleSpendTxValidator(new NullifierCache(db)),
22
- new PhasesTxValidator(contractDataSource, setupAllowList, timestamp),
23
- new BlockHeaderTxValidator(new ArchiveCache(db))
24
- ];
25
- if (!skipFeeEnforcement) {
26
- validators.push(new GasTxValidator(new DatabasePublicStateSource(db), ProtocolContractAddress.FeeJuice, gasFees));
27
- }
28
- if (verifier) {
29
- validators.push(new TxProofValidator(verifier));
30
- }
31
- return new AggregateTxValidator(...validators);
32
- }
33
- export function createValidatorForBlockBuilding(db, contractDataSource, globalVariables, setupAllowList) {
34
- const nullifierCache = new NullifierCache(db);
35
- const archiveCache = new ArchiveCache(db);
36
- const publicStateSource = new DatabasePublicStateSource(db);
37
- return {
38
- preprocessValidator: preprocessValidator(nullifierCache, archiveCache, publicStateSource, contractDataSource, globalVariables, setupAllowList),
39
- nullifierCache
40
- };
41
- }
42
- function preprocessValidator(nullifierCache, archiveCache, publicStateSource, contractDataSource, globalVariables, setupAllowList) {
43
- // We don't include the TxProofValidator nor the DataTxValidator here because they are already checked by the time we get to block building.
44
- return new AggregateTxValidator(new MetadataTxValidator({
45
- l1ChainId: globalVariables.chainId,
46
- rollupVersion: globalVariables.version,
47
- protocolContractsHash,
48
- vkTreeRoot: getVKTreeRoot()
49
- }), new TimestampTxValidator({
50
- timestamp: globalVariables.timestamp,
51
- blockNumber: globalVariables.blockNumber
52
- }), new DoubleSpendTxValidator(nullifierCache), new PhasesTxValidator(contractDataSource, setupAllowList, globalVariables.timestamp), new GasTxValidator(publicStateSource, ProtocolContractAddress.FeeJuice, globalVariables.gasFees), new BlockHeaderTxValidator(archiveCache));
53
- }
@@ -1,217 +0,0 @@
1
- import { MerkleTreeId } from '@aztec/aztec.js/trees';
2
- import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
3
- import { merge, pick } from '@aztec/foundation/collection';
4
- import { Fr } from '@aztec/foundation/curves/bn254';
5
- import { createLogger } from '@aztec/foundation/log';
6
- import { bufferToHex } from '@aztec/foundation/string';
7
- import { DateProvider, Timer, elapsed } from '@aztec/foundation/timer';
8
- import { getDefaultAllowedSetupFunctions } from '@aztec/p2p/msg_validators';
9
- import { LightweightCheckpointBuilder } from '@aztec/prover-client/light';
10
- import {
11
- GuardedMerkleTreeOperations,
12
- PublicContractsDB,
13
- PublicProcessor,
14
- createPublicTxSimulatorForBlockBuilding,
15
- } from '@aztec/simulator/server';
16
- import { L2BlockNew } from '@aztec/stdlib/block';
17
- import { Checkpoint } from '@aztec/stdlib/checkpoint';
18
- import type { ContractDataSource } from '@aztec/stdlib/contract';
19
- import { Gas } from '@aztec/stdlib/gas';
20
- import {
21
- type FullNodeBlockBuilderConfig,
22
- FullNodeBlockBuilderConfigKeys,
23
- type MerkleTreeWriteOperations,
24
- type PublicProcessorLimits,
25
- } from '@aztec/stdlib/interfaces/server';
26
- import { type CheckpointGlobalVariables, type FailedTx, GlobalVariables, Tx } from '@aztec/stdlib/tx';
27
- import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
28
-
29
- import { createValidatorForBlockBuilding } from '../tx_validator/tx_validator_factory.js';
30
-
31
- const log = createLogger('checkpoint-builder');
32
-
33
- export interface BuildBlockInCheckpointResult {
34
- block: L2BlockNew;
35
- publicGas: Gas;
36
- publicProcessorDuration: number;
37
- numTxs: number;
38
- failedTxs: FailedTx[];
39
- blockBuildingTimer: Timer;
40
- usedTxs: Tx[];
41
- }
42
-
43
- /**
44
- * Builder for a single checkpoint. Handles building blocks within the checkpoint
45
- * and completing it.
46
- */
47
- export class CheckpointBuilder {
48
- constructor(
49
- private checkpointBuilder: LightweightCheckpointBuilder,
50
- private fork: MerkleTreeWriteOperations,
51
- private config: FullNodeBlockBuilderConfig,
52
- private contractDataSource: ContractDataSource,
53
- private dateProvider: DateProvider,
54
- private telemetryClient: TelemetryClient,
55
- ) {}
56
-
57
- getConstantData(): CheckpointGlobalVariables {
58
- return this.checkpointBuilder.constants;
59
- }
60
-
61
- /**
62
- * Builds a single block within this checkpoint.
63
- */
64
- async buildBlock(
65
- pendingTxs: Iterable<Tx> | AsyncIterable<Tx>,
66
- blockNumber: BlockNumber,
67
- timestamp: bigint,
68
- opts: PublicProcessorLimits,
69
- ): Promise<BuildBlockInCheckpointResult> {
70
- const blockBuildingTimer = new Timer();
71
- const slot = this.checkpointBuilder.constants.slotNumber;
72
-
73
- log.verbose(`Building block ${blockNumber} for slot ${slot} within checkpoint`, { slot, blockNumber, ...opts });
74
-
75
- const constants = this.checkpointBuilder.constants;
76
- const globalVariables = GlobalVariables.from({
77
- chainId: constants.chainId,
78
- version: constants.version,
79
- blockNumber,
80
- slotNumber: constants.slotNumber,
81
- timestamp,
82
- coinbase: constants.coinbase,
83
- feeRecipient: constants.feeRecipient,
84
- gasFees: constants.gasFees,
85
- });
86
- const { processor, validator } = await this.makeBlockBuilderDeps(globalVariables, this.fork);
87
-
88
- const [publicProcessorDuration, [processedTxs, failedTxs, usedTxs]] = await elapsed(() =>
89
- processor.process(pendingTxs, opts, validator),
90
- );
91
-
92
- // Add block to checkpoint
93
- const block = await this.checkpointBuilder.addBlock(globalVariables, processedTxs);
94
-
95
- // How much public gas was processed
96
- const publicGas = processedTxs.reduce((acc, tx) => acc.add(tx.gasUsed.publicGas), Gas.empty());
97
-
98
- const res = {
99
- block,
100
- publicGas,
101
- publicProcessorDuration,
102
- numTxs: processedTxs.length,
103
- failedTxs,
104
- blockBuildingTimer,
105
- usedTxs,
106
- };
107
- log.debug('Built block within checkpoint', res.block.header);
108
- return res;
109
- }
110
-
111
- /** Completes the checkpoint and returns it. */
112
- async completeCheckpoint(): Promise<Checkpoint> {
113
- const checkpoint = await this.checkpointBuilder.completeCheckpoint();
114
-
115
- log.verbose(`Completed checkpoint ${checkpoint.number}`, {
116
- checkpointNumber: checkpoint.number,
117
- numBlocks: checkpoint.blocks.length,
118
- archiveRoot: checkpoint.archive.root.toString(),
119
- });
120
-
121
- return checkpoint;
122
- }
123
-
124
- /** Gets the checkpoint currently in progress. */
125
- getCheckpoint(): Promise<Checkpoint> {
126
- return this.checkpointBuilder.clone().completeCheckpoint();
127
- }
128
-
129
- protected async makeBlockBuilderDeps(globalVariables: GlobalVariables, fork: MerkleTreeWriteOperations) {
130
- const txPublicSetupAllowList = this.config.txPublicSetupAllowList ?? (await getDefaultAllowedSetupFunctions());
131
- const contractsDB = new PublicContractsDB(this.contractDataSource);
132
- const guardedFork = new GuardedMerkleTreeOperations(fork);
133
-
134
- const publicTxSimulator = createPublicTxSimulatorForBlockBuilding(
135
- guardedFork,
136
- contractsDB,
137
- globalVariables,
138
- this.telemetryClient,
139
- );
140
-
141
- const processor = new PublicProcessor(
142
- globalVariables,
143
- guardedFork,
144
- contractsDB,
145
- publicTxSimulator,
146
- this.dateProvider,
147
- this.telemetryClient,
148
- undefined,
149
- this.config,
150
- );
151
-
152
- const validator = createValidatorForBlockBuilding(
153
- fork,
154
- this.contractDataSource,
155
- globalVariables,
156
- txPublicSetupAllowList,
157
- );
158
-
159
- return {
160
- processor,
161
- validator,
162
- };
163
- }
164
- }
165
-
166
- /**
167
- * Factory for creating checkpoint builders.
168
- */
169
- export class FullNodeCheckpointsBuilder {
170
- constructor(
171
- private config: FullNodeBlockBuilderConfig,
172
- private contractDataSource: ContractDataSource,
173
- private dateProvider: DateProvider,
174
- private telemetryClient: TelemetryClient = getTelemetryClient(),
175
- ) {}
176
-
177
- public updateConfig(config: Partial<FullNodeBlockBuilderConfig>) {
178
- this.config = merge(this.config, pick(config, ...FullNodeBlockBuilderConfigKeys));
179
- }
180
-
181
- /**
182
- * Starts a new checkpoint and returns a CheckpointBuilder to build blocks within it.
183
- */
184
- async startCheckpoint(
185
- checkpointNumber: CheckpointNumber,
186
- constants: CheckpointGlobalVariables,
187
- l1ToL2Messages: Fr[],
188
- fork: MerkleTreeWriteOperations,
189
- ): Promise<CheckpointBuilder> {
190
- const stateReference = await fork.getStateReference();
191
- const archiveTree = await fork.getTreeInfo(MerkleTreeId.ARCHIVE);
192
-
193
- log.verbose(`Building checkpoint ${checkpointNumber}`, {
194
- checkpointNumber,
195
- msgCount: l1ToL2Messages.length,
196
- initialStateReference: stateReference.toInspect(),
197
- initialArchiveRoot: bufferToHex(archiveTree.root),
198
- constants,
199
- });
200
-
201
- const lightweightBuilder = await LightweightCheckpointBuilder.startNewCheckpoint(
202
- checkpointNumber,
203
- constants,
204
- l1ToL2Messages,
205
- fork,
206
- );
207
-
208
- return new CheckpointBuilder(
209
- lightweightBuilder,
210
- fork,
211
- this.config,
212
- this.contractDataSource,
213
- this.dateProvider,
214
- this.telemetryClient,
215
- );
216
- }
217
- }
@@ -1,30 +0,0 @@
1
- import type { NullifierSource } from '@aztec/p2p';
2
- import type { MerkleTreeReadOperations } from '@aztec/stdlib/interfaces/server';
3
- import { MerkleTreeId } from '@aztec/stdlib/trees';
4
-
5
- /**
6
- * Implements a nullifier source by checking a DB and an in-memory collection.
7
- * Intended for validating transactions as they are added to a block.
8
- */
9
- export class NullifierCache implements NullifierSource {
10
- nullifiers: Set<string>;
11
-
12
- constructor(private db: MerkleTreeReadOperations) {
13
- this.nullifiers = new Set();
14
- }
15
-
16
- public async nullifiersExist(nullifiers: Buffer[]): Promise<boolean[]> {
17
- const cacheResults = nullifiers.map(n => this.nullifiers.has(n.toString()));
18
- const toCheckDb = nullifiers.filter((_n, index) => !cacheResults[index]);
19
- const dbHits = await this.db.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, toCheckDb);
20
-
21
- let dbIndex = 0;
22
- return nullifiers.map((_n, index) => cacheResults[index] || dbHits[dbIndex++] !== undefined);
23
- }
24
-
25
- public addNullifiers(nullifiers: Buffer[]) {
26
- for (const nullifier of nullifiers) {
27
- this.nullifiers.add(nullifier.toString());
28
- }
29
- }
30
- }
@@ -1,133 +0,0 @@
1
- import { BlockNumber } from '@aztec/foundation/branded-types';
2
- import { Fr } from '@aztec/foundation/curves/bn254';
3
- import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
4
- import {
5
- AggregateTxValidator,
6
- ArchiveCache,
7
- BlockHeaderTxValidator,
8
- DataTxValidator,
9
- DoubleSpendTxValidator,
10
- GasTxValidator,
11
- MetadataTxValidator,
12
- PhasesTxValidator,
13
- TimestampTxValidator,
14
- TxPermittedValidator,
15
- TxProofValidator,
16
- } from '@aztec/p2p';
17
- import { ProtocolContractAddress, protocolContractsHash } from '@aztec/protocol-contracts';
18
- import type { ContractDataSource } from '@aztec/stdlib/contract';
19
- import type { GasFees } from '@aztec/stdlib/gas';
20
- import type {
21
- AllowedElement,
22
- ClientProtocolCircuitVerifier,
23
- MerkleTreeReadOperations,
24
- PublicProcessorValidator,
25
- } from '@aztec/stdlib/interfaces/server';
26
- import { DatabasePublicStateSource, type PublicStateSource } from '@aztec/stdlib/trees';
27
- import { GlobalVariables, type Tx, type TxValidator } from '@aztec/stdlib/tx';
28
- import type { UInt64 } from '@aztec/stdlib/types';
29
-
30
- import { NullifierCache } from './nullifier_cache.js';
31
-
32
- export function createValidatorForAcceptingTxs(
33
- db: MerkleTreeReadOperations,
34
- contractDataSource: ContractDataSource,
35
- verifier: ClientProtocolCircuitVerifier | undefined,
36
- {
37
- l1ChainId,
38
- rollupVersion,
39
- setupAllowList,
40
- gasFees,
41
- skipFeeEnforcement,
42
- timestamp,
43
- blockNumber,
44
- txsPermitted,
45
- }: {
46
- l1ChainId: number;
47
- rollupVersion: number;
48
- setupAllowList: AllowedElement[];
49
- gasFees: GasFees;
50
- skipFeeEnforcement?: boolean;
51
- timestamp: UInt64;
52
- blockNumber: BlockNumber;
53
- txsPermitted: boolean;
54
- },
55
- ): TxValidator<Tx> {
56
- const validators: TxValidator<Tx>[] = [
57
- new TxPermittedValidator(txsPermitted),
58
- new DataTxValidator(),
59
- new MetadataTxValidator({
60
- l1ChainId: new Fr(l1ChainId),
61
- rollupVersion: new Fr(rollupVersion),
62
- protocolContractsHash,
63
- vkTreeRoot: getVKTreeRoot(),
64
- }),
65
- new TimestampTxValidator({
66
- timestamp,
67
- blockNumber,
68
- }),
69
- new DoubleSpendTxValidator(new NullifierCache(db)),
70
- new PhasesTxValidator(contractDataSource, setupAllowList, timestamp),
71
- new BlockHeaderTxValidator(new ArchiveCache(db)),
72
- ];
73
-
74
- if (!skipFeeEnforcement) {
75
- validators.push(new GasTxValidator(new DatabasePublicStateSource(db), ProtocolContractAddress.FeeJuice, gasFees));
76
- }
77
-
78
- if (verifier) {
79
- validators.push(new TxProofValidator(verifier));
80
- }
81
-
82
- return new AggregateTxValidator(...validators);
83
- }
84
-
85
- export function createValidatorForBlockBuilding(
86
- db: MerkleTreeReadOperations,
87
- contractDataSource: ContractDataSource,
88
- globalVariables: GlobalVariables,
89
- setupAllowList: AllowedElement[],
90
- ): PublicProcessorValidator {
91
- const nullifierCache = new NullifierCache(db);
92
- const archiveCache = new ArchiveCache(db);
93
- const publicStateSource = new DatabasePublicStateSource(db);
94
-
95
- return {
96
- preprocessValidator: preprocessValidator(
97
- nullifierCache,
98
- archiveCache,
99
- publicStateSource,
100
- contractDataSource,
101
- globalVariables,
102
- setupAllowList,
103
- ),
104
- nullifierCache,
105
- };
106
- }
107
-
108
- function preprocessValidator(
109
- nullifierCache: NullifierCache,
110
- archiveCache: ArchiveCache,
111
- publicStateSource: PublicStateSource,
112
- contractDataSource: ContractDataSource,
113
- globalVariables: GlobalVariables,
114
- setupAllowList: AllowedElement[],
115
- ): TxValidator<Tx> {
116
- // We don't include the TxProofValidator nor the DataTxValidator here because they are already checked by the time we get to block building.
117
- return new AggregateTxValidator(
118
- new MetadataTxValidator({
119
- l1ChainId: globalVariables.chainId,
120
- rollupVersion: globalVariables.version,
121
- protocolContractsHash,
122
- vkTreeRoot: getVKTreeRoot(),
123
- }),
124
- new TimestampTxValidator({
125
- timestamp: globalVariables.timestamp,
126
- blockNumber: globalVariables.blockNumber,
127
- }),
128
- new DoubleSpendTxValidator(nullifierCache),
129
- new PhasesTxValidator(contractDataSource, setupAllowList, globalVariables.timestamp),
130
- new GasTxValidator(publicStateSource, ProtocolContractAddress.FeeJuice, globalVariables.gasFees),
131
- new BlockHeaderTxValidator(archiveCache),
132
- );
133
- }