diff --git a/cbc_casper_simulator/estimator/lmd_ghost_estimator.py b/cbc_casper_simulator/estimator/lmd_ghost_estimator.py index 2611fe6..725c4df 100644 --- a/cbc_casper_simulator/estimator/lmd_ghost_estimator.py +++ b/cbc_casper_simulator/estimator/lmd_ghost_estimator.py @@ -12,9 +12,11 @@ def estimate(cls, state: State, justification: Justification) -> Block: store: Store = state.store best_block = store.genesis_block() + while store.has_children_blocks(best_block): + # If "tie" exists, choose the block with the smallest hash. best_block = max(store.children_blocks( - best_block), key=lambda x: scores.get(x, 0)) + best_block), key=lambda block: (scores.get(block, 0), -block.hash)) return Block(best_block.hash) @classmethod