Skip to content
Merged
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
2 changes: 2 additions & 0 deletions spartan/aztec-network/templates/pxe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ spec:
value: "{{ .Values.telemetry.useGcloudObservability }}"
- name: OTEL_EXCLUDE_METRICS
value: "{{ .Values.telemetry.excludeMetrics }}"
- name: L1_CHAIN_ID
value: "{{ .Values.ethereum.chainId }}"
ports:
- name: http
containerPort: {{ .Values.pxe.service.nodePort }}
Expand Down
2 changes: 2 additions & 0 deletions spartan/aztec-network/templates/transaction-bot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ spec:
value: "{{ .Values.telemetry.useGcloudObservability }}"
- name: OTEL_EXCLUDE_METRICS
value: "{{ .Values.telemetry.excludeMetrics }}"
- name: L1_CHAIN_ID
value: "{{ .Values.ethereum.chainId }}"
ports:
- name: http
containerPort: {{ .Values.bot.service.nodePort }}
Expand Down
1 change: 1 addition & 0 deletions yarn-project/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ noir-protocol-circuits-types/src/private_kernel_reset_data.ts
noir-protocol-circuits-types/src/private_kernel_reset_vks.ts
noir-protocol-circuits-types/src/private_kernel_reset_types.ts
noir-protocol-circuits-types/src/client_artifacts_helper.ts
noir-protocol-circuits-types/src/vk_tree.ts
noir-protocol-circuits-types/src/types/
ivc-integration/artifacts
ivc-integration/src/types/
Expand Down
1 change: 1 addition & 0 deletions yarn-project/archiver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"@aztec/kv-store": "workspace:^",
"@aztec/l1-artifacts": "workspace:^",
"@aztec/noir-contracts.js": "workspace:^",
"@aztec/noir-protocol-circuits-types": "workspace:^",
"@aztec/protocol-contracts": "workspace:^",
"@aztec/telemetry-client": "workspace:^",
"@aztec/types": "workspace:^",
Expand Down
5 changes: 4 additions & 1 deletion yarn-project/archiver/src/archiver/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { type ChainConfig, chainConfigMappings } from '@aztec/circuit-types/config';
import {
type L1ContractAddresses,
type L1ContractsConfig,
Expand Down Expand Up @@ -39,7 +40,8 @@ export type ArchiverConfig = {
/** The max number of logs that can be obtained in 1 "getPublicLogs" call. */
maxLogs?: number;
} & L1ReaderConfig &
L1ContractsConfig;
L1ContractsConfig &
ChainConfig;

export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
archiverUrl: {
Expand Down Expand Up @@ -67,6 +69,7 @@ export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
description: 'The max number of logs that can be obtained in 1 "getPublicLogs" call.',
...numberConfigHelper(1_000),
},
...chainConfigMappings,
...l1ReaderConfigMappings,
viemPollingIntervalMS: {
env: 'ARCHIVER_VIEM_POLLING_INTERVAL_MS',
Expand Down
10 changes: 7 additions & 3 deletions yarn-project/archiver/src/factory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type BlobSinkClientInterface } from '@aztec/blob-sink/client';
import { type ArchiverApi, type Service } from '@aztec/circuit-types';
import { type ArchiverApi, type Service, getComponentsVersionsFromConfig } from '@aztec/circuit-types';
import {
type ContractClassPublic,
computePublicBytecodeCommitment,
Expand All @@ -12,7 +12,8 @@ import { type DataStoreConfig } from '@aztec/kv-store/config';
import { createStore } from '@aztec/kv-store/lmdb-v2';
import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token';
import { TokenBridgeContractArtifact } from '@aztec/noir-contracts.js/TokenBridge';
import { protocolContractNames } from '@aztec/protocol-contracts';
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vks';
import { protocolContractNames, protocolContractTreeRoot } from '@aztec/protocol-contracts';
import { getCanonicalProtocolContract } from '@aztec/protocol-contracts/bundle';
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';

Expand All @@ -34,7 +35,10 @@ export async function createArchiver(
await registerCommonContracts(archiverStore);
return Archiver.createAndSync(config, archiverStore, { telemetry, blobSinkClient }, opts.blockUntilSync);
} else {
return createArchiverClient(config.archiverUrl);
return createArchiverClient(
config.archiverUrl,
getComponentsVersionsFromConfig(config, protocolContractTreeRoot, getVKTreeRoot()),
);
}
}

Expand Down
19 changes: 16 additions & 3 deletions yarn-project/archiver/src/rpc/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
import { type ArchiverApi, ArchiverApiSchema } from '@aztec/circuit-types';
import {
type ArchiverApi,
ArchiverApiSchema,
type ComponentsVersions,
getVersioningResponseHandler,
} from '@aztec/circuit-types';
import { createSafeJsonRpcClient } from '@aztec/foundation/json-rpc/client';
import { createTracedJsonRpcServer, makeTracedFetch } from '@aztec/telemetry-client';

export function createArchiverClient(url: string, fetch = makeTracedFetch([1, 2, 3], true)): ArchiverApi {
return createSafeJsonRpcClient<ArchiverApi>(url, ArchiverApiSchema, false, 'archiver', fetch);
export function createArchiverClient(
url: string,
versions: Partial<ComponentsVersions>,
fetch = makeTracedFetch([1, 2, 3], true),
): ArchiverApi {
return createSafeJsonRpcClient<ArchiverApi>(url, ArchiverApiSchema, {
namespaceMethods: 'archiver',
fetch,
onResponse: getVersioningResponseHandler(versions),
});
}

export function createArchiverRpcServer(handler: ArchiverApi) {
Expand Down
3 changes: 3 additions & 0 deletions yarn-project/archiver/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
{
"path": "../noir-contracts.js"
},
{
"path": "../noir-protocol-circuits-types"
},
{
"path": "../protocol-contracts"
},
Expand Down
5 changes: 0 additions & 5 deletions yarn-project/aztec-node/src/aztec-node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,6 @@ export class AztecNodeService implements AztecNode, Traceable {

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

// we identify the P2P transaction protocol by using the rollup contract address.
// this may well change in future
const rollupAddress = config.l1Contracts.rollupAddress;
config.transactionProtocol = `/aztec/tx/${rollupAddress.toString()}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the interest of cleaning up config i can remove this from config in a follow up


// now create the merkle trees and the world state synchronizer
const worldStateSynchronizer = await createWorldStateSynchronizer(config, archiver, telemetry);
const proofVerifier = config.realProofs ? await BBCircuitVerifier.new(config) : new TestCircuitVerifier();
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec.js/src/api/ethereum/l1_contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { retryUntil } from '@aztec/foundation/retry';
import { createPXEClient } from '../../rpc_clients/index.js';

export const getL1ContractAddresses = async (url: string): Promise<L1ContractAddresses> => {
const pxeClient = createPXEClient(url);
const pxeClient = createPXEClient(url, {});
const response = await retryUntil(
async () => {
try {
Expand Down
20 changes: 14 additions & 6 deletions yarn-project/aztec.js/src/rpc_clients/node/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type PXE } from '@aztec/circuit-types';
import { type ComponentsVersions, type PXE } from '@aztec/circuit-types';
import { jsonStringify } from '@aztec/foundation/json-rpc';
import { type Logger } from '@aztec/foundation/log';
import { type Logger, createLogger } from '@aztec/foundation/log';
import { NoRetryError, makeBackoff, retry } from '@aztec/foundation/retry';

import { Axios, type AxiosError } from 'axios';
Expand Down Expand Up @@ -33,9 +33,13 @@ async function axiosFetch(host: string, rpcMethod: string, body: any, useApiEndp

const isOK = resp.status >= 200 && resp.status < 300;
if (isOK) {
return resp.data;
const headers = {
get: (header: string) =>
typeof resp.headers.get === 'function' ? resp.headers.get(header)?.toString() : undefined,
};
return { response: resp.data, headers };
} else {
const errorMessage = `(JSON-RPC PROPAGATED) (host ${host}) (method ${rpcMethod}) (code ${resp.status}) ${resp.data.error.message}`;
const errorMessage = `Error ${resp.status} from json-rpc server ${host} on ${rpcMethod}: ${resp.data.error.message}`;
if (resp.status >= 400 && resp.status < 500) {
throw new NoRetryError(errorMessage);
} else {
Expand All @@ -51,7 +55,11 @@ async function axiosFetch(host: string, rpcMethod: string, body: any, useApiEndp
* @param _logger - Debug logger to warn version incompatibilities.
* @returns A PXE client.
*/
export function createCompatibleClient(rpcUrl: string, logger: Logger): Promise<PXE> {
export function createCompatibleClient(
rpcUrl: string,
logger: Logger = createLogger('aztecjs:pxe_client'),
versions: Partial<ComponentsVersions> = {},
): Promise<PXE> {
// Use axios due to timeout issues with fetch when proving TXs.
const fetch = async (host: string, rpcMethod: string, body: any, useApiEndpoints: boolean) => {
return await retry(
Expand All @@ -62,7 +70,7 @@ export function createCompatibleClient(rpcUrl: string, logger: Logger): Promise<
false,
);
};
const pxe = createPXEClient(rpcUrl, fetch);
const pxe = createPXEClient(rpcUrl, versions, fetch);

return Promise.resolve(pxe);
}
17 changes: 15 additions & 2 deletions yarn-project/aztec.js/src/rpc_clients/pxe_client.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
import { type ComponentsVersions, getVersioningResponseHandler } from '@aztec/circuit-types';
import { type PXE, PXESchema } from '@aztec/circuit-types/interfaces';
import { createSafeJsonRpcClient, makeFetch } from '@aztec/foundation/json-rpc/client';
import { protocolContractTreeRoot } from '@aztec/protocol-contracts';

/**
* Creates a JSON-RPC client to remotely talk to PXE.
* @param url - The URL of the PXE.
* @param fetch - The fetch implementation to use.
* @returns A JSON-RPC client of PXE.
*/
export function createPXEClient(url: string, fetch = makeFetch([1, 2, 3], false)): PXE {
return createSafeJsonRpcClient<PXE>(url, PXESchema, false, 'pxe', fetch);
export function createPXEClient(
url: string,
versions: Partial<ComponentsVersions> = {},
fetch = makeFetch([1, 2, 3], false),
): PXE {
return createSafeJsonRpcClient<PXE>(url, PXESchema, {
namespaceMethods: 'pxe',
fetch,
onResponse: getVersioningResponseHandler({
l2ProtocolContractsTreeRoot: protocolContractTreeRoot.toString(),
...versions,
}),
});
}
21 changes: 12 additions & 9 deletions yarn-project/aztec/src/cli/aztec_start_action.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { deployInitialTestAccounts } from '@aztec/accounts/testing';
import { AztecNodeApiSchema, PXESchema } from '@aztec/circuit-types';
import { AztecNodeApiSchema, PXESchema, getVersioningMiddleware } from '@aztec/circuit-types';
import { type ChainConfig } from '@aztec/circuit-types/config';
import {
type NamespacedApiHandlers,
createNamespacedSafeJsonRpcServer,
Expand All @@ -15,6 +16,7 @@ import { dirname, resolve } from 'path';
import { createSandbox } from '../sandbox.js';
import { github, splash } from '../splash.js';
import { createAccountLogs, extractNamespacedOptions, installSignalHandlers } from './util.js';
import { getVersions } from './versioning.js';

const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../../package.json');
const cliVersion: string = JSON.parse(readFileSync(packageJsonPath).toString()).version;
Expand All @@ -23,6 +25,7 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
// list of 'stop' functions to call when process ends
const signalHandlers: Array<() => Promise<void>> = [];
const services: NamespacedApiHandlers = {};
let config: ChainConfig | undefined = undefined;

if (options.sandbox) {
const sandboxOptions = extractNamespacedOptions(options, 'sandbox');
Expand Down Expand Up @@ -61,7 +64,7 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
} else {
if (options.node) {
const { startNode } = await import('./cmds/start_node.js');
await startNode(options, signalHandlers, services, userLog);
({ config } = await startNode(options, signalHandlers, services, userLog));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice

} else if (options.proofVerifier) {
const { startProofVerifier } = await import('./cmds/start_proof_verifier.js');
await startProofVerifier(options, signalHandlers, userLog);
Expand All @@ -70,16 +73,16 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
await startBot(options, signalHandlers, services, userLog);
} else if (options.proverNode) {
const { startProverNode } = await import('./cmds/start_prover_node.js');
await startProverNode(options, signalHandlers, services, userLog);
({ config } = await startProverNode(options, signalHandlers, services, userLog));
} else if (options.pxe) {
const { startPXE } = await import('./cmds/start_pxe.js');
await startPXE(options, signalHandlers, services, userLog);
({ config } = await startPXE(options, signalHandlers, services, userLog));
} else if (options.archiver) {
const { startArchiver } = await import('./cmds/start_archiver.js');
await startArchiver(options, signalHandlers, services);
({ config } = await startArchiver(options, signalHandlers, services));
} else if (options.p2pBootstrap) {
const { startP2PBootstrap } = await import('./cmds/start_p2p_bootstrap.js');
await startP2PBootstrap(options, signalHandlers, services, userLog);
({ config } = await startP2PBootstrap(options, signalHandlers, services, userLog));
} else if (options.proverAgent) {
const { startProverAgent } = await import('./cmds/start_prover_agent.js');
await startProverAgent(options, signalHandlers, services, userLog);
Expand All @@ -102,14 +105,14 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
}

installSignalHandlers(debugLogger.info, signalHandlers);

const versions = getVersions(config);
if (Object.entries(services).length > 0) {
const rpcServer = createNamespacedSafeJsonRpcServer(services, {
http200OnError: false,
log: debugLogger,
middlewares: [getOtelJsonRpcPropagationMiddleware()],
middlewares: [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions)],
});
const { port } = await startHttpRpcServer(rpcServer, { port: options.port });
debugLogger.info(`Aztec Server listening on port ${port}`);
debugLogger.info(`Aztec Server listening on port ${port}`, versions);
}
}
7 changes: 5 additions & 2 deletions yarn-project/aztec/src/cli/cmds/start_archiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } fro
import { extractRelevantOptions } from '../util.js';
import { validateL1Config } from '../validation.js';

export type { ArchiverConfig, DataStoreConfig };

/** Starts a standalone archiver. */
export async function startArchiver(
options: any,
signalHandlers: (() => Promise<void>)[],
services: NamespacedApiHandlers,
) {
): Promise<{ config: ArchiverConfig & DataStoreConfig }> {
const archiverConfig = extractRelevantOptions<ArchiverConfig & DataStoreConfig>(
options,
{
Expand All @@ -43,5 +45,6 @@ export async function startArchiver(
const archiver = await Archiver.createAndSync(archiverConfig, archiverStore, { telemetry, blobSinkClient }, true);
services.archiver = [archiver, ArchiverApiSchema];
signalHandlers.push(archiver.stop);
return services;

return { config: archiverConfig };
}
2 changes: 1 addition & 1 deletion yarn-project/aztec/src/cli/cmds/start_bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function startBot(
let pxe: PXE | undefined;
if (options.pxe) {
const { addPXE } = await import('./start_pxe.js');
pxe = await addPXE(options, signalHandlers, services, userLog);
({ pxe } = await addPXE(options, signalHandlers, services, userLog));
}

const telemetry = initTelemetryClient(getTelemetryClientConfig());
Expand Down
4 changes: 3 additions & 1 deletion yarn-project/aztec/src/cli/cmds/start_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,14 @@ export async function startNode(
let pxe: PXE | undefined;
if (options.pxe) {
const { addPXE } = await import('./start_pxe.js');
pxe = await addPXE(options, signalHandlers, services, userLog, { node });
({ pxe } = await addPXE(options, signalHandlers, services, userLog, { node }));
}

// Add a txs bot if requested
if (options.bot) {
const { addBot } = await import('./start_bot.js');
await addBot(options, signalHandlers, services, { pxe, node, telemetry });
}

return { config: nodeConfig };
}
1 change: 1 addition & 0 deletions yarn-project/aztec/src/cli/cmds/start_p2p_bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ export async function startP2PBootstrap(
signalHandlers.push(() => node.stop());
services.bootstrap = [node, P2PBootstrapApiSchema];
userLog(`P2P bootstrap node started on ${config.udpListenAddress}`);
return { config };
}
3 changes: 2 additions & 1 deletion yarn-project/aztec/src/cli/cmds/start_prover_agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { getProverNodeAgentConfigFromEnv } from '@aztec/prover-node';
import { initTelemetryClient, telemetryClientConfigMappings } from '@aztec/telemetry-client';

import { extractRelevantOptions } from '../util.js';
import { getVersions } from '../versioning.js';

export async function startProverAgent(
options: any,
Expand All @@ -38,7 +39,7 @@ export async function startProverAgent(
process.exit(1);
}

const broker = createProvingJobBrokerClient(config.proverBrokerUrl);
const broker = createProvingJobBrokerClient(config.proverBrokerUrl, getVersions());

const telemetry = initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
const prover = await buildServerCircuitProver(config, telemetry);
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/aztec/src/cli/cmds/start_prover_broker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function startProverBroker(
signalHandlers: (() => Promise<void>)[],
services: NamespacedApiHandlers,
userLog: LogFn,
): Promise<ProvingJobBroker> {
): Promise<{ broker: ProvingJobBroker; config: ProverBrokerConfig }> {
if (options.node || options.sequencer || options.pxe || options.p2pBootstrap || options.txe) {
userLog(`Starting a prover broker with --node, --sequencer, --pxe, --p2p-bootstrap, or --txe is not supported.`);
process.exit(1);
Expand All @@ -33,5 +33,5 @@ export async function startProverBroker(
services.proverBroker = [broker, ProvingJobBrokerSchema];
signalHandlers.push(() => broker.stop());

return broker;
return { broker, config };
}
Loading