mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-02 04:03:35 +00:00
Merge remote-tracking branch 'upstream/unstable' into claude/gloas-http-tests-fix-151c7b
This commit is contained in:
@@ -2793,6 +2793,89 @@ impl ApiTester {
|
||||
self
|
||||
}
|
||||
|
||||
fn make_valid_payload_attestation_message(
|
||||
&self,
|
||||
ptc_offset: usize,
|
||||
) -> PayloadAttestationMessage {
|
||||
let head = self.chain.head_snapshot();
|
||||
let head_slot = head.beacon_block.slot();
|
||||
let head_root = head.beacon_block_root;
|
||||
let fork = head.beacon_state.fork();
|
||||
let genesis_validators_root = self.chain.genesis_validators_root;
|
||||
|
||||
let ptc = head
|
||||
.beacon_state
|
||||
.get_ptc(head_slot, &self.chain.spec)
|
||||
.expect("should get PTC");
|
||||
|
||||
// Find distinct validator indices in the PTC (may contain duplicates due to
|
||||
// weighted sampling with a small validator set).
|
||||
let mut seen = std::collections::HashSet::new();
|
||||
let distinct_indices: Vec<usize> = ptc
|
||||
.0
|
||||
.iter()
|
||||
.copied()
|
||||
.filter(|idx| seen.insert(*idx))
|
||||
.collect();
|
||||
let validator_index = distinct_indices[ptc_offset % distinct_indices.len()];
|
||||
|
||||
let data = PayloadAttestationData {
|
||||
beacon_block_root: head_root,
|
||||
slot: head_slot,
|
||||
payload_present: true,
|
||||
blob_data_available: true,
|
||||
};
|
||||
|
||||
let epoch = head_slot.epoch(E::slots_per_epoch());
|
||||
let domain =
|
||||
self.chain
|
||||
.spec
|
||||
.get_domain(epoch, Domain::PTCAttester, &fork, genesis_validators_root);
|
||||
let signing_root = data.signing_root(domain);
|
||||
let sk = &self.validator_keypairs()[validator_index].sk;
|
||||
let signature = sk.sign(signing_root);
|
||||
|
||||
PayloadAttestationMessage {
|
||||
validator_index: validator_index as u64,
|
||||
data,
|
||||
signature,
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn test_post_beacon_pool_payload_attestations_valid(mut self) -> Self {
|
||||
let message = self.make_valid_payload_attestation_message(0);
|
||||
let fork_name = self.chain.spec.fork_name_at_slot::<E>(message.data.slot);
|
||||
|
||||
self.client
|
||||
.post_beacon_pool_payload_attestations(&[message], fork_name)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(
|
||||
self.network_rx.network_recv.recv().await.is_some(),
|
||||
"valid payload attestation should be sent to network"
|
||||
);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub async fn test_post_beacon_pool_payload_attestations_valid_ssz(mut self) -> Self {
|
||||
let message = self.make_valid_payload_attestation_message(1);
|
||||
let fork_name = self.chain.spec.fork_name_at_slot::<E>(message.data.slot);
|
||||
|
||||
self.client
|
||||
.post_beacon_pool_payload_attestations_ssz(&[message], fork_name)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(
|
||||
self.network_rx.network_recv.recv().await.is_some(),
|
||||
"valid payload attestation (SSZ) should be sent to network"
|
||||
);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub async fn test_get_config_fork_schedule(self) -> Self {
|
||||
let result = self.client.get_config_fork_schedule().await.unwrap().data;
|
||||
|
||||
@@ -8251,6 +8334,19 @@ async fn get_validator_payload_attestation_data_pre_gloas() {
|
||||
.await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn post_beacon_pool_payload_attestations_valid() {
|
||||
if !fork_name_from_env().is_some_and(|f| f.gloas_enabled()) {
|
||||
return;
|
||||
}
|
||||
ApiTester::new()
|
||||
.await
|
||||
.test_post_beacon_pool_payload_attestations_valid()
|
||||
.await
|
||||
.test_post_beacon_pool_payload_attestations_valid_ssz()
|
||||
.await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn get_validator_aggregate_attestation_v1() {
|
||||
ApiTester::new()
|
||||
|
||||
Reference in New Issue
Block a user