diff --git a/circuits/cpp/barretenberg b/circuits/cpp/barretenberg index 97c9bc72aeba..af243b20ebf3 160000 --- a/circuits/cpp/barretenberg +++ b/circuits/cpp/barretenberg @@ -1 +1 @@ -Subproject commit 97c9bc72aebab850b4a647d6e6cc50085226eafb +Subproject commit af243b20ebf38b27e79a1631cc056eab66573fd3 diff --git a/yarn-project/archiver/src/index.ts b/yarn-project/archiver/src/index.ts index 7f7d5e5896ab..cab552e72069 100644 --- a/yarn-project/archiver/src/index.ts +++ b/yarn-project/archiver/src/index.ts @@ -3,9 +3,12 @@ import { createPublicClient, http } from 'viem'; import { localhost } from 'viem/chains'; import { Archiver, getConfigEnvVars } from './archiver/index.js'; import { MemoryArchiverStore } from './archiver/archiver_store.js'; +import { createLogger } from '@aztec/foundation/log'; export * from './archiver/index.js'; +const log = createLogger('aztec:archiver_init'); + /** * A function which instantiates and starts Archiver. */ @@ -35,7 +38,7 @@ async function main() { if (process.argv[1] === fileURLToPath(import.meta.url).replace(/\/index\.js$/, '')) { // eslint-disable-next-line @typescript-eslint/no-floating-promises main().catch(err => { - console.log(err); + log(err); process.exit(1); }); } diff --git a/yarn-project/aztec-cli/src/index.ts b/yarn-project/aztec-cli/src/index.ts index 3ddc3054e092..d88187a3f676 100644 --- a/yarn-project/aztec-cli/src/index.ts +++ b/yarn-project/aztec-cli/src/index.ts @@ -1,7 +1,9 @@ #!/usr/bin/env node +import { createLogger } from '@aztec/foundation/log'; import { Command } from 'commander'; const program = new Command(); +const log = createLogger('aztec:aztec-cli'); /** * A placeholder for the Aztec-cli. @@ -11,13 +13,13 @@ async function main() { .command('run') .argument('', 'command') .action((cmd: string) => { - console.log(`Running '${cmd}'...`); + log(`Running '${cmd}'...`); }); await program.parseAsync(process.argv); } main().catch(err => { - console.log(`Error thrown: ${err}`); + log(`Error thrown: ${err}`); process.exit(1); }); diff --git a/yarn-project/aztec-rpc/src/synchroniser/synchroniser.ts b/yarn-project/aztec-rpc/src/synchroniser/synchroniser.ts index 0f26b71246f3..aaf3187b7e75 100644 --- a/yarn-project/aztec-rpc/src/synchroniser/synchroniser.ts +++ b/yarn-project/aztec-rpc/src/synchroniser/synchroniser.ts @@ -97,7 +97,7 @@ export class Synchroniser { from += unverifiedData.length; return from; } catch (err) { - console.log(err); + this.log(err); await this.interruptableSleep.sleep(retryInterval); return from; } diff --git a/yarn-project/barretenberg.js/src/crypto/pedersen/pedersen.test.ts b/yarn-project/barretenberg.js/src/crypto/pedersen/pedersen.test.ts index 3462214894da..986f80df663a 100644 --- a/yarn-project/barretenberg.js/src/crypto/pedersen/pedersen.test.ts +++ b/yarn-project/barretenberg.js/src/crypto/pedersen/pedersen.test.ts @@ -17,11 +17,11 @@ describe('pedersen', () => { }); it('hasher_consistency_and_benchmark', () => { - const start1 = new Date().getTime(); + // const start1 = new Date().getTime(); const result = pedersenGetHashTree(barretenbergWasm, values); - const end1 = new Date().getTime() - start1; + // const end1 = new Date().getTime() - start1; - console.log(`Single hasher: ~${end1 / values.length}ms / value`); + // console.log(`Single hasher: ~${end1 / values.length}ms / value`); // TODO more than smoke-test this expect(result.length).toBe(values.length * 2 - 1); // TODO diff --git a/yarn-project/circuits.js/src/kernel/public_kernel.test.ts b/yarn-project/circuits.js/src/kernel/public_kernel.test.ts index e39105412349..68f9d7c8b267 100644 --- a/yarn-project/circuits.js/src/kernel/public_kernel.test.ts +++ b/yarn-project/circuits.js/src/kernel/public_kernel.test.ts @@ -1,4 +1,4 @@ -import { Fr, simulatePublicKernelCircuit, simulatePublicKernelCircuitNoPreviousKernel } from '../index.js'; +import { simulatePublicKernelCircuit, simulatePublicKernelCircuitNoPreviousKernel } from '../index.js'; import { makePublicKernelInputsNoKernelInput, makePublicKernelInputsWithEmptyOutput } from '../tests/factories.js'; describe('kernel/public_kernel', () => { diff --git a/yarn-project/circuits.js/src/structs/call_stack_item.ts b/yarn-project/circuits.js/src/structs/call_stack_item.ts index 1722a533db75..cf44f8e09432 100644 --- a/yarn-project/circuits.js/src/structs/call_stack_item.ts +++ b/yarn-project/circuits.js/src/structs/call_stack_item.ts @@ -9,6 +9,9 @@ import { PublicCircuitPublicInputs } from './public_circuit_public_inputs.js'; * @see cpp/src/aztec3/circuits/abis/call_stack_item.hpp. */ export class PrivateCallStackItem { + /** + * Whether the current callstack item should be considered a public fn execution request. + */ public readonly isExecutionRequest = false; constructor( @@ -61,6 +64,9 @@ export class PublicCallStackItem { * Public inputs to the public kernel circuit. */ public publicInputs: PublicCircuitPublicInputs, + /** + * Whether the current callstack item should be considered a public fn execution request. + */ public isExecutionRequest: boolean, ) {} diff --git a/yarn-project/circuits.js/src/structs/public_call_request.ts b/yarn-project/circuits.js/src/structs/public_call_request.ts index e15f251b796c..065238b71e94 100644 --- a/yarn-project/circuits.js/src/structs/public_call_request.ts +++ b/yarn-project/circuits.js/src/structs/public_call_request.ts @@ -15,9 +15,21 @@ import { */ export class PublicCallRequest { constructor( + /** + *Address of the contract on which the function is invoked. + */ public contractAddress: AztecAddress, + /** + * Data identifying the function being called. + */ public functionData: FunctionData, + /** + * Context of the public call. + */ public callContext: CallContext, + /** + * Function arguments. + */ public args: Fr[], ) {} diff --git a/yarn-project/foundation/.eslintrc.cjs b/yarn-project/foundation/.eslintrc.cjs index 49ed17381aa7..b9bd5ae36404 100644 --- a/yarn-project/foundation/.eslintrc.cjs +++ b/yarn-project/foundation/.eslintrc.cjs @@ -67,12 +67,13 @@ module.exports = { '@typescript-eslint/no-empty-function': 'off', '@typescript-eslint/await-thenable': 'error', '@typescript-eslint/no-floating-promises': 2, - '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }], + '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], 'require-await': 2, + 'no-console': 'error', 'no-constant-condition': 'off', camelcase: 2, 'no-restricted-imports': [ - 'warn', + 'error', { patterns: [ { @@ -86,9 +87,9 @@ module.exports = { ], }, ], - 'tsdoc/syntax': 'warn', + 'tsdoc/syntax': 'error', 'jsdoc/require-jsdoc': [ - 'warn', + 'error', { contexts, checkConstructors: false, @@ -96,17 +97,16 @@ module.exports = { checkSetters: true, }, ], - 'jsdoc/require-description': ['warn', { contexts }], - 'jsdoc/require-description-complete-sentence': ['warn'], - 'jsdoc/require-hyphen-before-param-description': ['warn'], + 'jsdoc/require-description': ['error', { contexts }], + 'jsdoc/require-hyphen-before-param-description': ['error'], 'jsdoc/require-param': ['error', { contexts, checkDestructured: false }], - 'jsdoc/require-param-description': ['warn', { contexts }], - 'jsdoc/require-param-name': ['warn', { contexts }], - 'jsdoc/require-property': ['warn', { contexts }], - 'jsdoc/require-property-description': ['warn', { contexts }], - 'jsdoc/require-property-name': ['warn', { contexts }], - 'jsdoc/require-returns': ['warn', { contexts }], - 'jsdoc/require-returns-description': ['warn', { contexts }], + 'jsdoc/require-param-description': ['error', { contexts }], + 'jsdoc/require-param-name': ['error', { contexts }], + 'jsdoc/require-property': ['error', { contexts }], + 'jsdoc/require-property-description': ['error', { contexts }], + 'jsdoc/require-property-name': ['error', { contexts }], + 'jsdoc/require-returns': ['error', { contexts }], + 'jsdoc/require-returns-description': ['error', { contexts }], }, ignorePatterns: ['node_modules', 'dest*', 'dist', '*.js', '.eslintrc.cjs'], }; diff --git a/yarn-project/foundation/src/abi/index.ts b/yarn-project/foundation/src/abi/index.ts index 76c685c632db..da8cbe23063a 100644 --- a/yarn-project/foundation/src/abi/index.ts +++ b/yarn-project/foundation/src/abi/index.ts @@ -12,6 +12,9 @@ export interface ABIVariable { type: ABIType; } +/** + * Indicates whether a parameter is public or secret/private. + */ export enum ABIParameterVisibility { PUBLIC = 'public', SECRET = 'secret', @@ -21,6 +24,9 @@ export enum ABIParameterVisibility { * A function parameter. */ export interface ABIParameter extends ABIVariable { + /** + * Indicates whether a parameter is public or secret/private. + */ visibility: ABIParameterVisibility; } @@ -88,7 +94,7 @@ export interface StructType extends BasicType<'struct'> { } /** - * Noir function types + * Noir function types. */ export enum FunctionType { SECRET = 'secret', @@ -126,6 +132,9 @@ export interface FunctionAbi { verificationKey?: string; } +/** + * Defines ABI of a contract. + */ export interface ContractAbi { /** * The name of the contract. diff --git a/yarn-project/foundation/src/fifo/bounded_serial_queue.ts b/yarn-project/foundation/src/fifo/bounded_serial_queue.ts index cb3b9b74233a..2920f5745b2d 100644 --- a/yarn-project/foundation/src/fifo/bounded_serial_queue.ts +++ b/yarn-project/foundation/src/fifo/bounded_serial_queue.ts @@ -1,3 +1,4 @@ +import { createLogger } from '../log/console.js'; import { Semaphore } from './semaphore.js'; import { SerialQueue } from './serial_queue.js'; @@ -9,7 +10,7 @@ export class BoundedSerialQueue { private readonly queue = new SerialQueue(); private semaphore: Semaphore; - constructor(maxQueueSize: number) { + constructor(maxQueueSize: number, private log = createLogger('aztec:foundation:bounded_serial_queue')) { this.semaphore = new Semaphore(maxQueueSize); } @@ -70,7 +71,7 @@ export class BoundedSerialQueue { } }) .catch(err => { - console.error('BoundedSerialQueue handler exception:', err); + this.log('BoundedSerialQueue handler exception:', err); }); } diff --git a/yarn-project/foundation/src/fifo/memory_fifo.ts b/yarn-project/foundation/src/fifo/memory_fifo.ts index 2272479b4414..c796581ec591 100644 --- a/yarn-project/foundation/src/fifo/memory_fifo.ts +++ b/yarn-project/foundation/src/fifo/memory_fifo.ts @@ -1,3 +1,5 @@ +import { createLogger } from '../log/console.js'; + /** * A simple fifo queue. It can grow unbounded. It can have multiple producers and consumers. * Putting an item onto the queue always succeeds, unless either end() or cancel() has been called in which case @@ -8,6 +10,8 @@ export class MemoryFifo { private items: T[] = []; private flushing = false; + constructor(private log = createLogger('aztec:foundation:memory_fifo')) {} + /** * Returns the current number of items in the queue. * The length represents the size of the queue at the time of invocation and may change as new items are added or consumed. @@ -104,7 +108,7 @@ export class MemoryFifo { await handler(item); } } catch (err) { - console.error('Queue handler exception:', err); + this.log('Queue handler exception:', err); } } } diff --git a/yarn-project/foundation/src/json-rpc/server/json_rpc_server.ts b/yarn-project/foundation/src/json-rpc/server/json_rpc_server.ts index adafb1881100..06e318f5307d 100644 --- a/yarn-project/foundation/src/json-rpc/server/json_rpc_server.ts +++ b/yarn-project/foundation/src/json-rpc/server/json_rpc_server.ts @@ -6,9 +6,7 @@ import { ClassConverterInput } from '../class_converter.js'; import Koa from 'koa'; import bodyParser from 'koa-bodyparser'; import { JsonProxy } from './json_proxy.js'; -import { createDebugLogger } from '../../log/index.js'; - -const debug = createDebugLogger('json-rpc:json_rpc_server'); +import { createLogger } from '../../log/index.js'; /** * JsonRpcServer. @@ -16,7 +14,11 @@ const debug = createDebugLogger('json-rpc:json_rpc_server'); */ export class JsonRpcServer { proxy: JsonProxy; - constructor(private handler: object, input: ClassConverterInput) { + constructor( + private handler: object, + input: ClassConverterInput, + private log = createLogger('aztec:foundation:json-rpc:server'), + ) { this.proxy = new JsonProxy(handler, input); } @@ -31,14 +33,14 @@ export class JsonRpcServer { try { await next(); } catch (err: any) { - console.log(err); + this.log(err); ctx.status = 400; ctx.body = { error: err.message }; } }; const app = new Koa(); app.on('error', error => { - console.log(`KOA app-level error. ${JSON.stringify({ error })}`); + this.log(`KOA app-level error. ${JSON.stringify({ error })}`); }); app.use(compress({ br: false } as any)); app.use(bodyParser()); @@ -66,7 +68,6 @@ export class JsonRpcServer { } router.post(`/${method}`, async (ctx: Koa.Context) => { const { params = [], jsonrpc, id } = ctx.request.body as any; - debug('JsonRpcServer:getRouter', method, '<-', params); const result = await this.proxy.call(method, params); ctx.body = { jsonrpc, id, result }; ctx.status = 200; diff --git a/yarn-project/foundation/src/log/console.ts b/yarn-project/foundation/src/log/console.ts index 06d11e3ac3c6..191c2c801869 100644 --- a/yarn-project/foundation/src/log/console.ts +++ b/yarn-project/foundation/src/log/console.ts @@ -1,3 +1,5 @@ +/* eslint-disable no-console */ + /** * Logger is a utility type that represents a logging function that accepts any number of arguments. * It is used to provide customizable logging functionality, allowing developers to easily log messages diff --git a/yarn-project/foundation/src/retry/index.ts b/yarn-project/foundation/src/retry/index.ts index 03db341683b8..4bc7fec7e525 100644 --- a/yarn-project/foundation/src/retry/index.ts +++ b/yarn-project/foundation/src/retry/index.ts @@ -1,3 +1,4 @@ +import { createLogger } from '../log/index.js'; import { sleep } from '../sleep/index.js'; import { Timer } from '../timer/index.js'; @@ -24,9 +25,15 @@ export function* backoffGenerator() { * @param fn - The asynchronous function to be retried. * @param name - The optional name of the operation, used for logging purposes. * @param backoff - The optional backoff generator providing the intervals in seconds between retries. Defaults to a predefined series. + * @param log - Logger to use for logging. * @returns A Promise that resolves with the successful result of the provided function, or rejects if backoff generator ends. */ -export async function retry(fn: () => Promise, name = 'Operation', backoff = backoffGenerator()) { +export async function retry( + fn: () => Promise, + name = 'Operation', + backoff = backoffGenerator(), + log = createLogger('aztec:foundation:retry'), +) { while (true) { try { return await fn(); @@ -35,8 +42,8 @@ export async function retry(fn: () => Promise, name = 'Operation if (s === undefined) { throw err; } - console.log(`${name} failed. Will retry in ${s}s...`); - console.log(err); + log(`${name} failed. Will retry in ${s}s...`); + log(err); await sleep(s * 1000); continue; } diff --git a/yarn-project/foundation/src/transport/dispatch/create_dispatch_fn.ts b/yarn-project/foundation/src/transport/dispatch/create_dispatch_fn.ts index 21665adb8aa7..bb3be1982754 100644 --- a/yarn-project/foundation/src/transport/dispatch/create_dispatch_fn.ts +++ b/yarn-project/foundation/src/transport/dispatch/create_dispatch_fn.ts @@ -1,3 +1,5 @@ +import { createDebugLogger } from '../../log/debug.js'; + /** * Represents a message object for dispatching function calls. * Contains the function name ('fn') and an array of arguments ('args') required to call the target method. @@ -17,13 +19,12 @@ export interface DispatchMsg { * Creates a dispatch function that calls the target's specified method with provided arguments. * The created dispatch function takes a DispatchMsg object as input, which contains the name of * the method to be called ('fn') and an array of arguments to be passed to the method ('args'). - * An optional 'debug' parameter can be passed, which defaults to console.error, to log dispatched messages. * * @param targetFn - A function that returns the target object containing the methods to be dispatched. - * @param debug - Optional logging function for debugging purposes (defaults to console.error). + * @param debug - Optional logging function for debugging purposes. * @returns A dispatch function that accepts a DispatchMsg object and calls the target's method with provided arguments. */ -export function createDispatchFn(targetFn: () => any, debug = console.error) { +export function createDispatchFn(targetFn: () => any, debug = createDebugLogger('aztec:foundation:dispatch')) { return async ({ fn, args }: DispatchMsg) => { const target = targetFn(); debug(`dispatching to ${target}: ${fn}`, args); diff --git a/yarn-project/foundation/src/wasm/memory_fifo.ts b/yarn-project/foundation/src/wasm/memory_fifo.ts index 8663e167e919..c796581ec591 100644 --- a/yarn-project/foundation/src/wasm/memory_fifo.ts +++ b/yarn-project/foundation/src/wasm/memory_fifo.ts @@ -1,4 +1,5 @@ -// TODO should come from a dependency +import { createLogger } from '../log/console.js'; + /** * A simple fifo queue. It can grow unbounded. It can have multiple producers and consumers. * Putting an item onto the queue always succeeds, unless either end() or cancel() has been called in which case @@ -9,9 +10,13 @@ export class MemoryFifo { private items: T[] = []; private flushing = false; + constructor(private log = createLogger('aztec:foundation:memory_fifo')) {} + /** - * Length of queue. - * @returns The length. + * Returns the current number of items in the queue. + * The length represents the size of the queue at the time of invocation and may change as new items are added or consumed. + * + * @returns The number of items in the queue. */ public length() { return this.items.length; @@ -21,8 +26,8 @@ export class MemoryFifo { * Returns next item within the queue, or blocks until and item has been put into the queue. * If given a timeout, the promise will reject if no item is received after `timeout` seconds. * If the queue is flushing, `null` is returned. - * @param timeout - In seconds. - * @returns Promise of result. + * @param timeout - The timeout in seconds. + * @returns A result promise. */ public get(timeout?: number): Promise { if (this.items.length) { @@ -85,8 +90,13 @@ export class MemoryFifo { } /** - * Helper method that can be used to continously consume and process items on the queue. - * @param handler - The item handler function. + * Process items from the queue using a provided handler function. + * The function iterates over items in the queue, invoking the handler for each item until the queue is empty or flushing. + * If the handler throws an error, it will be caught and logged as 'Queue handler exception:', but the iteration will continue. + * The process function returns a promise that resolves when there are no more items in the queue or the queue is flushing. + * + * @param handler - A function that takes an item of type T and returns a Promise after processing the item. + * @returns A Promise that resolves when the queue is finished processing. */ public async process(handler: (item: T) => Promise) { try { @@ -98,7 +108,7 @@ export class MemoryFifo { await handler(item); } } catch (err) { - console.error('Queue handler exception:', err); + this.log('Queue handler exception:', err); } } } diff --git a/yarn-project/foundation/src/wasm/transport/dispatch/create_dispatch_fn.ts b/yarn-project/foundation/src/wasm/transport/dispatch/create_dispatch_fn.ts index a283ec6a5895..896e00a8e58f 100644 --- a/yarn-project/foundation/src/wasm/transport/dispatch/create_dispatch_fn.ts +++ b/yarn-project/foundation/src/wasm/transport/dispatch/create_dispatch_fn.ts @@ -1,28 +1,30 @@ +import { createDebugLogger } from '../../../log/debug.js'; + /** - * Represents a dispatch message interface. - * Contains the target function name and its arguments to be executed in a dispatched manner. + * Represents a message object for dispatching function calls. + * Contains the function name ('fn') and an array of arguments ('args') required to call the target method. */ export interface DispatchMsg { /** - * The name of the function to be called on the target object. + * Name of the target method to be called. */ fn: string; /** - * An array of arguments to be passed to the target function. + * An array of arguments to be passed to the target method. */ args: any[]; } /** - * Creates a dispatch function that calls a specified method on the target object returned by the targetFn. - * The created dispatch function takes a single argument, an object containing the name of the function to be called (fn) and an array of arguments (args) to be passed to the function. - * If the debug flag is enabled, it logs the dispatched call information to the console. + * Creates a dispatch function that calls the target's specified method with provided arguments. + * The created dispatch function takes a DispatchMsg object as input, which contains the name of + * the method to be called ('fn') and an array of arguments to be passed to the method ('args'). * - * @param targetFn - A function that returns the target object on which the method should be called. - * @param debug - An optional console.error function for logging dispatched call information. Defaults to console.error. - * @returns A dispatch function that takes a DispatchMsg object and calls the specified function on the target object with provided arguments. + * @param targetFn - A function that returns the target object containing the methods to be dispatched. + * @param debug - Optional logging function for debugging purposes. + * @returns A dispatch function that accepts a DispatchMsg object and calls the target's method with provided arguments. */ -export function createDispatchFn(targetFn: () => any, debug = console.error) { +export function createDispatchFn(targetFn: () => any, debug = createDebugLogger('aztec:foundation:dispatch')) { return async ({ fn, args }: DispatchMsg) => { const target = targetFn(); debug(`dispatching to ${target}: ${fn}`, args); diff --git a/yarn-project/merkle-tree/src/sparse_tree/sparse_tree.test.ts b/yarn-project/merkle-tree/src/sparse_tree/sparse_tree.test.ts index 3e0c02aeb3aa..b1a5ef96cfe1 100644 --- a/yarn-project/merkle-tree/src/sparse_tree/sparse_tree.test.ts +++ b/yarn-project/merkle-tree/src/sparse_tree/sparse_tree.test.ts @@ -11,6 +11,9 @@ import { INITIAL_LEAF, SiblingPath } from '../index.js'; import { UpdateOnlyTree } from '../interfaces/update_only_tree.js'; import { newTree } from '../new_tree.js'; import { loadTree } from '../load_tree.js'; +import { createLogger } from '@aztec/foundation/log'; + +const log = createLogger('aztec:sparse_tree_test'); const createDb = async ( levelUp: levelup.LevelUp, @@ -166,6 +169,6 @@ describe('SparseTreeSpecific', () => { const start = Date.now(); await Promise.all(leaves.map((leaf, i) => tree.updateLeaf(leaf, indices[i]))); const end = Date.now(); - console.log(`Inserting 1000 leaves at random positions for depth 254 took ${end - start}ms`); + log(`Inserting 1000 leaves at random positions for depth 254 took ${end - start}ms`); }, 300_000); }); diff --git a/yarn-project/merkle-tree/src/standard_indexed_tree/standard_indexed_tree.ts b/yarn-project/merkle-tree/src/standard_indexed_tree/standard_indexed_tree.ts index 1033a54ae07b..b32d8d0404aa 100644 --- a/yarn-project/merkle-tree/src/standard_indexed_tree/standard_indexed_tree.ts +++ b/yarn-project/merkle-tree/src/standard_indexed_tree/standard_indexed_tree.ts @@ -2,6 +2,9 @@ import { toBigIntBE, toBufferBE } from '@aztec/foundation/bigint-buffer'; import { Hasher } from '../hasher.js'; import { IndexedTree, LeafData } from '../interfaces/indexed_tree.js'; import { TreeBase } from '../tree_base.js'; +import { createLogger } from '@aztec/foundation/log'; + +const log = createLogger('aztec:standard-indexed-tree'); const indexToKeyLeaf = (name: string, index: bigint) => { return `${name}:leaf:${index}`; @@ -239,7 +242,7 @@ export class StandardIndexedTree extends TreeBase implements IndexedTree { resolve(); }) .on('error', function () { - console.log('stream error'); + log('stream error'); reject(); }); }); diff --git a/yarn-project/noir-compiler/src/cli.ts b/yarn-project/noir-compiler/src/cli.ts index ed0485ea8fba..25f7355e5ab3 100644 --- a/yarn-project/noir-compiler/src/cli.ts +++ b/yarn-project/noir-compiler/src/cli.ts @@ -4,8 +4,10 @@ import fs from 'fs/promises'; import fsExtra from 'fs-extra'; import { Command } from 'commander'; import { ContractCompiler } from './compile.js'; +import { createLogger } from '@aztec/foundation/log'; const program = new Command(); +const log = createLogger('noir-compiler-cli'); const main = async () => { program @@ -32,6 +34,6 @@ const main = async () => { }; main().catch(err => { - console.log(`Error thrown: ${err}`); + log(`Error thrown: ${err}`); process.exit(1); }); diff --git a/yarn-project/noir-contracts/src/scripts/copy_output.ts b/yarn-project/noir-contracts/src/scripts/copy_output.ts index caa0726bcf63..0c554b77515a 100644 --- a/yarn-project/noir-contracts/src/scripts/copy_output.ts +++ b/yarn-project/noir-contracts/src/scripts/copy_output.ts @@ -4,8 +4,10 @@ import snakeCase from 'lodash.snakecase'; import upperFirst from 'lodash.upperfirst'; import mockedKeys from './mockedKeys.json' assert { type: 'json' }; import { ABIParameter, ABIType, FunctionType } from '@aztec/foundation/abi'; +import { createLogger } from '@aztec/foundation/log'; const STATEMENT_TYPES = ['type', 'params', 'return'] as const; +const log = createLogger('aztec:noir-contracts'); /** * Creates an Aztec function entry. @@ -87,12 +89,12 @@ const main = () => { const exampleFile = `${examples}/${snakeCase(name)}_contract.json`; writeFileSync(exampleFile, JSON.stringify(abi, null, 2) + '\n'); - console.log(`Written ${exampleFile}`); + log(`Written ${exampleFile}`); }; try { main(); } catch (err: unknown) { - console.error(err); + log(err); process.exit(1); } diff --git a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.ts b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.ts index 6c61451314ec..a31b2a3bbce7 100644 --- a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.ts +++ b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.ts @@ -5,7 +5,6 @@ import { CONTRACT_TREE_ROOTS_TREE_HEIGHT, CircuitsWasm, ConstantBaseRollupData, - KERNEL_NEW_NULLIFIERS_LENGTH, L1_TO_L2_MESSAGES_ROOTS_TREE_HEIGHT, L1_TO_L2_MESSAGES_SUBTREE_HEIGHT, MembershipWitness, diff --git a/yarn-project/sequencer-client/src/sequencer/processed_tx.ts b/yarn-project/sequencer-client/src/sequencer/processed_tx.ts index a5ebc2bb4b4e..11e430eda7f2 100644 --- a/yarn-project/sequencer-client/src/sequencer/processed_tx.ts +++ b/yarn-project/sequencer-client/src/sequencer/processed_tx.ts @@ -1,5 +1,5 @@ import { CombinedHistoricTreeRoots, KernelCircuitPublicInputs, makeEmptyProof } from '@aztec/circuits.js'; -import { PrivateTx, PublicTx, Tx, TxHash, UnverifiedData } from '@aztec/types'; +import { PrivateTx, Tx, TxHash, UnverifiedData } from '@aztec/types'; import { Proof } from '../prover/index.js'; /** diff --git a/yarn-project/types/src/l2_block_downloader/l2_block_downloader.ts b/yarn-project/types/src/l2_block_downloader/l2_block_downloader.ts index 4ef805ec2943..7eb837dce042 100644 --- a/yarn-project/types/src/l2_block_downloader/l2_block_downloader.ts +++ b/yarn-project/types/src/l2_block_downloader/l2_block_downloader.ts @@ -1,6 +1,9 @@ import { InterruptableSleep } from '@aztec/foundation/sleep'; import { MemoryFifo, Semaphore } from '@aztec/foundation/fifo'; import { L2BlockSource, L2Block, INITIAL_L2_BLOCK_NUM } from '../index.js'; +import { createLogger } from '@aztec/foundation/log'; + +const log = createLogger('aztec:l2_block_downloader'); /** * Downloads L2 blocks from a L2BlockSource. @@ -49,7 +52,7 @@ export class L2BlockDownloader { this.queue.put(blocks); this.from += blocks.length; } catch (err) { - console.log(err); + log(err); await this.interruptableSleep.sleep(this.pollIntervalMS); } } diff --git a/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts b/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts index 4fd843bf6cc7..2d5658411b03 100644 --- a/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts +++ b/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts @@ -10,6 +10,7 @@ import { ServerWorldStateSynchroniser } from './server_world_state_synchroniser. import { WorldStateRunningState } from './world_state_synchroniser.js'; import { Fr } from '@aztec/foundation/fields'; import { sleep } from '@aztec/foundation/sleep'; +import { createLogger } from '@aztec/foundation/log'; /** * Generic mock implementation. @@ -72,6 +73,8 @@ const getMockBlock = (blockNumber: number, newContractsCommitments?: Buffer[]) = const createSynchroniser = (merkleTreeDb: any, rollupSource: any) => new ServerWorldStateSynchroniser(merkleTreeDb as MerkleTreeDb, rollupSource as L2BlockSource); +const log = createLogger('aztec:server_world_state_synchroniser_test'); + describe('server_world_state_synchroniser', () => { const rollupSource: Mockify> = { getBlockHeight: jest.fn().mockImplementation(getLatestBlockNumber), @@ -115,7 +118,7 @@ describe('server_world_state_synchroniser', () => { nextBlocks = [getMockBlock(currentBlockNumber + 1)]; // start the sync process but don't await - server.start().catch(err => console.log('Sync not completed: ', err)); + server.start().catch(err => log('Sync not completed: ', err)); // now setup a loop to monitor the sync progress and push new blocks in while (currentBlockNumber <= LATEST_BLOCK_NUMBER) { diff --git a/yarn-project/world-state/src/world-state-db/index.ts b/yarn-project/world-state/src/world-state-db/index.ts index 0cd9236c085c..958fbeddf767 100644 --- a/yarn-project/world-state/src/world-state-db/index.ts +++ b/yarn-project/world-state/src/world-state-db/index.ts @@ -1,3 +1,4 @@ +import { createDebugLogger } from '@aztec/foundation/log'; import { LeafData, SiblingPath } from '@aztec/merkle-tree'; import { MerkleTreeId } from '@aztec/types'; @@ -160,9 +161,13 @@ export interface MerkleTreeDb extends MerkleTreeDbOperations { } /** - * Outputs a tree leaves to console.log for debugging purposes. + * Outputs a tree leaves using for debugging purposes. */ -export async function inspectTree(db: MerkleTreeOperations, treeId: MerkleTreeId) { +export async function inspectTree( + db: MerkleTreeOperations, + treeId: MerkleTreeId, + log = createDebugLogger('aztec:inspect-tree'), +) { const info = await db.getTreeInfo(treeId); const output = [`Tree id=${treeId} size=${info.size} root=0x${info.root.toString('hex')}`]; for (let i = 0; i < info.size; i++) { @@ -170,5 +175,5 @@ export async function inspectTree(db: MerkleTreeOperations, treeId: MerkleTreeId ` Leaf ${i}: ${await db.getLeafValue(treeId, BigInt(i)).then(x => x?.toString('hex') ?? '[undefined]')}`, ); } - console.log(output.join('\n')); + log(output.join('\n')); }