-
Notifications
You must be signed in to change notification settings - Fork 7
Primitives, Components and Interfaces Design #29
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
770df2f
primitives and l1 contracts
frisitano 6d0fc65
add database empty lib
frisitano fb58c5e
commit updated code strucutre
frisitano 2795c09
update codec and interfaces
frisitano 69016d7
updates
frisitano 9d495b2
Refactor L1Watcher to return PipelineEvent(u64) (#31)
frisitano 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| [package] | ||
| name = "codec" | ||
| version.workspace = true | ||
| edition.workspace = true | ||
| rust-version.workspace = true | ||
| license.workspace = true | ||
| exclude.workspace = true | ||
|
|
||
| [dependencies] | ||
|
|
||
| [lints] | ||
| workspace = true |
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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| pub struct BatchCodec; |
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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| pub struct ChunkCodec; |
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 |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| pub enum CodecError { | ||
| Error, | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| mod batch; | ||
| mod chunk; | ||
| mod error; |
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 |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| [package] | ||
| name = "database" | ||
| version.workspace = true | ||
| edition.workspace = true | ||
| rust-version.workspace = true | ||
| license.workspace = true | ||
| exclude.workspace = true | ||
|
|
||
| [dependencies] | ||
|
|
||
| [lints] | ||
| workspace = true |
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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| pub struct Database; |
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 |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| [package] | ||
| name = "scroll-indexer" | ||
| version.workspace = true | ||
| edition.workspace = true | ||
| rust-version.workspace = true | ||
| license.workspace = true | ||
| exclude.workspace = true | ||
|
|
||
| [dependencies] | ||
| # rollup-node | ||
| scroll-l1.workspace = true | ||
| scroll-primitives.workspace = true | ||
|
|
||
| [lints] | ||
| workspace = true |
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 |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| //! A library responsible for indexing data relevant to the L1. | ||
|
|
||
| use scroll_l1::L1Event; | ||
| use scroll_primitives::{BatchInput, L1Message}; | ||
| use std::sync::Arc; | ||
|
|
||
| /// The indexer is responsible for indexing data relevant to the L1. | ||
| #[derive(Debug)] | ||
| pub struct Indexer; | ||
|
|
||
| impl Indexer { | ||
| /// Handles an event from the L1. | ||
| pub async fn handle_l1_event(&mut self, event: L1Event) { | ||
| match event { | ||
| L1Event::Reorg(block_number) => self.handle_reorg(block_number).await, | ||
| L1Event::NewBlock(block_number) => todo!(), | ||
| L1Event::Finalized(block_number) => self.handle_finalized(block_number).await, | ||
| L1Event::L1Message(l1_message) => self.handle_l1_message(l1_message).await, | ||
| L1Event::PipelineEvent(block_number) => (), | ||
| } | ||
| } | ||
|
|
||
| async fn handle_reorg(&mut self, _block_number: u64) { | ||
| todo!() | ||
| } | ||
|
|
||
| async fn handle_finalized(&mut self, _block_number: u64) { | ||
| todo!() | ||
| } | ||
|
|
||
| async fn handle_l1_message(&mut self, _l1_message: Arc<L1Message>) { | ||
| todo!() | ||
| } | ||
|
|
||
| async fn handle_batch_input(&mut self, _batch_input: Arc<BatchInput>) { | ||
| todo!() | ||
| } | ||
| } | ||
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 |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| [package] | ||
| name = "scroll-l1" | ||
| version.workspace = true | ||
| edition.workspace = true | ||
| rust-version.workspace = true | ||
| license.workspace = true | ||
| exclude.workspace = true | ||
|
|
||
| [dependencies] | ||
| # alloy | ||
| alloy-sol-types = { version = "0.8.20", features = ["json"] } | ||
| alloy-contract = { version = "0.11.1", default-features = false } | ||
| alloy-primitives.workspace = true | ||
|
|
||
| # rollup-node | ||
| scroll-primitives.workspace = true | ||
|
|
||
| # misc | ||
| futures.workspace = true | ||
|
|
||
| [lints] | ||
| workspace = true |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| use alloy_sol_types::sol; | ||
|
|
||
| // L1 Message Queue Contract | ||
| sol!( | ||
| #[allow(missing_docs)] | ||
| #[sol(rpc)] | ||
| L1MessageQueue, | ||
| "abi/L1MessageQueue.json", | ||
| ); | ||
|
|
||
| // Scroll Chain Contract | ||
| sol!( | ||
| #[allow(missing_docs)] | ||
| #[sol(rpc)] | ||
| ScrollChain, | ||
| "abi/ScrollChain.json", | ||
| ); |
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 |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| use alloy_primitives::{address, Address}; | ||
|
|
||
| // TODO: Update the addresses. | ||
|
|
||
| /// The address of the L1 Message Queue contract on mainnet. | ||
| pub const MAINNET_L1_MESSAGE_QUEUE_ADDRESS: Address = | ||
| address!("0000000000000000000000000000000000000000"); | ||
|
|
||
| /// The address of the Scroll Chain contract on mainnet. | ||
| pub const MAINNET_L1_SCROLL_CHAIN_ADDRESS: Address = | ||
| address!("0000000000000000000000000000000000000000"); |
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 |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| use scroll_primitives::L1Message; | ||
| use std::sync::Arc; | ||
|
|
||
| /// An observation from the L1. | ||
| #[derive(Debug)] | ||
| pub enum L1Event { | ||
| /// A block containing a pipeline event has been added to the L1. | ||
| PipelineEvent(u64), | ||
| /// A new L1 message has been added to the L1. | ||
| L1Message(Arc<L1Message>), | ||
| /// A new block has been added to the L1. | ||
| NewBlock(u64), | ||
| /// A reorg has occurred at the given block number. | ||
| Reorg(u64), | ||
| /// The L1 has been finalized at the given block number. | ||
| Finalized(u64), | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| //! A library containing the logic required to interact with L1. | ||
|
|
||
| mod abi; | ||
| mod constants; | ||
| mod event; | ||
| mod watcher; | ||
|
|
||
| pub use constants::*; | ||
| pub use event::L1Event; | ||
| pub use watcher::L1Watcher; |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CommitBatchandL1Messageare specific events to Scroll and the others are general L1 "events". Is this correct?What about
RevertandFinalizeevents for batches?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we will need to index
Finalizeto determine the rollup finality status.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is such a good idea to add the rollup events here.
When having a new version: If we add or change the events intrinsic meaning, even if we remove an event we will always need to support all of this here to be able to sync from genesis.
I still think we should try to encapsulate all the derivation specifics as much as possible and push them into a specific derivation pipeline implementation. We could have derivation pipeline implementations for different versions of the protocol/codec.
This way the general node framework stays the same: