1
- // Part of this code was adapted from foundry and is distributed under their licenss:
1
+ // Part of this code was adapted from foundry and is distributed under their
2
+ // licenss:
2
3
// - https://github.com/foundry-rs/foundry/blob/01b16238ff87dc7ca8ee3f5f13e389888c2a2ee4/LICENSE-APACHE
3
4
// - https://github.com/foundry-rs/foundry/blob/01b16238ff87dc7ca8ee3f5f13e389888c2a2ee4/LICENSE-MIT
4
5
// For the original context see: https://github.com/foundry-rs/foundry/blob/01b16238ff87dc7ca8ee3f5f13e389888c2a2ee4/anvil/core/src/eth/block.rs
@@ -54,7 +55,8 @@ pub struct Block {
54
55
}
55
56
56
57
impl Block {
57
- /// Constructs a new block from the provided partial header, transactions, and ommers.
58
+ /// Constructs a new block from the provided partial header, transactions,
59
+ /// and ommers.
58
60
pub fn new (
59
61
mut partial_header : PartialHeader ,
60
62
transactions : Vec < SignedTransaction > ,
@@ -138,7 +140,8 @@ pub struct Header {
138
140
/// Blob gas was added by EIP-4844 and is ignored in older headers.
139
141
#[ cfg_attr( feature = "serde" , serde( flatten) ) ]
140
142
pub blob_gas : Option < BlobGas > ,
141
- /// The hash tree root of the parent beacon block for the given execution block (EIP-4788).
143
+ /// The hash tree root of the parent beacon block for the given execution
144
+ /// block (EIP-4788).
142
145
pub parent_beacon_block_root : Option < B256 > ,
143
146
}
144
147
@@ -159,16 +162,19 @@ impl From<B64Def> for B64 {
159
162
#[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
160
163
#[ cfg_attr( feature = "serde" , serde( rename_all = "camelCase" ) ) ]
161
164
pub struct BlobGas {
162
- /// The total amount of blob gas consumed by the transactions within the block.
165
+ /// The total amount of blob gas consumed by the transactions within the
166
+ /// block.
163
167
pub gas_used : u64 ,
164
168
/// The running total of blob gas consumed in excess of the target, prior to
165
- /// the block. Blocks with above-target blob gas consumption increase this value,
166
- /// blocks with below-target blob gas consumption decrease it (bounded at 0).
169
+ /// the block. Blocks with above-target blob gas consumption increase this
170
+ /// value, blocks with below-target blob gas consumption decrease it
171
+ /// (bounded at 0).
167
172
pub excess_gas : u64 ,
168
173
}
169
174
170
175
impl Header {
171
- /// Constructs a header from the provided [`PartialHeader`], ommers' root hash, transactions' root hash, and withdrawals' root hash.
176
+ /// Constructs a header from the provided [`PartialHeader`], ommers' root
177
+ /// hash, transactions' root hash, and withdrawals' root hash.
172
178
pub fn new ( partial_header : PartialHeader , ommers_hash : B256 , transactions_root : B256 ) -> Self {
173
179
Self {
174
180
parent_hash : partial_header. parent_hash ,
@@ -341,12 +347,14 @@ pub struct PartialHeader {
341
347
pub withdrawals_root : Option < B256 > ,
342
348
/// Blob gas was added by EIP-4844 and is ignored in older headers.
343
349
pub blob_gas : Option < BlobGas > ,
344
- /// The hash tree root of the parent beacon block for the given execution block (EIP-4788).
350
+ /// The hash tree root of the parent beacon block for the given execution
351
+ /// block (EIP-4788).
345
352
pub parent_beacon_block_root : Option < B256 > ,
346
353
}
347
354
348
355
impl PartialHeader {
349
- /// Constructs a new instance based on the provided [`BlockOptions`] and parent [`Header`] for the given [`SpecId`].
356
+ /// Constructs a new instance based on the provided [`BlockOptions`] and
357
+ /// parent [`Header`] for the given [`SpecId`].
350
358
pub fn new ( spec_id : SpecId , options : BlockOptions , parent : Option < & Header > ) -> Self {
351
359
let timestamp = options. timestamp . unwrap_or_default ( ) ;
352
360
let number = options. number . unwrap_or ( {
@@ -403,7 +411,8 @@ impl PartialHeader {
403
411
} ) ,
404
412
blob_gas : if spec_id >= SpecId :: CANCUN {
405
413
let excess_gas = parent. and_then ( |parent| parent. blob_gas . as_ref ( ) ) . map_or (
406
- // For the first (post-fork) block, both parent.blob_gas_used and parent.excess_blob_gas are evaluated as 0.
414
+ // For the first (post-fork) block, both parent.blob_gas_used and
415
+ // parent.excess_blob_gas are evaluated as 0.
407
416
0 ,
408
417
|BlobGas {
409
418
gas_used,
0 commit comments