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
13 changes: 5 additions & 8 deletions spartan/environments/network-defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,6 @@ networks:
# P2P
P2P_MAX_PENDING_TX_COUNT: 1000
P2P_TX_POOL_DELETE_TXS_AFTER_REORG: false
# Auto-update
AUTO_UPDATE: none
AUTO_UPDATE_URL: ""
# Telemetry
PUBLIC_OTEL_OPT_OUT: true
PUBLIC_OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: ""
Expand All @@ -252,6 +249,7 @@ networks:
SLASH_UNKNOWN_PENALTY: 10e18
SLASH_INVALID_BLOCK_PENALTY: 10e18
SLASH_GRACE_PERIOD_L2_SLOTS: 0
ENABLE_VERSION_CHECK: true

testnet:
<<: *prodlike
Expand Down Expand Up @@ -296,6 +294,7 @@ networks:
SLASH_UNKNOWN_PENALTY: 10e18
SLASH_INVALID_BLOCK_PENALTY: 10e18
SLASH_GRACE_PERIOD_L2_SLOTS: 64
ENABLE_VERSION_CHECK: true

mainnet:
<<: *prodlike
Expand Down Expand Up @@ -338,12 +337,10 @@ networks:
# P2P
P2P_MAX_PENDING_TX_COUNT: 0
P2P_TX_POOL_DELETE_TXS_AFTER_REORG: true
# Auto-update
AUTO_UPDATE: notify
AUTO_UPDATE_URL: "https://storage.googleapis.com/aztec-mainnet/auto-update/mainnet.json"
# Telemetry
PUBLIC_OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: "https://telemetry.alpha-testnet.aztec-labs.com/v1/metrics"
PUBLIC_OTEL_COLLECT_FROM: sequencer
PUBLIC_OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: ""
PUBLIC_OTEL_COLLECT_FROM: ""
ENABLE_VERSION_CHECK: false
# Slasher penalties - more lenient initially
SLASH_PRUNE_PENALTY: 0
SLASH_DATA_WITHHOLDING_PENALTY: 0
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/aztec/src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import { injectCommands as injectMiscCommands } from '@aztec/cli/misc';
import { injectCommands as injectValidatorKeysCommands } from '@aztec/cli/validator_keys';
import { getActiveNetworkName } from '@aztec/foundation/config';
import { createConsoleLogger, createLogger } from '@aztec/foundation/log';
import { getPackageVersion } from '@aztec/stdlib/update-checker';

import { Command } from 'commander';

import { injectCompileCommand } from '../cli/cmds/compile.js';
import { injectMigrateCommand } from '../cli/cmds/migrate_ha_db.js';
import { injectProfileCommand } from '../cli/cmds/profile.js';
import { injectAztecCommands } from '../cli/index.js';
import { getCliVersion } from '../cli/release_version.js';

const NETWORK_FLAG = 'network';

Expand Down Expand Up @@ -47,7 +47,7 @@ async function main() {
await enrichEnvironmentWithNetworkConfig(networkName);
enrichEnvironmentWithChainName(networkName);

const cliVersion = getCliVersion();
const cliVersion = getPackageVersion() ?? 'unknown';
let program = new Command('aztec');
program.description('Aztec command line interface').version(cliVersion).enablePositionalOptions();
program = injectAztecCommands(program, userLog, debugLogger);
Expand Down
8 changes: 5 additions & 3 deletions yarn-project/aztec/src/cli/aztec_start_action.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getActiveNetworkName } from '@aztec/foundation/config';
import {
type NamespacedApiHandlers,
createNamespacedSafeJsonRpcServer,
Expand All @@ -7,13 +8,13 @@ import {
import type { LogFn, Logger } from '@aztec/foundation/log';
import type { ChainConfig } from '@aztec/stdlib/config';
import { AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
import { getPackageVersion } from '@aztec/stdlib/update-checker';
import { getVersioningMiddleware } from '@aztec/stdlib/versioning';
import { getOtelJsonRpcPropagationMiddleware } from '@aztec/telemetry-client';

import { createLocalNetwork } from '../local-network/index.js';
import { github, splash } from '../splash.js';
import { resolveAdminApiKey } from './admin_api_key_store.js';
import { getCliVersion } from './release_version.js';
import { extractNamespacedOptions, installSignalHandlers } from './util.js';
import { getVersions } from './versioning.js';

Expand All @@ -25,7 +26,7 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
let config: ChainConfig | undefined = undefined;

if (options.localNetwork) {
const cliVersion = getCliVersion();
const cliVersion = getPackageVersion() ?? 'unknown';
const localNetwork = extractNamespacedOptions(options, 'local-network');
localNetwork.testAccounts = true;
userLog(`${splash}\n${github}\n\n`);
Expand Down Expand Up @@ -57,7 +58,8 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg

if (options.node) {
const { startNode } = await import('./cmds/start_node.js');
({ config } = await startNode(options, signalHandlers, services, adminServices, userLog));
const networkName = getActiveNetworkName(options.network);
({ config } = await startNode(options, signalHandlers, services, adminServices, userLog, networkName));
} else if (options.bot) {
const { startBot } = await import('./cmds/start_bot.js');
await startBot(options, signalHandlers, services, userLog);
Expand Down
3 changes: 1 addition & 2 deletions yarn-project/aztec/src/cli/aztec_start_options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
env: 'NETWORK',
},

configToFlag('--auto-update', sharedNodeConfigMappings.autoUpdate),
configToFlag('--auto-update-url', sharedNodeConfigMappings.autoUpdateUrl),
configToFlag('--enable-version-check', sharedNodeConfigMappings.enableVersionCheck),

configToFlag('--sync-mode', sharedNodeConfigMappings.syncMode),
configToFlag('--snapshots-urls', sharedNodeConfigMappings.snapshotsUrls),
Expand Down
30 changes: 17 additions & 13 deletions yarn-project/aztec/src/cli/cmds/start_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
import { getL1Config } from '@aztec/cli/config';
import { getPublicClient } from '@aztec/ethereum/client';
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
import { SecretValue } from '@aztec/foundation/config';
import { EthAddress } from '@aztec/foundation/eth-address';
import { type NetworkNames, SecretValue } from '@aztec/foundation/config';
import type { EthAddress } from '@aztec/foundation/eth-address';
import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
import { startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
import { Agent, makeUndiciFetch } from '@aztec/foundation/json-rpc/undici';
Expand All @@ -32,7 +32,7 @@ import {
extractNamespacedOptions,
extractRelevantOptions,
preloadCrsDataForVerifying,
setupUpdateMonitor,
setupVersionChecker,
} from '../util.js';
import { getVersions } from '../versioning.js';
import { startProverBroker } from './start_prover_broker.js';
Expand Down Expand Up @@ -109,6 +109,7 @@ export async function startNode(
services: NamespacedApiHandlers,
adminServices: NamespacedApiHandlers,
userLog: LogFn,
networkName: NetworkNames,
): Promise<{ config: AztecNodeConfig }> {
// All options set from environment variables
const configFromEnvVars = getConfigEnvVars();
Expand Down Expand Up @@ -268,16 +269,19 @@ export async function startNode(
await addBot(options, signalHandlers, services, wallet, node, telemetry, undefined);
}

if (nodeConfig.autoUpdate !== 'disabled' && nodeConfig.autoUpdateUrl) {
await setupUpdateMonitor(
nodeConfig.autoUpdate,
new URL(nodeConfig.autoUpdateUrl),
followsCanonicalRollup,
getPublicClient(nodeConfig!),
nodeConfig.l1Contracts.registryAddress,
signalHandlers,
async config => node.setConfig((await AztecNodeAdminApiSchema.setConfig.parameters().parseAsync([config]))[0]),
);
if (nodeConfig.enableVersionCheck && networkName !== 'local') {
const cacheDir = process.env.DATA_DIRECTORY ? `${process.env.DATA_DIRECTORY}/cache` : undefined;
try {
await setupVersionChecker(
networkName,
followsCanonicalRollup,
getPublicClient(nodeConfig!),
signalHandlers,
cacheDir,
);
} catch {
/* no-op */
}
}

return { config: nodeConfig };
Expand Down
15 changes: 1 addition & 14 deletions yarn-project/aztec/src/cli/cmds/start_prover_broker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { getL1Config } from '@aztec/cli/config';
import { getPublicClient } from '@aztec/ethereum/client';
import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
import type { LogFn } from '@aztec/foundation/log';
import {
Expand All @@ -13,7 +12,7 @@ import { getProverNodeBrokerConfigFromEnv } from '@aztec/prover-node';
import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';

import { extractRelevantOptions, setupUpdateMonitor } from '../util.js';
import { extractRelevantOptions } from '../util.js';

export async function startProverBroker(
options: any,
Expand All @@ -35,7 +34,6 @@ export async function startProverBroker(
throw new Error('L1 registry address is required to start Aztec Node without --deploy-aztec-contracts option');
}

const followsCanonicalRollup = typeof config.rollupVersion !== 'number';
const { addresses, config: rollupConfig } = await getL1Config(
config.l1Contracts.registryAddress,
config.l1RpcUrls,
Expand All @@ -49,17 +47,6 @@ export async function startProverBroker(
const client = await initTelemetryClient(getTelemetryClientConfig());
const broker = await createAndStartProvingBroker(config, client);

if (options.autoUpdate !== 'disabled' && options.autoUpdateUrl) {
await setupUpdateMonitor(
options.autoUpdate,
new URL(options.autoUpdateUrl),
followsCanonicalRollup,
getPublicClient(config),
config.l1Contracts.registryAddress,
signalHandlers,
);
}

services.proverBroker = [
broker,
config.proverBrokerDebugReplayEnabled ? ProvingJobBrokerSchemaWithDebug : ProvingJobBrokerSchema,
Expand Down
21 changes: 0 additions & 21 deletions yarn-project/aztec/src/cli/release_version.ts

This file was deleted.

115 changes: 41 additions & 74 deletions yarn-project/aztec/src/cli/util.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import type { AztecNodeConfig } from '@aztec/aztec-node';
import type { AccountManager } from '@aztec/aztec.js/wallet';
import { getNetworkConfig } from '@aztec/cli/config';
import { RegistryContract } from '@aztec/ethereum/contracts';
import type { ViemClient } from '@aztec/ethereum/types';
import type { ConfigMappingsType } from '@aztec/foundation/config';
import { EthAddress } from '@aztec/foundation/eth-address';
import type { ConfigMappingsType, NetworkNames } from '@aztec/foundation/config';
import { jsonStringify } from '@aztec/foundation/json-rpc';
import { type LogFn, createLogger } from '@aztec/foundation/log';
import type { SharedNodeConfig } from '@aztec/node-lib/config';
import type { ProverConfig } from '@aztec/stdlib/interfaces/server';
import { getTelemetryClient } from '@aztec/telemetry-client/start';
import { type VersionCheck, getPackageVersion } from '@aztec/stdlib/update-checker';
import type { EmbeddedWallet } from '@aztec/wallets/embedded';

import chalk from 'chalk';
import type { Command } from 'commander';
import type { Hex } from 'viem';

import { type AztecStartOption, aztecStartOptions } from './aztec_start_options.js';

Expand Down Expand Up @@ -290,92 +291,58 @@ export async function preloadCrsDataForServerSideProving(
}
}

export async function setupUpdateMonitor(
autoUpdateMode: SharedNodeConfig['autoUpdate'],
updatesLocation: URL,
export async function setupVersionChecker(
network: NetworkNames,
followsCanonicalRollup: boolean,
publicClient: ViemClient,
registryContractAddress: EthAddress,
signalHandlers: Array<() => Promise<void>>,
updateNodeConfig?: (config: object) => Promise<void>,
) {
const logger = createLogger('update-check');
const { UpdateChecker } = await import('@aztec/stdlib/update-checker');
const checker = await UpdateChecker.new({
baseURL: updatesLocation,
publicClient,
registryContractAddress,
});
cacheDir?: string,
): Promise<void> {
const networkConfig = await getNetworkConfig(network, cacheDir);
if (!networkConfig) {
return;
}

// eslint-disable-next-line @typescript-eslint/no-misused-promises
checker.on('newRollupVersion', async ({ latestVersion, currentVersion }) => {
if (isShuttingDown()) {
return;
}
const { VersionChecker } = await import('@aztec/stdlib/update-checker');

// if node follows canonical rollup then this is equivalent to a config update
if (!followsCanonicalRollup) {
return;
}
const logger = createLogger('version_check');
const registry = new RegistryContract(publicClient, networkConfig.registryAddress as Hex);

if (autoUpdateMode === 'config' || autoUpdateMode === 'config-and-version') {
logger.info(`New rollup version detected. Please restart the node`, { latestVersion, currentVersion });
await shutdown(logger.info, ExitCode.ROLLUP_UPGRADE, signalHandlers);
} else if (autoUpdateMode === 'notify') {
logger.warn(`New rollup detected. Please restart the node`, { latestVersion, currentVersion });
}
const checks: Array<VersionCheck> = [];
checks.push({
name: 'node',
currentVersion: getPackageVersion() ?? 'unknown',
getLatestVersion: async () => {
const cfg = await getNetworkConfig(network, cacheDir);
return cfg?.nodeVersion;
},
});

// eslint-disable-next-line @typescript-eslint/no-misused-promises
checker.on('newNodeVersion', async ({ latestVersion, currentVersion }) => {
if (isShuttingDown()) {
return;
}
if (autoUpdateMode === 'config-and-version') {
logger.info(`New node version detected. Please update and restart the node`, { latestVersion, currentVersion });
await shutdown(logger.info, ExitCode.VERSION_UPGRADE, signalHandlers);
} else if (autoUpdateMode === 'notify') {
logger.info(`New node version detected. Please update and restart the node`, { latestVersion, currentVersion });
if (followsCanonicalRollup) {
const getLatestVersion = async () => {
const version = (await registry.getRollupVersions()).at(-1);
return version !== undefined ? String(version) : undefined;
};
const currentVersion = await getLatestVersion();
if (currentVersion !== undefined) {
checks.push({
name: 'rollup',
currentVersion,
getLatestVersion,
});
}
});
}

// eslint-disable-next-line @typescript-eslint/no-misused-promises
checker.on('updateNodeConfig', async config => {
const checker = new VersionChecker(checks, 600_000, logger);
checker.on('newVersion', ({ name, latestVersion, currentVersion }) => {
if (isShuttingDown()) {
return;
}

if ((autoUpdateMode === 'config' || autoUpdateMode === 'config-and-version') && updateNodeConfig) {
logger.warn(`Config change detected. Updating node`, config);
try {
await updateNodeConfig(config);
} catch (err) {
logger.warn('Failed to update config', { err });
}
}
// don't notify on these config changes
});

checker.on('updatePublicTelemetryConfig', config => {
if (autoUpdateMode === 'config' || autoUpdateMode === 'config-and-version') {
logger.warn(`Public telemetry config change detected. Updating telemetry client`, config);
try {
const publicIncludeMetrics: unknown = (config as any).publicIncludeMetrics;
if (Array.isArray(publicIncludeMetrics) && publicIncludeMetrics.every(m => typeof m === 'string')) {
getTelemetryClient().setExportedPublicTelemetry(publicIncludeMetrics);
}
const publicMetricsCollectFrom: unknown = (config as any).publicMetricsCollectFrom;
if (Array.isArray(publicMetricsCollectFrom) && publicMetricsCollectFrom.every(m => typeof m === 'string')) {
getTelemetryClient().setPublicTelemetryCollectFrom(publicMetricsCollectFrom);
}
} catch (err) {
logger.warn('Failed to update config', { err });
}
}
// don't notify on these config changes
logger.warn(`New ${name} version available`, { latestVersion, currentVersion });
});

checker.start();
signalHandlers.push(() => checker.stop());
}

export function stringifyConfig(config: object): string {
Expand Down
Loading
Loading