From aea776155a9ea68f2c87178e0ea8a1b3827067c0 Mon Sep 17 00:00:00 2001 From: PhilWindle <60546371+PhilWindle@users.noreply.github.com> Date: Wed, 13 Dec 2023 09:55:17 +0000 Subject: [PATCH] chore: Reduced spam logging in archiver (#3671) This PR reduces the redundant logging in the archiver. # Checklist: Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge. - [ ] If the pull request requires a cryptography review (e.g. cryptographic algorithm implementations) I have added the 'crypto' tag. - [ ] I have reviewed my diff in github, line by line and removed unexpected formatting changes, testing logs, or commented-out code. - [ ] Every change is related to the PR description. - [ ] I have [linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) this pull request to relevant issues (if any exist). --- .../archiver/src/archiver/archiver.ts | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/yarn-project/archiver/src/archiver/archiver.ts b/yarn-project/archiver/src/archiver/archiver.ts index 5f3c855d224..e8860ceac92 100644 --- a/yarn-project/archiver/src/archiver/archiver.ts +++ b/yarn-project/archiver/src/archiver/archiver.ts @@ -197,20 +197,25 @@ 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,