diff --git a/x/wasm/handler/query_grpc.go b/x/wasm/handler/query_grpc.go index 7b91515fe..4785456e6 100644 --- a/x/wasm/handler/query_grpc.go +++ b/x/wasm/handler/query_grpc.go @@ -2,7 +2,6 @@ package handler import ( "fmt" - "sync" msgv1 "cosmossdk.io/api/cosmos/msg/v1" queryv1 "cosmossdk.io/api/cosmos/query/v1" @@ -25,7 +24,6 @@ type GRPCQuerier struct { codec codec.Codec // map[query proto URL]proto response type acceptedQueries map[string]func() gogoproto.Message - mu sync.Mutex } // NewGRPCQuerier returns a new instance of GRPCQuerier. @@ -40,7 +38,6 @@ func NewGRPCQuerier(gRPCQueryRouter *baseapp.GRPCQueryRouter, codec codec.Codec) gRPCQueryRouter: gRPCQueryRouter, codec: codec, acceptedQueries: acceptedQueries, - mu: sync.Mutex{}, } } @@ -59,12 +56,10 @@ func (q *GRPCQuerier) Query(ctx sdk.Context, request *wasmvmtypes.GrpcQuery) (go return nil, wasmvmtypes.UnsupportedRequest{Kind: fmt.Sprintf("No route to query '%s'", request.Path)} } - q.mu.Lock() res, err := handler(ctx, &abci.RequestQuery{ Data: request.Data, Path: request.Path, }) - q.mu.Unlock() if err != nil { return nil, err } diff --git a/x/wasm/handler/query_grpc_test.go b/x/wasm/handler/query_grpc_test.go index 514a34379..3106b952f 100644 --- a/x/wasm/handler/query_grpc_test.go +++ b/x/wasm/handler/query_grpc_test.go @@ -19,7 +19,7 @@ import ( "github.com/CoreumFoundation/coreum/v5/x/wasm/handler" ) -func TestGRPCQuerier_Query(t *testing.T) { +func TestGRPCQuerier(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) t.Cleanup(cancel) @@ -49,13 +49,15 @@ func TestGRPCQuerier_Query(t *testing.T) { eg, _ := errgroup.WithContext(ctx) for range 1000 { + // rebuild the ctx + routineSDKCtx := testApp.BaseApp.NewContext(false) eg.Go(func() error { wasmGrpcReq := &wasmvmtypes.GrpcQuery{ Data: wasmGrpcData, // url which corresponds query token Path: "/coreum.asset.ft.v1.Query/Token", } - wasmGrpcRes, err := q.Query(sdkCtx, wasmGrpcReq) + wasmGrpcRes, err := q.Query(routineSDKCtx, wasmGrpcReq) if err != nil { return err }