From 8a337e596303f35640c9ba7a83486221f0f2222c Mon Sep 17 00:00:00 2001 From: mjalalzai <33738574+MForensic@users.noreply.github.com> Date: Thu, 28 Sep 2023 14:13:26 -0700 Subject: [PATCH] update timeout_qc --- carnot/carnot-vote-aggregation.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/carnot/carnot-vote-aggregation.py b/carnot/carnot-vote-aggregation.py index e613c07..b815b8f 100644 --- a/carnot/carnot-vote-aggregation.py +++ b/carnot/carnot-vote-aggregation.py @@ -286,3 +286,20 @@ class Carnot: if not self.last_view_timeout_qc or timeout_qc.view > self.last_view_timeout_qc.view: self.last_view_timeout_qc = timeout_qc + def receive_block(self, block: Block): + assert block.parent() in self.safe_blocks + + # Check if the block is already in safe_blocks, if it's from a previous view, + # or if there are existing blocks for the same view + if block.id() in self.safe_blocks or block.view <= self.latest_committed_view() or self.blocks_in_view( + block.view): + # TODO: Report malicious leader or handle potential fork divergence + return + + # TODO: Verify if the proposer is indeed the leader + + # If the block is safe, add it to safe_blocks and update the high QC + if self.block_is_safe(block): + self.safe_blocks[block.id()] = block + self.update_high_qc(block.qc) +