@aztec/sequencer-client 0.65.2 → 0.66.0

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.
@@ -1,92 +0,0 @@
1
- import { createDebugLogger } from '@aztec/aztec.js';
2
- import {
3
- type BlockBuilder,
4
- L2Block,
5
- MerkleTreeId,
6
- type MerkleTreeWriteOperations,
7
- type ProcessedTx,
8
- makeEmptyProcessedTx,
9
- } from '@aztec/circuit-types';
10
- import { Fr, type GlobalVariables, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/circuits.js';
11
- import { padArrayEnd } from '@aztec/foundation/collection';
12
- import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types';
13
- import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
14
- import { buildBaseRollupHints, buildHeaderAndBodyFromTxs, getTreeSnapshot } from '@aztec/prover-client/helpers';
15
- import { type TelemetryClient } from '@aztec/telemetry-client';
16
- import { NoopTelemetryClient } from '@aztec/telemetry-client/noop';
17
-
18
- import { inspect } from 'util';
19
-
20
- /**
21
- * Builds a block and its header from a set of processed tx without running any circuits.
22
- */
23
- export class LightweightBlockBuilder implements BlockBuilder {
24
- private numTxs?: number;
25
- private globalVariables?: GlobalVariables;
26
- private l1ToL2Messages?: Fr[];
27
-
28
- private readonly txs: ProcessedTx[] = [];
29
-
30
- private readonly logger = createDebugLogger('aztec:sequencer-client:block_builder_light');
31
-
32
- constructor(private db: MerkleTreeWriteOperations, private telemetry: TelemetryClient) {}
33
-
34
- async startNewBlock(numTxs: number, globalVariables: GlobalVariables, l1ToL2Messages: Fr[]): Promise<void> {
35
- this.logger.verbose('Starting new block', { numTxs, globalVariables: inspect(globalVariables), l1ToL2Messages });
36
- this.numTxs = numTxs;
37
- this.globalVariables = globalVariables;
38
- this.l1ToL2Messages = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
39
-
40
- // Update L1 to L2 tree
41
- await this.db.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, this.l1ToL2Messages!);
42
- }
43
-
44
- async addNewTx(tx: ProcessedTx): Promise<void> {
45
- this.logger.verbose('Adding new tx to block', { txHash: tx.hash.toString() });
46
- this.txs.push(tx);
47
- await buildBaseRollupHints(tx, this.globalVariables!, this.db);
48
- }
49
-
50
- async setBlockCompleted(): Promise<L2Block> {
51
- const paddingTxCount = this.numTxs! - this.txs.length;
52
- this.logger.verbose(`Setting block as completed and adding ${paddingTxCount} padding txs`);
53
- for (let i = 0; i < paddingTxCount; i++) {
54
- await this.addNewTx(
55
- makeEmptyProcessedTx(
56
- this.db.getInitialHeader(),
57
- this.globalVariables!.chainId,
58
- this.globalVariables!.version,
59
- getVKTreeRoot(),
60
- protocolContractTreeRoot,
61
- ),
62
- );
63
- }
64
-
65
- return this.buildBlock();
66
- }
67
-
68
- private async buildBlock(): Promise<L2Block> {
69
- this.logger.verbose(`Finalising block`);
70
-
71
- const { header, body } = await buildHeaderAndBodyFromTxs(
72
- this.txs,
73
- this.globalVariables!,
74
- this.l1ToL2Messages!,
75
- this.db,
76
- );
77
-
78
- await this.db.updateArchive(header);
79
- const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db);
80
-
81
- const block = new L2Block(newArchive, header, body);
82
- return block;
83
- }
84
- }
85
-
86
- export class LightweightBlockBuilderFactory {
87
- constructor(private telemetry?: TelemetryClient) {}
88
-
89
- create(db: MerkleTreeWriteOperations): BlockBuilder {
90
- return new LightweightBlockBuilder(db, this.telemetry ?? new NoopTelemetryClient());
91
- }
92
- }
@@ -1,43 +0,0 @@
1
- import { TestCircuitProver } from '@aztec/bb-prover';
2
- import {
3
- type BlockBuilder,
4
- type L2Block,
5
- type MerkleTreeWriteOperations,
6
- type ProcessedTx,
7
- } from '@aztec/circuit-types';
8
- import { type Fr, type GlobalVariables } from '@aztec/circuits.js';
9
- import { ProvingOrchestrator } from '@aztec/prover-client/orchestrator';
10
- import { type SimulationProvider } from '@aztec/simulator';
11
- import { type TelemetryClient } from '@aztec/telemetry-client';
12
- import { NoopTelemetryClient } from '@aztec/telemetry-client/noop';
13
-
14
- /**
15
- * Implements a block simulator using a test circuit prover under the hood, which just simulates circuits and outputs empty proofs.
16
- * This class is unused at the moment, but could be leveraged by a prover-node to ascertain that it can prove a block before
17
- * committing to proving it by sending a quote.
18
- */
19
- export class OrchestratorBlockBuilder implements BlockBuilder {
20
- private orchestrator: ProvingOrchestrator;
21
- constructor(db: MerkleTreeWriteOperations, simulationProvider: SimulationProvider, telemetry: TelemetryClient) {
22
- const testProver = new TestCircuitProver(telemetry, simulationProvider);
23
- this.orchestrator = new ProvingOrchestrator(db, testProver, telemetry);
24
- }
25
-
26
- startNewBlock(numTxs: number, globalVariables: GlobalVariables, l1ToL2Messages: Fr[]): Promise<void> {
27
- return this.orchestrator.startNewBlock(numTxs, globalVariables, l1ToL2Messages);
28
- }
29
- setBlockCompleted(): Promise<L2Block> {
30
- return this.orchestrator.setBlockCompleted();
31
- }
32
- addNewTx(tx: ProcessedTx): Promise<void> {
33
- return this.orchestrator.addNewTx(tx);
34
- }
35
- }
36
-
37
- export class OrchestratorBlockBuilderFactory {
38
- constructor(private simulationProvider: SimulationProvider, private telemetry?: TelemetryClient) {}
39
-
40
- create(db: MerkleTreeWriteOperations): BlockBuilder {
41
- return new OrchestratorBlockBuilder(db, this.simulationProvider, this.telemetry ?? new NoopTelemetryClient());
42
- }
43
- }