@@ -4,9 +4,10 @@ use alloy_rlp::Decodable;
4
4
use anyhow:: Result ;
5
5
use libflate:: zlib:: { Decoder as zlibDecoder, Encoder as zlibEncoder} ;
6
6
use reth_primitives:: TransactionSigned ;
7
- use tracing:: warn;
7
+ use tracing:: { error , warn} ;
8
8
9
9
use crate :: consts:: { ChainSpec , Network } ;
10
+ use crate :: input:: BlockProposedFork ;
10
11
#[ cfg( not( feature = "std" ) ) ]
11
12
use crate :: no_std:: * ;
12
13
@@ -24,25 +25,41 @@ fn validate_calldata_tx_list(tx_list: &[u8]) -> bool {
24
25
tx_list. len ( ) <= CALL_DATA_CAPACITY
25
26
}
26
27
27
- fn get_tx_list ( chain_spec : & ChainSpec , is_blob_data : bool , tx_list : & [ u8 ] ) -> Vec < u8 > {
28
+ fn unzip_tx_list_from_data_buf (
29
+ chain_spec : & ChainSpec ,
30
+ is_blob_data : bool ,
31
+ blob_slice_param : Option < ( usize , usize ) > ,
32
+ tx_list_data_buf : & [ u8 ] ,
33
+ ) -> Vec < u8 > {
28
34
#[ allow( clippy:: collapsible_else_if) ]
29
35
if chain_spec. is_taiko ( ) {
30
36
// taiko has some limitations to be aligned with taiko-client
31
37
if is_blob_data {
32
- let compressed_tx_list = decode_blob_data ( tx_list) ;
33
- zlib_decompress_data ( & compressed_tx_list) . unwrap_or_default ( )
38
+ let compressed_tx_list = decode_blob_data ( tx_list_data_buf) ;
39
+ assert ! ( compressed_tx_list. len( ) <= MAX_BLOB_DATA_SIZE ) ;
40
+ let slice_compressed_tx_list = if let Some ( ( offset, length) ) = blob_slice_param {
41
+ if offset + length > compressed_tx_list. len ( ) {
42
+ error ! ( "blob_slice_param ({offset},{length}) out of range, use empty tx_list" ) ;
43
+ vec ! [ ]
44
+ } else {
45
+ compressed_tx_list[ offset..offset + length] . to_vec ( )
46
+ }
47
+ } else {
48
+ compressed_tx_list. to_vec ( )
49
+ } ;
50
+ zlib_decompress_data ( & slice_compressed_tx_list) . unwrap_or_default ( )
34
51
} else {
35
52
if Network :: TaikoA7 . to_string ( ) == chain_spec. network ( ) {
36
- let tx_list = zlib_decompress_data ( tx_list ) . unwrap_or_default ( ) ;
53
+ let tx_list = zlib_decompress_data ( tx_list_data_buf ) . unwrap_or_default ( ) ;
37
54
if validate_calldata_tx_list ( & tx_list) {
38
55
tx_list
39
56
} else {
40
57
warn ! ( "validate_calldata_tx_list failed, use empty tx_list" ) ;
41
58
vec ! [ ]
42
59
}
43
60
} else {
44
- if validate_calldata_tx_list ( tx_list ) {
45
- zlib_decompress_data ( tx_list ) . unwrap_or_default ( )
61
+ if validate_calldata_tx_list ( tx_list_data_buf ) {
62
+ zlib_decompress_data ( tx_list_data_buf ) . unwrap_or_default ( )
46
63
} else {
47
64
warn ! ( "validate_calldata_tx_list failed, use empty tx_list" ) ;
48
65
vec ! [ ]
@@ -51,20 +68,23 @@ fn get_tx_list(chain_spec: &ChainSpec, is_blob_data: bool, tx_list: &[u8]) -> Ve
51
68
}
52
69
} else {
53
70
// no limitation on non-taiko chains
54
- zlib_decompress_data ( tx_list ) . unwrap_or_default ( )
71
+ zlib_decompress_data ( tx_list_data_buf ) . unwrap_or_default ( )
55
72
}
56
73
}
57
74
58
75
pub fn generate_transactions (
59
76
chain_spec : & ChainSpec ,
60
- is_blob_data : bool ,
61
- tx_list : & [ u8 ] ,
77
+ block_proposal : & BlockProposedFork ,
78
+ tx_list_data_buf : & [ u8 ] ,
62
79
anchor_tx : & Option < TransactionSigned > ,
63
80
) -> Vec < TransactionSigned > {
81
+ let is_blob_data = block_proposal. blob_used ( ) ;
82
+ let blob_slice_param = block_proposal. blob_tx_slice_param ( ) ;
64
83
// Decode the tx list from the raw data posted onchain
65
- let tx_list = get_tx_list ( chain_spec, is_blob_data, tx_list) ;
84
+ let unzip_tx_list_buf =
85
+ unzip_tx_list_from_data_buf ( chain_spec, is_blob_data, blob_slice_param, tx_list_data_buf) ;
66
86
// Decode the transactions from the tx list
67
- let mut transactions = decode_transactions ( & tx_list ) ;
87
+ let mut transactions = decode_transactions ( & unzip_tx_list_buf ) ;
68
88
// Add the anchor tx at the start of the list
69
89
if let Some ( anchor_tx) = anchor_tx {
70
90
transactions. insert ( 0 , anchor_tx. clone ( ) ) ;
0 commit comments