Skip to content

Commit

Permalink
Only clean votes if the block has been finalized (#1290)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHinshelwood authored Aug 14, 2024
1 parent 422a4c8 commit 72d1da7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

Unreleased changes.

- [#1174](https://github.com/Zilliqa/zq2/pull/1174): Limit the returned size of `GetSmartContractState` when the `state_rpc_limit` configuration is set.
- [#1290](https://github.com/Zilliqa/zq2/pull/1281): Fix over-eager clean up of votes which could cause votes for pending blocks to get lost.
- [#1281](https://github.com/Zilliqa/zq2/pull/1281): Emit an `ERROR` level log when a node panics.
- [#1174](https://github.com/Zilliqa/zq2/pull/1174): Limit the returned size of `GetSmartContractState` when the `state_rpc_limit` configuration is set.

## [0.1.0] - 2024-08-01

Expand Down
8 changes: 7 additions & 1 deletion zilliqa/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,13 @@ impl Consensus {

for key in keys_to_process {
if let Ok(Some(block)) = self.get_block(&key) {
if block.view() < self.view.get_view() {
// Remove votes for blocks that have been finalized. However, note that the block hashes which are keys
// into `self.votes` are the parent hash of the (potential) block that is being voted on. Therefore, we
// subtract one in this condition to ensure there is no chance of removing votes for blocks that still
// have a chance of being mined. It is possible this is unnecessary, since `self.finalized_view` is
// already at least 2 views behind the head of the chain, but keeping one extra vote in memory doesn't
// cost much and does make us more confident that we won't dispose of valid votes.
if block.view() < self.finalized_view.saturating_sub(1) {
self.votes.remove(&key);
}
} else {
Expand Down

0 comments on commit 72d1da7

Please sign in to comment.