Skip to content
9 changes: 3 additions & 6 deletions abci/client/local_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ func (app *localClient) SetResponseCallback(cb Callback) {
}

func (app *localClient) CheckTxAsync(ctx context.Context, req *types.RequestCheckTx) (*ReqRes, error) {
app.mtx.Lock()
defer app.mtx.Unlock()

res, err := app.Application.CheckTx(ctx, req)

if err != nil {
return nil, err
}
Expand Down Expand Up @@ -93,10 +91,9 @@ func (app *localClient) Info(ctx context.Context, req *types.RequestInfo) (*type
}

func (app *localClient) CheckTx(ctx context.Context, req *types.RequestCheckTx) (*types.ResponseCheckTx, error) {
app.mtx.Lock()
defer app.mtx.Unlock()
res, err := app.Application.CheckTx(ctx, req)

return app.Application.CheckTx(ctx, req)
return res, err
}

func (app *localClient) Query(ctx context.Context, req *types.RequestQuery) (*types.ResponseQuery, error) {
Expand Down
40 changes: 40 additions & 0 deletions abci/client/local_client_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package abcicli

import (
"context"
"testing"

"github.com/cometbft/cometbft/abci/types"
cmtsync "github.com/cometbft/cometbft/libs/sync"
"github.com/stretchr/testify/require"
)

func TestNewLocalClient(t *testing.T) {
t.Run("CheckTx should not lock mutex", func(t *testing.T) {
mutex := new(cmtsync.Mutex)
app := types.NewBaseApplication()
client := NewLocalClient(mutex, app)

mutex.Lock()
// If CheckTx called Lock on the mutex, the next line would cause a deadlock.
_, err := client.CheckTx(context.Background(), &types.RequestCheckTx{})
require.NoError(t, err)
mutex.Unlock()
})
t.Run("CheckTxAsync should not lock mutex", func(t *testing.T) {
mutex := new(cmtsync.Mutex)
app := types.NewBaseApplication()
client := NewLocalClient(mutex, app)
client.SetResponseCallback(mockCallback())

mutex.Lock()
// If CheckTxAsync called Lock on the mutex, the next line would cause a deadlock.
_, err := client.CheckTxAsync(context.Background(), &types.RequestCheckTx{})
require.NoError(t, err)
mutex.Unlock()
})
}

func mockCallback() func(*types.Request, *types.Response) {
return func(req *types.Request, res *types.Response) {}
}
2 changes: 1 addition & 1 deletion consensus/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func NewReactor(consensusState *State, propagator propagation.Propagator, waitSy
traceClient: trace.NoOpTracer(),
propagator: propagator,
}
conR.gossipDataEnabled.Store(true)
conR.gossipDataEnabled.Store(false)
conR.BaseReactor = *p2p.NewBaseReactor("Consensus", conR, p2p.WithIncomingQueueSize(ReactorIncomingMessageQueueSize))

for _, option := range options {
Expand Down
2 changes: 1 addition & 1 deletion node/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ func createConsensusReactor(config *cfg.Config,
if privValidator != nil {
consensusState.SetPrivValidator(privValidator)
}
consensusReactor := cs.NewReactor(consensusState, propagator, waitSync, cs.ReactorMetrics(csMetrics), cs.ReactorTracing(traceClient), cs.WithGossipDataEnabled(true))
consensusReactor := cs.NewReactor(consensusState, propagator, waitSync, cs.ReactorMetrics(csMetrics), cs.ReactorTracing(traceClient), cs.WithGossipDataEnabled(false))
consensusReactor.SetLogger(consensusLogger)
// services which will be publishing and/or subscribing for messages (events)
// consensusReactor will set it on consensusState and blockExecutor
Expand Down
Loading