Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(consensus): Fix some peer messages taking write locks on the cs … #92

Merged
merged 3 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [`consensus`] Fix some reactor messages taking write locks instead of read locks.
([\#3159](https://github.com/cometbft/cometbft/issues/3159)
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* [#85](https://github.com/osmosis-labs/cometbft/pull/85) perf(flowrate): Speedup flowrate.Clock (#3016)
* [#86](https://github.com/osmosis-labs/cometbft/pull/86) Comment out expensive debug logs
* [#91](https://github.com/osmosis-labs/cometbft/pull/91) perf(consensus): Minor improvement by making add vote only do one peer set mutex call, not 3 (#3156)
* [#93](https://github.com/osmosis-labs/cometbft/pull/93) perf(consensus): Make some consensus reactor messages take RLock's not WLock's (#3159)

## v0.37.4-v25-osmo-5

Expand Down
12 changes: 6 additions & 6 deletions consensus/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ func (conR *Reactor) ReceiveEnvelope(e p2p.Envelope) {
case StateChannel:
switch msg := msg.(type) {
case *NewRoundStepMessage:
conR.conS.mtx.Lock()
conR.conS.mtx.RLock()
initialHeight := conR.conS.state.InitialHeight
conR.conS.mtx.Unlock()
conR.conS.mtx.RUnlock()
if err = msg.ValidateHeight(initialHeight); err != nil {
conR.Logger.Error("Peer sent us invalid msg", "peer", e.Src, "msg", msg, "err", err)
conR.Switch.StopPeerForError(e.Src, err)
Expand All @@ -277,9 +277,9 @@ func (conR *Reactor) ReceiveEnvelope(e p2p.Envelope) {
ps.ApplyHasVoteMessage(msg)
case *VoteSetMaj23Message:
cs := conR.conS
cs.mtx.Lock()
cs.mtx.RLock()
height, votes := cs.Height, cs.Votes
cs.mtx.Unlock()
cs.mtx.RUnlock()
if height != msg.Height {
return
}
Expand Down Expand Up @@ -364,9 +364,9 @@ func (conR *Reactor) ReceiveEnvelope(e p2p.Envelope) {
switch msg := msg.(type) {
case *VoteSetBitsMessage:
cs := conR.conS
cs.mtx.Lock()
cs.mtx.RLock()
height, votes := cs.Height, cs.Votes
cs.mtx.Unlock()
cs.mtx.RUnlock()

if height == msg.Height {
var ourVotes *bits.BitArray
Expand Down
Loading
Loading