From cd94717df70890ed71f07ae976b859247c886a82 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Wed, 9 Sep 2020 21:11:36 +1000 Subject: [PATCH] Add committees at slot field --- beacon_node/http_api/src/lib.rs | 1 + beacon_node/http_api/tests/tests.rs | 1 + common/eth2/src/types.rs | 2 ++ consensus/types/src/attestation_duty.rs | 2 ++ consensus/types/src/beacon_state/committee_cache.rs | 1 + 5 files changed, 7 insertions(+) diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index 6e98036fad9..200eb200c55 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -950,6 +950,7 @@ pub fn serve( Ok(api_types::AttesterData { pubkey: pubkey.into(), validator_index, + committees_at_slot: duty.committees_at_slot, committee_index: duty.index, committee_length: duty.committee_len as u64, validator_committee_index: duty.committee_position as u64, diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index 5f14597f000..7197fbb7917 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -1071,6 +1071,7 @@ impl ApiTester { let expected = AttesterData { pubkey: state.validators[i as usize].pubkey.clone().into(), validator_index: i, + committees_at_slot: duty.committees_at_slot, committee_index: duty.index, committee_length: duty.committee_len as u64, validator_committee_index: duty.committee_position as u64, diff --git a/common/eth2/src/types.rs b/common/eth2/src/types.rs index 318f258853d..597f23dc4b2 100644 --- a/common/eth2/src/types.rs +++ b/common/eth2/src/types.rs @@ -353,6 +353,8 @@ pub struct AttesterData { #[serde(with = "serde_utils::quoted_u64")] pub validator_index: u64, #[serde(with = "serde_utils::quoted_u64")] + pub committees_at_slot: u64, + #[serde(with = "serde_utils::quoted_u64")] pub committee_index: CommitteeIndex, #[serde(with = "serde_utils::quoted_u64")] pub committee_length: u64, diff --git a/consensus/types/src/attestation_duty.rs b/consensus/types/src/attestation_duty.rs index c32e4683e18..b1a53d22518 100644 --- a/consensus/types/src/attestation_duty.rs +++ b/consensus/types/src/attestation_duty.rs @@ -12,4 +12,6 @@ pub struct AttestationDuty { pub committee_position: usize, /// The total number of attesters in the committee. pub committee_len: usize, + /// The committee count at `attestation_slot`. + pub committees_at_slot: u64, } diff --git a/consensus/types/src/beacon_state/committee_cache.rs b/consensus/types/src/beacon_state/committee_cache.rs index f71ad2e893e..a6018df304c 100644 --- a/consensus/types/src/beacon_state/committee_cache.rs +++ b/consensus/types/src/beacon_state/committee_cache.rs @@ -185,6 +185,7 @@ impl CommitteeCache { index, committee_position, committee_len, + committees_at_slot: self.committees_per_slot(), }) }) }