Skip to content

consensus: correctly save reference to previous height precommits (backport #9760)#214

Merged
jmalicevic merged 2 commits intov0.37.xfrom
jasmina/213-mergev37.1-to-v0.37.x
Jan 27, 2023
Merged

consensus: correctly save reference to previous height precommits (backport #9760)#214
jmalicevic merged 2 commits intov0.37.xfrom
jasmina/213-mergev37.1-to-v0.37.x

Conversation

@jmalicevic
Copy link
Copy Markdown
Collaborator

This re-introduces the change done in tendermint/tendermint#9760.
Addresses #213

mergify bot and others added 2 commits January 26, 2023 21:58
…ckport #9760) (#9775)

* consensus: correctly save reference to previous height precommits (#9760)

This change reduces the number of Precommit messages sent to peers by 50%.

During the `ApplyNewRoundStepMessage`, we update the known state of the peer sending us the message.

We set the value of `ps.PRS.Precommits` to nil in this method if the peer is entering a new height or round.
https://github.com/tendermint/tendermint/blob/34ca3fb4741cdb205a4714d345218a0d5e9fefd0/consensus/reactor.go#L1368

We then assign `ps.PRS.LastCommit = ps.PRS.Precommits` if the peer is entering a new height only - this does not happen during just a round change. This therefore results in `ps.PRS.LastCommit` having the value `nil`.

When the `LastCommit` bit field is seen as `nil` in the reactor, an empty bit field is initialized.
https://github.com/tendermint/tendermint/blob/34ca3fb4741cdb205a4714d345218a0d5e9fefd0/consensus/reactor.go#L1273

The code responsible for gossiping votes from the previous height uses this `LastCommit` value and, seeing an empty `LastCommit` will resend every `Precommit` from the previous height since it lost the information it previously had detailing which precommits from the previous height the peer had.

This can be seen in the code responsible for gossiping precommits from the previous height:
https://github.com/tendermint/tendermint/blob/34ca3fb4741cdb205a4714d345218a0d5e9fefd0/consensus/reactor.go#L773

Where this code grabs the, previously `nil`, `LastCommit` bit field:
https://github.com/tendermint/tendermint/blob/34ca3fb4741cdb205a4714d345218a0d5e9fefd0/consensus/reactor.go#L1204-L1212

---

- [ ] Tests written/updated, or no tests needed
- [ ] `CHANGELOG_PENDING.md` updated, or no changelog entry needed
- [ ] Updated relevant documentation (`docs/`) and code comments, or no
      documentation updates needed

(cherry picked from commit da204d3)

* changelog

Co-authored-by: William Banfield <4561443+williambanfield@users.noreply.github.com>
Co-authored-by: William Banfield <wbanfield@gmail.com>
@jmalicevic jmalicevic requested a review from a team as a code owner January 26, 2023 21:05
@jmalicevic jmalicevic self-assigned this Jan 26, 2023
@jmalicevic jmalicevic merged commit f1880d2 into v0.37.x Jan 27, 2023
@jmalicevic jmalicevic deleted the jasmina/213-mergev37.1-to-v0.37.x branch January 27, 2023 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants