-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
fault_proving(compression_service): initial scaffold for dedicated compression service #2788
base: master
Are you sure you want to change the base?
Conversation
035c97c
to
c82613f
Compare
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.
Nice stuff. Just some nits and suggestions but nothing major from me.
@@ -0,0 +1,21 @@ | |||
use thiserror::Error; |
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.
Nit: I believe thiserror doesn't work with no-std. Don't think we need it for now, but if we were to pivot to run compression in a zkvm in the future it's a bit more convenient if we derive derive_more::Error
instead.
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.
we will never mount the service inside a zkvm. there's no need to make this no-std compatible yet
#[derive(Error, Debug)] | ||
pub enum CompressionError { | ||
// L2 block source Errors | ||
/// Failed to get l2 block | ||
#[error("failed to get l2 block: `{0}`")] | ||
FailedToGetBlock(String), | ||
// Compression storage Errors | ||
/// Failed to read compressed block from storage | ||
#[error("failed to write compressed block to storage: `{0}`")] | ||
FailedToWriteCompressedBlock(String), | ||
// Service errors | ||
/// Failed to create service | ||
#[error("failed to create service: `{0}`")] | ||
FailedToCreateService(String), | ||
/// Failed to handle new block | ||
#[error("failed to handle new block: `{0}`")] | ||
FailedToHandleNewBlock(String), | ||
} |
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 don't see these used anywhere. Are the inner String
s just placeholders for later dedicated types? Nit: I'd default to &'static str
instead of String
.
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.
placeholder for now.
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.
even the String
's are just placeholders till we get some concrete types in :)
pub type Block = fuel_core_types::blockchain::block::Block; | ||
|
||
/// Port for L2 blocks source | ||
/// Each time `.next()` is called, the service expects the same behaviour as an iterator. | ||
pub trait BlockSource { | ||
/// Get the next block from the source | ||
fn next( | ||
&self, | ||
) -> impl core::future::Future<Output = crate::Result<Option<Block>>> + Send + Sync; | ||
} |
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.
Nit: I'd rename the method to next_block
for clarity. But I think next
probably also works if the variable in the calling code is properly named.
pub type Block = fuel_core_types::blockchain::block::Block; | |
/// Port for L2 blocks source | |
/// Each time `.next()` is called, the service expects the same behaviour as an iterator. | |
pub trait BlockSource { | |
/// Get the next block from the source | |
fn next( | |
&self, | |
) -> impl core::future::Future<Output = crate::Result<Option<Block>>> + Send + Sync; | |
} | |
pub type Block = fuel_core_types::blockchain::block::Block; | |
/// Port for L2 blocks source | |
/// Each time `.next()` is called, the service expects the same behaviour as an iterator. | |
pub trait BlockSource { | |
/// Get the next block from the source | |
fn next_block( | |
&self, | |
) -> impl core::future::Future<Output = crate::Result<Option<Block>>> + Send + Sync; | |
} |
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.
block_source.next() makes more sense to me than block_source.next_block(). also given that we allude to an iterator format here I think it is reasonable to assume the stream is of blocks.
…mpression service
c82613f
to
9336bd0
Compare
Linked Issues/PRs
Description
Given that we want to modularize the compression service from the offchain worker, this PR begins the refactor.
Things to keep in mind while reviewing -
This pull request introduces a new dedicated compression service for fuel blocks. The key changes include scaffolding the service, defining its configuration, errors, and ports, and implementing the service logic. Below are the most important changes:
New Service Implementation:
.changes/added/2788.md
)CompressionService
struct and its associated methods to handle new blocks, perform compression, and manage service state. (crates/services/compression/src/service.rs
)Configuration and Dependencies:
Cargo.toml
,crates/services/compression/Cargo.toml
) [1] [2]CompressionConfig
struct for service configuration. (crates/services/compression/src/config.rs
)Error Handling:
CompressionError
enum to handle various errors that may occur during the compression process. (crates/services/compression/src/errors.rs
)Ports and Interfaces:
crates/services/compression/src/ports.rs
,crates/services/compression/src/ports/block_source.rs
,crates/services/compression/src/ports/compression_storage.rs
,crates/services/compression/src/ports/configuration.rs
) [1] [2] [3] [4]Code Ownership:
.github/CODEOWNERS
)Checklist
Before requesting review
After merging, notify other teams
[Add or remove entries as needed]