Skip to content

Commit

Permalink
Remove head_proposer_shuffling_decision_root
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhauner committed Jun 28, 2022
1 parent 5cda3ee commit 67ca5d7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
9 changes: 7 additions & 2 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3698,10 +3698,15 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
// any longer than necessary.
let (head_slot, head_root, head_decision_root, head_random, forkchoice_update_params) = {
let canonical_head = self.canonical_head.read();
let head_block_root = canonical_head.head_block_root();
let decision_root = canonical_head
.head_snapshot
.beacon_state
.proposer_shuffling_decision_root(head_block_root)?;
(
canonical_head.head_slot(),
canonical_head.head_block_root(),
canonical_head.head_proposer_shuffling_decision_root,
head_block_root,
decision_root,
canonical_head.head_random()?,
canonical_head
.fork_choice
Expand Down
4 changes: 0 additions & 4 deletions beacon_node/beacon_chain/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,10 +732,6 @@ where
let canonical_head = CanonicalHead {
fork_choice,
fork_choice_view,
head_proposer_shuffling_decision_root: head_snapshot
.beacon_state
.proposer_shuffling_decision_root(head_snapshot.beacon_block_root)
.map_err(|e| format!("Failed to determine shuffling root: {:?}", e))?,
head_snapshot,
};

Expand Down
8 changes: 0 additions & 8 deletions beacon_node/beacon_chain/src/canonical_head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ pub struct CanonicalHead<T: BeaconChainTypes> {
pub fork_choice_view: ForkChoiceView,
/// Provides the head block and state from the last time the head was updated.
pub head_snapshot: BeaconSnapshot<T::EthSpec>,
/// This value is pre-computed to make life simpler for downstream users.
pub head_proposer_shuffling_decision_root: Hash256,
}

impl<T: BeaconChainTypes> CanonicalHead<T> {
Expand All @@ -53,8 +51,6 @@ impl<T: BeaconChainTypes> CanonicalHead<T> {
let beacon_state = store
.get_state(&beacon_state_root, Some(beacon_block.slot()))?
.ok_or(Error::MissingBeaconState(beacon_state_root))?;
let head_proposer_shuffling_decision_root =
beacon_state.proposer_shuffling_decision_root(beacon_block_root)?;
let head_snapshot = BeaconSnapshot {
beacon_block_root,
beacon_block,
Expand All @@ -65,7 +61,6 @@ impl<T: BeaconChainTypes> CanonicalHead<T> {
fork_choice,
fork_choice_view,
head_snapshot,
head_proposer_shuffling_decision_root,
})
}

Expand Down Expand Up @@ -340,9 +335,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
})?;

// Enshrine the new value as the head.
canonical_head_write_lock.head_proposer_shuffling_decision_root = new_head
.beacon_state
.proposer_shuffling_decision_root(new_head.beacon_block_root)?;
let old_head = mem::replace(&mut canonical_head_write_lock.head_snapshot, new_head);

// Clear the early attester cache in case it conflicts with `self.canonical_head`.
Expand Down
12 changes: 7 additions & 5 deletions beacon_node/http_api/src/proposer_duties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@ fn try_proposer_duties_from_cache<T: BeaconChainTypes>(
) -> Result<Option<ApiDuties>, warp::reject::Rejection> {
let (head_slot, head_block_root, head_decision_root) = {
let head = chain.canonical_head.read();
(
head.head_slot(),
head.head_block_root(),
head.head_proposer_shuffling_decision_root,
)
let head_block_root = head.head_block_root();
let decision_root = head
.head_snapshot
.beacon_state
.proposer_shuffling_decision_root(head_block_root)
.map_err(warp_utils::reject::beacon_state_error)?;
(head.head_slot(), head_block_root, decision_root)
};
let head_epoch = head_slot.epoch(T::EthSpec::slots_per_epoch());

Expand Down

0 comments on commit 67ca5d7

Please sign in to comment.