From 65c11817ec760e7642793ae9b1e21a581dbe00fb Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Wed, 13 Dec 2023 09:16:26 +0000 Subject: [PATCH 1/2] Reduced smap logging in archiver --- .../archiver/src/archiver/archiver.ts | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/yarn-project/archiver/src/archiver/archiver.ts b/yarn-project/archiver/src/archiver/archiver.ts index 5f3c855d224..df5937ebde1 100644 --- a/yarn-project/archiver/src/archiver/archiver.ts +++ b/yarn-project/archiver/src/archiver/archiver.ts @@ -197,20 +197,24 @@ export class Archiver implements L2BlockSource, L2LogsSource, ContractDataSource // TODO (#717): optimize this - there could be messages in confirmed that are also in pending. // Or messages in pending that are also cancelled in the same block. No need to modify storage for them. - // Store l1 to l2 messages - this.log('Adding pending l1 to l2 messages to store'); - await this.store.addPendingL1ToL2Messages(retrievedPendingL1ToL2Messages.retrievedData); - // remove cancelled messages from the pending message store: - this.log('Removing pending l1 to l2 messages from store where messages were cancelled'); - await this.store.cancelPendingL1ToL2Messages(retrievedCancelledL1ToL2Messages.retrievedData); + + if (retrievedPendingL1ToL2Messages.retrievedData.length) { + // Store l1 to l2 messages + this.log(`Adding ${retrievedPendingL1ToL2Messages.retrievedData.length} pending l1 to l2 messages to store`); + await this.store.addPendingL1ToL2Messages(retrievedPendingL1ToL2Messages.retrievedData); + } + + if (retrievedCancelledL1ToL2Messages.retrievedData.length) { + // remove cancelled messages from the pending message store: + this.log(`Removing ${retrievedCancelledL1ToL2Messages.retrievedData.length} pending l1 to l2 messages from store where messages were cancelled`); + await this.store.cancelPendingL1ToL2Messages(retrievedCancelledL1ToL2Messages.retrievedData); + } + // ********** Events that are processed per block ********** // Read all data from chain and then write to our stores at the end const nextExpectedL2BlockNum = BigInt((await this.store.getBlockNumber()) + 1); - this.log( - `Retrieving chain state from L1 block: ${this.nextL2BlockFromL1Block}, next expected l2 block number: ${nextExpectedL2BlockNum}`, - ); const retrievedBlocks = await retrieveBlocks( this.publicClient, this.rollupAddress, From 8f6c98de1fa55cd9d3bb050541a154a82e81a84d Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Wed, 13 Dec 2023 09:31:44 +0000 Subject: [PATCH 2/2] Formatting --- yarn-project/archiver/src/archiver/archiver.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/yarn-project/archiver/src/archiver/archiver.ts b/yarn-project/archiver/src/archiver/archiver.ts index df5937ebde1..e8860ceac92 100644 --- a/yarn-project/archiver/src/archiver/archiver.ts +++ b/yarn-project/archiver/src/archiver/archiver.ts @@ -197,20 +197,21 @@ export class Archiver implements L2BlockSource, L2LogsSource, ContractDataSource // TODO (#717): optimize this - there could be messages in confirmed that are also in pending. // Or messages in pending that are also cancelled in the same block. No need to modify storage for them. - + if (retrievedPendingL1ToL2Messages.retrievedData.length) { // Store l1 to l2 messages this.log(`Adding ${retrievedPendingL1ToL2Messages.retrievedData.length} pending l1 to l2 messages to store`); await this.store.addPendingL1ToL2Messages(retrievedPendingL1ToL2Messages.retrievedData); } - + if (retrievedCancelledL1ToL2Messages.retrievedData.length) { // remove cancelled messages from the pending message store: - this.log(`Removing ${retrievedCancelledL1ToL2Messages.retrievedData.length} pending l1 to l2 messages from store where messages were cancelled`); + this.log( + `Removing ${retrievedCancelledL1ToL2Messages.retrievedData.length} pending l1 to l2 messages from store where messages were cancelled`, + ); await this.store.cancelPendingL1ToL2Messages(retrievedCancelledL1ToL2Messages.retrievedData); } - // ********** Events that are processed per block ********** // Read all data from chain and then write to our stores at the end