Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions beacon_node/http_api/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3354,6 +3354,8 @@ impl ApiTester {
self
}

// TODO(EIP-7732): Add test_get_validator_duties_ptc function to test PTC duties endpoint

pub async fn test_get_validator_duties_early(self) -> Self {
let current_epoch = self.chain.epoch().unwrap();
let next_epoch = current_epoch + 1;
Expand Down
30 changes: 30 additions & 0 deletions common/eth2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ const HTTP_PROPOSER_DUTIES_TIMEOUT_QUOTIENT: u32 = 4;
const HTTP_SYNC_COMMITTEE_CONTRIBUTION_TIMEOUT_QUOTIENT: u32 = 4;
const HTTP_SYNC_DUTIES_TIMEOUT_QUOTIENT: u32 = 4;
const HTTP_SYNC_AGGREGATOR_TIMEOUT_QUOTIENT: u32 = 24; // For DVT involving middleware only
// TODO(EIP-7732): Determine what this quotient should be
const HTTP_PTC_DUTIES_TIMEOUT_QUOTIENT: u32 = 4;
const HTTP_GET_BEACON_BLOCK_SSZ_TIMEOUT_QUOTIENT: u32 = 4;
const HTTP_GET_DEBUG_BEACON_STATE_QUOTIENT: u32 = 4;
const HTTP_GET_DEPOSIT_SNAPSHOT_QUOTIENT: u32 = 4;
Expand Down Expand Up @@ -159,6 +161,7 @@ pub struct Timeouts {
pub sync_committee_contribution: Duration,
pub sync_duties: Duration,
pub sync_aggregators: Duration,
pub ptc_duties: Duration,
pub get_beacon_blocks_ssz: Duration,
pub get_debug_beacon_states: Duration,
pub get_deposit_snapshot: Duration,
Expand All @@ -179,6 +182,7 @@ impl Timeouts {
sync_committee_contribution: timeout,
sync_duties: timeout,
sync_aggregators: timeout,
ptc_duties: timeout,
get_beacon_blocks_ssz: timeout,
get_debug_beacon_states: timeout,
get_deposit_snapshot: timeout,
Expand All @@ -201,6 +205,7 @@ impl Timeouts {
/ HTTP_SYNC_COMMITTEE_CONTRIBUTION_TIMEOUT_QUOTIENT,
sync_duties: base_timeout / HTTP_SYNC_DUTIES_TIMEOUT_QUOTIENT,
sync_aggregators: base_timeout / HTTP_SYNC_AGGREGATOR_TIMEOUT_QUOTIENT,
ptc_duties: base_timeout / HTTP_PTC_DUTIES_TIMEOUT_QUOTIENT,
get_beacon_blocks_ssz: base_timeout / HTTP_GET_BEACON_BLOCK_SSZ_TIMEOUT_QUOTIENT,
get_debug_beacon_states: base_timeout / HTTP_GET_DEBUG_BEACON_STATE_QUOTIENT,
get_deposit_snapshot: base_timeout / HTTP_GET_DEPOSIT_SNAPSHOT_QUOTIENT,
Expand Down Expand Up @@ -2927,6 +2932,31 @@ impl BeaconNodeHttpClient {
self.post_with_timeout_and_response(path, &selections, self.timeouts.sync_aggregators)
.await
}

// TODO(EIP-7732): Create corresponding beacon node response endpoint per spec
// https://github.com/ethereum/beacon-APIs/pull/552
/// `POST validator/duties/ptc/{epoch}`
pub async fn post_validator_duties_ptc(
&self,
epoch: Epoch,
indices: &[u64],
) -> Result<DutiesResponse<Vec<PtcDuty>>, Error> {
let mut path = self.eth_path(V1)?;

path.path_segments_mut()
.map_err(|()| Error::InvalidUrl(self.server.clone()))?
.push("validator")
.push("duties")
.push("ptc")
.push(&epoch.to_string());

self.post_with_timeout_and_response(
path,
&ValidatorIndexDataRef(indices),
self.timeouts.ptc_duties,
)
.await
}
}

/// Returns `Ok(response)` if the response is a `200 OK` response. Otherwise, creates an
Expand Down
8 changes: 8 additions & 0 deletions common/eth2/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,14 @@ pub struct ProposerData {
pub slot: Slot,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PtcDuty {
pub pubkey: PublicKeyBytes,
#[serde(with = "serde_utils::quoted_u64")]
pub validator_index: u64,
pub slot: Slot,
}

#[derive(Clone, Deserialize)]
pub struct ValidatorBlocksQuery {
pub randao_reveal: SignatureBytes,
Expand Down
2 changes: 2 additions & 0 deletions testing/simulator/src/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ pub async fn verify_full_sync_aggregates_up_to<E: EthSpec>(
Ok(())
}

// TODO(EIP-7732): Add verify_ptc_duties_executed function to verify that PTC duties are being fetched and executed correctly when Gloas fork is enabled

/// Verify that the first merged PoS block got finalized.
pub async fn verify_transition_block_finalized<E: EthSpec>(
network: LocalNetwork<E>,
Expand Down
10 changes: 10 additions & 0 deletions validator_client/http_metrics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ pub fn gather_prometheus_metrics<E: EthSpec>(
&[NEXT_EPOCH],
duties_service.attester_count(next_epoch) as i64,
);
set_int_gauge(
&PTC_COUNT,
&[CURRENT_EPOCH],
duties_service.ptc_count(current_epoch) as i64,
);
set_int_gauge(
&PTC_COUNT,
&[NEXT_EPOCH],
duties_service.ptc_count(next_epoch) as i64,
);
}
}

Expand Down
12 changes: 12 additions & 0 deletions validator_client/validator_metrics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ pub const UPDATE_ATTESTERS_CURRENT_EPOCH: &str = "update_attesters_current_epoch
pub const UPDATE_ATTESTERS_NEXT_EPOCH: &str = "update_attesters_next_epoch";
pub const UPDATE_ATTESTERS_FETCH: &str = "update_attesters_fetch";
pub const UPDATE_ATTESTERS_STORE: &str = "update_attesters_store";
pub const UPDATE_PTC_CURRENT_EPOCH: &str = "update_ptc_current_epoch";
pub const UPDATE_PTC_NEXT_EPOCH: &str = "update_ptc_next_epoch";
pub const UPDATE_PTC_FETCH: &str = "update_ptc_fetch";
pub const UPDATE_PTC_STORE: &str = "update_ptc_store";
pub const ATTESTER_DUTIES_HTTP_POST: &str = "attester_duties_http_post";
pub const PTC_DUTIES_HTTP_POST: &str = "ptc_duties_http_post";
pub const PROPOSER_DUTIES_HTTP_GET: &str = "proposer_duties_http_get";
pub const VALIDATOR_DUTIES_SYNC_HTTP_POST: &str = "validator_duties_sync_http_post";
pub const VALIDATOR_ID_HTTP_GET: &str = "validator_id_http_get";
Expand Down Expand Up @@ -162,6 +167,13 @@ pub static ATTESTER_COUNT: LazyLock<Result<IntGaugeVec>> = LazyLock::new(|| {
&["task"],
)
});
pub static PTC_COUNT: LazyLock<Result<IntGaugeVec>> = LazyLock::new(|| {
try_create_int_gauge_vec(
"vc_beacon_ptc_count",
"Number of PTC (Payload Timeliness Committee) validators on this host",
&["task"],
)
});
pub static PROPOSAL_CHANGED: LazyLock<Result<IntCounter>> = LazyLock::new(|| {
try_create_int_counter(
"vc_beacon_block_proposal_changed",
Expand Down
Loading
Loading