Skip to content

Commit

Permalink
consensus: limit number of faults in new block
Browse files Browse the repository at this point in the history
  • Loading branch information
fed-franz committed Sep 6, 2024
1 parent c5996d5 commit 6938202
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion consensus/src/proposal/block_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::cmp::max;

use crate::merkle::merkle_root;

use crate::config::MINIMUM_BLOCK_TIME;
use crate::config::{MAX_NUMBER_OF_FAULTS, MINIMUM_BLOCK_TIME};
use dusk_bytes::Serializable;
use node_data::message::payload::Candidate;
use node_data::message::{ConsensusHeader, Message, SignInfo, StepMessage};
Expand Down Expand Up @@ -92,6 +92,13 @@ impl<T: Operations> Generator<T> {
faults: &[Fault],
voters: &[Voter],
) -> Result<Block, crate::operations::Error> {
// Limit number of faults in the block
let faults = if faults.len() > MAX_NUMBER_OF_FAULTS {
&faults[..MAX_NUMBER_OF_FAULTS]
} else {
faults
};

let to_slash =
Slash::from_iterations_and_faults(&failed_iterations, faults)?;

Expand Down

0 comments on commit 6938202

Please sign in to comment.