Skip to content

Commit

Permalink
chore: integrate
Browse files Browse the repository at this point in the history
  • Loading branch information
Maddiaa0 committed Jan 3, 2025
1 parent 0963450 commit 93b98da
Show file tree
Hide file tree
Showing 18 changed files with 95 additions and 63 deletions.
4 changes: 4 additions & 0 deletions yarn-project/archiver/src/archiver/archiver.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { type BlobSinkClientInterface } from '@aztec/blob-sink/client';
import { InboxLeaf, type L1RollupConstants, L2Block } from '@aztec/circuit-types';
import { GENESIS_ARCHIVE_ROOT, PrivateLog } from '@aztec/circuits.js';
import { DefaultL1ContractsConfig } from '@aztec/ethereum';
Expand Down Expand Up @@ -53,6 +54,7 @@ describe('Archiver', () => {

let publicClient: MockProxy<PublicClient<HttpTransport, Chain>>;
let instrumentation: MockProxy<ArchiverInstrumentation>;
let blobSinkClient: MockProxy<BlobSinkClientInterface>;
let archiverStore: ArchiverDataStore;
let now: number;
let l1Constants: L1RollupConstants;
Expand Down Expand Up @@ -92,6 +94,7 @@ describe('Archiver', () => {
);
}) as any,
});
blobSinkClient = mock<BlobSinkClientInterface>();

const tracer = new NoopTelemetryClient().getTracer();
instrumentation = mock<ArchiverInstrumentation>({ isEnabled: () => true, tracer });
Expand All @@ -109,6 +112,7 @@ describe('Archiver', () => {
{ rollupAddress, inboxAddress, registryAddress },
archiverStore,
{ pollingIntervalMs: 1000, batchSize: 1000 },
blobSinkClient,
instrumentation,
l1Constants,
);
Expand Down
8 changes: 6 additions & 2 deletions yarn-project/archiver/src/archiver/archiver.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { type BlobSinkClientInterface, createBlobSinkClient } from '@aztec/blob-sink/client';
import {
type GetUnencryptedLogsResponse,
type InBlock,
Expand Down Expand Up @@ -51,6 +52,7 @@ import {
} from '@aztec/protocol-contracts/class-registerer';
import { ContractInstanceDeployedEvent } from '@aztec/protocol-contracts/instance-deployer';
import { Attributes, type TelemetryClient, type Traceable, type Tracer, trackSpan } from '@aztec/telemetry-client';
import { NoopTelemetryClient } from '@aztec/telemetry-client/noop';

import groupBy from 'lodash.groupby';
import {
Expand Down Expand Up @@ -115,6 +117,7 @@ export class Archiver implements ArchiveSource, Traceable {
private readonly l1Addresses: { rollupAddress: EthAddress; inboxAddress: EthAddress; registryAddress: EthAddress },
readonly dataStore: ArchiverDataStore,
private readonly config: { pollingIntervalMs: number; batchSize: number },
private readonly _blobSinkClient: BlobSinkClientInterface,
private readonly instrumentation: ArchiverInstrumentation,
private readonly l1constants: L1RollupConstants,
private readonly log: Logger = createLogger('archiver'),
Expand Down Expand Up @@ -145,7 +148,7 @@ export class Archiver implements ArchiveSource, Traceable {
public static async createAndSync(
config: ArchiverConfig,
archiverStore: ArchiverDataStore,
telemetry: TelemetryClient,
deps: { telemetry: TelemetryClient; blobSinkClient: BlobSinkClientInterface },
blockUntilSynced = true,
): Promise<Archiver> {
const chain = createEthereumChain(config.l1RpcUrl, config.l1ChainId);
Expand Down Expand Up @@ -176,7 +179,8 @@ export class Archiver implements ArchiveSource, Traceable {
pollingIntervalMs: config.archiverPollingIntervalMS ?? 10_000,
batchSize: config.archiverBatchSize ?? 100,
},
await ArchiverInstrumentation.new(telemetry, () => archiverStore.estimateSize()),
deps.blobSinkClient,
await ArchiverInstrumentation.new(deps.telemetry, () => archiverStore.estimateSize()),
{ l1StartBlock, l1GenesisTime, epochDuration, slotDuration, ethereumSlotDuration },
);
await archiver.start(blockUntilSynced);
Expand Down
4 changes: 3 additions & 1 deletion yarn-project/archiver/src/factory.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { type BlobSinkClientInterface } from '@aztec/blob-sink/client';
import { type ArchiverApi, type Service } from '@aztec/circuit-types';
import {
type ContractClassPublic,
Expand All @@ -23,6 +24,7 @@ import { createArchiverClient } from './rpc/index.js';

export async function createArchiver(
config: ArchiverConfig & DataStoreConfig,
blobSinkClient: BlobSinkClientInterface,
telemetry: TelemetryClient = new NoopTelemetryClient(),
opts: { blockUntilSync: boolean } = { blockUntilSync: true },
): Promise<ArchiverApi & Maybe<Service>> {
Expand All @@ -31,7 +33,7 @@ export async function createArchiver(
const archiverStore = new KVArchiverDataStore(store, config.maxLogs);
await registerProtocolContracts(archiverStore);
await registerCommonContracts(archiverStore);
return Archiver.createAndSync(config, archiverStore, telemetry, opts.blockUntilSync);
return Archiver.createAndSync(config, archiverStore, { telemetry, blobSinkClient }, opts.blockUntilSync);
} else {
return createArchiverClient(config.archiverUrl);
}
Expand Down
8 changes: 6 additions & 2 deletions yarn-project/aztec-node/src/aztec-node/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createArchiver } from '@aztec/archiver';
import { BBCircuitVerifier, TestCircuitVerifier } from '@aztec/bb-prover';
import { BlobSinkClientInterface, createBlobSinkClient } from '@aztec/blob-sink/client';
import {
type AztecNode,
type ClientProtocolCircuitVerifier,
Expand Down Expand Up @@ -140,11 +141,13 @@ export class AztecNodeService implements AztecNode, Traceable {
logger?: Logger;
publisher?: L1Publisher;
dateProvider?: DateProvider;
blobSinkClient?: BlobSinkClientInterface;
} = {},
): Promise<AztecNodeService> {
const telemetry = deps.telemetry ?? new NoopTelemetryClient();
const log = deps.logger ?? createLogger('node');
const dateProvider = deps.dateProvider ?? new DateProvider();
const blobSinkClient = deps.blobSinkClient ?? createBlobSinkClient(config.blobSinkUrl);
const ethereumChain = createEthereumChain(config.l1RpcUrl, config.l1ChainId);
//validate that the actual chain id matches that specified in configuration
if (config.l1ChainId !== ethereumChain.chainInfo.id) {
Expand All @@ -153,7 +156,7 @@ export class AztecNodeService implements AztecNode, Traceable {
);
}

const archiver = await createArchiver(config, telemetry, { blockUntilSync: true });
const archiver = await createArchiver(config, blobSinkClient, telemetry, { blockUntilSync: true });

// we identify the P2P transaction protocol by using the rollup contract address.
// this may well change in future
Expand Down Expand Up @@ -189,6 +192,7 @@ export class AztecNodeService implements AztecNode, Traceable {
const sequencer = config.disableValidator
? undefined
: await SequencerClient.new(config, {
...deps,
validatorClient,
p2pClient,
worldStateSynchronizer,
Expand All @@ -197,7 +201,7 @@ export class AztecNodeService implements AztecNode, Traceable {
l1ToL2MessageSource: archiver,
telemetry,
dateProvider,
...deps,
blobSinkClient,
});

return new AztecNodeService(
Expand Down
5 changes: 4 additions & 1 deletion yarn-project/aztec/src/cli/cmds/start_archiver.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Archiver, type ArchiverConfig, KVArchiverDataStore, archiverConfigMappings } from '@aztec/archiver';
import { createLogger } from '@aztec/aztec.js';
import { createBlobSinkClient } from '@aztec/blob-sink/client';
import { ArchiverApiSchema } from '@aztec/circuit-types';
import { type NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
Expand Down Expand Up @@ -31,7 +32,9 @@ export async function startArchiver(
const archiverStore = new KVArchiverDataStore(store, archiverConfig.maxLogs);

const telemetry = await createAndStartTelemetryClient(getTelemetryClientConfig());
const archiver = await Archiver.createAndSync(archiverConfig, archiverStore, telemetry, true);
// TODO(ISSUE): place CL url in config here
const blobSinkClient = createBlobSinkClient();
const archiver = await Archiver.createAndSync(archiverConfig, archiverStore, { telemetry, blobSinkClient }, true);
services.archiver = [archiver, ArchiverApiSchema];
signalHandlers.push(archiver.stop);
return services;
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec/src/cli/cmds/start_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export async function startNode(
const telemetry = await createAndStartTelemetryClient(telemetryConfig);

// Create and start Aztec Node
const node = await createAztecNode(nodeConfig, telemetry);
const node = await createAztecNode(nodeConfig, { telemetry });

// Add node and p2p to services list
services.node = [node, AztecNodeApiSchema];
Expand Down
14 changes: 10 additions & 4 deletions yarn-project/aztec/src/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
import { AnvilTestWatcher, EthCheatCodes, SignerlessWallet, retryUntil } from '@aztec/aztec.js';
import { DefaultMultiCallEntrypoint } from '@aztec/aztec.js/entrypoint';
import { type BlobSinkClientInterface, createBlobSinkClient } from '@aztec/blob-sink/client';
import { type AztecNode } from '@aztec/circuit-types';
import { setupCanonicalL2FeeJuice } from '@aztec/cli/setup-contracts';
import {
Expand Down Expand Up @@ -143,8 +144,10 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}) {
await watcher.start();
}

const client = await createAndStartTelemetryClient(getTelemetryClientConfig());
const node = await createAztecNode(aztecNodeConfig, client);
const telemetry = await createAndStartTelemetryClient(getTelemetryClientConfig());
// Create a local blob sink client inside the sandbox, no http connectivity
const blobSinkClient = createBlobSinkClient();
const node = await createAztecNode(aztecNodeConfig, { telemetry, blobSinkClient });
const pxe = await createAztecPXE(node);

if (config.enableGas) {
Expand All @@ -168,9 +171,12 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}) {
* Create and start a new Aztec RPC HTTP Server
* @param config - Optional Aztec node settings.
*/
export async function createAztecNode(config: Partial<AztecNodeConfig> = {}, telemetryClient?: TelemetryClient) {
export async function createAztecNode(
config: Partial<AztecNodeConfig> = {},
deps: { telemetry?: TelemetryClient; blobSinkClient?: BlobSinkClientInterface } = {},
) {
const aztecNodeConfig: AztecNodeConfig = { ...getConfigEnvVars(), ...config };
const node = await AztecNodeService.createAndSync(aztecNodeConfig, { telemetry: telemetryClient });
const node = await AztecNodeService.createAndSync(aztecNodeConfig, deps);
return node;
}

Expand Down
1 change: 0 additions & 1 deletion yarn-project/blob-sink/src/client/http.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe('HttpBlobSinkClient', () => {
await server.start();

const client = new HttpBlobSinkClient(`http://localhost:${server.port}`);
console.log(`HttpBlobSinkClient listening on port ${server.port}`);

return {
client,
Expand Down
1 change: 0 additions & 1 deletion yarn-project/blob-sink/src/client/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export class HttpBlobSinkClient implements BlobSinkClientInterface {
this.log.error('Failed to get blob sidecar', res.status);
return [];
} catch (err) {
console.log('err', err);
this.log.error(`Error getting blob sidecar`, err);
return [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ describe('L1Publisher integration', () => {
ethereumSlotDuration: config.ethereumSlotDuration,
blobSinkUrl: BLOB_SINK_URL,
},
new NoopTelemetryClient(),
{ telemetry: new NoopTelemetryClient() },
);

coinbase = config.coinbase || EthAddress.random();
Expand Down
8 changes: 8 additions & 0 deletions yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {
TestCircuitVerifier,
type UltraKeccakHonkProtocolArtifact,
} from '@aztec/bb-prover';
import { createBlobSinkClient } from '@aztec/blob-sink/client';
import { type BlobSinkServer } from '@aztec/blob-sink/server';
import { compileContract } from '@aztec/ethereum';
import { Buffer32 } from '@aztec/foundation/buffer';
import { RollupAbi, TestERC20Abi } from '@aztec/l1-artifacts';
Expand Down Expand Up @@ -76,6 +78,7 @@ export class FullProverTest {
aztecNode!: AztecNode;
pxe!: PXEService;
cheatCodes!: CheatCodes;
blobSink!: BlobSinkServer;
private provenComponents: ProvenSetup[] = [];
private bbConfigCleanup?: () => Promise<void>;
private acvmConfigCleanup?: () => Promise<void>;
Expand Down Expand Up @@ -163,8 +166,11 @@ export class FullProverTest {
aztecNode: this.aztecNode,
deployL1ContractsValues: this.l1Contracts,
cheatCodes: this.cheatCodes,
blobSink: this.blobSink,
} = this.context);

const blobSinkClient = createBlobSinkClient(`http://localhost:${this.blobSink.port}`);

// Configure a full prover PXE
let acvmConfig: Awaited<ReturnType<typeof getACVMConfig>> | undefined;
let bbConfig: Awaited<ReturnType<typeof getBBConfig>> | undefined;
Expand Down Expand Up @@ -247,6 +253,7 @@ export class FullProverTest {
this.logger.verbose('Starting archiver for new prover node');
const archiver = await createArchiver(
{ ...this.context.aztecNodeConfig, dataDirectory: undefined },
blobSinkClient,
new NoopTelemetryClient(),
{ blockUntilSync: true },
);
Expand Down Expand Up @@ -279,6 +286,7 @@ export class FullProverTest {
this.proverNode = await createProverNode(proverConfig, {
aztecNodeTxProvider: this.aztecNode,
archiver: archiver as Archiver,
blobSinkClient,
});
await this.proverNode.start();

Expand Down
10 changes: 8 additions & 2 deletions yarn-project/end-to-end/src/e2e_synching.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
createLogger,
sleep,
} from '@aztec/aztec.js';
import { createBlobSinkClient } from '@aztec/blob-sink/client';
// eslint-disable-next-line no-restricted-imports
import { L2Block, tryStop } from '@aztec/circuit-types';
import { type AztecAddress } from '@aztec/circuits.js';
Expand Down Expand Up @@ -382,6 +383,8 @@ describe('e2e_synching', () => {
await (sequencer as any).stop();
await watcher?.stop();

const blobSinkClient = createBlobSinkClient(`http://localhost:${blobSink?.port ?? 5052}`);

const sequencerPK: `0x${string}` = `0x${getPrivateKeyFromIndex(0)!.toString('hex')}`;
const publisher = new L1Publisher(
{
Expand All @@ -395,7 +398,7 @@ describe('e2e_synching', () => {
ethereumSlotDuration: ETHEREUM_SLOT_DURATION,
blobSinkUrl: `http://localhost:${blobSink?.port ?? 5052}`,
},
new NoopTelemetryClient(),
{ telemetry: new NoopTelemetryClient(), blobSinkClient },
);

const blocks = variant.loadBlocks();
Expand Down Expand Up @@ -498,7 +501,10 @@ describe('e2e_synching', () => {
await aztecNode.stop();
}

const archiver = await createArchiver(opts.config!);
const blobSinkClient = createBlobSinkClient(`http://localhost:${opts.blobSink?.port ?? 5052}`);
const archiver = await createArchiver(opts.config!, blobSinkClient, new NoopTelemetryClient(), {
blockUntilSync: true,
});
const pendingBlockNumber = await rollup.read.getPendingBlockNumber();

const worldState = await createWorldStateSynchronizer(opts.config!, archiver, new NoopTelemetryClient());
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/src/fixtures/snapshot_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
type Wallet,
} from '@aztec/aztec.js';
import { deployInstance, registerContractClass } from '@aztec/aztec.js/deployment';
import { type BlobSinkServer, createBlobSinkServer } from '@aztec/blob-sink';
import { type BlobSinkServer, createBlobSinkServer } from '@aztec/blob-sink/server';
import { type DeployL1ContractsArgs, createL1Clients, getL1ContractsConfigEnvVars, l1Artifacts } from '@aztec/ethereum';
import { EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
import { asyncMap } from '@aztec/foundation/async-map';
Expand Down
22 changes: 17 additions & 5 deletions yarn-project/end-to-end/src/fixtures/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import {
import { deployInstance, registerContractClass } from '@aztec/aztec.js/deployment';
import { DefaultMultiCallEntrypoint } from '@aztec/aztec.js/entrypoint';
import { type BBNativePrivateKernelProver } from '@aztec/bb-prover';
import { type BlobSinkServer, createBlobSinkServer } from '@aztec/blob-sink';
import { createBlobSinkClient } from '@aztec/blob-sink/client';
import { type BlobSinkServer, createBlobSinkServer } from '@aztec/blob-sink/server';
import { type EthAddress, FEE_JUICE_INITIAL_MINT, Fr, Gas, getContractClassFromArtifact } from '@aztec/circuits.js';
import {
type DeployL1ContractsArgs,
Expand Down Expand Up @@ -453,8 +454,15 @@ export async function setup(
config.l1PublishRetryIntervalMS = 100;

const telemetry = await telemetryPromise;
const publisher = new TestL1Publisher(config, telemetry);
const aztecNode = await AztecNodeService.createAndSync(config, { telemetry, publisher, dateProvider });

const blobSinkClient = createBlobSinkClient(config.blobSinkUrl);
const publisher = new TestL1Publisher(config, { telemetry, blobSinkClient });
const aztecNode = await AztecNodeService.createAndSync(config, {
telemetry,
publisher,
dateProvider,
blobSinkClient,
});
const sequencer = aztecNode.getSequencer();

let proverNode: ProverNode | undefined = undefined;
Expand Down Expand Up @@ -724,9 +732,13 @@ export async function createAndSyncProverNode(
stop: () => Promise.resolve(),
};

const blobSinkClient = createBlobSinkClient();
// Creating temp store and archiver for simulated prover node
const archiverConfig = { ...aztecNodeConfig, dataDirectory };
const archiver = await createArchiver(archiverConfig, new NoopTelemetryClient(), { blockUntilSync: true });
const telemetry = new NoopTelemetryClient();
const archiver = await createArchiver(archiverConfig, blobSinkClient, telemetry, {
blockUntilSync: true,
});

// Prover node config is for simulated proofs
const proverConfig: ProverNodeConfig = {
Expand All @@ -747,7 +759,7 @@ export async function createAndSyncProverNode(
};

// Use testing l1 publisher
const publisher = new TestL1Publisher(proverConfig, new NoopTelemetryClient());
const publisher = new TestL1Publisher(proverConfig, { telemetry, blobSinkClient });

const proverNode = await createProverNode(proverConfig, {
aztecNodeTxProvider: aztecNodeWithoutStop,
Expand Down
Loading

0 comments on commit 93b98da

Please sign in to comment.