@@ -68,6 +68,7 @@ use serde_json::Value;
6868use slot_clock:: SlotClock ;
6969use ssz:: Encode ;
7070pub use state_id:: StateId ;
71+ use std:: collections:: HashSet ;
7172use std:: future:: Future ;
7273use std:: net:: { IpAddr , Ipv4Addr , SocketAddr } ;
7374use std:: path:: PathBuf ;
@@ -86,13 +87,14 @@ use tokio_stream::{
8687 StreamExt ,
8788} ;
8889use tracing:: { debug, error, info, warn} ;
90+ use types:: AttestationData ;
8991use types:: {
90- fork_versioned_response:: EmptyMetadata , Attestation , AttestationData , AttestationShufflingId ,
91- AttesterSlashing , BeaconStateError , ChainSpec , Checkpoint , CommitteeCache , ConfigAndPreset ,
92- Epoch , EthSpec , ForkName , ForkVersionedResponse , Hash256 , ProposerPreparationData ,
93- ProposerSlashing , RelativeEpoch , SignedAggregateAndProof , SignedBlindedBeaconBlock ,
94- SignedBlsToExecutionChange , SignedContributionAndProof , SignedValidatorRegistrationData ,
95- SignedVoluntaryExit , Slot , SyncCommitteeMessage , SyncContributionData ,
92+ fork_versioned_response:: EmptyMetadata , Attestation , AttestationShufflingId , AttesterSlashing ,
93+ BeaconStateError , ChainSpec , Checkpoint , CommitteeCache , ConfigAndPreset , Epoch , EthSpec ,
94+ ForkName , ForkVersionedResponse , Hash256 , ProposerPreparationData , ProposerSlashing ,
95+ RelativeEpoch , SignedAggregateAndProof , SignedBlindedBeaconBlock , SignedBlsToExecutionChange ,
96+ SignedContributionAndProof , SignedValidatorRegistrationData , SignedVoluntaryExit , Slot ,
97+ SyncCommitteeMessage , SyncContributionData ,
9698} ;
9799use validator:: pubkey_to_validator_index;
98100use version:: {
@@ -1145,6 +1147,39 @@ pub fn serve<T: BeaconChainTypes>(
11451147 } ,
11461148 ) ;
11471149
1150+ // GET beacon/states/{state_id}/pending_consolidations
1151+ let get_beacon_state_pending_consolidations = beacon_states_path
1152+ . clone ( )
1153+ . and ( warp:: path ( "pending_consolidations" ) )
1154+ . and ( warp:: path:: end ( ) )
1155+ . then (
1156+ |state_id : StateId ,
1157+ task_spawner : TaskSpawner < T :: EthSpec > ,
1158+ chain : Arc < BeaconChain < T > > | {
1159+ task_spawner. blocking_json_task ( Priority :: P1 , move || {
1160+ let ( data, execution_optimistic, finalized) = state_id
1161+ . map_state_and_execution_optimistic_and_finalized (
1162+ & chain,
1163+ |state, execution_optimistic, finalized| {
1164+ let Ok ( consolidations) = state. pending_consolidations ( ) else {
1165+ return Err ( warp_utils:: reject:: custom_bad_request (
1166+ "Pending consolidations not found" . to_string ( ) ,
1167+ ) ) ;
1168+ } ;
1169+
1170+ Ok ( ( consolidations. clone ( ) , execution_optimistic, finalized) )
1171+ } ,
1172+ ) ?;
1173+
1174+ Ok ( api_types:: ExecutionOptimisticFinalizedResponse {
1175+ data,
1176+ execution_optimistic : Some ( execution_optimistic) ,
1177+ finalized : Some ( finalized) ,
1178+ } )
1179+ } )
1180+ } ,
1181+ ) ;
1182+
11481183 // GET beacon/headers
11491184 //
11501185 // Note: this endpoint only returns information about blocks in the canonical chain. Given that
@@ -1927,11 +1962,11 @@ pub fn serve<T: BeaconChainTypes>(
19271962 chain : Arc < BeaconChain < T > > ,
19281963 query : api_types:: AttestationPoolQuery | {
19291964 task_spawner. blocking_response_task ( Priority :: P1 , move || {
1930- let query_filter = |data : & AttestationData | {
1965+ let query_filter = |data : & AttestationData , committee_indices : HashSet < u64 > | {
19311966 query. slot . is_none_or ( |slot| slot == data. slot )
19321967 && query
19331968 . committee_index
1934- . is_none_or ( |index| index == data . index )
1969+ . is_none_or ( |index| committee_indices . contains ( & index) )
19351970 } ;
19361971
19371972 let mut attestations = chain. op_pool . get_filtered_attestations ( query_filter) ;
@@ -1940,7 +1975,9 @@ pub fn serve<T: BeaconChainTypes>(
19401975 . naive_aggregation_pool
19411976 . read ( )
19421977 . iter ( )
1943- . filter ( |& att| query_filter ( att. data ( ) ) )
1978+ . filter ( |& att| {
1979+ query_filter ( att. data ( ) , att. get_committee_indices_map ( ) )
1980+ } )
19441981 . cloned ( ) ,
19451982 ) ;
19461983 // Use the current slot to find the fork version, and convert all messages to the
@@ -4737,6 +4774,7 @@ pub fn serve<T: BeaconChainTypes>(
47374774 . uor ( get_beacon_state_randao)
47384775 . uor ( get_beacon_state_pending_deposits)
47394776 . uor ( get_beacon_state_pending_partial_withdrawals)
4777+ . uor ( get_beacon_state_pending_consolidations)
47404778 . uor ( get_beacon_headers)
47414779 . uor ( get_beacon_headers_block_id)
47424780 . uor ( get_beacon_block)
0 commit comments