@@ -5,7 +5,7 @@ use cb_common::{
55 pbs:: {
66 error:: { PbsError , ValidationError } ,
77 RelayClient , SignedBlindedBeaconBlock , SubmitBlindedBlockResponse , HEADER_SLOT_UUID_KEY ,
8- HEADER_START_TIME_UNIX_MS , MAX_SIZE ,
8+ HEADER_START_TIME_UNIX_MS ,
99 } ,
1010 utils:: { get_user_agent_with_version, utcnow_ms} ,
1111} ;
@@ -14,9 +14,10 @@ use reqwest::header::USER_AGENT;
1414use tracing:: { debug, warn} ;
1515
1616use crate :: {
17- constants:: { SUBMIT_BLINDED_BLOCK_ENDPOINT_TAG , TIMEOUT_ERROR_CODE_STR } ,
17+ constants:: { MAX_SIZE_SUBMIT_BLOCK , SUBMIT_BLINDED_BLOCK_ENDPOINT_TAG , TIMEOUT_ERROR_CODE_STR } ,
1818 metrics:: { RELAY_LATENCY , RELAY_STATUS_CODE } ,
1919 state:: { BuilderApiState , PbsState } ,
20+ utils:: read_chunked_body_with_max,
2021} ;
2122
2223/// Implements https://ethereum.github.io/builder-specs/#/Builder/submitBlindedBlock
@@ -94,18 +95,14 @@ async fn send_submit_block(
9495 . with_label_values ( & [ code. as_str ( ) , SUBMIT_BLINDED_BLOCK_ENDPOINT_TAG , & relay. id ] )
9596 . inc ( ) ;
9697
97- let response_bytes = res. bytes ( ) . await ?;
98-
99- if response_bytes. len ( ) > MAX_SIZE {
100- return Err ( PbsError :: PayloadTooLarge { max : MAX_SIZE , got : response_bytes. len ( ) } ) ;
101- }
98+ let response_bytes = read_chunked_body_with_max ( res, MAX_SIZE_SUBMIT_BLOCK ) . await ?;
10299 if !code. is_success ( ) {
103100 let err = PbsError :: RelayResponse {
104101 error_msg : String :: from_utf8_lossy ( & response_bytes) . into_owned ( ) ,
105102 code : code. as_u16 ( ) ,
106103 } ;
107104
108- // we request payload to all relays, but some may have not received it
105+ // we requested the payload from all relays, but some may have not received it
109106 warn ! ( %err, "failed to get payload (this might be ok if other relays have it)" ) ;
110107 return Err ( err) ;
111108 } ;
0 commit comments