Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Full simulations and public views #1400

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions yarn-project/aztec-node/src/aztec-node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import {
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { createDebugLogger } from '@aztec/foundation/log';
import { InMemoryTxPool, P2P, createP2PClient } from '@aztec/p2p';
import { SequencerClient, getCombinedHistoricTreeRoots } from '@aztec/sequencer-client';
import {
PublicProcessor,
PublicProcessorFactory,
SequencerClient,
getCombinedHistoricTreeRoots,
} from '@aztec/sequencer-client';
import {
AztecNode,
ContractData,
Expand Down Expand Up @@ -57,6 +62,7 @@ export class AztecNodeService implements AztecNode {
protected sequencer: SequencerClient,
protected chainId: number,
protected version: number,
protected publicProcessor: PublicProcessor,
private log = createDebugLogger('aztec:node'),
) {}

Expand All @@ -83,14 +89,17 @@ export class AztecNodeService implements AztecNode {
// start both and wait for them to sync from the block source
await Promise.all([p2pClient.start(), worldStateSynchroniser.start()]);

const publicProcessorFactory = new PublicProcessorFactory(worldStateSynchroniser.getLatest(), archiver, archiver);
const publicProcessor = publicProcessorFactory.create();

// now create the sequencer
const sequencer = await SequencerClient.new(
config,
p2pClient,
worldStateSynchroniser,
archiver,
archiver,
archiver,
publicProcessor,
);
return new AztecNodeService(
p2pClient,
Expand All @@ -104,6 +113,7 @@ export class AztecNodeService implements AztecNode {
sequencer,
config.chainId,
config.version,
publicProcessor,
);
}

Expand Down
12 changes: 5 additions & 7 deletions yarn-project/sequencer-client/src/client/sequencer-client.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { P2P } from '@aztec/p2p';
import { ContractDataSource, L1ToL2MessageSource, L2BlockSource } from '@aztec/types';
import { L1ToL2MessageSource, L2BlockSource } from '@aztec/types';
import { WorldStateSynchroniser } from '@aztec/world-state';

import { SoloBlockBuilder } from '../block_builder/solo_block_builder.js';
import { SequencerClientConfig } from '../config.js';
import { getGlobalVariableBuilder } from '../global_variable_builder/index.js';
import { Sequencer, getL1Publisher, getVerificationKeys } from '../index.js';
import { EmptyRollupProver } from '../prover/empty.js';
import { PublicProcessorFactory } from '../sequencer/public_processor.js';
import { PublicProcessor } from '../sequencer/public_processor.js';
import { WasmRollupCircuitSimulator } from '../simulator/rollup.js';

/**
Expand All @@ -21,18 +21,18 @@ export class SequencerClient {
* @param config - Configuration for the sequencer, publisher, and L1 tx sender.
* @param p2pClient - P2P client that provides the txs to be sequenced.
* @param worldStateSynchroniser - Provides access to world state.
* @param contractDataSource - Provides access to contract bytecode for public executions.
* @param l2BlockSource - Provides information about the previously published blocks.
* @param l1ToL2MessageSource - Provides access to L1 to L2 messages.
* @param publicProcessor - Public processor.
* @returns A new running instance.
*/
public static async new(
config: SequencerClientConfig,
p2pClient: P2P,
worldStateSynchroniser: WorldStateSynchroniser,
contractDataSource: ContractDataSource,
l2BlockSource: L2BlockSource,
l1ToL2MessageSource: L1ToL2MessageSource,
publicProcessor: PublicProcessor,
) {
const publisher = getL1Publisher(config);
const globalsBuilder = getGlobalVariableBuilder(config);
Expand All @@ -45,8 +45,6 @@ export class SequencerClient {
new EmptyRollupProver(),
);

const publicProcessorFactory = new PublicProcessorFactory(merkleTreeDb, contractDataSource, l1ToL2MessageSource);

const sequencer = new Sequencer(
publisher,
globalsBuilder,
Expand All @@ -55,7 +53,7 @@ export class SequencerClient {
blockBuilder,
l2BlockSource,
l1ToL2MessageSource,
publicProcessorFactory,
publicProcessor,
config,
);

Expand Down
1 change: 1 addition & 0 deletions yarn-project/sequencer-client/src/sequencer/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './sequencer.js';
export * from './config.js';
export * from './utils.js';
export * from './public_processor.js';
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ describe('sequencer', () => {
makeEmptyProcessedTx: () => makeEmptyProcessedTx(CombinedHistoricTreeRoots.empty(), chainId, version),
});

publicProcessorFactory = mock<PublicProcessorFactory>({
create: () => publicProcessor,
});

l2BlockSource = mock<L2BlockSource>({
getBlockHeight: () => Promise.resolve(lastBlockNumber),
});
Expand All @@ -80,7 +76,7 @@ describe('sequencer', () => {
blockBuilder,
l2BlockSource,
l1ToL2MessageSource,
publicProcessorFactory,
publicProcessor,
{
chainId: Number(chainId.value),
version: Number(version.value),
Expand Down
9 changes: 4 additions & 5 deletions yarn-project/sequencer-client/src/sequencer/sequencer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { L1Publisher } from '../publisher/l1-publisher.js';
import { ceilPowerOfTwo } from '../utils.js';
import { SequencerConfig } from './config.js';
import { ProcessedTx } from './processed_tx.js';
import { PublicProcessorFactory } from './public_processor.js';
import { PublicProcessor } from './public_processor.js';

/**
* Sequencer client
Expand Down Expand Up @@ -51,7 +51,7 @@ export class Sequencer {
private blockBuilder: BlockBuilder,
private l2BlockSource: L2BlockSource,
private l1ToL2MessageSource: L1ToL2MessageSource,
private publicProcessorFactory: PublicProcessorFactory,
private publicProcessor: PublicProcessor,
config: SequencerConfig,
private log = createDebugLogger('aztec:sequencer'),
) {
Expand Down Expand Up @@ -145,8 +145,7 @@ export class Sequencer {

// Process txs and drop the ones that fail processing
// We create a fresh processor each time to reset any cached state (eg storage writes)
const processor = this.publicProcessorFactory.create();
const [processedTxs, failedTxs] = await processor.process(validTxs, globalVariables);
const [processedTxs, failedTxs] = await this.publicProcessor.process(validTxs, globalVariables);
if (failedTxs.length > 0) {
this.log(`Dropping failed txs ${(await Tx.getHashes(failedTxs)).join(', ')}`);
await this.p2pClient.deleteTxs(await Tx.getHashes(failedTxs));
Expand All @@ -164,7 +163,7 @@ export class Sequencer {

// Build the new block by running the rollup circuits
this.log(`Assembling block with txs ${processedTxs.map(tx => tx.hash).join(', ')}`);
const emptyTx = await processor.makeEmptyProcessedTx(this.chainId, this.version);
const emptyTx = await this.publicProcessor.makeEmptyProcessedTx(this.chainId, this.version);

const block = await this.buildBlock(processedTxs, l1ToL2Messages, emptyTx, globalVariables);
this.log(`Assembled block ${block.number}`);
Expand Down