Skip to content

Commit

Permalink
revert block seen cache changes
Browse files Browse the repository at this point in the history
  • Loading branch information
realbigsean committed Jan 4, 2024
1 parent 4c3239d commit 8bd9d85
Show file tree
Hide file tree
Showing 4 changed files with 215 additions and 63 deletions.
4 changes: 2 additions & 2 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3161,9 +3161,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
blobs: FixedBlobSidecarList<T::EthSpec>,
) -> Result<AvailabilityProcessingStatus, BlockError<T::EthSpec>> {
if let Some(slasher) = self.slasher.as_ref() {
let mut slashable_cache = self.observed_slashable.write();
for blob_sidecar in blobs.iter().filter_map(|blob| blob.clone()) {
self.observed_slashable
.write()
slashable_cache
.observe_slashable(
blob_sidecar.slot(),
blob_sidecar.block_proposer_index(),
Expand Down
20 changes: 13 additions & 7 deletions beacon_node/beacon_chain/src/block_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ use crate::execution_payload::{
is_optimistic_candidate_block, validate_execution_payload_for_gossip, validate_merge_block,
AllowOptimisticImport, NotifyExecutionLayer, PayloadNotifier,
};
use crate::observed_block_producers::SeenBlock;
use crate::snapshot_cache::PreProcessingSnapshot;
use crate::validator_monitor::HISTORIC_EPOCHS as VALIDATOR_MONITOR_HISTORIC_EPOCHS;
use crate::validator_pubkey_cache::ValidatorPubkeyCache;
Expand Down Expand Up @@ -955,13 +956,17 @@ impl<T: BeaconChainTypes> GossipVerifiedBlock<T> {
//
// It's important to double-check that the proposer still hasn't been observed so we don't
// have a race-condition when verifying two blocks simultaneously.
if chain
match chain
.observed_block_producers
.write()
.observe_proposal(block.message())
.observe_proposal(block_root, block.message())
.map_err(|e| BlockError::BeaconChainError(e.into()))?
{
return Err(BlockError::BlockIsAlreadyKnown);
SeenBlock::Slashable => {
return Err(BlockError::Slashable);
}
SeenBlock::Duplicate => return Err(BlockError::BlockIsAlreadyKnown),
SeenBlock::UniqueNonSlashable => {}
};

if block.message().proposer_index() != expected_proposer as u64 {
Expand Down Expand Up @@ -1242,14 +1247,15 @@ impl<T: BeaconChainTypes> ExecutionPendingBlock<T> {
notify_execution_layer: NotifyExecutionLayer,
) -> Result<Self, BlockError<T::EthSpec>> {
chain
.observed_block_producers
.observed_slashable
.write()
.observe_proposal(block.message())
.observe_slashable(block.slot(), block.message().proposer_index(), block_root)
.map_err(|e| BlockError::BeaconChainError(e.into()))?;

chain
.observed_slashable
.observed_block_producers
.write()
.observe_slashable(block.slot(), block.message().proposer_index(), block_root)
.observe_proposal(block_root, block.message())
.map_err(|e| BlockError::BeaconChainError(e.into()))?;

if let Some(parent) = chain
Expand Down
Loading

0 comments on commit 8bd9d85

Please sign in to comment.