Skip to content

Commit 00c629c

Browse files
authored
chore: More logs cleanup (#10630)
Cleanup of logs across archiver, sequencer, and pxe.
1 parent eb472ff commit 00c629c

File tree

27 files changed

+282
-147
lines changed

27 files changed

+282
-147
lines changed

yarn-project/archiver/src/archiver/archiver.ts

+2
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,8 @@ export class Archiver implements ArchiveSource {
491491
this.log.info(`Downloaded L2 block ${block.data.number}`, {
492492
blockHash: block.data.hash(),
493493
blockNumber: block.data.number,
494+
txCount: block.data.body.txEffects.length,
495+
globalVariables: block.data.header.globalVariables.toInspect(),
494496
});
495497
}
496498
} while (searchEndBlock < currentL1BlockNumber);

yarn-project/aztec-node/src/aztec-node/server.ts

+12-13
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,7 @@ export class AztecNodeService implements AztecNode {
110110
this.packageVersion = getPackageInfo().version;
111111
this.metrics = new NodeMetrics(telemetry, 'AztecNodeService');
112112

113-
const message =
114-
`Started Aztec Node against chain 0x${l1ChainId.toString(16)} with contracts - \n` +
115-
`Rollup: ${config.l1Contracts.rollupAddress.toString()}\n` +
116-
`Registry: ${config.l1Contracts.registryAddress.toString()}\n` +
117-
`Inbox: ${config.l1Contracts.inboxAddress.toString()}\n` +
118-
`Outbox: ${config.l1Contracts.outboxAddress.toString()}`;
119-
this.log.info(message);
113+
this.log.info(`Aztec Node started on chain 0x${l1ChainId.toString(16)}`, config.l1Contracts);
120114
}
121115

122116
public addEpochProofQuote(quote: EpochProofQuote): Promise<void> {
@@ -163,7 +157,9 @@ export class AztecNodeService implements AztecNode {
163157
// now create the merkle trees and the world state synchronizer
164158
const worldStateSynchronizer = await createWorldStateSynchronizer(config, archiver, telemetry);
165159
const proofVerifier = config.realProofs ? await BBCircuitVerifier.new(config) : new TestCircuitVerifier();
166-
log.info(`Aztec node accepting ${config.realProofs ? 'real' : 'test'} proofs`);
160+
if (!config.realProofs) {
161+
log.warn(`Aztec node is accepting fake proofs`);
162+
}
167163

168164
// create the tx pool and the p2p client, which will need the l2 block source
169165
const p2pClient = await createP2PClient(config, archiver, proofVerifier, worldStateSynchronizer, telemetry);
@@ -784,7 +780,7 @@ export class AztecNodeService implements AztecNode {
784780
* @param tx - The transaction to simulate.
785781
**/
786782
public async simulatePublicCalls(tx: Tx): Promise<PublicSimulationOutput> {
787-
this.log.info(`Simulating tx ${tx.getTxHash()}`);
783+
const txHash = tx.getTxHash();
788784
const blockNumber = (await this.blockSource.getBlockNumber()) + 1;
789785

790786
// If sequencer is not initialized, we just set these values to zero for simulation.
@@ -798,23 +794,26 @@ export class AztecNodeService implements AztecNode {
798794
);
799795
const prevHeader = (await this.blockSource.getBlock(-1))?.header;
800796
const publicProcessorFactory = new PublicProcessorFactory(this.contractDataSource, this.telemetry);
801-
802797
const fork = await this.worldStateSynchronizer.fork();
803798

799+
this.log.verbose(`Simulating public calls for tx ${tx.getTxHash()}`, {
800+
globalVariables: newGlobalVariables.toInspect(),
801+
txHash,
802+
blockNumber,
803+
});
804+
804805
try {
805806
const processor = publicProcessorFactory.create(fork, prevHeader, newGlobalVariables);
806807

807808
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
808809
const [processedTxs, failedTxs, returns] = await processor.process([tx]);
809810
// REFACTOR: Consider returning the error rather than throwing
810811
if (failedTxs.length) {
811-
this.log.warn(`Simulated tx ${tx.getTxHash()} fails: ${failedTxs[0].error}`);
812+
this.log.warn(`Simulated tx ${tx.getTxHash()} fails: ${failedTxs[0].error}`, { txHash });
812813
throw failedTxs[0].error;
813814
}
814815

815816
const [processedTx] = processedTxs;
816-
this.log.debug(`Simulated tx ${tx.getTxHash()} ${processedTx.revertReason ? 'Reverts' : 'Succeeds'}`);
817-
818817
return new PublicSimulationOutput(
819818
processedTx.revertReason,
820819
processedTx.constants,

yarn-project/circuit-types/src/l2_block_downloader/l2_block_stream.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('L2BlockStream', () => {
3737
Promise.resolve(compactArray(times(limit, i => (from + i > latest ? undefined : makeBlock(from + i))))),
3838
);
3939

40-
blockStream = new TestL2BlockStream(blockSource, localData, handler, { batchSize: 10 });
40+
blockStream = new TestL2BlockStream(blockSource, localData, handler, undefined, { batchSize: 10 });
4141
});
4242

4343
const makeBlock = (number: number) => ({ number } as L2Block);

yarn-project/circuit-types/src/l2_block_downloader/l2_block_stream.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ import { type L2BlockId, type L2BlockSource, type L2Tips } from '../l2_block_sou
99
export class L2BlockStream {
1010
private readonly runningPromise: RunningPromise;
1111

12-
private readonly log = createLogger('types:l2_block_stream');
13-
1412
constructor(
1513
private l2BlockSource: Pick<L2BlockSource, 'getBlocks' | 'getBlockHeader' | 'getL2Tips'>,
1614
private localData: L2BlockStreamLocalDataProvider,
1715
private handler: L2BlockStreamEventHandler,
16+
private readonly log = createLogger('types:block_stream'),
1817
private opts: {
1918
proven?: boolean;
2019
pollIntervalMS?: number;

yarn-project/circuit-types/src/logs/tx_l2_logs.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export abstract class TxL2Logs {
2121
abstract hash(): Buffer;
2222

2323
constructor(
24-
/** * An array containing logs emitted in individual function invocations in this tx. */
24+
/** An array containing logs emitted in individual function invocations in this tx. */
2525
public readonly functionLogs: UnencryptedFunctionL2Logs[],
2626
) {}
2727

yarn-project/circuit-types/src/tx/tx.ts

+9
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,15 @@ export class Tx extends Gossipable {
179179
return new TxHash(firstNullifier.toBuffer());
180180
}
181181

182+
/** Returns the tx hash, or undefined if none is set. */
183+
tryGetTxHash(): TxHash | undefined {
184+
try {
185+
return this.getTxHash();
186+
} catch {
187+
return undefined;
188+
}
189+
}
190+
182191
/** Returns stats about this tx. */
183192
getStats(): TxStats {
184193
return {

yarn-project/circuits.js/src/structs/block_header.ts

+11
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,17 @@ export class BlockHeader {
152152
return poseidon2HashWithSeparator(this.toFields(), GeneratorIndex.BLOCK_HASH);
153153
}
154154

155+
toInspect() {
156+
return {
157+
lastArchive: this.lastArchive.root.toString(),
158+
contentCommitment: this.contentCommitment.toInspect(),
159+
state: this.state.toInspect(),
160+
globalVariables: this.globalVariables.toInspect(),
161+
totalFees: this.totalFees.toBigInt(),
162+
totalManaUsed: this.totalManaUsed.toBigInt(),
163+
};
164+
}
165+
155166
[inspect.custom]() {
156167
return `Header {
157168
lastArchive: ${inspect(this.lastArchive)},

yarn-project/circuits.js/src/structs/content_commitment.ts

+9
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ export class ContentCommitment {
5252
return serializeToBuffer(this.numTxs, this.txsEffectsHash, this.inHash, this.outHash);
5353
}
5454

55+
toInspect() {
56+
return {
57+
numTxs: this.numTxs.toNumber(),
58+
txsEffectsHash: bufferToHex(this.txsEffectsHash),
59+
inHash: bufferToHex(this.inHash),
60+
outHash: bufferToHex(this.outHash),
61+
};
62+
}
63+
5564
toFields(): Fr[] {
5665
const serialized = [
5766
this.numTxs,

yarn-project/circuits.js/src/structs/revert_code.ts

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export class RevertCode {
3333
static readonly TEARDOWN_REVERTED: RevertCode = new RevertCode(RevertCodeEnum.TEARDOWN_REVERTED);
3434
static readonly BOTH_REVERTED: RevertCode = new RevertCode(RevertCodeEnum.BOTH_REVERTED);
3535

36+
public getCode(): RevertCodeEnum {
37+
return this.code;
38+
}
39+
3640
public equals(other: RevertCode): boolean {
3741
return this.code === other.code;
3842
}

yarn-project/circuits.js/src/structs/state_reference.ts

+9
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ export class StateReference {
6969
return this.l1ToL2MessageTree.isZero() && this.partial.isEmpty();
7070
}
7171

72+
toInspect() {
73+
return {
74+
l1ToL2MessageTree: this.l1ToL2MessageTree.root.toString(),
75+
noteHashTree: this.partial.noteHashTree.root.toString(),
76+
nullifierTree: this.partial.nullifierTree.root.toString(),
77+
publicDataTree: this.partial.publicDataTree.root.toString(),
78+
};
79+
}
80+
7281
[inspect.custom]() {
7382
return `StateReference {
7483
l1ToL2MessageTree: ${inspect(this.l1ToL2MessageTree)},

yarn-project/ethereum/src/deploy_l1_contracts.ts

+19-17
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ export const deployL1Contracts = async (
304304
if (res.error) {
305305
throw new Error(`Error setting block interval: ${res.error.message}`);
306306
}
307-
logger.info(`Set block interval to ${args.ethereumSlotDuration}`);
307+
logger.warn(`Set block interval to ${args.ethereumSlotDuration}`);
308308
}
309309

310310
logger.verbose(`Deploying contracts from ${account.address.toString()}`);
@@ -315,21 +315,21 @@ export const deployL1Contracts = async (
315315
const govDeployer = new L1Deployer(walletClient, publicClient, args.salt, logger);
316316

317317
const registryAddress = await govDeployer.deploy(l1Artifacts.registry, [account.address.toString()]);
318-
logger.info(`Deployed Registry at ${registryAddress}`);
318+
logger.verbose(`Deployed Registry at ${registryAddress}`);
319319

320320
const feeAssetAddress = await govDeployer.deploy(l1Artifacts.feeAsset, [
321321
'FeeJuice',
322322
'FEE',
323323
account.address.toString(),
324324
]);
325-
logger.info(`Deployed Fee Juice at ${feeAssetAddress}`);
325+
logger.verbose(`Deployed Fee Juice at ${feeAssetAddress}`);
326326

327327
const stakingAssetAddress = await govDeployer.deploy(l1Artifacts.stakingAsset, [
328328
'Staking',
329329
'STK',
330330
account.address.toString(),
331331
]);
332-
logger.info(`Deployed Staking Asset at ${stakingAssetAddress}`);
332+
logger.verbose(`Deployed Staking Asset at ${stakingAssetAddress}`);
333333

334334
// @todo #8084
335335
// @note These numbers are just chosen to make testing simple.
@@ -340,29 +340,29 @@ export const deployL1Contracts = async (
340340
quorumSize,
341341
roundSize,
342342
]);
343-
logger.info(`Deployed GovernanceProposer at ${governanceProposerAddress}`);
343+
logger.verbose(`Deployed GovernanceProposer at ${governanceProposerAddress}`);
344344

345345
// @note @LHerskind the assets are expected to be the same at some point, but for better
346346
// configurability they are different for now.
347347
const governanceAddress = await govDeployer.deploy(l1Artifacts.governance, [
348348
feeAssetAddress.toString(),
349349
governanceProposerAddress.toString(),
350350
]);
351-
logger.info(`Deployed Governance at ${governanceAddress}`);
351+
logger.verbose(`Deployed Governance at ${governanceAddress}`);
352352

353353
const coinIssuerAddress = await govDeployer.deploy(l1Artifacts.coinIssuer, [
354354
feeAssetAddress.toString(),
355355
1n * 10n ** 18n, // @todo #8084
356356
governanceAddress.toString(),
357357
]);
358-
logger.info(`Deployed CoinIssuer at ${coinIssuerAddress}`);
358+
logger.verbose(`Deployed CoinIssuer at ${coinIssuerAddress}`);
359359

360360
const rewardDistributorAddress = await govDeployer.deploy(l1Artifacts.rewardDistributor, [
361361
feeAssetAddress.toString(),
362362
registryAddress.toString(),
363363
governanceAddress.toString(),
364364
]);
365-
logger.info(`Deployed RewardDistributor at ${rewardDistributorAddress}`);
365+
logger.verbose(`Deployed RewardDistributor at ${rewardDistributorAddress}`);
366366

367367
logger.verbose(`Waiting for governance contracts to be deployed`);
368368
await govDeployer.waitForDeployments();
@@ -375,7 +375,7 @@ export const deployL1Contracts = async (
375375
feeAssetAddress.toString(),
376376
args.l2FeeJuiceAddress.toString(),
377377
]);
378-
logger.info(`Deployed Fee Juice Portal at ${feeJuicePortalAddress}`);
378+
logger.verbose(`Deployed Fee Juice Portal at ${feeJuicePortalAddress}`);
379379

380380
const rollupConfigArgs = {
381381
aztecSlotDuration: args.aztecSlotDuration,
@@ -394,10 +394,10 @@ export const deployL1Contracts = async (
394394
rollupConfigArgs,
395395
];
396396
const rollupAddress = await deployer.deploy(l1Artifacts.rollup, rollupArgs);
397-
logger.info(`Deployed Rollup at ${rollupAddress}`, rollupConfigArgs);
397+
logger.verbose(`Deployed Rollup at ${rollupAddress}`, rollupConfigArgs);
398398

399399
await deployer.waitForDeployments();
400-
logger.info(`All core contracts deployed`);
400+
logger.verbose(`All core contracts have been deployed`);
401401

402402
const feeJuicePortal = getContract({
403403
address: feeJuicePortalAddress.toString(),
@@ -428,7 +428,7 @@ export const deployL1Contracts = async (
428428

429429
{
430430
const txHash = await feeAsset.write.setFreeForAll([true], {} as any);
431-
logger.info(`Fee asset set to free for all in ${txHash}`);
431+
logger.verbose(`Fee asset set to free for all in ${txHash}`);
432432
txHashes.push(txHash);
433433
}
434434

@@ -464,7 +464,7 @@ export const deployL1Contracts = async (
464464
// @note This is used to ensure we fully wait for the transaction when running against a real chain
465465
// otherwise we execute subsequent transactions too soon
466466
await publicClient.waitForTransactionReceipt({ hash: mintTxHash });
467-
logger.info(`Funding fee juice portal contract with fee juice in ${mintTxHash}`);
467+
logger.verbose(`Funding fee juice portal contract with fee juice in ${mintTxHash}`);
468468

469469
if (!(await feeJuicePortal.read.initialized([]))) {
470470
const initPortalTxHash = await feeJuicePortal.write.initialize([]);
@@ -474,7 +474,7 @@ export const deployL1Contracts = async (
474474
logger.verbose(`Fee juice portal is already initialized`);
475475
}
476476

477-
logger.info(
477+
logger.verbose(
478478
`Initialized Fee Juice Portal at ${feeJuicePortalAddress} to bridge between L1 ${feeAssetAddress} to L2 ${args.l2FeeJuiceAddress}`,
479479
);
480480

@@ -504,15 +504,15 @@ export const deployL1Contracts = async (
504504
// Set initial blocks as proven if requested
505505
if (args.assumeProvenThrough && args.assumeProvenThrough > 0) {
506506
await rollup.write.setAssumeProvenThroughBlockNumber([BigInt(args.assumeProvenThrough)], { account });
507-
logger.warn(`Set Rollup assumedProvenUntil to ${args.assumeProvenThrough}`);
507+
logger.warn(`Rollup set to assumedProvenUntil to ${args.assumeProvenThrough}`);
508508
}
509509

510510
// Inbox and Outbox are immutable and are deployed from Rollup's constructor so we just fetch them from the contract.
511511
const inboxAddress = EthAddress.fromString((await rollup.read.INBOX([])) as any);
512-
logger.info(`Inbox available at ${inboxAddress}`);
512+
logger.verbose(`Inbox available at ${inboxAddress}`);
513513

514514
const outboxAddress = EthAddress.fromString((await rollup.read.OUTBOX([])) as any);
515-
logger.info(`Outbox available at ${outboxAddress}`);
515+
logger.verbose(`Outbox available at ${outboxAddress}`);
516516

517517
// We need to call a function on the registry to set the various contract addresses.
518518
const registryContract = getContract({
@@ -562,6 +562,8 @@ export const deployL1Contracts = async (
562562
governanceAddress,
563563
};
564564

565+
logger.info(`Aztec L1 contracts initialized`, l1Contracts);
566+
565567
return {
566568
walletClient,
567569
publicClient,

yarn-project/ethereum/src/eth_cheat_codes.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,15 @@ export class EthCheatCodes {
7777
* @param numberOfBlocks - The number of blocks to mine
7878
*/
7979
public async mine(numberOfBlocks = 1): Promise<void> {
80+
await this.doMine(numberOfBlocks);
81+
this.logger.verbose(`Mined ${numberOfBlocks} L1 blocks`);
82+
}
83+
84+
private async doMine(numberOfBlocks = 1): Promise<void> {
8085
const res = await this.rpcCall('hardhat_mine', [numberOfBlocks]);
8186
if (res.error) {
8287
throw new Error(`Error mining: ${res.error.message}`);
8388
}
84-
this.logger.verbose(`Mined ${numberOfBlocks} L1 blocks`);
8589
}
8690

8791
/**
@@ -188,7 +192,7 @@ export class EthCheatCodes {
188192
if (res.error) {
189193
throw new Error(`Error warping: ${res.error.message}`);
190194
}
191-
await this.mine();
195+
await this.doMine();
192196
this.logger.verbose(`Warped L1 timestamp to ${timestamp}`);
193197
}
194198

yarn-project/foundation/src/log/pino-logger.ts

+4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ export function createLogger(module: string): Logger {
3636
/** Log as trace. Use for when we want to denial-of-service any recipient of the logs. */
3737
trace: (msg: string, data?: unknown) => logFn('trace', msg, data),
3838
level: pinoLogger.level as LogLevel,
39+
/** Whether the given level is enabled for this logger. */
3940
isLevelEnabled: (level: LogLevel) => isLevelEnabled(pinoLogger, level),
41+
/** Module name for the logger. */
42+
module,
4043
};
4144
}
4245

@@ -183,6 +186,7 @@ type ErrorLogFn = (msg: string, err?: Error | unknown, data?: LogData) => void;
183186
export type Logger = { [K in LogLevel]: LogFn } & { /** Error log function */ error: ErrorLogFn } & {
184187
level: LogLevel;
185188
isLevelEnabled: (level: LogLevel) => boolean;
189+
module: string;
186190
};
187191

188192
/**

yarn-project/kv-store/src/interfaces/utils.ts

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const mockLogger = {
1212
trace: (msg: string, data: any) => console.log(msg, data),
1313
level: 'trace' as const,
1414
isLevelEnabled: (_level: string) => true,
15+
module: 'kv-store:mock-logger',
1516
};
1617
/* eslint-enable no-console */
1718

yarn-project/p2p/src/client/p2p_client.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export class P2PClient extends WithTracer implements P2P {
221221

222222
this.keepAttestationsInPoolFor = keepAttestationsInPoolFor;
223223

224-
this.blockStream = new L2BlockStream(l2BlockSource, this, this, {
224+
this.blockStream = new L2BlockStream(l2BlockSource, this, this, createLogger('p2p:block_stream'), {
225225
batchSize: blockRequestBatchSize,
226226
pollIntervalMS: blockCheckIntervalMS,
227227
});
@@ -359,7 +359,7 @@ export class P2PClient extends WithTracer implements P2P {
359359
this.setCurrentState(P2PClientState.RUNNING);
360360
this.syncPromise = Promise.resolve();
361361
await this.p2pService.start();
362-
this.log.verbose(`Block ${syncedLatestBlock} (proven ${syncedProvenBlock}) already beyond current block`);
362+
this.log.debug(`Block ${syncedLatestBlock} (proven ${syncedProvenBlock}) already beyond current block`);
363363
}
364364

365365
// publish any txs in TxPool after its doing initial sync

0 commit comments

Comments
 (0)