@@ -668,6 +668,7 @@ pub fn validate_commit_transaction(
668668 active_wips : & ActiveWips ,
669669 superblock_period : u16 ,
670670 protocol_version : ProtocolVersion ,
671+ stakes : & Stakes < PublicKeyHash , Wit , u32 , u64 > ,
671672) -> Result < ( Hash , u16 , u64 ) , failure:: Error > {
672673 // Get DataRequest information
673674 let dr_pointer = co_tx. body . dr_pointer ;
@@ -680,9 +681,28 @@ pub fn validate_commit_transaction(
680681
681682 let dr_output = & dr_state. data_request ;
682683
684+ let proof_pkh = co_tx. body . proof . proof . pkh ( ) ;
685+
686+ // Check if the commit transaction is from an eligible validator
687+ if protocol_version >= ProtocolVersion :: V2_0 {
688+ let eligibility = stakes. witnessing_eligibility (
689+ proof_pkh,
690+ epoch,
691+ dr_state. data_request . witnesses ,
692+ dr_state. info . current_commit_round ,
693+ ) ;
694+ if eligibility == Ok ( Eligible :: No ( InsufficientPower ) )
695+ || eligibility == Ok ( Eligible :: No ( NotStaking ) )
696+ {
697+ return Err ( TransactionError :: ValidatorNotEligible {
698+ validator : proof_pkh,
699+ }
700+ . into ( ) ) ;
701+ }
702+ }
703+
683704 // Commitment's output is only for change propose, so it only has to be one output and the
684705 // address has to be the same than the address which creates the commitment
685- let proof_pkh = co_tx. body . proof . proof . pkh ( ) ;
686706 if co_tx. body . outputs . len ( ) > 1 {
687707 return Err ( TransactionError :: SeveralCommitOutputs . into ( ) ) ;
688708 }
@@ -1787,6 +1807,7 @@ pub fn validate_block_transactions(
17871807 active_wips,
17881808 consensus_constants. superblock_period ,
17891809 protocol_version,
1810+ stakes,
17901811 ) ?;
17911812
17921813 // Validation for only one commit for pkh/data request in a block
@@ -2307,7 +2328,8 @@ pub fn validate_new_transaction(
23072328 minimum_reppoe_difficulty,
23082329 active_wips,
23092330 superblock_period,
2310- protocol_version
2331+ protocol_version,
2332+ stakes,
23112333 )
23122334 . map ( |( _, _, fee) | fee) ,
23132335 Transaction :: Reveal ( tx) => {
0 commit comments