-
Notifications
You must be signed in to change notification settings - Fork 231
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
feat(consensus): Generic Block Type #1319
Changes from 7 commits
fe31e10
41ae5c0
15d43c2
1f84798
526e9ef
e197a09
5a9bf0c
76ff168
f956528
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,38 @@ | ||||||||||||
//! Genesic Block Type | ||||||||||||
|
||||||||||||
use crate::{Header, Requests}; | ||||||||||||
use alloc::vec::Vec; | ||||||||||||
use alloy_eips::{ | ||||||||||||
eip2718::{Decodable2718, Encodable2718}, | ||||||||||||
eip4895::Withdrawal, | ||||||||||||
}; | ||||||||||||
use alloy_rlp::{Decodable, Encodable, RlpDecodable, RlpEncodable}; | ||||||||||||
|
||||||||||||
/// Ethereum full block. | ||||||||||||
/// | ||||||||||||
/// Withdrawals can be optionally included at the end of the RLP encoded message. | ||||||||||||
/// | ||||||||||||
/// Taken from [reth-primitives](https://github.com/paradigmxyz/reth) | ||||||||||||
#[derive(Debug, Clone, PartialEq, Eq, Default, RlpEncodable, RlpDecodable)] | ||||||||||||
#[rlp(trailing)] | ||||||||||||
pub struct Block<T: Encodable + Decodable + Encodable2718 + Decodable2718> { | ||||||||||||
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. same 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. this should only use and it is expected that this is equivalent to alloy/crates/eips/src/eip2718.rs Line 219 in 21bc07e
see: alloy/crates/consensus/src/transaction/envelope.rs Lines 329 to 332 in 21bc07e
because this type is the p2p type |
||||||||||||
/// Block header. | ||||||||||||
pub header: Header, | ||||||||||||
/// Block body. | ||||||||||||
#[rlp(flatten)] | ||||||||||||
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. I don't think |
||||||||||||
pub body: BlockBody<T>, | ||||||||||||
} | ||||||||||||
|
||||||||||||
/// A block body. | ||||||||||||
#[derive(Debug, Clone, PartialEq, Eq, Default, RlpEncodable, RlpDecodable)] | ||||||||||||
#[rlp(trailing)] | ||||||||||||
pub struct BlockBody<T: Encodable + Decodable + Encodable2718 + Decodable2718> { | ||||||||||||
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. let's not require anything here 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. I think we need Encodable + Decodable for the 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. I see 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. hmm, I don't think it's needed? those derives will add bounds for respective impl blocks |
||||||||||||
/// Transactions in this block. | ||||||||||||
pub transactions: Vec<T>, | ||||||||||||
/// Ommers/uncles header. | ||||||||||||
pub ommers: Vec<Header>, | ||||||||||||
/// Block withdrawals. | ||||||||||||
pub withdrawals: Option<Vec<Withdrawal>>, | ||||||||||||
/// Block requests | ||||||||||||
pub requests: Option<Requests>, | ||||||||||||
} |
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.
can we add this as context:
https://github.com/paradigmxyz/reth/blob/3fa1e28e12cf7b05a365e93ade19a6de9e2aafd3/crates/primitives/src/block.rs#L567-L569
and reference
https://github.com/ethereum/devp2p/blob/master/caps/eth.md#block-encoding-and-validity