Skip to content

Commit 8a556c5

Browse files
committed
Remove validation checks that prevent inclusion of self-incriminating slashings into proposed block
1 parent 703d41e commit 8a556c5

File tree

2 files changed

+16
-82
lines changed

2 files changed

+16
-82
lines changed

validator/src/slot_head.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use core::fmt::Debug;
2-
use std::{collections::HashSet, sync::Arc};
2+
use std::sync::Arc;
33

44
use anyhow::Result;
55
use bls::{CachedPublicKey, PublicKeyBytes, SignatureBytes};
@@ -55,15 +55,6 @@ impl<P: Preset> SlotHead<P> {
5555
.pubkey
5656
}
5757

58-
#[must_use]
59-
pub fn is_validator_index_protected(
60-
&self,
61-
validator_index: ValidatorIndex,
62-
own_public_keys: &HashSet<PublicKeyBytes>,
63-
) -> bool {
64-
own_public_keys.contains(&self.public_key(validator_index).to_bytes())
65-
}
66-
6758
pub fn proposer_index(&self) -> Result<ValidatorIndex> {
6859
accessors::get_beacon_proposer_index(&self.beacon_state)
6960
}

validator/src/validator.rs

Lines changed: 15 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{
88
time::SystemTime,
99
};
1010

11-
use anyhow::{ensure, Error as AnyhowError, Result};
11+
use anyhow::{Error as AnyhowError, Result};
1212
use bls::{AggregateSignature, PublicKeyBytes, Signature, SignatureBytes};
1313
use builder_api::{
1414
combined::SignedBuilderBid,
@@ -57,7 +57,6 @@ use ssz::{BitList, BitVector, ContiguousList, SszHash as _};
5757
use static_assertions::assert_not_impl_any;
5858
use std_ext::ArcExt as _;
5959
use tap::{Conv as _, Pipe as _};
60-
use thiserror::Error;
6160
use tokio::{
6261
sync::{OnceCell as TokioOnceCell, RwLock},
6362
task::JoinHandle,
@@ -135,16 +134,6 @@ const MAX_VALIDATORS_PER_REGISTRATION: usize = 500;
135134
const PAYLOAD_CACHE_SIZE: usize = 20;
136135
const PAYLOAD_ID_CACHE_SIZE: usize = 10;
137136

138-
#[derive(Debug, Error)]
139-
enum Error<P: Preset> {
140-
#[error("self-incriminating attester slashing: {attester_slashing:?}")]
141-
SelfIncriminatingAttesterSlashing {
142-
attester_slashing: AttesterSlashing<P>,
143-
},
144-
#[error("self-incriminating proposer slashing: {proposer_slashing:?}")]
145-
SelfIncriminatingProposerSlashing { proposer_slashing: ProposerSlashing },
146-
}
147-
148137
#[derive(Display)]
149138
#[display(fmt = "too many empty slots after head: {head_slot} + {max_empty_slots} < {slot}")]
150139
struct HeadFarBehind {
@@ -1055,8 +1044,6 @@ impl<P: Preset, W: Wait + Sync> Validator<P, W> {
10551044
.best_proposable_attestations(slot_head.beacon_state.clone_arc())
10561045
.await?;
10571046

1058-
let own_public_keys = self.own_public_keys().await;
1059-
10601047
tokio::task::block_in_place(|| -> Result<_> {
10611048
let eth1_data = match self.eth1_chain.eth1_vote(
10621049
&self.chain_config,
@@ -1094,10 +1081,8 @@ impl<P: Preset, W: Wait + Sync> Validator<P, W> {
10941081
// in an invalid block because a validator can only exit or be
10951082
// slashed once. The code below can handle invalid blocks, but it may
10961083
// prevent the validator from proposing.
1097-
let attester_slashings =
1098-
self.prepare_attester_slashings_for_proposal(slot_head, &own_public_keys);
1099-
let proposer_slashings =
1100-
self.prepare_proposer_slashings_for_proposal(slot_head, &own_public_keys);
1084+
let attester_slashings = self.prepare_attester_slashings_for_proposal(slot_head);
1085+
let proposer_slashings = self.prepare_proposer_slashings_for_proposal(slot_head);
11011086
let voluntary_exits = self.prepare_voluntary_exits_for_proposal(slot_head);
11021087

11031088
let without_state_root = match slot_head.beacon_state.phase() {
@@ -2613,56 +2598,6 @@ impl<P: Preset, W: Wait + Sync> Validator<P, W> {
26132598
.await
26142599
}
26152600

2616-
// This cannot be a method due to a borrow conflict.
2617-
fn validate_proposer_slashing_for_block(
2618-
proposer_slashing: &ProposerSlashing,
2619-
slot_head: &SlotHead<P>,
2620-
own_public_keys: &HashSet<PublicKeyBytes>,
2621-
) -> Result<()> {
2622-
unphased::validate_proposer_slashing(
2623-
&slot_head.config,
2624-
&slot_head.beacon_state,
2625-
*proposer_slashing,
2626-
)?;
2627-
2628-
// check matching proposer_indexes
2629-
let proposer_index_1 = proposer_slashing.signed_header_1.message.proposer_index;
2630-
2631-
// check for self-incrimination
2632-
ensure!(
2633-
!slot_head.is_validator_index_protected(proposer_index_1, own_public_keys),
2634-
Error::SelfIncriminatingProposerSlashing::<P> {
2635-
proposer_slashing: *proposer_slashing,
2636-
},
2637-
);
2638-
2639-
Ok(())
2640-
}
2641-
2642-
// This cannot be a method due to a borrow conflict.
2643-
fn validate_attester_slashing_for_block(
2644-
attester_slashing: &AttesterSlashing<P>,
2645-
slot_head: &SlotHead<P>,
2646-
own_public_keys: &HashSet<PublicKeyBytes>,
2647-
) -> Result<()> {
2648-
let slashable_indices = unphased::validate_attester_slashing(
2649-
&slot_head.config,
2650-
&slot_head.beacon_state,
2651-
attester_slashing,
2652-
)?;
2653-
2654-
ensure!(
2655-
!slashable_indices.into_iter().any(|validator_index| {
2656-
slot_head.is_validator_index_protected(validator_index, own_public_keys)
2657-
}),
2658-
Error::SelfIncriminatingAttesterSlashing::<P> {
2659-
attester_slashing: attester_slashing.clone()
2660-
},
2661-
);
2662-
2663-
Ok(())
2664-
}
2665-
26662601
fn prepare_voluntary_exits_for_proposal(
26672602
&mut self,
26682603
slot_head: &SlotHead<P>,
@@ -2698,15 +2633,19 @@ impl<P: Preset, W: Wait + Sync> Validator<P, W> {
26982633
fn prepare_attester_slashings_for_proposal(
26992634
&mut self,
27002635
slot_head: &SlotHead<P>,
2701-
own_public_keys: &HashSet<PublicKeyBytes>,
27022636
) -> ContiguousList<AttesterSlashing<P>, P::MaxAttesterSlashings> {
27032637
let _timer = self
27042638
.metrics
27052639
.as_ref()
27062640
.map(|metrics| metrics.prepare_attester_slashings_times.start_timer());
27072641

27082642
let split_index = itertools::partition(&mut self.attester_slashings, |slashing| {
2709-
Self::validate_attester_slashing_for_block(slashing, slot_head, own_public_keys).is_ok()
2643+
unphased::validate_attester_slashing(
2644+
&slot_head.config,
2645+
&slot_head.beacon_state,
2646+
slashing,
2647+
)
2648+
.is_ok()
27102649
});
27112650

27122651
let attester_slashings = ContiguousList::try_from_iter(
@@ -2835,15 +2774,19 @@ impl<P: Preset, W: Wait + Sync> Validator<P, W> {
28352774
fn prepare_proposer_slashings_for_proposal(
28362775
&mut self,
28372776
slot_head: &SlotHead<P>,
2838-
own_public_keys: &HashSet<PublicKeyBytes>,
28392777
) -> ContiguousList<ProposerSlashing, P::MaxProposerSlashings> {
28402778
let _timer = self
28412779
.metrics
28422780
.as_ref()
28432781
.map(|metrics| metrics.prepare_proposer_slashings_times.start_timer());
28442782

28452783
let split_index = itertools::partition(&mut self.proposer_slashings, |slashing| {
2846-
Self::validate_proposer_slashing_for_block(slashing, slot_head, own_public_keys).is_ok()
2784+
unphased::validate_proposer_slashing(
2785+
&slot_head.config,
2786+
&slot_head.beacon_state,
2787+
*slashing,
2788+
)
2789+
.is_ok()
28472790
});
28482791

28492792
let proposer_slashings = ContiguousList::try_from_iter(

0 commit comments

Comments
 (0)