Skip to content

Commit 261ada5

Browse files
committed
use usize
1 parent c67e2de commit 261ada5

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/l1block.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ impl L1BlockInfo {
250250

251251
fn calculate_tx_l1_cost_galileo(
252252
&self,
253-
tx_size: u32, // size of the original rlp-encoded transaction
253+
tx_size: usize, // size of the original rlp-encoded transaction
254254
spec_id: ScrollSpecId,
255-
compressed_size: u32, // size of the compressed rlp-encoded transaction
255+
compressed_size: usize, // size of the compressed rlp-encoded transaction
256256
) -> U256 {
257257
// Post Galileo rollup fee formula:
258258
// rollup_fee(tx) = fee_per_byte * compressed_size(tx) * (1 + penalty(tx)) / PRECISION
@@ -282,7 +282,7 @@ impl L1BlockInfo {
282282
.unwrap_or_else(|| panic!("missing l1 blob base fee in spec_id={spec_id:?}"));
283283

284284
let penalty_factor = match self.penalty_factor {
285-
Some(f) if f == U256::from(0) => U256::from(1), // sanitize zero penalty factor
285+
Some(f) if f == U256::ZERO => U256::ONE, // sanitize zero penalty factor
286286
Some(f) => f,
287287
None => panic!("missing penalty factor in spec_id={spec_id:?}"),
288288
};
@@ -308,7 +308,7 @@ impl L1BlockInfo {
308308
input: &[u8],
309309
spec_id: ScrollSpecId,
310310
compression_ratio: Option<U256>,
311-
compressed_size: Option<u32>,
311+
compressed_size: Option<usize>,
312312
) -> U256 {
313313
let l1_cost = if !spec_id.is_enabled_in(ScrollSpecId::CURIE) {
314314
self.calculate_tx_l1_cost_shanghai(input, spec_id)
@@ -322,7 +322,7 @@ impl L1BlockInfo {
322322
} else {
323323
let compressed_size = compressed_size
324324
.unwrap_or_else(|| panic!("compressed size should be set in spec_id={spec_id:?}"));
325-
self.calculate_tx_l1_cost_galileo(input.len() as u32, spec_id, compressed_size)
325+
self.calculate_tx_l1_cost_galileo(input.len(), spec_id, compressed_size)
326326
};
327327
l1_cost.min(U64_MAX)
328328
}

src/transaction.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub trait ScrollTxTr: Transaction {
3030
/// The size of the full rlp-encoded transaction after compression.
3131
/// This is used for calculating the cost associated with posting the transaction on L1.
3232
/// Note: compressed_size(tx) = min(size(zstd(rlp(tx))), size(rlp(tx)))
33-
fn compressed_size(&self) -> Option<u32>;
33+
fn compressed_size(&self) -> Option<usize>;
3434
}
3535

3636
/// A Scroll transaction. Wraps around a base transaction and provides the optional RLPed bytes for
@@ -41,15 +41,15 @@ pub struct ScrollTransaction<T: Transaction> {
4141
pub base: T,
4242
pub rlp_bytes: Option<Bytes>,
4343
pub compression_ratio: Option<U256>,
44-
pub compressed_size: Option<u32>,
44+
pub compressed_size: Option<usize>,
4545
}
4646

4747
impl<T: Transaction> ScrollTransaction<T> {
4848
pub fn new(
4949
base: T,
5050
rlp_bytes: Option<Bytes>,
5151
compression_ratio: Option<U256>,
52-
compressed_size: Option<u32>,
52+
compressed_size: Option<usize>,
5353
) -> Self {
5454
Self { base, rlp_bytes, compression_ratio, compressed_size }
5555
}
@@ -154,7 +154,7 @@ impl<T: Transaction> ScrollTxTr for ScrollTransaction<T> {
154154
self.compression_ratio
155155
}
156156

157-
fn compressed_size(&self) -> Option<u32> {
157+
fn compressed_size(&self) -> Option<usize> {
158158
self.compressed_size
159159
}
160160
}

0 commit comments

Comments
 (0)