@@ -33,8 +33,8 @@ use crate::{
3333 eth2:: { ENR_ETH2_KEY , EnrForkId } ,
3434 subnet:: {
3535 ATTESTATION_BITFIELD_ENR_KEY , AttestationSubnets , CUSTODY_GROUP_COUNT_ENR_KEY ,
36- EPOCHS_PER_SUBNET_SUBSCRIPTION , NEXT_FORK_DIGEST_ENR_KEY , NextForkDigest ,
37- SYNC_COMMITTEE_BITFIELD_ENR_KEY , attestation_subnet_predicate, compute_subscribed_subnets,
36+ EPOCHS_PER_SUBNET_SUBSCRIPTION , NEXT_FORK_DIGEST_ENR_KEY , SYNC_COMMITTEE_BITFIELD_ENR_KEY ,
37+ attestation_subnet_predicate, compute_subscribed_subnets, next_fork_digest ,
3838 sync_committee_subnet_predicate,
3939 } ,
4040} ;
@@ -91,21 +91,25 @@ impl Discovery {
9191 ) -> anyhow:: Result < Self > {
9292 let enr_local =
9393 convert_to_enr ( local_key) . map_err ( |err| anyhow ! ( "Failed to convert key: {err:?}" ) ) ?;
94+ let current_epoch = compute_epoch_at_slot ( current_slot) ;
9495
9596 let mut enr_builder = Enr :: builder ( ) ;
9697 enr_builder. ip ( config. socket_address ) ;
9798 enr_builder. tcp4 ( config. socket_port ) ;
9899 enr_builder. udp4 ( config. discovery_port ) ;
99100
100101 let enr = enr_builder
101- . add_value ( ENR_ETH2_KEY , & EnrForkId :: electra ( genesis_validators_root ( ) ) )
102+ . add_value (
103+ ENR_ETH2_KEY ,
104+ & EnrForkId :: current ( genesis_validators_root ( ) , current_epoch) ,
105+ )
102106 . add_value ( ATTESTATION_BITFIELD_ENR_KEY , & config. attestation_subnets )
103107 . add_value (
104108 SYNC_COMMITTEE_BITFIELD_ENR_KEY ,
105109 & config. sync_committee_subnets ,
106110 )
107111 . add_value ( CUSTODY_GROUP_COUNT_ENR_KEY , & config. custody_group_count )
108- . add_value ( NEXT_FORK_DIGEST_ENR_KEY , & NextForkDigest :: default ( ) )
112+ . add_value ( NEXT_FORK_DIGEST_ENR_KEY , & next_fork_digest ( current_epoch ) )
109113 . build ( & enr_local)
110114 . map_err ( |err| anyhow ! ( "Failed to build ENR: {err}" ) ) ?;
111115
@@ -126,8 +130,7 @@ impl Discovery {
126130 }
127131
128132 // Compute and set attestation subnets
129- let subnets =
130- compute_subscribed_subnets ( enr. node_id ( ) , compute_epoch_at_slot ( current_slot) ) ?;
133+ let subnets = compute_subscribed_subnets ( enr. node_id ( ) , current_epoch) ?;
131134 let mut config = config. clone ( ) ;
132135 config. attestation_subnets = AttestationSubnets :: new ( ) ;
133136 for subnet_id in subnets {
@@ -136,7 +139,7 @@ impl Discovery {
136139 . enable_attestation_subnet ( subnet_id) ?;
137140 }
138141
139- let subscription_epoch = compute_epoch_at_slot ( current_slot ) ;
142+ let subscription_epoch = current_epoch ;
140143
141144 let event_stream = if !config. disable_discovery {
142145 discv5
0 commit comments