@@ -123,6 +123,9 @@ impl BeaconRPCClient {
123123 "{}/{}/{}" ,
124124 self . endpoint_url, self . routes. get_block, block_id
125125 ) ;
126+ let url = url. replace ( "//" , "/" ) ;
127+ let url = url. replace ( "http:/" , "http://" ) ;
128+ println ! ( "URL: {}" , url) ;
126129
127130 let json_str = & self . get_json_from_raw_request ( & url) ?;
128131
@@ -147,6 +150,10 @@ impl BeaconRPCClient {
147150 "{}/{}/{}" ,
148151 self . endpoint_url, self . routes. get_block_header, block_id
149152 ) ;
153+ // Strip double slashes
154+ let url = url. replace ( "//" , "/" ) ;
155+ let url = url. replace ( "https:/" , "https://" ) ;
156+ println ! ( "URL: {}" , url) ;
150157
151158 let json_str = & self . get_json_from_raw_request ( & url) ?;
152159 self . check_block_found_for_slot ( json_str) ?;
@@ -168,6 +175,10 @@ impl BeaconRPCClient {
168175 "{}/{}?start_period={}&count=1" ,
169176 self . endpoint_url, self . routes. get_light_client_update, period
170177 ) ;
178+ // Strip double slashes
179+ let url = url. replace ( "//" , "/" ) ;
180+ let url = url. replace ( "http:/" , "http://" ) ;
181+ println ! ( "URL: {}" , url) ;
171182 let light_client_update_json_str = self . get_json_from_raw_request ( & url) ?;
172183 self . light_client_update_from_json_str ( light_client_update_json_str)
173184 }
@@ -203,6 +214,11 @@ impl BeaconRPCClient {
203214 "{}/{}?epoch={}" ,
204215 self . endpoint_url, self . routes. get_light_client_update_by_epoch, epoch
205216 ) ;
217+ // Strip double slashes
218+ let url = url. replace ( "//" , "/" ) ;
219+ let url = url. replace ( "https:/" , "https://" ) ;
220+ println ! ( "URL: {}" , url) ;
221+
206222 let mut light_client_update_json_str = self . get_json_from_raw_request ( & url) ?;
207223 let v: Value = serde_json:: from_str ( light_client_update_json_str. as_str ( ) ) ?;
208224 let object = json ! ( {
@@ -240,6 +256,10 @@ impl BeaconRPCClient {
240256 "{}/{}/{}" ,
241257 self . endpoint_url, self . routes. get_bootstrap, block_root
242258 ) ;
259+ // Strip double slashes
260+ let url = url. replace ( "//" , "/" ) ;
261+ let url = url. replace ( "http:/" , "http://" ) ;
262+ println ! ( "URL: {}" , url) ;
243263
244264 let light_client_snapshot_json_str = self . get_json_from_raw_request ( & url) ?;
245265 let parsed_json: Value = serde_json:: from_str ( & light_client_snapshot_json_str) ?;
@@ -266,6 +286,10 @@ impl BeaconRPCClient {
266286 "{}/eth/v1/beacon/states/finalized/finality_checkpoints" ,
267287 self . endpoint_url
268288 ) ;
289+ // Strip double slashes
290+ let url = url. replace ( "//" , "/" ) ;
291+ let url = url. replace ( "http:/" , "http://" ) ;
292+ println ! ( "URL: {}" , url) ;
269293 let checkpoint_json_str = self . get_json_from_raw_request ( & url) ?;
270294 let parsed_json: Value = serde_json:: from_str ( & checkpoint_json_str) ?;
271295
@@ -295,6 +319,10 @@ impl BeaconRPCClient {
295319 "{}/{}/{}" ,
296320 self . endpoint_url, self . routes. get_block, beacon_block_hash_str
297321 ) ;
322+ // Strip double slashes
323+ let url = url. replace ( "//" , "/" ) ;
324+ let url = url. replace ( "http:/" , "http://" ) ;
325+ println ! ( "URL: {}" , url) ;
298326 let block_json_str = & self . get_json_from_raw_request ( & url) ?;
299327 let v: Value = serde_json:: from_str ( block_json_str) ?;
300328 let slot = utils:: trim_quotes ( v[ "data" ] [ "message" ] [ "slot" ] . to_string ( ) ) . parse :: < u64 > ( ) ?;
@@ -317,7 +345,10 @@ impl BeaconRPCClient {
317345 "{}/{}" ,
318346 self . endpoint_url, self . routes. get_light_client_finality_update,
319347 ) ;
320-
348+ // Strip double slashes
349+ let url = url. replace ( "//" , "/" ) ;
350+ let url = url. replace ( "http:/" , "http://" ) ;
351+ println ! ( "URL: {}" , url) ;
321352 let light_client_update_json_str = self . get_json_from_raw_request ( & url) ?;
322353 let v: Value = serde_json:: from_str ( & light_client_update_json_str) ?;
323354 let light_client_update_json_str = serde_json:: to_string ( & json ! ( { "data" : [ v[ "data" ] ] } ) ) ?;
@@ -345,6 +376,10 @@ impl BeaconRPCClient {
345376 "{}/{}/{}" ,
346377 self . endpoint_url, self . routes. get_state, state_id
347378 ) ;
379+ // Strip double slashes
380+ let url_request = url_request. replace ( "//" , "/" ) ;
381+ let url_request = url_request. replace ( "http:/" , "http://" ) ;
382+ println ! ( "URL: {}" , url_request) ;
348383 let json_str = Self :: get_json_from_client ( & self . client_state_request , & url_request) ?;
349384
350385 let v: Value = serde_json:: from_str ( & json_str) ?;
@@ -690,7 +725,11 @@ mod tests {
690725 let beacon_rpc_client =
691726 BeaconRPCClient :: new ( & url, TIMEOUT_SECONDS , TIMEOUT_STATE_SECONDS , None ) ;
692727 let rpc_json_str = beacon_rpc_client. get_json_from_raw_request ( & url) ;
693- assert_eq ! ( rpc_json_str. unwrap( ) , file_json_str. trim( ) ) ;
728+
729+ let rpc_json_str = rpc_json_str. unwrap ( ) ;
730+ let rpc_json: Value = serde_json:: from_str ( & rpc_json_str) . unwrap ( ) ;
731+ let file_json: Value = serde_json:: from_str ( & file_json_str) . unwrap ( ) ;
732+ assert_eq ! ( rpc_json, file_json) ;
694733 }
695734
696735 #[ test]
@@ -733,27 +772,25 @@ mod tests {
733772
734773 assert_eq ! (
735774 beacon_block_header. slot,
736- trim_quotes( v[ "data" ] [ "header" ] [ "message" ] [ "slot" ] . to_string( ) )
737- . parse:: <u64 >( )
738- . unwrap( )
775+ trim_quotes( v[ "slot" ] . to_string( ) ) . parse:: <u64 >( ) . unwrap( )
739776 ) ;
740777 assert_eq ! (
741778 beacon_block_header. proposer_index,
742- trim_quotes( v[ "data" ] [ "header" ] [ "message" ] [ " proposer_index"] . to_string( ) )
779+ trim_quotes( v[ "proposer_index" ] . to_string( ) )
743780 . parse:: <u64 >( )
744781 . unwrap( )
745782 ) ;
746783 assert_eq ! (
747784 format!( "{:?}" , beacon_block_header. body_root) ,
748- trim_quotes( v[ "data" ] [ "header" ] [ "message" ] [ " body_root"] . to_string( ) )
785+ trim_quotes( v[ "body_root" ] . to_string( ) )
749786 ) ;
750787 assert_eq ! (
751788 format!( "{:?}" , beacon_block_header. parent_root) ,
752- trim_quotes( v[ "data" ] [ "header" ] [ "message" ] [ " parent_root"] . to_string( ) )
789+ trim_quotes( v[ "parent_root" ] . to_string( ) )
753790 ) ;
754791 assert_eq ! (
755792 format!( "{:?}" , beacon_block_header. state_root) ,
756- trim_quotes( v[ "data" ] [ "header" ] [ "message" ] [ " state_root"] . to_string( ) )
793+ trim_quotes( v[ "state_root" ] . to_string( ) )
757794 ) ;
758795 }
759796
@@ -774,7 +811,7 @@ mod tests {
774811 std:: fs:: read_to_string ( config. path_to_block ) . expect ( "Unable to read file" ) ;
775812 let v: Value = serde_json:: from_str ( & block_json_str) . unwrap ( ) ;
776813 assert_eq ! (
777- beacon_block_body. attestations_base ( ) . unwrap( ) . len( ) ,
814+ beacon_block_body. attestations_electra ( ) . unwrap( ) . len( ) ,
778815 v[ "data" ] [ "message" ] [ "body" ] [ "attestations" ]
779816 . as_array( )
780817 . unwrap( )
@@ -789,7 +826,7 @@ mod tests {
789826 #[ test]
790827 fn test_is_sync ( ) {
791828 assert ! ( !BeaconRPCClient :: new(
792- "https://lodestar-goerli .chainsafe.io" ,
829+ "https://lodestar-sepolia .chainsafe.io" ,
793830 TIMEOUT_SECONDS ,
794831 TIMEOUT_STATE_SECONDS ,
795832 None
0 commit comments