Skip to content

Commit

Permalink
fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
dapplion committed Feb 26, 2024
1 parent 5e4c129 commit 0ad7641
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
14 changes: 9 additions & 5 deletions beacon_node/beacon_chain/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ where
/// A list of sync messages for the given state.
pub fn make_sync_committee_messages(
&self,
state: &BeaconState<E>,
state: &mut BeaconState<E>,
head_block_root: Hash256,
message_slot: Slot,
relative_sync_committee: RelativeSyncCommittee,
Expand All @@ -1191,6 +1191,8 @@ where
.spec
.fork_at_epoch(message_slot.epoch(E::slots_per_epoch()));

state.update_pubkey_cache().unwrap();

sync_committee
.pubkeys
.as_ref()
Expand Down Expand Up @@ -1387,14 +1389,16 @@ where

pub fn make_sync_contributions(
&self,
state: &BeaconState<E>,
state: &mut BeaconState<E>,
block_hash: Hash256,
slot: Slot,
relative_sync_committee: RelativeSyncCommittee,
) -> HarnessSyncContributions<E> {
let sync_messages =
self.make_sync_committee_messages(state, block_hash, slot, relative_sync_committee);

state.update_pubkey_cache().unwrap();

let sync_contributions: Vec<Option<SignedContributionAndProof<E>>> = sync_messages
.iter()
.enumerate()
Expand Down Expand Up @@ -2008,7 +2012,7 @@ where

pub fn sync_committee_sign_block(
&self,
state: &BeaconState<E>,
state: &mut BeaconState<E>,
block_hash: Hash256,
slot: Slot,
relative_sync_committee: RelativeSyncCommittee,
Expand Down Expand Up @@ -2043,14 +2047,14 @@ where
validators: &[usize],
sync_committee_strategy: SyncCommitteeStrategy,
) -> Result<(SignedBeaconBlockHash, BeaconState<E>), BlockError<E>> {
let (block_hash, block, state) = self.add_block_at_slot(slot, state).await?;
let (block_hash, block, mut state) = self.add_block_at_slot(slot, state).await?;
self.attest_block(&state, state_root, block_hash, &block.0, validators);

if sync_committee_strategy == SyncCommitteeStrategy::AllValidators
&& state.current_sync_committee().is_ok()
{
self.sync_committee_sign_block(
&state,
&mut state,
block_hash.into(),
slot,
if (slot + 1).epoch(E::slots_per_epoch())
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/tests/rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async fn test_sync_committee_rewards() {

// Create and add sync committee message to op_pool
let sync_contributions = harness.make_sync_contributions(
&harness.get_current_state(),
&mut harness.get_current_state(),
latest_block_root,
harness.get_current_slot(),
RelativeSyncCommittee::Current,
Expand Down
11 changes: 6 additions & 5 deletions beacon_node/beacon_chain/tests/sync_committee_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ fn get_valid_sync_committee_message_for_block(
message_index: usize,
block_root: Hash256,
) -> (SyncCommitteeMessage, usize, SecretKey, SyncSubnetId) {
let head_state = harness.chain.head_beacon_state_cloned();
let mut head_state = harness.chain.head_beacon_state_cloned();
let (signature, _) = harness
.make_sync_committee_messages(&head_state, block_root, slot, relative_sync_committee)
.make_sync_committee_messages(&mut head_state, block_root, slot, relative_sync_committee)
.get(0)
.expect("sync messages should exist")
.get(message_index)
Expand All @@ -94,13 +94,14 @@ fn get_valid_sync_contribution(
harness: &BeaconChainHarness<EphemeralHarnessType<E>>,
relative_sync_committee: RelativeSyncCommittee,
) -> (SignedContributionAndProof<E>, usize, SecretKey) {
let head_state = harness.chain.head_beacon_state_cloned();
let mut head_state = harness.chain.head_beacon_state_cloned();

let head_block_root = harness.chain.head_snapshot().beacon_block_root;
let head_state_slot = head_state.slot();
let sync_contributions = harness.make_sync_contributions(
&head_state,
&mut head_state,
head_block_root,
head_state.slot(),
head_state_slot,
relative_sync_committee,
);

Expand Down
6 changes: 3 additions & 3 deletions beacon_node/http_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ pub fn serve<T: BeaconChainTypes>(
let index_opt = match &validator_id {
ValidatorId::PublicKey(pubkey) => state
.get_validator_index_readonly(pubkey)
.map_err(|e| warp_utils::reject::beacon_state_error(e))?,
.map_err(warp_utils::reject::beacon_state_error)?,
ValidatorId::Index(index) => Some(*index as usize),
};

Expand Down Expand Up @@ -1040,12 +1040,12 @@ pub fn serve<T: BeaconChainTypes>(
.pubkeys
.iter()
.map(|pubkey| {
Ok(state
state
.get_validator_index_readonly(pubkey)?
.map(|index| index as u64)
.ok_or(BeaconChainError::ValidatorPubkeyUnknown(
*pubkey,
))?)
))
})
.collect::<Result<Vec<_>, BeaconChainError>>()
.map_err(warp_utils::reject::beacon_chain_error)?;
Expand Down

0 comments on commit 0ad7641

Please sign in to comment.