@@ -10,8 +10,8 @@ use crate::{
1010 feynman:: apply_feynman_hard_fork,
1111 } ,
1212 system_caller:: ScrollSystemCaller ,
13- FromTxWithCompressionRatio , ScrollDefaultPrecompilesFactory , ScrollEvm , ScrollEvmFactory ,
14- ScrollPrecompilesFactory , ScrollTransactionIntoTxEnv , ToTxWithCompressionRatio ,
13+ FromTxWithCompressionInfo , ScrollDefaultPrecompilesFactory , ScrollEvm , ScrollEvmFactory ,
14+ ScrollPrecompilesFactory , ScrollTransactionIntoTxEnv , ToTxWithCompressionInfo ,
1515} ;
1616use alloc:: { boxed:: Box , format, vec:: Vec } ;
1717
@@ -39,8 +39,11 @@ use revm_scroll::builder::ScrollContext;
3939use scroll_alloy_consensus:: L1_MESSAGE_TRANSACTION_TYPE ;
4040use scroll_alloy_hardforks:: { ScrollHardfork , ScrollHardforks } ;
4141
42- /// A cache for transaction compression ratios.
43- pub type ScrollTxCompressionRatios = Vec < U256 > ;
42+ /// Compression info is a pair of (compression ratio, compressed size).
43+ pub type ScrollTxCompressionInfo = ( U256 , usize ) ;
44+
45+ /// A cache for transaction compression infos, i.e. (compression ratio, compressed size) pairs.
46+ pub type ScrollTxCompressionInfos = Vec < ScrollTxCompressionInfo > ;
4447
4548/// Context for Scroll Block Execution.
4649#[ derive( Debug , Default , Clone ) ]
@@ -102,30 +105,31 @@ where
102105 DB = & ' db mut State < DB > ,
103106 Tx : FromRecoveredTx < R :: Transaction >
104107 + FromTxWithEncoded < R :: Transaction >
105- + FromTxWithCompressionRatio < R :: Transaction > ,
108+ + FromTxWithCompressionInfo < R :: Transaction > ,
106109 > ,
107110 R : ScrollReceiptBuilder < Transaction : Transaction + Encodable2718 , Receipt : TxReceipt > ,
108111 Spec : ScrollHardforks ,
109112{
110113 /// Executes all transactions in a block, applying pre and post execution changes. The provided
111- /// transaction compression ratios are expected to be in the same order as the
114+ /// transaction compression infos are expected to be in the same order as the
112115 /// transactions.
113116 pub fn execute_block_with_compression_cache (
114117 mut self ,
115118 transactions : impl IntoIterator <
116119 Item = impl ExecutableTx < Self >
117- + ToTxWithCompressionRatio < <Self as BlockExecutor >:: Transaction > ,
120+ + ToTxWithCompressionInfo < <Self as BlockExecutor >:: Transaction > ,
118121 > ,
119- compression_ratios : impl IntoIterator < Item = U256 > ,
122+ compression_infos : impl IntoIterator < Item = ScrollTxCompressionInfo > ,
120123 ) -> Result < BlockExecutionResult < R :: Receipt > , BlockExecutionError >
121124 where
122125 Self : Sized ,
123126 {
124127 self . apply_pre_execution_changes ( ) ?;
125128
126- for ( tx, compression_ratio) in transactions. into_iter ( ) . zip ( compression_ratios. into_iter ( ) )
129+ for ( tx, ( compression_ratio, compressed_size) ) in
130+ transactions. into_iter ( ) . zip ( compression_infos. into_iter ( ) )
127131 {
128- let tx = tx. with_compression_ratio ( compression_ratio) ;
132+ let tx = tx. with_compression_info ( compression_ratio, compressed_size ) ;
129133 self . execute_transaction ( & tx) ?;
130134 }
131135
@@ -335,10 +339,12 @@ where
335339 let l1_block_info = & self . ctx ( ) . chain ;
336340 let transaction_rlp_bytes = self . ctx ( ) . tx . rlp_bytes . as_ref ( ) ?;
337341 let compression_ratio = self . ctx ( ) . tx . compression_ratio ;
342+ let compressed_size = self . ctx ( ) . tx . compressed_size ;
338343 Some ( l1_block_info. calculate_tx_l1_cost (
339344 transaction_rlp_bytes,
340345 self . ctx ( ) . cfg . spec ,
341346 compression_ratio,
347+ compressed_size,
342348 ) )
343349 }
344350}
0 commit comments