From 7f5032155c1648ff8194ae064bfd1a24aaddeae7 Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Wed, 10 Jan 2024 17:30:06 +0000 Subject: [PATCH 1/2] Logging --- yarn-project/p2p/src/client/p2p_client.ts | 1 + yarn-project/p2p/src/service/libp2p_service.ts | 13 +++---------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/yarn-project/p2p/src/client/p2p_client.ts b/yarn-project/p2p/src/client/p2p_client.ts index 99798622e1d..9950724f721 100644 --- a/yarn-project/p2p/src/client/p2p_client.ts +++ b/yarn-project/p2p/src/client/p2p_client.ts @@ -197,6 +197,7 @@ export class P2PClient implements P2P { await this.blockDownloader.stop(); await this.runningPromise; this.setCurrentState(P2PClientState.STOPPED); + this.log('P2P client stopped...'); } /** diff --git a/yarn-project/p2p/src/service/libp2p_service.ts b/yarn-project/p2p/src/service/libp2p_service.ts index e13c7e18eda..772c27ff53d 100644 --- a/yarn-project/p2p/src/service/libp2p_service.ts +++ b/yarn-project/p2p/src/service/libp2p_service.ts @@ -31,8 +31,6 @@ import { getEncodedMessage, } from './tx_messages.js'; -const INITIAL_PEER_REFRESH_INTERVAL = 20000; - /** * Create a libp2p peer ID from the private key if provided, otherwise creates a new random ID. * @param privateKey - Optional peer ID private key as hex string @@ -63,7 +61,6 @@ export function exportLibP2PPeerIdToString(peerId: PeerId) { */ export class LibP2PService implements P2PService { private jobQueue: SerialQueue = new SerialQueue(); - private timeout: NodeJS.Timer | undefined = undefined; private knownTxLookup: KnownTxLookup = new KnownTxLookup(); constructor( private config: P2PConfig, @@ -118,10 +115,6 @@ export class LibP2PService implements P2PService { ); const dht = this.node.services['kadDHT'] as DualKadDHT; this.logger(`Started P2P client as ${await dht.getMode()} with Peer ID ${this.node.peerId.toString()}`); - this.timeout = setTimeout(async () => { - this.logger(`Refreshing routing table...`); - await dht.refreshRoutingTable(); - }, INITIAL_PEER_REFRESH_INTERVAL); } /** @@ -129,11 +122,11 @@ export class LibP2PService implements P2PService { * @returns An empty promise. */ public async stop() { - if (this.timeout) { - clearTimeout(this.timeout); - } + this.logger('Stopping job queue...'); await this.jobQueue.end(); + this.logger('Stopping LibP2P...'); await this.node.stop(); + this.logger('LibP2P service stopped'); } /** From 3b0d4219a8e36f407a904506f637997f4887bc68 Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Thu, 11 Jan 2024 10:23:22 +0000 Subject: [PATCH 2/2] More logging --- yarn-project/aztec-node/src/aztec-node/server.ts | 1 + yarn-project/p2p/src/client/p2p_client.ts | 2 ++ yarn-project/sequencer-client/src/sequencer/sequencer.ts | 1 + .../src/synchronizer/server_world_state_synchronizer.ts | 4 ++++ 4 files changed, 8 insertions(+) diff --git a/yarn-project/aztec-node/src/aztec-node/server.ts b/yarn-project/aztec-node/src/aztec-node/server.ts index 1a8ff721839..d2fd81c6075 100644 --- a/yarn-project/aztec-node/src/aztec-node/server.ts +++ b/yarn-project/aztec-node/src/aztec-node/server.ts @@ -285,6 +285,7 @@ export class AztecNodeService implements AztecNode { await this.p2pClient.stop(); await this.worldStateSynchronizer.stop(); await this.blockSource.stop(); + this.log('Closing Merkle Trees'); await this.merkleTreesDb.close(); this.log.info(`Stopped`); } diff --git a/yarn-project/p2p/src/client/p2p_client.ts b/yarn-project/p2p/src/client/p2p_client.ts index 9950724f721..96a5738752d 100644 --- a/yarn-project/p2p/src/client/p2p_client.ts +++ b/yarn-project/p2p/src/client/p2p_client.ts @@ -194,7 +194,9 @@ export class P2PClient implements P2P { this.log('Stopping p2p client...'); this.stopping = true; await this.p2pService.stop(); + this.log('Stopped p2p service'); await this.blockDownloader.stop(); + this.log('Stopped block downloader'); await this.runningPromise; this.setCurrentState(P2PClientState.STOPPED); this.log('P2P client stopped...'); diff --git a/yarn-project/sequencer-client/src/sequencer/sequencer.ts b/yarn-project/sequencer-client/src/sequencer/sequencer.ts index 59d53665595..4bc5d91f204 100644 --- a/yarn-project/sequencer-client/src/sequencer/sequencer.ts +++ b/yarn-project/sequencer-client/src/sequencer/sequencer.ts @@ -83,6 +83,7 @@ export class Sequencer { * Stops the sequencer from processing txs and moves to STOPPED state. */ public async stop(): Promise { + this.log(`Stopping sequencer`); await this.runningPromise?.stop(); this.publisher.interrupt(); this.state = SequencerState.STOPPED; diff --git a/yarn-project/world-state/src/synchronizer/server_world_state_synchronizer.ts b/yarn-project/world-state/src/synchronizer/server_world_state_synchronizer.ts index 200db8482a4..a064f6ae1af 100644 --- a/yarn-project/world-state/src/synchronizer/server_world_state_synchronizer.ts +++ b/yarn-project/world-state/src/synchronizer/server_world_state_synchronizer.ts @@ -117,9 +117,13 @@ export class ServerWorldStateSynchronizer implements WorldStateSynchronizer { this.log('Stopping world state...'); this.stopping = true; await this.l2BlockDownloader.stop(); + this.log('Cancelling job queue...'); await this.jobQueue.cancel(); + this.log('Stopping Merkle trees'); await this.merkleTreeDb.stop(); + this.log('Awaiting promise'); await this.runningPromise; + this.log('Commiting current block number'); await this.commitCurrentL2BlockNumber(); this.setCurrentState(WorldStateRunningState.STOPPED); }