Skip to content
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

replace block fields with BlockBody #10907

Open
mattsse opened this issue Sep 14, 2024 · 3 comments · May be fixed by #10913
Open

replace block fields with BlockBody #10907

mattsse opened this issue Sep 14, 2024 · 3 comments · May be fixed by #10913
Assignees
Labels
A-sdk Related to reth's use as a library C-debt Refactor of code section that is hard to understand or maintain C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started

Comments

@mattsse
Copy link
Collaborator

mattsse commented Sep 14, 2024

Describe the feature

currently Block has a flattened blockbody as its fields:

/// Transactions in this block.
pub body: Vec<TransactionSigned>,
/// Ommers/uncles header.
pub ommers: Vec<Header>,
/// Block withdrawals.
pub withdrawals: Option<Withdrawals>,
/// Block requests.
pub requests: Option<Requests>,

pub struct BlockBody {
/// Transactions in the block
pub transactions: Vec<TransactionSigned>,
/// Uncle headers for the given block
pub ommers: Vec<Header>,
/// Withdrawals in the block.
pub withdrawals: Option<Withdrawals>,
/// Requests in the block.
pub requests: Option<Requests>,
}

if we want to abstract a block as

trait Block {type Body;}

then we need to use the container type

see also:

/// Create a new sealed block instance using the sealed header and block body.
#[inline]
pub fn new(header: SealedHeader, body: BlockBody) -> Self {
let BlockBody { transactions, ommers, withdrawals, requests } = body;
Self { header, body: transactions, ommers, withdrawals, requests }
}

TODO

  • replace fields with BlockBody

Additional context

fyi @refcell

alloy-rs/alloy#1290

@mattsse mattsse added C-enhancement New feature or request S-needs-triage This issue needs to be labelled D-good-first-issue Nice and easy! A great choice to get started C-debt Refactor of code section that is hard to understand or maintain A-sdk Related to reth's use as a library and removed S-needs-triage This issue needs to be labelled labels Sep 14, 2024
@roynalnaruto
Copy link
Contributor

@mattsse can I take this up?

In addition to the above, may be some methods can be moved to the BlockBody, for instance has_blob_transactions, has_eip7702_transactions, and a few others. With Block dereferencing to BlockBody for those ?

@PoulavBhowmick03
Copy link

@mattsse I am a new contributor to reth. I would love to work on this!

@roynalnaruto roynalnaruto linked a pull request Sep 15, 2024 that will close this issue
@roynalnaruto
Copy link
Contributor

roynalnaruto commented Sep 15, 2024

@mattsse I have some preliminary work here: #10913, let me know if it generally looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sdk Related to reth's use as a library C-debt Refactor of code section that is hard to understand or maintain C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

3 participants