-
Notifications
You must be signed in to change notification settings - Fork 598
refactor: l1 l2 messages cleanup #5270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6cc9f5a
4607876
d9fd5c8
17518eb
c2a3161
0528d33
dfd769a
ed27e71
cd9deb0
3d9914d
588a1ad
e27707f
e779f92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,11 +16,11 @@ import { | |
| /** | ||
| * Data retrieved from logs | ||
| */ | ||
| type DataRetrieval<T> = { | ||
| export type DataRetrieval<T> = { | ||
| /** | ||
| * The next block number. | ||
| * Blocknumber of the last L1 block from which we obtained data. | ||
| */ | ||
| nextEthBlockNumber: bigint; | ||
| lastProcessedL1BlockNumber: bigint; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did this change because in places where we consume the value we need the last processed block num and not the next one after it so I think it makes sense to pass the value around in that format. |
||
| /** | ||
| * The data returned. | ||
| */ | ||
|
|
@@ -69,7 +69,7 @@ export async function retrieveBlockMetadataFromRollup( | |
| searchStartBlock = l2BlockProcessedLogs[l2BlockProcessedLogs.length - 1].blockNumber! + 1n; | ||
| expectedNextL2BlockNum += BigInt(newBlockMetadata.length); | ||
| } while (blockUntilSynced && searchStartBlock <= searchEndBlock); | ||
| return { nextEthBlockNumber: searchStartBlock, retrievedData: retrievedBlockMetadata }; | ||
| return { lastProcessedL1BlockNumber: searchStartBlock - 1n, retrievedData: retrievedBlockMetadata }; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -108,7 +108,7 @@ export async function retrieveBlockBodiesFromAvailabilityOracle( | |
| retrievedBlockBodies.push(...newBlockBodies); | ||
| searchStartBlock = l2TxsPublishedLogs[l2TxsPublishedLogs.length - 1].blockNumber! + 1n; | ||
| } while (blockUntilSynced && searchStartBlock <= searchEndBlock); | ||
| return { nextEthBlockNumber: searchStartBlock, retrievedData: retrievedBlockBodies }; | ||
| return { lastProcessedL1BlockNumber: searchStartBlock - 1n, retrievedData: retrievedBlockBodies }; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -141,5 +141,5 @@ export async function retrieveL1ToL2Messages( | |
| // handles the case when there are no new messages: | ||
| searchStartBlock = (leafInsertedLogs.findLast(msgLog => !!msgLog)?.blockNumber || searchStartBlock) + 1n; | ||
| } while (blockUntilSynced && searchStartBlock <= searchEndBlock); | ||
| return { nextEthBlockNumber: searchStartBlock, retrievedData: retrievedL1ToL2Messages }; | ||
| return { lastProcessedL1BlockNumber: searchStartBlock - 1n, retrievedData: retrievedL1ToL2Messages }; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,9 +52,9 @@ export class L1ToL2MessageStore { | |
| /** | ||
| * Gets the L1 to L2 message index in the L1 to L2 message tree. | ||
| * @param l1ToL2Message - The L1 to L2 message. | ||
| * @returns The index of the L1 to L2 message in the L1 to L2 message tree. | ||
| * @returns The index of the L1 to L2 message in the L1 to L2 message tree (undefined if not found). | ||
| */ | ||
| getMessageIndex(l1ToL2Message: Fr): bigint { | ||
| getMessageIndex(l1ToL2Message: Fr): bigint | undefined { | ||
| for (const [key, message] of this.store.entries()) { | ||
| if (message.equals(l1ToL2Message)) { | ||
| const [blockNumber, messageIndex] = key.split('-'); | ||
|
|
@@ -64,6 +64,6 @@ export class L1ToL2MessageStore { | |
| return indexInTheWholeTree; | ||
| } | ||
| } | ||
| throw new Error(`L1 to L2 message index not found in the store for message ${l1ToL2Message.toString()}`); | ||
| return undefined; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returning undefined now because that is how other endpoints returning indices behave and it makes it more convenient for the implementation of the new |
||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.