@@ -52,6 +52,7 @@ use eth2::types::{
52
52
} ;
53
53
use eth2:: { CONSENSUS_VERSION_HEADER , CONTENT_TYPE_HEADER , SSZ_CONTENT_TYPE_HEADER } ;
54
54
use health_metrics:: observe:: Observe ;
55
+ use lighthouse_network:: rpc:: methods:: MetaData ;
55
56
use lighthouse_network:: { types:: SyncState , EnrExt , NetworkGlobals , PeerId , PubsubMessage } ;
56
57
use lighthouse_version:: version_with_platform;
57
58
use logging:: SSELoggingComponents ;
@@ -82,6 +83,7 @@ use tokio_stream::{
82
83
wrappers:: { errors:: BroadcastStreamRecvError , BroadcastStream } ,
83
84
StreamExt ,
84
85
} ;
86
+ use types:: ChainSpec ;
85
87
use types:: {
86
88
fork_versioned_response:: EmptyMetadata , Attestation , AttestationData , AttestationShufflingId ,
87
89
AttesterSlashing , BeaconStateError , CommitteeCache , ConfigAndPreset , Epoch , EthSpec , ForkName ,
@@ -2898,36 +2900,24 @@ pub fn serve<T: BeaconChainTypes>(
2898
2900
. and ( warp:: path:: end ( ) )
2899
2901
. and ( task_spawner_filter. clone ( ) )
2900
2902
. and ( network_globals. clone ( ) )
2903
+ . and ( chain_filter. clone ( ) )
2901
2904
. then (
2902
2905
|task_spawner : TaskSpawner < T :: EthSpec > ,
2903
- network_globals : Arc < NetworkGlobals < T :: EthSpec > > | {
2906
+ network_globals : Arc < NetworkGlobals < T :: EthSpec > > ,
2907
+ chain : Arc < BeaconChain < T > > | {
2904
2908
task_spawner. blocking_json_task ( Priority :: P1 , move || {
2905
2909
let enr = network_globals. local_enr ( ) ;
2906
2910
let p2p_addresses = enr. multiaddr_p2p_tcp ( ) ;
2907
2911
let discovery_addresses = enr. multiaddr_p2p_udp ( ) ;
2908
- let meta_data = network_globals. local_metadata . read ( ) ;
2909
2912
Ok ( api_types:: GenericResponse :: from ( api_types:: IdentityData {
2910
2913
peer_id : network_globals. local_peer_id ( ) . to_base58 ( ) ,
2911
2914
enr,
2912
2915
p2p_addresses,
2913
2916
discovery_addresses,
2914
- metadata : api_types:: MetaData {
2915
- seq_number : * meta_data. seq_number ( ) ,
2916
- attnets : format ! (
2917
- "0x{}" ,
2918
- hex:: encode( meta_data. attnets( ) . clone( ) . into_bytes( ) ) ,
2919
- ) ,
2920
- syncnets : format ! (
2921
- "0x{}" ,
2922
- hex:: encode(
2923
- meta_data
2924
- . syncnets( )
2925
- . cloned( )
2926
- . unwrap_or_default( )
2927
- . into_bytes( )
2928
- )
2929
- ) ,
2930
- } ,
2917
+ metadata : from_meta_data :: < T :: EthSpec > (
2918
+ & network_globals. local_metadata ,
2919
+ & chain. spec ,
2920
+ ) ,
2931
2921
} ) )
2932
2922
} )
2933
2923
} ,
@@ -4844,6 +4834,39 @@ pub fn serve<T: BeaconChainTypes>(
4844
4834
Ok ( http_server)
4845
4835
}
4846
4836
4837
+ fn from_meta_data < E : EthSpec > (
4838
+ meta_data : & RwLock < MetaData < E > > ,
4839
+ spec : & ChainSpec ,
4840
+ ) -> api_types:: MetaData {
4841
+ let meta_data = meta_data. read ( ) ;
4842
+ let format_hex = |bytes : & [ u8 ] | format ! ( "0x{}" , hex:: encode( bytes) ) ;
4843
+
4844
+ let seq_number = * meta_data. seq_number ( ) ;
4845
+ let attnets = format_hex ( & meta_data. attnets ( ) . clone ( ) . into_bytes ( ) ) ;
4846
+ let syncnets = format_hex (
4847
+ & meta_data
4848
+ . syncnets ( )
4849
+ . cloned ( )
4850
+ . unwrap_or_default ( )
4851
+ . into_bytes ( ) ,
4852
+ ) ;
4853
+
4854
+ if spec. is_peer_das_scheduled ( ) {
4855
+ api_types:: MetaData :: V3 ( api_types:: MetaDataV3 {
4856
+ seq_number,
4857
+ attnets,
4858
+ syncnets,
4859
+ custody_group_count : meta_data. custody_group_count ( ) . cloned ( ) . unwrap_or_default ( ) ,
4860
+ } )
4861
+ } else {
4862
+ api_types:: MetaData :: V2 ( api_types:: MetaDataV2 {
4863
+ seq_number,
4864
+ attnets,
4865
+ syncnets,
4866
+ } )
4867
+ }
4868
+ }
4869
+
4847
4870
/// Publish a message to the libp2p pubsub network.
4848
4871
fn publish_pubsub_message < E : EthSpec > (
4849
4872
network_tx : & UnboundedSender < NetworkMessage < E > > ,
0 commit comments