Skip to content

Commit 9a23291

Browse files
committed
rename
1 parent b283c74 commit 9a23291

File tree

5 files changed

+69
-55
lines changed

5 files changed

+69
-55
lines changed

crates/consensus/src/block/any.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pub struct AnyHeader {
105105
skip_serializing_if = "Option::is_none"
106106
)
107107
)]
108-
pub target_blob_count: Option<u64>,
108+
pub target_blobs_per_block: Option<u64>,
109109
}
110110

111111
impl BlockHeader for AnyHeader {
@@ -189,8 +189,8 @@ impl BlockHeader for AnyHeader {
189189
self.requests_hash
190190
}
191191

192-
fn target_blob_count(&self) -> Option<u64> {
193-
self.target_blob_count
192+
fn target_blobs_per_block(&self) -> Option<u64> {
193+
self.target_blobs_per_block
194194
}
195195

196196
fn extra_data(&self) -> &Bytes {
@@ -222,7 +222,7 @@ impl From<super::Header> for AnyHeader {
222222
excess_blob_gas,
223223
parent_beacon_block_root,
224224
requests_hash,
225-
target_blob_count,
225+
target_blobs_per_block,
226226
} = value;
227227

228228
Self {
@@ -247,7 +247,7 @@ impl From<super::Header> for AnyHeader {
247247
excess_blob_gas,
248248
parent_beacon_block_root,
249249
requests_hash,
250-
target_blob_count,
250+
target_blobs_per_block,
251251
}
252252
}
253253
}

crates/consensus/src/block/header.rs

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ pub struct Header {
136136
skip_serializing_if = "Option::is_none"
137137
)
138138
)]
139-
pub target_blob_count: Option<u64>,
139+
pub target_blobs_per_block: Option<u64>,
140140
}
141141

142142
impl AsRef<Self> for Header {
@@ -169,7 +169,7 @@ impl Default for Header {
169169
excess_blob_gas: None,
170170
parent_beacon_block_root: None,
171171
requests_hash: None,
172-
target_blob_count: None,
172+
target_blobs_per_block: None,
173173
}
174174
}
175175
}
@@ -219,16 +219,19 @@ impl Header {
219219
///
220220
/// Returns `None` if `excess_blob_gas` is None.
221221
///
222-
/// If `next_block_target_blob_count` is [`Some`], uses EIP-7742 formula for calculating the
223-
/// blob gas price, otherwise uses EIP-4844 formula.
222+
/// If `next_block_target_blobs_per_block` is [`Some`], uses EIP-7742 formula for calculating
223+
/// the blob gas price, otherwise uses EIP-4844 formula.
224224
///
225225
/// See also [Self::next_block_excess_blob_gas]
226-
pub fn next_block_blob_fee(&self, next_block_target_blob_count: Option<u64>) -> Option<u128> {
226+
pub fn next_block_blob_fee(
227+
&self,
228+
next_block_target_blobs_per_block: Option<u64>,
229+
) -> Option<u128> {
227230
let next_block_excess_blob_gas = self.next_block_excess_blob_gas()?;
228-
Some(next_block_target_blob_count.map_or_else(
231+
Some(next_block_target_blobs_per_block.map_or_else(
229232
|| eip4844::calc_blob_gasprice(next_block_excess_blob_gas),
230-
|target_blob_count| {
231-
eip7742::calc_blob_gasprice(next_block_excess_blob_gas, target_blob_count)
233+
|target_blobs_per_block| {
234+
eip7742::calc_blob_gasprice(next_block_excess_blob_gas, target_blobs_per_block)
232235
},
233236
))
234237
}
@@ -253,10 +256,14 @@ impl Header {
253256
let excess_blob_gas = self.excess_blob_gas?;
254257
let blob_gas_used = self.blob_gas_used?;
255258

256-
Some(self.target_blob_count.map_or_else(
259+
Some(self.target_blobs_per_block.map_or_else(
257260
|| eip4844::calc_excess_blob_gas(excess_blob_gas, blob_gas_used),
258-
|target_blob_count| {
259-
eip7742::calc_excess_blob_gas(excess_blob_gas, blob_gas_used, target_blob_count)
261+
|target_blobs_per_block| {
262+
eip7742::calc_excess_blob_gas(
263+
excess_blob_gas,
264+
blob_gas_used,
265+
target_blobs_per_block,
266+
)
260267
},
261268
))
262269
}
@@ -333,8 +340,8 @@ impl Header {
333340
length += requests_hash.length();
334341
}
335342

336-
if let Some(target_blob_count) = self.target_blob_count {
337-
length += target_blob_count.length();
343+
if let Some(target_blobs_per_block) = self.target_blobs_per_block {
344+
length += target_blobs_per_block.length();
338345
}
339346

340347
length
@@ -431,8 +438,8 @@ impl Encodable for Header {
431438
requests_hash.encode(out);
432439
}
433440

434-
if let Some(ref target_blob_count) = self.target_blob_count {
435-
target_blob_count.encode(out);
441+
if let Some(ref target_blobs_per_block) = self.target_blobs_per_block {
442+
target_blobs_per_block.encode(out);
436443
}
437444
}
438445

@@ -473,7 +480,7 @@ impl Decodable for Header {
473480
excess_blob_gas: None,
474481
parent_beacon_block_root: None,
475482
requests_hash: None,
476-
target_blob_count: None,
483+
target_blobs_per_block: None,
477484
};
478485
if started_len - buf.len() < rlp_head.payload_length {
479486
this.base_fee_per_gas = Some(u64::decode(buf)?);
@@ -505,7 +512,7 @@ impl Decodable for Header {
505512

506513
// Decode target blob count.
507514
if started_len - buf.len() < rlp_head.payload_length {
508-
this.target_blob_count = Some(u64::decode(buf)?);
515+
this.target_blobs_per_block = Some(u64::decode(buf)?);
509516
}
510517

511518
let consumed = started_len - buf.len();
@@ -584,7 +591,7 @@ impl<'a> arbitrary::Arbitrary<'a> for Header {
584591
parent_beacon_block_root: u.arbitrary()?,
585592
requests_hash: u.arbitrary()?,
586593
withdrawals_root: u.arbitrary()?,
587-
target_blob_count: u.arbitrary()?,
594+
target_blobs_per_block: u.arbitrary()?,
588595
};
589596

590597
Ok(generate_valid_header(
@@ -660,7 +667,7 @@ pub trait BlockHeader {
660667
fn requests_hash(&self) -> Option<B256>;
661668

662669
/// Retrieves the target blob count of the block, if available
663-
fn target_blob_count(&self) -> Option<u64>;
670+
fn target_blobs_per_block(&self) -> Option<u64>;
664671

665672
/// Retrieves the block's extra data field
666673
fn extra_data(&self) -> &Bytes;
@@ -673,10 +680,14 @@ pub trait BlockHeader {
673680
let excess_blob_gas = self.excess_blob_gas()?;
674681
let blob_gas_used = self.blob_gas_used()?;
675682

676-
Some(self.target_blob_count().map_or_else(
683+
Some(self.target_blobs_per_block().map_or_else(
677684
|| eip4844::calc_excess_blob_gas(excess_blob_gas, blob_gas_used),
678-
|target_blob_count| {
679-
eip7742::calc_excess_blob_gas(excess_blob_gas, blob_gas_used, target_blob_count)
685+
|target_blobs_per_block| {
686+
eip7742::calc_excess_blob_gas(
687+
excess_blob_gas,
688+
blob_gas_used,
689+
target_blobs_per_block,
690+
)
680691
},
681692
))
682693
}
@@ -685,16 +696,16 @@ pub trait BlockHeader {
685696
///
686697
/// Returns `None` if `excess_blob_gas` is None.
687698
///
688-
/// If `next_block_target_blob_count` is [`Some`], uses EIP-7742 formula for calculating the
689-
/// blob gas price, otherwise uses EIP-4844 formula.
699+
/// If `next_block_target_blobs_per_block` is [`Some`], uses EIP-7742 formula for calculating
700+
/// the blob gas price, otherwise uses EIP-4844 formula.
690701
///
691702
/// See also [BlockHeader::next_block_excess_blob_gas]
692-
fn next_block_blob_fee(&self, next_block_target_blob_count: Option<u64>) -> Option<u128> {
703+
fn next_block_blob_fee(&self, next_block_target_blobs_per_block: Option<u64>) -> Option<u128> {
693704
let next_block_excess_blob_gas = self.next_block_excess_blob_gas()?;
694-
Some(next_block_target_blob_count.map_or_else(
705+
Some(next_block_target_blobs_per_block.map_or_else(
695706
|| eip4844::calc_blob_gasprice(next_block_excess_blob_gas),
696-
|target_blob_count| {
697-
eip7742::calc_blob_gasprice(next_block_excess_blob_gas, target_blob_count)
707+
|target_blobs_per_block| {
708+
eip7742::calc_blob_gasprice(next_block_excess_blob_gas, target_blobs_per_block)
698709
},
699710
))
700711
}
@@ -781,8 +792,8 @@ impl BlockHeader for Header {
781792
self.requests_hash
782793
}
783794

784-
fn target_blob_count(&self) -> Option<u64> {
785-
self.target_blob_count
795+
fn target_blobs_per_block(&self) -> Option<u64> {
796+
self.target_blobs_per_block
786797
}
787798

788799
fn extra_data(&self) -> &Bytes {
@@ -842,7 +853,7 @@ pub(crate) mod serde_bincode_compat {
842853
#[serde(default)]
843854
requests_hash: Option<B256>,
844855
#[serde(default)]
845-
target_blob_count: Option<u64>,
856+
target_blobs_per_block: Option<u64>,
846857
extra_data: Cow<'a, Bytes>,
847858
}
848859

@@ -870,7 +881,7 @@ pub(crate) mod serde_bincode_compat {
870881
parent_beacon_block_root: value.parent_beacon_block_root,
871882
requests_hash: value.requests_hash,
872883
extra_data: Cow::Borrowed(&value.extra_data),
873-
target_blob_count: value.target_blob_count,
884+
target_blobs_per_block: value.target_blobs_per_block,
874885
}
875886
}
876887
}
@@ -899,7 +910,7 @@ pub(crate) mod serde_bincode_compat {
899910
parent_beacon_block_root: value.parent_beacon_block_root,
900911
requests_hash: value.requests_hash,
901912
extra_data: value.extra_data.into_owned(),
902-
target_blob_count: value.target_blob_count,
913+
target_blobs_per_block: value.target_blobs_per_block,
903914
}
904915
}
905916
}

crates/eips/src/eip7742.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@
22
33
use crate::eip4844::{fake_exponential, BLOB_TX_MIN_BLOB_GASPRICE, DATA_GAS_PER_BLOB};
44

5-
/// Controls the update rate of the blob base fee based on `target_blob_count`.
5+
/// Controls the update rate of the blob base fee based on `target_blobs_per_block`.
66
pub const BLOB_BASE_FEE_UPDATE_FRACTION_PER_TARGET_BLOB: u64 = 1112825;
77

88
/// Calculates the `excess_blob_gas` from the parent header's `blob_gas_used`, `excess_blob_gas` and
9-
/// `target_blob_count`.
9+
/// `target_blobs_per_block`.
1010
///
1111
/// Similar to [crate::eip4844::calc_excess_blob_gas], but derives the target blob gas from
12-
/// `parent_target_blob_count`.
12+
/// `parent_target_blobs_per_block`.
1313
#[inline]
1414
pub const fn calc_excess_blob_gas(
1515
parent_excess_blob_gas: u64,
1616
parent_blob_gas_used: u64,
17-
parent_target_blob_count: u64,
17+
parent_target_blobs_per_block: u64,
1818
) -> u64 {
1919
(parent_excess_blob_gas + parent_blob_gas_used)
20-
.saturating_sub(DATA_GAS_PER_BLOB * parent_target_blob_count)
20+
.saturating_sub(DATA_GAS_PER_BLOB * parent_target_blobs_per_block)
2121
}
2222

2323
/// Calculates the blob gas price from the header's excess blob gas field.
2424
///
2525
/// Similar to [crate::eip4844::calc_blob_gasprice], but adjusts the update rate based on
26-
/// `target_blob_count`.
26+
/// `target_blobs_per_block`.
2727
#[inline]
28-
pub fn calc_blob_gasprice(excess_blob_gas: u64, target_blob_count: u64) -> u128 {
29-
let update_fraction = BLOB_BASE_FEE_UPDATE_FRACTION_PER_TARGET_BLOB * target_blob_count;
28+
pub fn calc_blob_gasprice(excess_blob_gas: u64, target_blobs_per_block: u64) -> u128 {
29+
let update_fraction = BLOB_BASE_FEE_UPDATE_FRACTION_PER_TARGET_BLOB * target_blobs_per_block;
3030
fake_exponential(BLOB_TX_MIN_BLOB_GASPRICE, excess_blob_gas as u128, update_fraction as u128)
3131
}

crates/provider/src/fillers/gas.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ where
238238
//
239239
// Blob target increases are expected to be rare, thus this should be correct most of
240240
// the time
241-
.next_block_blob_fee(latest_header.target_blob_count())
241+
.next_block_blob_fee(latest_header.target_blobs_per_block())
242242
.map(Into::into)
243243
.ok_or(RpcError::UnsupportedFeature("eip4844"))
244244
}

crates/rpc-types-eth/src/block.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,11 @@ impl<H: BlockHeader> Header<H> {
135135
/// Returns `None` if `excess_blob_gas` is None.
136136
///
137137
/// See also [Self::next_block_excess_blob_gas]
138-
pub fn next_block_blob_fee(&self, next_block_target_blob_count: Option<u64>) -> Option<u128> {
139-
self.inner.next_block_blob_fee(next_block_target_blob_count)
138+
pub fn next_block_blob_fee(
139+
&self,
140+
next_block_target_blobs_per_block: Option<u64>,
141+
) -> Option<u128> {
142+
self.inner.next_block_blob_fee(next_block_target_blobs_per_block)
140143
}
141144

142145
/// Calculate excess blob gas for the next block according to the EIP-4844
@@ -344,7 +347,7 @@ mod tests {
344347
excess_blob_gas: None,
345348
parent_beacon_block_root: None,
346349
requests_hash: None,
347-
target_blob_count: None,
350+
target_blobs_per_block: None,
348351
},
349352
total_difficulty: Some(U256::from(100000)),
350353
size: None,
@@ -392,7 +395,7 @@ mod tests {
392395
excess_blob_gas: None,
393396
parent_beacon_block_root: None,
394397
requests_hash: None,
395-
target_blob_count: None,
398+
target_blobs_per_block: None,
396399
},
397400
size: None,
398401
total_difficulty: Some(U256::from(100000)),
@@ -438,7 +441,7 @@ mod tests {
438441
excess_blob_gas: None,
439442
parent_beacon_block_root: None,
440443
requests_hash: None,
441-
target_blob_count: None,
444+
target_blobs_per_block: None,
442445
},
443446
total_difficulty: Some(U256::from(100000)),
444447
size: None,
@@ -710,7 +713,7 @@ mod tests {
710713
excess_blob_gas: None,
711714
parent_beacon_block_root: None,
712715
requests_hash: None,
713-
target_blob_count: None,
716+
target_blobs_per_block: None,
714717
},
715718
size: None,
716719
total_difficulty: None,
@@ -757,7 +760,7 @@ mod tests {
757760
excess_blob_gas: None,
758761
parent_beacon_block_root: None,
759762
requests_hash: None,
760-
target_blob_count: None,
763+
target_blobs_per_block: None,
761764
},
762765
total_difficulty: None,
763766
size: Some(U256::from(505)),
@@ -816,7 +819,7 @@ mod tests {
816819
excess_blob_gas: None,
817820
parent_beacon_block_root: None,
818821
requests_hash: None,
819-
target_blob_count: None,
822+
target_blobs_per_block: None,
820823
},
821824
total_difficulty: Some(U256::from(100000)),
822825
size: Some(U256::from(19)),

0 commit comments

Comments
 (0)