From 04f314849c3662854b2cce334e3ea9c8637e2bb1 Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Tue, 15 Nov 2022 16:17:44 +0100 Subject: [PATCH] remove global mutex from local abci client --- abci/client/local_client.go | 6 +----- consensus/byzantine_test.go | 6 ++---- consensus/common_test.go | 7 ++----- consensus/reactor_test.go | 6 ++---- proxy/client.go | 5 +---- 5 files changed, 8 insertions(+), 22 deletions(-) diff --git a/abci/client/local_client.go b/abci/client/local_client.go index 62b0942c1..cb68567a7 100644 --- a/abci/client/local_client.go +++ b/abci/client/local_client.go @@ -26,12 +26,8 @@ var _ Client = (*localClient)(nil) // methods of the given app. // // Both Async and Sync methods ignore the given context.Context parameter. -func NewLocalClient(mtx *tmsync.Mutex, app types.Application) Client { - if mtx == nil { - mtx = new(tmsync.Mutex) - } +func NewLocalClient(app types.Application) Client { cli := &localClient{ - mtx: mtx, Application: app, } cli.BaseService = *service.NewBaseService(nil, "localClient", cli) diff --git a/consensus/byzantine_test.go b/consensus/byzantine_test.go index d301c0ccd..4d5f1d3c3 100644 --- a/consensus/byzantine_test.go +++ b/consensus/byzantine_test.go @@ -19,7 +19,6 @@ import ( "github.com/tendermint/tendermint/evidence" "github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/service" - tmsync "github.com/tendermint/tendermint/libs/sync" mempl "github.com/tendermint/tendermint/mempool" cfg "github.com/tendermint/tendermint/config" @@ -65,10 +64,9 @@ func TestByzantinePrevoteEquivocation(t *testing.T) { blockDB := dbm.NewMemDB() blockStore := store.NewBlockStore(blockDB) - mtx := new(tmsync.Mutex) // one for mempool, one for consensus - proxyAppConnCon := abcicli.NewLocalClient(mtx, app) - proxyAppConnConMem := abcicli.NewLocalClient(mtx, app) + proxyAppConnCon := abcicli.NewLocalClient(app) + proxyAppConnConMem := abcicli.NewLocalClient(app) // Make Mempool var mempool mempl.Mempool diff --git a/consensus/common_test.go b/consensus/common_test.go index 73d601b55..d82d20061 100644 --- a/consensus/common_test.go +++ b/consensus/common_test.go @@ -27,7 +27,6 @@ import ( "github.com/tendermint/tendermint/libs/log" tmos "github.com/tendermint/tendermint/libs/os" tmpubsub "github.com/tendermint/tendermint/libs/pubsub" - tmsync "github.com/tendermint/tendermint/libs/sync" mempl "github.com/tendermint/tendermint/mempool" mempoolv0 "github.com/tendermint/tendermint/mempool/v0" mempoolv1 "github.com/tendermint/tendermint/mempool/v1" @@ -390,10 +389,8 @@ func newStateWithConfigAndBlockStore( blockStore := store.NewBlockStore(blockDB) // one for mempool, one for consensus - mtx := new(tmsync.Mutex) - - proxyAppConnCon := abcicli.NewLocalClient(mtx, app) - proxyAppConnConMem := abcicli.NewLocalClient(mtx, app) + proxyAppConnCon := abcicli.NewLocalClient(app) + proxyAppConnConMem := abcicli.NewLocalClient(app) // Make Mempool memplMetrics := mempl.NopMetrics() diff --git a/consensus/reactor_test.go b/consensus/reactor_test.go index 851070ba6..22fde1243 100644 --- a/consensus/reactor_test.go +++ b/consensus/reactor_test.go @@ -28,7 +28,6 @@ import ( "github.com/tendermint/tendermint/libs/bits" "github.com/tendermint/tendermint/libs/bytes" "github.com/tendermint/tendermint/libs/log" - tmsync "github.com/tendermint/tendermint/libs/sync" mempl "github.com/tendermint/tendermint/mempool" mempoolv0 "github.com/tendermint/tendermint/mempool/v0" mempoolv1 "github.com/tendermint/tendermint/mempool/v1" @@ -158,11 +157,10 @@ func TestReactorWithEvidence(t *testing.T) { blockDB := dbm.NewMemDB() blockStore := store.NewBlockStore(blockDB) - mtx := new(tmsync.Mutex) memplMetrics := mempl.NopMetrics() // one for mempool, one for consensus - proxyAppConnCon := abcicli.NewLocalClient(mtx, app) - proxyAppConnConMem := abcicli.NewLocalClient(mtx, app) + proxyAppConnCon := abcicli.NewLocalClient(app) + proxyAppConnConMem := abcicli.NewLocalClient(app) // Make Mempool var mempool mempl.Mempool diff --git a/proxy/client.go b/proxy/client.go index 68498d574..c42f785df 100644 --- a/proxy/client.go +++ b/proxy/client.go @@ -7,7 +7,6 @@ import ( "github.com/tendermint/tendermint/abci/example/counter" "github.com/tendermint/tendermint/abci/example/kvstore" "github.com/tendermint/tendermint/abci/types" - tmsync "github.com/tendermint/tendermint/libs/sync" e2e "github.com/tendermint/tendermint/test/e2e/app" ) @@ -23,7 +22,6 @@ type ClientCreator interface { // local proxy uses a mutex on an in-proc app type localClientCreator struct { - mtx *tmsync.Mutex app types.Application } @@ -31,13 +29,12 @@ type localClientCreator struct { // which will be running locally. func NewLocalClientCreator(app types.Application) ClientCreator { return &localClientCreator{ - mtx: new(tmsync.Mutex), app: app, } } func (l *localClientCreator) NewABCIClient() (abcicli.Client, error) { - return abcicli.NewLocalClient(l.mtx, l.app), nil + return abcicli.NewLocalClient(l.app), nil } //---------------------------------------------------------------