From 693820233d0404ce25c591f7b6bea436c2448e0a Mon Sep 17 00:00:00 2001 From: Federico Franzoni <8609060+fed-franz@users.noreply.github.com> Date: Fri, 6 Sep 2024 17:14:26 +0200 Subject: [PATCH] consensus: limit number of faults in new block --- consensus/src/proposal/block_generator.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/consensus/src/proposal/block_generator.rs b/consensus/src/proposal/block_generator.rs index e53a0585e4..d67348d6f9 100644 --- a/consensus/src/proposal/block_generator.rs +++ b/consensus/src/proposal/block_generator.rs @@ -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}; @@ -92,6 +92,13 @@ impl Generator { faults: &[Fault], voters: &[Voter], ) -> Result { + // 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)?;