-
Notifications
You must be signed in to change notification settings - Fork 607
archiver stores L1ToL2 pending messages #642
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,12 @@ | ||
| import { ContractPublicData, L2Block, UnverifiedData, INITIAL_L2_BLOCK_NUM, ContractData } from '@aztec/types'; | ||
| import { | ||
| ContractPublicData, | ||
| L2Block, | ||
| UnverifiedData, | ||
| INITIAL_L2_BLOCK_NUM, | ||
| ContractData, | ||
| L1ToL2Message, | ||
| } from '@aztec/types'; | ||
| import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/circuits.js'; | ||
| import { AztecAddress } from '@aztec/foundation/aztec-address'; | ||
|
|
||
| /** | ||
|
|
@@ -9,6 +17,8 @@ export interface ArchiverDataStore { | |
| addL2Blocks(blocks: L2Block[]): Promise<boolean>; | ||
| getL2Blocks(from: number, take: number): Promise<L2Block[]>; | ||
| addUnverifiedData(data: UnverifiedData[]): Promise<boolean>; | ||
| addPendingL1ToL2Messages(messages: L1ToL2Message[]): Promise<boolean>; | ||
| getPendingL1ToL2Messages(take: number): Promise<L1ToL2Message[]>; | ||
| getUnverifiedData(from: number, take: number): Promise<UnverifiedData[]>; | ||
| addL2ContractPublicData(data: ContractPublicData[], blockNum: number): Promise<boolean>; | ||
| getL2ContractPublicData(contractAddress: AztecAddress): Promise<ContractPublicData | undefined>; | ||
|
|
@@ -40,6 +50,11 @@ export class MemoryArchiverStore implements ArchiverDataStore { | |
| */ | ||
| private contractPublicData: (ContractPublicData[] | undefined)[] = []; | ||
|
|
||
| /** | ||
| * An array containing all the pending L1 to L2 messages | ||
| */ | ||
| private pendingL1ToL2Messages: L1ToL2Message[] = []; | ||
|
|
||
| constructor() {} | ||
|
|
||
| /** | ||
|
|
@@ -62,6 +77,16 @@ export class MemoryArchiverStore implements ArchiverDataStore { | |
| return Promise.resolve(true); | ||
| } | ||
|
|
||
| /** | ||
| * Append new pending L1 to L2 messages to the store's list. | ||
| * @param messages - The L1 to L2 messages to be added to the store. | ||
| * @returns True if the operation is successful (always in this implementation). | ||
| */ | ||
| public addPendingL1ToL2Messages(messages: L1ToL2Message[]): Promise<boolean> { | ||
| this.pendingL1ToL2Messages.push(...messages); | ||
| return Promise.resolve(true); | ||
| } | ||
|
|
||
| /** | ||
| * Store new Contract Public Data from an L2 block to the store's list. | ||
| * @param data - List of contracts' data to be added. | ||
|
|
@@ -91,6 +116,17 @@ export class MemoryArchiverStore implements ArchiverDataStore { | |
| return Promise.resolve(this.l2Blocks.slice(startIndex, endIndex)); | ||
| } | ||
|
|
||
| /** | ||
| * Gets the `take` amount of pending L1 to L2 messages. | ||
| * @param take - The number of messages to return (by default NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP). | ||
| * @returns The requested L1 to L2 messages. | ||
| */ | ||
| public getPendingL1ToL2Messages(take: number = NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP): Promise<L1ToL2Message[]> { | ||
| // todo: @rahul https://github.com/AztecProtocol/aztec-packages/issues/529 - change this so that sequencer actually actually consumes messages sorted by fee or another value | ||
| // upon consumption, the messages are removed from the store | ||
| return Promise.resolve(this.pendingL1ToL2Messages.slice(0, take)); | ||
|
Member
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. Does this decrease the size of the existing
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. sampled for now - will remove in #529 |
||
| } | ||
|
|
||
| /** | ||
| * Gets the `take` amount of unverified data starting from `from`. | ||
| * @param from - Number of the L2 block to which corresponds the first `unverifiedData` to be returned. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.