Fix commit grandparent
This commit is contained in:
parent
44253376bc
commit
70bbba67cc
|
@ -158,7 +158,7 @@ class Carnot:
|
|||
def __init__(self, _id: Id):
|
||||
self.id: Id = _id
|
||||
self.current_view: View = 0
|
||||
self.highest_voted_view:View=0
|
||||
self.highest_voted_view: View = 0
|
||||
self.local_high_qc: Optional[Qc] = None
|
||||
self.latest_committed_view: View = 0
|
||||
self.safe_blocks: Dict[Id, Block] = dict()
|
||||
|
@ -176,8 +176,7 @@ class Carnot:
|
|||
case AggregateQc() as aggregated:
|
||||
if aggregated.high_qc().view < self.latest_committed_view:
|
||||
return False
|
||||
return block.view >= self.current_view and block.view == aggregated.view+1 # AggregatedQC must be
|
||||
#formed from previous round.
|
||||
return block.view >= self.current_view and block.view == (aggregated.view + 1)
|
||||
|
||||
def update_high_qc(self, qc: Qc):
|
||||
match (self.local_high_qc, qc):
|
||||
|
@ -192,11 +191,6 @@ class Carnot:
|
|||
|
||||
def receive_block(self, block: Block):
|
||||
assert block.parent() in self.safe_blocks
|
||||
# This condition is not needed because it will be true as qc of a block will hve lower view than
|
||||
#the block.
|
||||
# if block.qc.view < self.current_view:
|
||||
# return
|
||||
|
||||
if block.id() in self.safe_blocks or block.view <= self.latest_committed_view:
|
||||
return
|
||||
|
||||
|
@ -210,7 +204,8 @@ class Carnot:
|
|||
assert len(votes) == self.overlay.super_majority_threshold(self.id)
|
||||
assert all(self.overlay.child_committee(self.id, vote.voter) for vote in votes)
|
||||
assert all(vote.block == block.id() for vote in votes)
|
||||
assert (block.view>highest_voted_view)
|
||||
assert (block.view > self.highest_voted_view)
|
||||
|
||||
if self.overlay.member_of_root_com(self.id):
|
||||
vote: Vote = Vote(
|
||||
block=block.id(),
|
||||
|
@ -250,7 +245,7 @@ class Carnot:
|
|||
|
||||
def local_timeout(self, new_overlay: Overlay):
|
||||
self.last_timeout_view = self.current_view
|
||||
increment_voted_view(self.current_view) # to avoid voting again for this view.
|
||||
self.increment_voted_view(self.current_view)
|
||||
self.overlay = new_overlay
|
||||
if self.overlay.member_of_leaf_committee(self.id):
|
||||
raise NotImplementedError()
|
||||
|
@ -277,9 +272,10 @@ class Carnot:
|
|||
isinstance(parent.qc, (StandardQc, ))
|
||||
)
|
||||
if can_commit:
|
||||
self.committed_blocks[block.id()] = block
|
||||
def increment_voted_view(self,view: View):
|
||||
self.highest_voted_view = max(view,self.highest_voted_view)
|
||||
self.committed_blocks[grand_parent.id()] = grand_parent
|
||||
|
||||
def increment_voted_view(self, view: View):
|
||||
self.highest_voted_view = max(view, self.highest_voted_view)
|
||||
|
||||
def increment_view_qc(self, qc: Qc) -> bool:
|
||||
if qc.view < self.current_view:
|
||||
|
|
Loading…
Reference in New Issue