-
Notifications
You must be signed in to change notification settings - Fork 3
feat: check continuity of payload attributes #346
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
ab3f532
e187b38
b8c703a
ba234ed
aa573b2
74c5ac5
1d1fdcb
8a5acf4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ use core::{ | |
pin::Pin, | ||
task::{ready, Context, Poll}, | ||
}; | ||
use derive_more::{Deref, DerefMut}; | ||
use reth_primitives_traits::transaction::signed::SignedTransaction; | ||
use reth_scroll_primitives::{ScrollBlock, ScrollTransactionSigned}; | ||
use scroll_alloy_consensus::L1_MESSAGE_TRANSACTION_TYPE; | ||
|
@@ -83,69 +84,74 @@ impl arbitrary::Arbitrary<'_> for BlockInfo { | |
} | ||
} | ||
|
||
/// A type alias for a wrapper around a type to which a L1 finalized block number is attached. | ||
pub type WithFinalizedBlockNumber<T> = WithBlockNumber<T>; | ||
|
||
/// A wrapper around a type to which a block number is attached. | ||
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq)] | ||
pub struct WithBlockNumber<T> { | ||
/// The block number. | ||
pub number: u64, | ||
/// A wrapper around a type to which a L2 block number is attached. | ||
#[derive(Debug, Deref, DerefMut, Default, Copy, Clone, PartialEq, Eq)] | ||
pub struct WithL2BlockNumber<T> { | ||
/// The L2 block number. | ||
pub l2_block: u64, | ||
/// The wrapped type. | ||
#[deref] | ||
#[deref_mut] | ||
pub inner: T, | ||
} | ||
|
||
impl<T> WithBlockNumber<T> { | ||
/// Returns a new instance of a [`WithBlockNumber`] wrapper. | ||
pub const fn new(number: u64, inner: T) -> Self { | ||
Self { number, inner } | ||
impl<T> WithL2BlockNumber<T> { | ||
/// Returns a new instance of a [`WithL2BlockNumber`] wrapper. | ||
pub const fn new(l2_block: u64, inner: T) -> Self { | ||
Self { l2_block, inner } | ||
} | ||
} | ||
|
||
impl<T: Future + Unpin> Future for WithBlockNumber<T> { | ||
type Output = WithBlockNumber<<T as Future>::Output>; | ||
impl<T: Future + Unpin> Future for WithL2BlockNumber<T> { | ||
type Output = WithL2BlockNumber<<T as Future>::Output>; | ||
|
||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { | ||
let block_number = self.number; | ||
let block_number = self.l2_block; | ||
let inner = ready!(Pin::new(&mut self.get_mut().inner).poll(cx)); | ||
Poll::Ready(WithBlockNumber::new(block_number, inner)) | ||
Poll::Ready(WithL2BlockNumber::new(block_number, inner)) | ||
} | ||
} | ||
|
||
/// A type alias for a wrapper around a type to which a finalized batch information is attached. | ||
pub type WithFinalizedBatchInfo<T> = WithBatchInfo<T>; | ||
/// A wrapper around a type to which a L1 block number is attached. | ||
#[derive(Debug, Deref, DerefMut, Default, Copy, Clone, PartialEq, Eq)] | ||
pub struct WithL1FinalizedBlockNumber<T> { | ||
/// The block number. | ||
pub l1_block: u64, | ||
/// The wrapped type. | ||
#[deref] | ||
#[deref_mut] | ||
pub inner: T, | ||
} | ||
|
||
/// A type alias for a wrapper around a type to which a committed batch information is attached. | ||
pub type WithCommittedBatchInfo<T> = WithBatchInfo<T>; | ||
impl<T> WithL1FinalizedBlockNumber<T> { | ||
/// Returns a new instance of a [`WithL1FinalizedBlockNumber`] wrapper. | ||
pub const fn new(l1_block: u64, inner: T) -> Self { | ||
Self { l1_block, inner } | ||
} | ||
} | ||
|
||
/// A wrapper around a type to which a batch information is attached. | ||
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq)] | ||
#[derive(Debug, Deref, DerefMut, Default, Copy, Clone, PartialEq, Eq)] | ||
pub struct WithBatchInfo<T> { | ||
/// The l1 block number associated with the batch. | ||
pub number: u64, | ||
/// The index of the batch. | ||
pub index: u64, | ||
/// The hash of the batch. | ||
pub hash: B256, | ||
/// The wrapped type. | ||
#[deref] | ||
#[deref_mut] | ||
pub inner: T, | ||
} | ||
|
||
impl<T> WithBatchInfo<T> { | ||
/// Returns a new instance of a [`WithBatchInfo`] wrapper. | ||
pub const fn new(index: u64, number: u64, inner: T) -> Self { | ||
Self { index, number, inner } | ||
pub const fn new(index: u64, hash: B256, inner: T) -> Self { | ||
Self { index, hash, inner } | ||
} | ||
} | ||
|
||
impl<T: Future + Unpin> Future for WithBatchInfo<T> { | ||
type Output = WithBatchInfo<<T as Future>::Output>; | ||
|
||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { | ||
let block_number = self.number; | ||
let index = self.index; | ||
let inner = ready!(Pin::new(&mut self.get_mut().inner).poll(cx)); | ||
Poll::Ready(WithBatchInfo::new(index, block_number, inner)) | ||
} | ||
} | ||
/// Type alias for a wrapper type with the full L2 metadata. | ||
pub type WithFullL2Meta<T> = WithL1FinalizedBlockNumber<WithL2BlockNumber<WithBatchInfo<T>>>; | ||
|
||
|
||
/// This struct represents an L2 block with a vector the hashes of the L1 messages included in the | ||
/// block. | ||
|
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.
This type is getting unwieldy with the requirement of
.inner.inner.inner
. Should we consider refactoring the base types to include the additional metadata?