@@ -8,7 +8,7 @@ use std::{
8
8
time:: SystemTime ,
9
9
} ;
10
10
11
- use anyhow:: { ensure , Error as AnyhowError , Result } ;
11
+ use anyhow:: { Error as AnyhowError , Result } ;
12
12
use bls:: { AggregateSignature , PublicKeyBytes , Signature , SignatureBytes } ;
13
13
use builder_api:: {
14
14
combined:: SignedBuilderBid ,
@@ -57,7 +57,6 @@ use ssz::{BitList, BitVector, ContiguousList, SszHash as _};
57
57
use static_assertions:: assert_not_impl_any;
58
58
use std_ext:: ArcExt as _;
59
59
use tap:: { Conv as _, Pipe as _} ;
60
- use thiserror:: Error ;
61
60
use tokio:: {
62
61
sync:: { OnceCell as TokioOnceCell , RwLock } ,
63
62
task:: JoinHandle ,
@@ -135,16 +134,6 @@ const MAX_VALIDATORS_PER_REGISTRATION: usize = 500;
135
134
const PAYLOAD_CACHE_SIZE : usize = 20 ;
136
135
const PAYLOAD_ID_CACHE_SIZE : usize = 10 ;
137
136
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
-
148
137
#[ derive( Display ) ]
149
138
#[ display( fmt = "too many empty slots after head: {head_slot} + {max_empty_slots} < {slot}" ) ]
150
139
struct HeadFarBehind {
@@ -1055,8 +1044,6 @@ impl<P: Preset, W: Wait + Sync> Validator<P, W> {
1055
1044
. best_proposable_attestations ( slot_head. beacon_state . clone_arc ( ) )
1056
1045
. await ?;
1057
1046
1058
- let own_public_keys = self . own_public_keys ( ) . await ;
1059
-
1060
1047
tokio:: task:: block_in_place ( || -> Result < _ > {
1061
1048
let eth1_data = match self . eth1_chain . eth1_vote (
1062
1049
& self . chain_config ,
@@ -1094,10 +1081,8 @@ impl<P: Preset, W: Wait + Sync> Validator<P, W> {
1094
1081
// in an invalid block because a validator can only exit or be
1095
1082
// slashed once. The code below can handle invalid blocks, but it may
1096
1083
// 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) ;
1101
1086
let voluntary_exits = self . prepare_voluntary_exits_for_proposal ( slot_head) ;
1102
1087
1103
1088
let without_state_root = match slot_head. beacon_state . phase ( ) {
@@ -2613,56 +2598,6 @@ impl<P: Preset, W: Wait + Sync> Validator<P, W> {
2613
2598
. await
2614
2599
}
2615
2600
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
-
2666
2601
fn prepare_voluntary_exits_for_proposal (
2667
2602
& mut self ,
2668
2603
slot_head : & SlotHead < P > ,
@@ -2698,15 +2633,19 @@ impl<P: Preset, W: Wait + Sync> Validator<P, W> {
2698
2633
fn prepare_attester_slashings_for_proposal (
2699
2634
& mut self ,
2700
2635
slot_head : & SlotHead < P > ,
2701
- own_public_keys : & HashSet < PublicKeyBytes > ,
2702
2636
) -> ContiguousList < AttesterSlashing < P > , P :: MaxAttesterSlashings > {
2703
2637
let _timer = self
2704
2638
. metrics
2705
2639
. as_ref ( )
2706
2640
. map ( |metrics| metrics. prepare_attester_slashings_times . start_timer ( ) ) ;
2707
2641
2708
2642
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 ( )
2710
2649
} ) ;
2711
2650
2712
2651
let attester_slashings = ContiguousList :: try_from_iter (
@@ -2835,15 +2774,19 @@ impl<P: Preset, W: Wait + Sync> Validator<P, W> {
2835
2774
fn prepare_proposer_slashings_for_proposal (
2836
2775
& mut self ,
2837
2776
slot_head : & SlotHead < P > ,
2838
- own_public_keys : & HashSet < PublicKeyBytes > ,
2839
2777
) -> ContiguousList < ProposerSlashing , P :: MaxProposerSlashings > {
2840
2778
let _timer = self
2841
2779
. metrics
2842
2780
. as_ref ( )
2843
2781
. map ( |metrics| metrics. prepare_proposer_slashings_times . start_timer ( ) ) ;
2844
2782
2845
2783
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 ( )
2847
2790
} ) ;
2848
2791
2849
2792
let proposer_slashings = ContiguousList :: try_from_iter (
0 commit comments