Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
parent
0083431ba9
commit
3fcdcae7cb
@ -38,12 +38,12 @@ type (
|
||||
|
||||
// NewQueryServer creates a new CometBFT query server.
|
||||
func NewQueryServer(
|
||||
clientCtx CometRPC,
|
||||
cometRPC CometRPC,
|
||||
queryFn abciQueryFn,
|
||||
consensusAddressCodec address.Codec,
|
||||
) ServiceServer {
|
||||
return queryServer{
|
||||
rpc: clientCtx,
|
||||
rpc: cometRPC,
|
||||
queryFn: queryFn,
|
||||
consensusCodec: consensusAddressCodec,
|
||||
}
|
||||
@ -284,7 +284,7 @@ func (s queryServer) ABCIQuery(ctx context.Context, req *ABCIQueryRequest) (*ABC
|
||||
func RegisterTendermintService(
|
||||
clientCtx client.Context,
|
||||
server gogogrpc.Server,
|
||||
iRegistry codectypes.InterfaceRegistry,
|
||||
_ codectypes.InterfaceRegistry,
|
||||
queryFn abciQueryFn,
|
||||
) {
|
||||
node, err := clientCtx.GetNode()
|
||||
|
||||
22
proto/cosmos/base/node/v2/query.proto
Normal file
22
proto/cosmos/base/node/v2/query.proto
Normal file
@ -0,0 +1,22 @@
|
||||
syntax = "proto3";
|
||||
package cosmos.base.node.v2;
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
|
||||
option go_package = "cosmossdk.io/server/v2/api/grpc/nodeservice";
|
||||
|
||||
// Service defines the gRPC querier service for node related queries.
|
||||
service Service {
|
||||
// Config queries for the operator configuration.
|
||||
rpc Config(ConfigRequest) returns (ConfigResponse) {
|
||||
option (google.api.http).get = "/cosmos/base/node/v2/config";
|
||||
}
|
||||
}
|
||||
|
||||
// ConfigRequest defines the request structure for the Config gRPC query.
|
||||
message ConfigRequest {}
|
||||
|
||||
// ConfigResponse defines the response structure for the Config gRPC query.
|
||||
message ConfigResponse {
|
||||
string minimum_gas_price = 1;
|
||||
}
|
||||
@ -11,6 +11,9 @@ import (
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
abciproto "github.com/cometbft/cometbft/api/cometbft/abci/v1"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
|
||||
gogoproto "github.com/cosmos/gogoproto/proto"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
@ -27,7 +30,6 @@ import (
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/schema/appdata"
|
||||
"cosmossdk.io/server/v2/appmanager"
|
||||
"cosmossdk.io/server/v2/cometbft/client/grpc/cmtservice"
|
||||
"cosmossdk.io/server/v2/cometbft/handlers"
|
||||
"cosmossdk.io/server/v2/cometbft/mempool"
|
||||
"cosmossdk.io/server/v2/cometbft/types"
|
||||
@ -37,13 +39,18 @@ import (
|
||||
consensustypes "cosmossdk.io/x/consensus/types"
|
||||
)
|
||||
|
||||
const (
|
||||
QueryPathApp = "app"
|
||||
QueryPathP2P = "p2p"
|
||||
QueryPathStore = "store"
|
||||
)
|
||||
|
||||
var _ abci.Application = (*Consensus[transaction.Tx])(nil)
|
||||
|
||||
type Consensus[T transaction.Tx] struct {
|
||||
logger log.Logger
|
||||
appName, version string
|
||||
app appmanager.AppManager[T]
|
||||
appCloser func() error
|
||||
txCodec transaction.Codec[T]
|
||||
store types.Store
|
||||
streaming streaming.Manager
|
||||
@ -78,7 +85,6 @@ func NewConsensus[T transaction.Tx](
|
||||
logger log.Logger,
|
||||
appName string,
|
||||
app appmanager.AppManager[T],
|
||||
appCloser func() error,
|
||||
mp mempool.Mempool[T],
|
||||
indexedEvents map[string]struct{},
|
||||
queryHandlersMap map[string]appmodulev2.Handler,
|
||||
@ -91,7 +97,6 @@ func NewConsensus[T transaction.Tx](
|
||||
appName: appName,
|
||||
version: getCometBFTServerVersion(),
|
||||
app: app,
|
||||
appCloser: appCloser,
|
||||
cfg: cfg,
|
||||
store: store,
|
||||
logger: logger,
|
||||
@ -221,17 +226,17 @@ func (c *Consensus[T]) Query(ctx context.Context, req *abciproto.QueryRequest) (
|
||||
}
|
||||
|
||||
switch path[0] {
|
||||
case cmtservice.QueryPathApp:
|
||||
case QueryPathApp:
|
||||
resp, err = c.handlerQueryApp(ctx, path, req)
|
||||
|
||||
case cmtservice.QueryPathStore:
|
||||
resp, err = c.handleQueryStore(path, c.store, req)
|
||||
case QueryPathStore:
|
||||
resp, err = c.handleQueryStore(path, req)
|
||||
|
||||
case cmtservice.QueryPathP2P:
|
||||
case QueryPathP2P:
|
||||
resp, err = c.handleQueryP2P(path)
|
||||
|
||||
default:
|
||||
resp = QueryResult(errorsmod.Wrap(cometerrors.ErrUnknownRequest, "unknown query path"), c.cfg.AppTomlConfig.Trace)
|
||||
resp = QueryResult(errorsmod.Wrapf(cometerrors.ErrUnknownRequest, "unknown query path %s", req.Path), c.cfg.AppTomlConfig.Trace)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@ -267,6 +272,50 @@ func (c *Consensus[T]) maybeRunGRPCQuery(ctx context.Context, req *abci.QueryReq
|
||||
handlerFullName = string(md.Input().FullName())
|
||||
}
|
||||
|
||||
// special case for simulation as it is an external gRPC registered on the grpc server component
|
||||
// and not on the app itself, so it won't pass the router afterwards.
|
||||
if req.Path == "/cosmos.tx.v1beta1.Service/Simulate" {
|
||||
simulateRequest := &txtypes.SimulateRequest{}
|
||||
err = gogoproto.Unmarshal(req.Data, simulateRequest)
|
||||
if err != nil {
|
||||
return nil, true, fmt.Errorf("unable to decode gRPC request with path %s from ABCI.Query: %w", req.Path, err)
|
||||
}
|
||||
|
||||
tx, err := c.txCodec.Decode(simulateRequest.TxBytes)
|
||||
if err != nil {
|
||||
return nil, true, fmt.Errorf("failed to decode tx: %w", err)
|
||||
}
|
||||
|
||||
txResult, _, err := c.app.Simulate(ctx, tx)
|
||||
if err != nil {
|
||||
return nil, true, fmt.Errorf("%v with gas used: '%d'", err, txResult.GasUsed)
|
||||
}
|
||||
|
||||
msgResponses := make([]*codectypes.Any, 0, len(txResult.Resp))
|
||||
// pack the messages into Any
|
||||
for _, msg := range txResult.Resp {
|
||||
anyMsg, err := codectypes.NewAnyWithValue(msg)
|
||||
if err != nil {
|
||||
return nil, true, fmt.Errorf("failed to pack message response: %w", err)
|
||||
}
|
||||
|
||||
msgResponses = append(msgResponses, anyMsg)
|
||||
}
|
||||
|
||||
resp := &txtypes.SimulateResponse{
|
||||
GasInfo: &sdk.GasInfo{
|
||||
GasUsed: txResult.GasUsed,
|
||||
GasWanted: txResult.GasWanted,
|
||||
},
|
||||
Result: &sdk.Result{
|
||||
MsgResponses: msgResponses,
|
||||
},
|
||||
}
|
||||
|
||||
res, err := queryResponse(resp, req.Height)
|
||||
return res, true, err
|
||||
}
|
||||
|
||||
handler, found := c.queryHandlersMap[handlerFullName]
|
||||
if !found {
|
||||
return nil, true, fmt.Errorf("no query handler found for %s", req.Path)
|
||||
@ -281,7 +330,6 @@ func (c *Consensus[T]) maybeRunGRPCQuery(ctx context.Context, req *abci.QueryReq
|
||||
resp := QueryResult(err, c.cfg.AppTomlConfig.Trace)
|
||||
resp.Height = req.Height
|
||||
return resp, true, err
|
||||
|
||||
}
|
||||
|
||||
resp, err = queryResponse(res, req.Height)
|
||||
|
||||
@ -699,7 +699,7 @@ func setUpConsensus(t *testing.T, gasLimit uint64, mempool mempool.Mempool[mock.
|
||||
nil,
|
||||
)
|
||||
|
||||
return NewConsensus[mock.Tx](log.NewNopLogger(), "testing-app", am, func() error { return nil },
|
||||
return NewConsensus[mock.Tx](log.NewNopLogger(), "testing-app", am,
|
||||
mempool, map[string]struct{}{}, nil, mockStore,
|
||||
Config{AppTomlConfig: DefaultAppTomlConfig()}, mock.TxCodec{}, "test")
|
||||
}
|
||||
|
||||
@ -1,71 +0,0 @@
|
||||
package cmtservice
|
||||
|
||||
import (
|
||||
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
|
||||
cmtv1beta1 "cosmossdk.io/api/cosmos/base/tendermint/v1beta1"
|
||||
)
|
||||
|
||||
var CometBFTAutoCLIDescriptor = &autocliv1.ServiceCommandDescriptor{
|
||||
Service: cmtv1beta1.Service_ServiceDesc.ServiceName,
|
||||
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
|
||||
{
|
||||
RpcMethod: "GetNodeInfo",
|
||||
Use: "node-info",
|
||||
Short: "Query the current node info",
|
||||
},
|
||||
{
|
||||
RpcMethod: "GetSyncing",
|
||||
Use: "syncing",
|
||||
Short: "Query node syncing status",
|
||||
},
|
||||
{
|
||||
RpcMethod: "GetLatestBlock",
|
||||
Use: "block-latest",
|
||||
Short: "Query for the latest committed block",
|
||||
},
|
||||
{
|
||||
RpcMethod: "GetBlockByHeight",
|
||||
Use: "block-by-height <height>",
|
||||
Short: "Query for a committed block by height",
|
||||
Long: "Query for a specific committed block using the CometBFT RPC `block_by_height` method",
|
||||
PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "height"}},
|
||||
},
|
||||
{
|
||||
RpcMethod: "GetLatestValidatorSet",
|
||||
Use: "validator-set",
|
||||
Alias: []string{"validator-set-latest", "comet-validator-set", "cometbft-validator-set", "tendermint-validator-set"},
|
||||
Short: "Query for the latest validator set",
|
||||
},
|
||||
{
|
||||
RpcMethod: "GetValidatorSetByHeight",
|
||||
Use: "validator-set-by-height <height>",
|
||||
Short: "Query for a validator set by height",
|
||||
PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "height"}},
|
||||
},
|
||||
{
|
||||
RpcMethod: "ABCIQuery",
|
||||
Skip: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// NewCometBFTCommands is a fake `appmodule.Module` to be considered as a module
|
||||
// and be added in AutoCLI.
|
||||
func NewCometBFTCommands() *cometModule {
|
||||
return &cometModule{}
|
||||
}
|
||||
|
||||
type cometModule struct{}
|
||||
|
||||
func (m cometModule) IsOnePerModuleType() {}
|
||||
func (m cometModule) IsAppModule() {}
|
||||
|
||||
func (m cometModule) Name() string {
|
||||
return "comet"
|
||||
}
|
||||
|
||||
func (m cometModule) AutoCLIOptions() *autocliv1.ModuleOptions {
|
||||
return &autocliv1.ModuleOptions{
|
||||
Query: CometBFTAutoCLIDescriptor,
|
||||
}
|
||||
}
|
||||
@ -1,56 +0,0 @@
|
||||
package cmtservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
abci "github.com/cometbft/cometbft/api/cometbft/abci/v1"
|
||||
gogogrpc "github.com/cosmos/gogoproto/grpc"
|
||||
gogoprotoany "github.com/cosmos/gogoproto/types/any"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
|
||||
"cosmossdk.io/core/address"
|
||||
"cosmossdk.io/server/v2/cometbft/client/rpc"
|
||||
|
||||
cmtservice "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
|
||||
)
|
||||
|
||||
var _ gogoprotoany.UnpackInterfacesMessage = &cmtservice.GetLatestValidatorSetResponse{}
|
||||
|
||||
const (
|
||||
QueryPathApp = "app"
|
||||
QueryPathP2P = "p2p"
|
||||
QueryPathStore = "store"
|
||||
)
|
||||
|
||||
type abciQueryFn = func(context.Context, *abci.QueryRequest) (*abci.QueryResponse, error)
|
||||
|
||||
// RegisterTendermintService registers the CometBFT queries on the gRPC router.
|
||||
func RegisterTendermintService(
|
||||
client rpc.CometRPC,
|
||||
server gogogrpc.Server,
|
||||
queryFn abciQueryFn,
|
||||
consensusCodec address.Codec,
|
||||
) {
|
||||
cmtservice.RegisterServiceServer(server, cmtservice.NewQueryServer(client, queryFn, consensusCodec))
|
||||
}
|
||||
|
||||
// RegisterGRPCGatewayRoutes mounts the CometBFT service's GRPC-gateway routes on the
|
||||
// given Mux.
|
||||
func RegisterGRPCGatewayRoutes(clientConn gogogrpc.ClientConn, mux *runtime.ServeMux) {
|
||||
_ = cmtservice.RegisterServiceHandlerClient(context.Background(), mux, cmtservice.NewServiceClient(clientConn))
|
||||
}
|
||||
|
||||
// SplitABCIQueryPath splits a string path using the delimiter '/'.
|
||||
//
|
||||
// e.g. "this/is/funny" becomes []string{"this", "is", "funny"}
|
||||
func SplitABCIQueryPath(requestPath string) (path []string) {
|
||||
path = strings.Split(requestPath, "/")
|
||||
|
||||
// first element is empty string
|
||||
if len(path) > 0 && path[0] == "" {
|
||||
path = path[1:]
|
||||
}
|
||||
|
||||
return path
|
||||
}
|
||||
@ -50,9 +50,15 @@ func QueryBlocks(ctx context.Context, rpcClient CometRPC, page, limit int, query
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := NewSearchBlocksResult(int64(resBlocks.TotalCount), int64(len(blocks)), int64(page), int64(limit), blocks)
|
||||
|
||||
return result, nil
|
||||
totalPages := calcTotalPages(int64(resBlocks.TotalCount), int64(limit))
|
||||
return &sdk.SearchBlocksResult{
|
||||
TotalCount: int64(resBlocks.TotalCount),
|
||||
Count: int64(len(blocks)),
|
||||
PageNumber: int64(page),
|
||||
PageTotal: totalPages,
|
||||
Limit: int64(limit),
|
||||
Blocks: blocks,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// GetBlockByHeight gets block by height
|
||||
@ -65,7 +71,7 @@ func GetBlockByHeight(ctx context.Context, rpcClient CometRPC, height *int64) (*
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out, err := NewResponseResultBlock(resBlock)
|
||||
out, err := responseResultBlock(resBlock)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -90,7 +96,7 @@ func GetBlockByHash(ctx context.Context, rpcClient CometRPC, hashHexString strin
|
||||
} else if resBlock.Block == nil {
|
||||
return nil, fmt.Errorf("block not found with hash: %s", hashHexString)
|
||||
}
|
||||
out, err := NewResponseResultBlock(resBlock)
|
||||
out, err := responseResultBlock(resBlock)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -6,8 +6,6 @@ import (
|
||||
cmttypes "github.com/cometbft/cometbft/api/cometbft/types/v1"
|
||||
coretypes "github.com/cometbft/cometbft/rpc/core/types"
|
||||
gogoproto "github.com/cosmos/gogoproto/proto"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// formatBlockResults parses the indexed blocks into a slice of BlockResponse objects.
|
||||
@ -17,7 +15,7 @@ func formatBlockResults(resBlocks []*coretypes.ResultBlock) ([]*cmttypes.Block,
|
||||
out = make([]*cmttypes.Block, len(resBlocks))
|
||||
)
|
||||
for i := range resBlocks {
|
||||
out[i], err = NewResponseResultBlock(resBlocks[i])
|
||||
out[i], err = responseResultBlock(resBlocks[i])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to create response block from comet result block: %v: %w", resBlocks[i], err)
|
||||
}
|
||||
@ -29,20 +27,8 @@ func formatBlockResults(resBlocks []*coretypes.ResultBlock) ([]*cmttypes.Block,
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func NewSearchBlocksResult(totalCount, count, page, limit int64, blocks []*cmttypes.Block) *sdk.SearchBlocksResult {
|
||||
totalPages := calcTotalPages(totalCount, limit)
|
||||
return &sdk.SearchBlocksResult{
|
||||
TotalCount: totalCount,
|
||||
Count: count,
|
||||
PageNumber: page,
|
||||
PageTotal: totalPages,
|
||||
Limit: limit,
|
||||
Blocks: blocks,
|
||||
}
|
||||
}
|
||||
|
||||
// NewResponseResultBlock returns a BlockResponse given a ResultBlock from CometBFT
|
||||
func NewResponseResultBlock(res *coretypes.ResultBlock) (*cmttypes.Block, error) {
|
||||
// responseResultBlock returns a BlockResponse given a ResultBlock from CometBFT
|
||||
func responseResultBlock(res *coretypes.ResultBlock) (*cmttypes.Block, error) {
|
||||
blkProto, err := res.Block.ToProto()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@ -19,27 +19,27 @@ require (
|
||||
cosmossdk.io/core v1.0.0-alpha.6
|
||||
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5
|
||||
cosmossdk.io/log v1.5.0
|
||||
cosmossdk.io/server/v2 v2.0.0-20241108144957-78b5cd4dbd08 // main
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241029092041-78cfc68c83af // main
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241029092041-78cfc68c83af // main
|
||||
cosmossdk.io/server/v2 v2.0.0-20241119134933-d697a3de0f95 // main
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241119134933-d697a3de0f95 // main
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241119134933-d697a3de0f95 // main
|
||||
cosmossdk.io/store/v2 v2.0.0-20241108140525-43e28b43ad7a // main
|
||||
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000
|
||||
github.com/cometbft/cometbft v1.0.0-rc1.0.20240908111210-ab0be101882f
|
||||
github.com/cometbft/cometbft/api v1.0.0-rc.1
|
||||
github.com/cosmos/cosmos-sdk v0.52.0
|
||||
github.com/cosmos/gogoproto v1.7.0
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0
|
||||
github.com/spf13/cobra v1.8.1
|
||||
github.com/spf13/pflag v1.0.5
|
||||
github.com/stretchr/testify v1.9.0
|
||||
google.golang.org/protobuf v1.35.1
|
||||
google.golang.org/grpc v1.68.0
|
||||
google.golang.org/protobuf v1.35.2
|
||||
sigs.k8s.io/yaml v1.4.0
|
||||
)
|
||||
|
||||
require (
|
||||
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
|
||||
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
|
||||
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // indirect
|
||||
cosmossdk.io/core/testing v0.0.0-20241108153815-606544c7be7e // indirect
|
||||
cosmossdk.io/depinject v1.1.0 // indirect
|
||||
cosmossdk.io/errors v1.0.1 // indirect
|
||||
cosmossdk.io/math v1.3.0 // indirect
|
||||
@ -103,6 +103,7 @@ require (
|
||||
github.com/gorilla/mux v1.8.1 // indirect
|
||||
github.com/gorilla/websocket v1.5.3 // indirect
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
|
||||
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
|
||||
github.com/hashicorp/go-hclog v1.6.3 // indirect
|
||||
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
|
||||
@ -163,19 +164,18 @@ require (
|
||||
go.etcd.io/bbolt v1.4.0-alpha.1 // indirect
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
golang.org/x/crypto v0.28.0 // indirect
|
||||
golang.org/x/crypto v0.29.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
|
||||
golang.org/x/mod v0.21.0 // indirect
|
||||
golang.org/x/net v0.30.0 // indirect
|
||||
golang.org/x/sync v0.9.0 // indirect
|
||||
golang.org/x/sys v0.27.0 // indirect
|
||||
golang.org/x/term v0.25.0 // indirect
|
||||
golang.org/x/term v0.26.0 // indirect
|
||||
golang.org/x/text v0.20.0 // indirect
|
||||
golang.org/x/tools v0.25.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect
|
||||
google.golang.org/grpc v1.68.0 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gotest.tools/v3 v3.5.1 // indirect
|
||||
|
||||
@ -10,8 +10,8 @@ cosmossdk.io/collections v0.4.1-0.20241107084833-00f3065e70ee h1:OLqvi9ekfShobmd
|
||||
cosmossdk.io/collections v0.4.1-0.20241107084833-00f3065e70ee/go.mod h1:DcD++Yfcq0OFtM3CJNYLIBjfZ+4DEyeJ/AUk6gkwlOE=
|
||||
cosmossdk.io/core v1.0.0-alpha.6 h1:5ukC4JcQKmemLQXcAgu/QoOvJI50hpBkIIg4ZT2EN8E=
|
||||
cosmossdk.io/core v1.0.0-alpha.6/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY=
|
||||
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 h1:NxxUo0GMJUbIuVg0R70e3cbn9eFTEuMr7ev1AFvypdY=
|
||||
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29/go.mod h1:8s2tPeJtSiQuoyPmr2Ag7meikonISO4Fv4MoO8+ORrs=
|
||||
cosmossdk.io/core/testing v0.0.0-20241108153815-606544c7be7e h1:F+ScucYxwrrDJU8guJXQXpGhdpziYSbxW6HMP2wCNxs=
|
||||
cosmossdk.io/core/testing v0.0.0-20241108153815-606544c7be7e/go.mod h1:3YvVv9aJayjPhdX0DY1IMrGse4sR63hNBWx2VtDWjGQ=
|
||||
cosmossdk.io/depinject v1.1.0 h1:wLan7LG35VM7Yo6ov0jId3RHWCGRhe8E8bsuARorl5E=
|
||||
cosmossdk.io/depinject v1.1.0/go.mod h1:kkI5H9jCGHeKeYWXTqYdruogYrEeWvBQCw1Pj4/eCFI=
|
||||
cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=
|
||||
@ -24,12 +24,12 @@ cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
|
||||
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
|
||||
cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac h1:3joNZZWZ3k7fMsrBDL1ktuQ2xQwYLZOaDhkruadDFmc=
|
||||
cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
|
||||
cosmossdk.io/server/v2 v2.0.0-20241108144957-78b5cd4dbd08 h1:hmTWRUEaRvaZhFhgC/Bd7z/6Rhn+It/3Fja3lECIOHQ=
|
||||
cosmossdk.io/server/v2 v2.0.0-20241108144957-78b5cd4dbd08/go.mod h1:OecMMKlPdlFp2PxqV/capqhUhbIDaa5OiNkY1v5hi8c=
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241029092041-78cfc68c83af h1:uDQXvGBH3kZW1UXFccMlNCgHf2L5QCGjNmw51q6atzI=
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241029092041-78cfc68c83af/go.mod h1:mONOF8GRbxs5R04zMscuQQI1gx/XHTY7imKjcwLI5uo=
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241029092041-78cfc68c83af h1:jefP4LTtln0XsXHeSqRENeAGyPQ9qSbGHMy6811FE/c=
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241029092041-78cfc68c83af/go.mod h1:npAiRkgEOigiBlWyLhwTucbzghItNAIPm2eYWSHG/cI=
|
||||
cosmossdk.io/server/v2 v2.0.0-20241119134933-d697a3de0f95 h1:WUho1r7Zcg5aPn5YtYRN5TW9fvxUirX1mSihBDJ6ccg=
|
||||
cosmossdk.io/server/v2 v2.0.0-20241119134933-d697a3de0f95/go.mod h1:gPATMrgLSzDoJiyoY+N8ULwfvAJ3Ooh6TYFsW60tHW0=
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241119134933-d697a3de0f95 h1:GOznErJieaI0OS0LDUsu5Vy3qPnCyjdvkncejP0Zv5s=
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241119134933-d697a3de0f95/go.mod h1:elhlrldWtm+9U4PxE0G3wjz83yQwVVGVAOncXJPY1Xc=
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241119134933-d697a3de0f95 h1:cK7wvmlA18AvLcaInseKTBmt5EXtLwafe7oH1rx7veU=
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241119134933-d697a3de0f95/go.mod h1:4e9SzLyeGptQ3tSR6nKCNwCu7Ye4uUS2WIJih29dG2c=
|
||||
cosmossdk.io/store v1.0.0-rc.0.0.20241108140525-43e28b43ad7a h1:5ENKFUhhJPkpx6dGDmc0/LXinjE3oIQDEES9gVVA4xM=
|
||||
cosmossdk.io/store v1.0.0-rc.0.0.20241108140525-43e28b43ad7a/go.mod h1:pjNPBX9giCOI18kf3mgNtn4J3SFaZbV1mAmM58iHdgg=
|
||||
cosmossdk.io/store/v2 v2.0.0-20241108140525-43e28b43ad7a h1:3SB9LPBiLuy8pCUPgfFtCP9I4wYKYajxv5vssyO5YEs=
|
||||
@ -546,8 +546,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
|
||||
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
|
||||
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
|
||||
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk=
|
||||
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY=
|
||||
@ -630,8 +630,8 @@ golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
|
||||
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
|
||||
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
|
||||
golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU=
|
||||
golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
@ -697,8 +697,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
|
||||
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
|
||||
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
||||
220
server/v2/cometbft/grpc.go
Normal file
220
server/v2/cometbft/grpc.go
Normal file
@ -0,0 +1,220 @@
|
||||
package cometbft
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
v1 "github.com/cometbft/cometbft/api/cometbft/abci/v1"
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
|
||||
cmtv1beta1 "cosmossdk.io/api/cosmos/base/tendermint/v1beta1"
|
||||
"cosmossdk.io/core/server"
|
||||
"cosmossdk.io/core/transaction"
|
||||
errorsmod "cosmossdk.io/errors/v2"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
|
||||
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
|
||||
)
|
||||
|
||||
// GRPCServiceRegistrar returns a function that registers the CometBFT gRPC service
|
||||
// Those services are defined for backward compatibility.
|
||||
// Eventually, they will be removed in favor of the new gRPC services.
|
||||
func (c *Consensus[T]) GRPCServiceRegistrar(
|
||||
clientCtx client.Context,
|
||||
cfg server.ConfigMap,
|
||||
) func(srv *grpc.Server) error {
|
||||
return func(srv *grpc.Server) error {
|
||||
cmtservice.RegisterServiceServer(srv, cmtservice.NewQueryServer(clientCtx.Client, c.Query, clientCtx.ConsensusAddressCodec))
|
||||
txtypes.RegisterServiceServer(srv, txServer[T]{clientCtx, c})
|
||||
nodeservice.RegisterServiceServer(srv, nodeServer[T]{cfg, c})
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// CometBFTAutoCLIDescriptor is the auto-generated CLI descriptor for the CometBFT service
|
||||
var CometBFTAutoCLIDescriptor = &autocliv1.ServiceCommandDescriptor{
|
||||
Service: cmtv1beta1.Service_ServiceDesc.ServiceName,
|
||||
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
|
||||
{
|
||||
RpcMethod: "GetNodeInfo",
|
||||
Use: "node-info",
|
||||
Short: "Query the current node info",
|
||||
},
|
||||
{
|
||||
RpcMethod: "GetSyncing",
|
||||
Use: "syncing",
|
||||
Short: "Query node syncing status",
|
||||
},
|
||||
{
|
||||
RpcMethod: "GetLatestBlock",
|
||||
Use: "block-latest",
|
||||
Short: "Query for the latest committed block",
|
||||
},
|
||||
{
|
||||
RpcMethod: "GetBlockByHeight",
|
||||
Use: "block-by-height <height>",
|
||||
Short: "Query for a committed block by height",
|
||||
Long: "Query for a specific committed block using the CometBFT RPC `block_by_height` method",
|
||||
PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "height"}},
|
||||
},
|
||||
{
|
||||
RpcMethod: "GetLatestValidatorSet",
|
||||
Use: "validator-set",
|
||||
Alias: []string{"validator-set-latest", "comet-validator-set", "cometbft-validator-set", "tendermint-validator-set"},
|
||||
Short: "Query for the latest validator set",
|
||||
},
|
||||
{
|
||||
RpcMethod: "GetValidatorSetByHeight",
|
||||
Use: "validator-set-by-height <height>",
|
||||
Short: "Query for a validator set by height",
|
||||
PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "height"}},
|
||||
},
|
||||
{
|
||||
RpcMethod: "ABCIQuery",
|
||||
Skip: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
type txServer[T transaction.Tx] struct {
|
||||
clientCtx client.Context
|
||||
consensus *Consensus[T]
|
||||
}
|
||||
|
||||
// BroadcastTx implements tx.ServiceServer.
|
||||
func (t txServer[T]) BroadcastTx(ctx context.Context, req *txtypes.BroadcastTxRequest) (*txtypes.BroadcastTxResponse, error) {
|
||||
return client.TxServiceBroadcast(ctx, t.clientCtx, req)
|
||||
}
|
||||
|
||||
// GetBlockWithTxs implements tx.ServiceServer.
|
||||
func (t txServer[T]) GetBlockWithTxs(context.Context, *txtypes.GetBlockWithTxsRequest) (*txtypes.GetBlockWithTxsResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "not implemented")
|
||||
}
|
||||
|
||||
// GetTx implements tx.ServiceServer.
|
||||
func (t txServer[T]) GetTx(context.Context, *txtypes.GetTxRequest) (*txtypes.GetTxResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "not implemented")
|
||||
}
|
||||
|
||||
// GetTxsEvent implements tx.ServiceServer.
|
||||
func (t txServer[T]) GetTxsEvent(context.Context, *txtypes.GetTxsEventRequest) (*txtypes.GetTxsEventResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "not implemented")
|
||||
}
|
||||
|
||||
// Simulate implements tx.ServiceServer.
|
||||
func (t txServer[T]) Simulate(ctx context.Context, req *txtypes.SimulateRequest) (*txtypes.SimulateResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "invalid empty tx")
|
||||
}
|
||||
|
||||
txBytes := req.TxBytes
|
||||
if txBytes == nil && req.Tx != nil {
|
||||
// This block is for backwards-compatibility.
|
||||
// We used to support passing a `Tx` in req. But if we do that, sig
|
||||
// verification might not pass, because the .Marshal() below might not
|
||||
// be the same marshaling done by the client.
|
||||
var err error
|
||||
txBytes, err = proto.Marshal(req.Tx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "invalid tx; %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if txBytes == nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "empty txBytes is not allowed")
|
||||
}
|
||||
|
||||
tx, err := t.consensus.txCodec.Decode(txBytes)
|
||||
if err != nil {
|
||||
return nil, errorsmod.Wrap(err, "failed to decode tx")
|
||||
}
|
||||
|
||||
txResult, _, err := t.consensus.app.Simulate(ctx, tx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Unknown, "%v with gas used: '%d'", err, txResult.GasUsed)
|
||||
}
|
||||
|
||||
msgResponses := make([]*codectypes.Any, 0, len(txResult.Resp))
|
||||
// pack the messages into Any
|
||||
for _, msg := range txResult.Resp {
|
||||
anyMsg, err := codectypes.NewAnyWithValue(msg)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Unknown, "failed to pack message response: %v", err)
|
||||
}
|
||||
msgResponses = append(msgResponses, anyMsg)
|
||||
}
|
||||
|
||||
return &txtypes.SimulateResponse{
|
||||
GasInfo: &sdk.GasInfo{
|
||||
GasUsed: txResult.GasUsed,
|
||||
GasWanted: txResult.GasWanted,
|
||||
},
|
||||
Result: &sdk.Result{
|
||||
MsgResponses: msgResponses,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
// TxDecode implements tx.ServiceServer.
|
||||
func (t txServer[T]) TxDecode(context.Context, *txtypes.TxDecodeRequest) (*txtypes.TxDecodeResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "not implemented")
|
||||
}
|
||||
|
||||
// TxDecodeAmino implements tx.ServiceServer.
|
||||
func (t txServer[T]) TxDecodeAmino(context.Context, *txtypes.TxDecodeAminoRequest) (*txtypes.TxDecodeAminoResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "not implemented")
|
||||
}
|
||||
|
||||
// TxEncode implements tx.ServiceServer.
|
||||
func (t txServer[T]) TxEncode(context.Context, *txtypes.TxEncodeRequest) (*txtypes.TxEncodeResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "not implemented")
|
||||
}
|
||||
|
||||
// TxEncodeAmino implements tx.ServiceServer.
|
||||
func (t txServer[T]) TxEncodeAmino(context.Context, *txtypes.TxEncodeAminoRequest) (*txtypes.TxEncodeAminoResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "not implemented")
|
||||
}
|
||||
|
||||
var _ txtypes.ServiceServer = txServer[transaction.Tx]{}
|
||||
|
||||
type nodeServer[T transaction.Tx] struct {
|
||||
cfg server.ConfigMap
|
||||
consensus *Consensus[T]
|
||||
}
|
||||
|
||||
func (s nodeServer[T]) Config(ctx context.Context, _ *nodeservice.ConfigRequest) (*nodeservice.ConfigResponse, error) {
|
||||
minGasPricesStr := ""
|
||||
minGasPrices, ok := s.cfg["server"].(map[string]interface{})["minimum-gas-prices"]
|
||||
if ok {
|
||||
minGasPricesStr = minGasPrices.(string)
|
||||
}
|
||||
|
||||
return &nodeservice.ConfigResponse{
|
||||
MinimumGasPrice: minGasPricesStr,
|
||||
PruningKeepRecent: "ambiguous in v2",
|
||||
PruningInterval: "ambiguous in v2",
|
||||
HaltHeight: s.consensus.cfg.AppTomlConfig.HaltHeight,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s nodeServer[T]) Status(ctx context.Context, _ *nodeservice.StatusRequest) (*nodeservice.StatusResponse, error) {
|
||||
nodeInfo, err := s.consensus.Info(ctx, &v1.InfoRequest{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &nodeservice.StatusResponse{
|
||||
Height: uint64(nodeInfo.LastBlockHeight),
|
||||
Timestamp: nil,
|
||||
AppHash: nil,
|
||||
ValidatorHash: nodeInfo.LastBlockAppHash,
|
||||
}, nil
|
||||
}
|
||||
@ -8,7 +8,6 @@ import (
|
||||
crypto "github.com/cometbft/cometbft/api/cometbft/crypto/v1"
|
||||
|
||||
errorsmod "cosmossdk.io/errors/v2"
|
||||
"cosmossdk.io/server/v2/cometbft/types"
|
||||
cometerrors "cosmossdk.io/server/v2/cometbft/types/errors"
|
||||
)
|
||||
|
||||
@ -84,7 +83,7 @@ func (c *Consensus[T]) handlerQueryApp(ctx context.Context, path []string, req *
|
||||
return nil, errorsmod.Wrapf(cometerrors.ErrUnknownRequest, "unknown query: %s", path)
|
||||
}
|
||||
|
||||
func (c *Consensus[T]) handleQueryStore(path []string, _ types.Store, req *abci.QueryRequest) (*abci.QueryResponse, error) {
|
||||
func (c *Consensus[T]) handleQueryStore(path []string, req *abci.QueryRequest) (*abci.QueryResponse, error) {
|
||||
req.Path = "/" + strings.Join(path[1:], "/")
|
||||
if req.Height <= 1 && req.Prove {
|
||||
return nil, errorsmod.Wrap(
|
||||
|
||||
@ -116,7 +116,6 @@ func New[T transaction.Tx](
|
||||
logger,
|
||||
appName,
|
||||
appManager,
|
||||
nil,
|
||||
srv.serverOptions.Mempool(cfg),
|
||||
indexEvents,
|
||||
queryHandlers,
|
||||
|
||||
@ -6,12 +6,12 @@ require (
|
||||
cosmossdk.io/api v0.8.0 // main
|
||||
cosmossdk.io/client/v2 v2.0.0-00010101000000-000000000000
|
||||
cosmossdk.io/core v1.0.0 // main
|
||||
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // indirect; main
|
||||
cosmossdk.io/core/testing v0.0.0 // indirect; main
|
||||
cosmossdk.io/depinject v1.1.0
|
||||
cosmossdk.io/log v1.5.0
|
||||
cosmossdk.io/math v1.3.0
|
||||
cosmossdk.io/runtime/v2 v2.0.0-20241105073932-55f7cfcebae4 // main
|
||||
cosmossdk.io/server/v2 v2.0.0-20241108144957-78b5cd4dbd08 // main
|
||||
cosmossdk.io/runtime/v2 v2.0.0-20241119134933-d697a3de0f95 // main
|
||||
cosmossdk.io/server/v2 v2.0.0-20241119134933-d697a3de0f95 // main
|
||||
cosmossdk.io/server/v2/cometbft v0.0.0-00010101000000-000000000000
|
||||
cosmossdk.io/store/v2 v2.0.0-20241108144957-78b5cd4dbd08 // main
|
||||
cosmossdk.io/tools/confix v0.0.0-00010101000000-000000000000
|
||||
@ -40,7 +40,7 @@ require (
|
||||
github.com/spf13/pflag v1.0.5
|
||||
github.com/spf13/viper v1.19.0
|
||||
github.com/stretchr/testify v1.9.0
|
||||
google.golang.org/protobuf v1.35.1
|
||||
google.golang.org/protobuf v1.35.2
|
||||
)
|
||||
|
||||
require (
|
||||
@ -72,8 +72,8 @@ require (
|
||||
cosmossdk.io/errors v1.0.1 // indirect
|
||||
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 // indirect
|
||||
cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac // indirect
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241029092041-78cfc68c83af // indirect; main
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241029092041-78cfc68c83af // indirect; main
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241119134933-d697a3de0f95 // indirect; main
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241119134933-d697a3de0f95 // indirect; main
|
||||
cosmossdk.io/store v1.1.1-0.20240909133312-50288938d1b6 // indirect; main
|
||||
cosmossdk.io/x/tx v1.0.0-alpha.2 // indirect; main
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
@ -226,14 +226,14 @@ require (
|
||||
go.opentelemetry.io/otel/metric v1.27.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.27.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
golang.org/x/crypto v0.28.0 // indirect
|
||||
golang.org/x/crypto v0.29.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
|
||||
golang.org/x/mod v0.21.0 // indirect
|
||||
golang.org/x/net v0.30.0 // indirect
|
||||
golang.org/x/oauth2 v0.23.0 // indirect
|
||||
golang.org/x/sync v0.9.0 // indirect
|
||||
golang.org/x/sys v0.27.0 // indirect
|
||||
golang.org/x/term v0.25.0 // indirect
|
||||
golang.org/x/term v0.26.0 // indirect
|
||||
golang.org/x/text v0.20.0 // indirect
|
||||
golang.org/x/time v0.5.0 // indirect
|
||||
golang.org/x/tools v0.25.0 // indirect
|
||||
@ -259,13 +259,14 @@ require (
|
||||
// SimApp on main always tests the latest extracted SDK modules importing the sdk
|
||||
replace (
|
||||
// pseudo version lower than the latest tag
|
||||
cosmossdk.io/api => cosmossdk.io/api v0.7.3-0.20241111180559-13c234f421e8 // main
|
||||
cosmossdk.io/api => cosmossdk.io/api v0.7.3-0.20241119134933-d697a3de0f95 // main
|
||||
cosmossdk.io/client/v2 => ../../client/v2
|
||||
// pseudo version lower than the latest tag
|
||||
cosmossdk.io/core => cosmossdk.io/core v1.0.0-alpha.6 // main
|
||||
cosmossdk.io/core/testing => cosmossdk.io/core/testing v0.0.0-20241119134933-d697a3de0f95 // main
|
||||
cosmossdk.io/server/v2/cometbft => ../../server/v2/cometbft
|
||||
// pseudo version lower than the latest tag
|
||||
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20241108140525-43e28b43ad7a // main
|
||||
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20241119134933-d697a3de0f95 // main
|
||||
cosmossdk.io/tools/confix => ../../tools/confix
|
||||
cosmossdk.io/x/accounts => ../../x/accounts
|
||||
cosmossdk.io/x/accounts/defaults/base => ../../x/accounts/defaults/base
|
||||
|
||||
@ -192,14 +192,14 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX
|
||||
cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg=
|
||||
cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0=
|
||||
cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M=
|
||||
cosmossdk.io/api v0.7.3-0.20241111180559-13c234f421e8 h1:g7SXTjhuNCfu3ovpfI5xUraWOAyUDLMpFZnO0QE2XrE=
|
||||
cosmossdk.io/api v0.7.3-0.20241111180559-13c234f421e8/go.mod h1:pPUWNdsU8ghYzPOeVD2sAzPVh2yniq215XjRYubdO4I=
|
||||
cosmossdk.io/api v0.7.3-0.20241119134933-d697a3de0f95 h1:nkbou1MO8ho3i+MJ+yehGTqaxGCC/L+sc+7sEAzBy0Y=
|
||||
cosmossdk.io/api v0.7.3-0.20241119134933-d697a3de0f95/go.mod h1:9XEDkRZgZGm1XxHL7Sj2DMXZurCk1pY4x06eR5wyfM0=
|
||||
cosmossdk.io/collections v0.4.1-0.20241107084833-00f3065e70ee h1:OLqvi9ekfShobmdgr4Q/8pu+LjzYJSrNl9tiadPg2xY=
|
||||
cosmossdk.io/collections v0.4.1-0.20241107084833-00f3065e70ee/go.mod h1:DcD++Yfcq0OFtM3CJNYLIBjfZ+4DEyeJ/AUk6gkwlOE=
|
||||
cosmossdk.io/core v1.0.0-alpha.6 h1:5ukC4JcQKmemLQXcAgu/QoOvJI50hpBkIIg4ZT2EN8E=
|
||||
cosmossdk.io/core v1.0.0-alpha.6/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY=
|
||||
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 h1:NxxUo0GMJUbIuVg0R70e3cbn9eFTEuMr7ev1AFvypdY=
|
||||
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29/go.mod h1:8s2tPeJtSiQuoyPmr2Ag7meikonISO4Fv4MoO8+ORrs=
|
||||
cosmossdk.io/core/testing v0.0.0-20241119134933-d697a3de0f95 h1:2WlnVICuVVx8AY70ueEHyfHJ8ctjFU9RnJsz4U263Fw=
|
||||
cosmossdk.io/core/testing v0.0.0-20241119134933-d697a3de0f95/go.mod h1:MJc850tGHoH50R6hC3FSaZvHJDcWWrP+mErk6SaDD4A=
|
||||
cosmossdk.io/depinject v1.1.0 h1:wLan7LG35VM7Yo6ov0jId3RHWCGRhe8E8bsuARorl5E=
|
||||
cosmossdk.io/depinject v1.1.0/go.mod h1:kkI5H9jCGHeKeYWXTqYdruogYrEeWvBQCw1Pj4/eCFI=
|
||||
cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=
|
||||
@ -210,18 +210,18 @@ cosmossdk.io/log v1.5.0 h1:dVdzPJW9kMrnAYyMf1duqacoidB9uZIl+7c6z0mnq0g=
|
||||
cosmossdk.io/log v1.5.0/go.mod h1:Tr46PUJjiUthlwQ+hxYtUtPn4D/oCZXAkYevBeh5+FI=
|
||||
cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
|
||||
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
|
||||
cosmossdk.io/runtime/v2 v2.0.0-20241105073932-55f7cfcebae4 h1:uo4LBzsp1bIZ3rBUyo1V0ON7WMhQ50+HtcLPwgABQLQ=
|
||||
cosmossdk.io/runtime/v2 v2.0.0-20241105073932-55f7cfcebae4/go.mod h1:SCdBCUiZGKVFNUvglrCUontMZSoXAES5iMbRvPv8bsI=
|
||||
cosmossdk.io/runtime/v2 v2.0.0-20241119134933-d697a3de0f95 h1:hYI7pvrmdkgFZJ4HVQow7ubopsTmleYet4S56tFMdI0=
|
||||
cosmossdk.io/runtime/v2 v2.0.0-20241119134933-d697a3de0f95/go.mod h1:J4Wv2eOwAz8t14Ak8XBMWDoFbwqwyllMaJF91O7n/wI=
|
||||
cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac h1:3joNZZWZ3k7fMsrBDL1ktuQ2xQwYLZOaDhkruadDFmc=
|
||||
cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
|
||||
cosmossdk.io/server/v2 v2.0.0-20241108144957-78b5cd4dbd08 h1:hmTWRUEaRvaZhFhgC/Bd7z/6Rhn+It/3Fja3lECIOHQ=
|
||||
cosmossdk.io/server/v2 v2.0.0-20241108144957-78b5cd4dbd08/go.mod h1:OecMMKlPdlFp2PxqV/capqhUhbIDaa5OiNkY1v5hi8c=
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241029092041-78cfc68c83af h1:uDQXvGBH3kZW1UXFccMlNCgHf2L5QCGjNmw51q6atzI=
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241029092041-78cfc68c83af/go.mod h1:mONOF8GRbxs5R04zMscuQQI1gx/XHTY7imKjcwLI5uo=
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241029092041-78cfc68c83af h1:jefP4LTtln0XsXHeSqRENeAGyPQ9qSbGHMy6811FE/c=
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241029092041-78cfc68c83af/go.mod h1:npAiRkgEOigiBlWyLhwTucbzghItNAIPm2eYWSHG/cI=
|
||||
cosmossdk.io/store v1.0.0-rc.0.0.20241108140525-43e28b43ad7a h1:5ENKFUhhJPkpx6dGDmc0/LXinjE3oIQDEES9gVVA4xM=
|
||||
cosmossdk.io/store v1.0.0-rc.0.0.20241108140525-43e28b43ad7a/go.mod h1:pjNPBX9giCOI18kf3mgNtn4J3SFaZbV1mAmM58iHdgg=
|
||||
cosmossdk.io/server/v2 v2.0.0-20241119134933-d697a3de0f95 h1:WUho1r7Zcg5aPn5YtYRN5TW9fvxUirX1mSihBDJ6ccg=
|
||||
cosmossdk.io/server/v2 v2.0.0-20241119134933-d697a3de0f95/go.mod h1:gPATMrgLSzDoJiyoY+N8ULwfvAJ3Ooh6TYFsW60tHW0=
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241119134933-d697a3de0f95 h1:GOznErJieaI0OS0LDUsu5Vy3qPnCyjdvkncejP0Zv5s=
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241119134933-d697a3de0f95/go.mod h1:elhlrldWtm+9U4PxE0G3wjz83yQwVVGVAOncXJPY1Xc=
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241119134933-d697a3de0f95 h1:cK7wvmlA18AvLcaInseKTBmt5EXtLwafe7oH1rx7veU=
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241119134933-d697a3de0f95/go.mod h1:4e9SzLyeGptQ3tSR6nKCNwCu7Ye4uUS2WIJih29dG2c=
|
||||
cosmossdk.io/store v1.0.0-rc.0.0.20241119134933-d697a3de0f95 h1:5hIgRL6VsicdJ7FVK6AG7cSy1C8tiVbCp6W3Y+QQ5ko=
|
||||
cosmossdk.io/store v1.0.0-rc.0.0.20241119134933-d697a3de0f95/go.mod h1:ceNwMZIU8ZIDoeUdA9+sGxz3GVt0orEGoVpkBfa/UtU=
|
||||
cosmossdk.io/store/v2 v2.0.0-20241108144957-78b5cd4dbd08 h1:7dIhcS/VhEM/vnZWDVtDKqCF/OGaq8Gx+5ekD9GT71k=
|
||||
cosmossdk.io/store/v2 v2.0.0-20241108144957-78b5cd4dbd08/go.mod h1:A2aW375561viy3GcD8GhUwUWnow+R2Du6yCSpAGwsgY=
|
||||
cosmossdk.io/x/tx v1.0.0-alpha.2 h1:UW80FMm7B0fiAMsrfe5+HabSJ3XBg+tQa6/GK9prqWk=
|
||||
@ -901,8 +901,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
|
||||
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
|
||||
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
|
||||
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
@ -1127,8 +1127,8 @@ golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
|
||||
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
|
||||
golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU=
|
||||
golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
@ -1434,8 +1434,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
|
||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
|
||||
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
|
||||
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
||||
@ -12,7 +12,7 @@ import (
|
||||
"cosmossdk.io/log"
|
||||
runtimev2 "cosmossdk.io/runtime/v2"
|
||||
serverv2 "cosmossdk.io/server/v2"
|
||||
"cosmossdk.io/server/v2/api/grpc"
|
||||
grpcserver "cosmossdk.io/server/v2/api/grpc"
|
||||
"cosmossdk.io/server/v2/api/rest"
|
||||
"cosmossdk.io/server/v2/api/telemetry"
|
||||
"cosmossdk.io/server/v2/cometbft"
|
||||
@ -40,7 +40,10 @@ type CommandDependencies[T transaction.Tx] struct {
|
||||
TxConfig client.TxConfig
|
||||
ModuleManager *runtimev2.MM[T]
|
||||
SimApp *simapp.SimApp[T]
|
||||
Consensus serverv2.ServerComponent[T]
|
||||
// could be more generic with serverv2.ServerComponent[T]
|
||||
// however, we want to register extra grpc handlers
|
||||
ConsensusServer *cometbft.CometBFTServer[T]
|
||||
ClientContext client.Context
|
||||
}
|
||||
|
||||
func InitRootCmd[T transaction.Tx](
|
||||
@ -66,8 +69,8 @@ func InitRootCmd[T transaction.Tx](
|
||||
|
||||
// build CLI skeleton for initial config parsing or a client application invocation
|
||||
if deps.SimApp == nil {
|
||||
if deps.Consensus == nil {
|
||||
deps.Consensus = cometbft.NewWithConfigOptions[T](initCometConfig())
|
||||
if deps.ConsensusServer == nil {
|
||||
deps.ConsensusServer = cometbft.NewWithConfigOptions[T](initCometConfig())
|
||||
}
|
||||
return serverv2.AddCommands[T](
|
||||
rootCmd,
|
||||
@ -75,8 +78,8 @@ func InitRootCmd[T transaction.Tx](
|
||||
io.NopCloser(nil),
|
||||
deps.GlobalConfig,
|
||||
initServerConfig(),
|
||||
deps.Consensus,
|
||||
&grpc.Server[T]{},
|
||||
deps.ConsensusServer,
|
||||
&grpcserver.Server[T]{},
|
||||
&serverstore.Server[T]{},
|
||||
&telemetry.Server[T]{},
|
||||
&rest.Server[T]{},
|
||||
@ -85,10 +88,7 @@ func InitRootCmd[T transaction.Tx](
|
||||
|
||||
// build full app!
|
||||
simApp := deps.SimApp
|
||||
grpcServer, err := grpc.New[T](logger, simApp.InterfaceRegistry(), simApp.QueryHandlers(), simApp.Query, deps.GlobalConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// store component (not a server)
|
||||
storeComponent, err := serverstore.New[T](simApp.Store(), deps.GlobalConfig)
|
||||
if err != nil {
|
||||
@ -100,8 +100,8 @@ func InitRootCmd[T transaction.Tx](
|
||||
}
|
||||
|
||||
// consensus component
|
||||
if deps.Consensus == nil {
|
||||
deps.Consensus, err = cometbft.New(
|
||||
if deps.ConsensusServer == nil {
|
||||
deps.ConsensusServer, err = cometbft.New(
|
||||
logger,
|
||||
simApp.Name(),
|
||||
simApp.Store(),
|
||||
@ -116,11 +116,29 @@ func InitRootCmd[T transaction.Tx](
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
telemetryServer, err := telemetry.New[T](deps.GlobalConfig, logger)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
grpcServer, err := grpcserver.New[T](
|
||||
logger,
|
||||
simApp.InterfaceRegistry(),
|
||||
simApp.QueryHandlers(),
|
||||
simApp.Query,
|
||||
deps.GlobalConfig,
|
||||
grpcserver.WithExtraGRPCHandlers[T](
|
||||
deps.ConsensusServer.Consensus.GRPCServiceRegistrar(
|
||||
deps.ClientContext,
|
||||
deps.GlobalConfig,
|
||||
),
|
||||
),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// wire server commands
|
||||
return serverv2.AddCommands[T](
|
||||
rootCmd,
|
||||
@ -128,7 +146,7 @@ func InitRootCmd[T transaction.Tx](
|
||||
simApp,
|
||||
deps.GlobalConfig,
|
||||
initServerConfig(),
|
||||
deps.Consensus,
|
||||
deps.ConsensusServer,
|
||||
grpcServer,
|
||||
storeComponent,
|
||||
telemetryServer,
|
||||
|
||||
@ -94,6 +94,7 @@ func NewRootCmd[T transaction.Tx](
|
||||
TxConfig: clientCtx.TxConfig,
|
||||
ModuleManager: moduleManager,
|
||||
SimApp: simApp,
|
||||
ClientContext: clientCtx,
|
||||
}
|
||||
rootCommand = &cobra.Command{
|
||||
Use: "simdv2",
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
|
||||
gogoproto "github.com/cosmos/gogoproto/proto"
|
||||
gogoany "github.com/cosmos/gogoproto/types/any"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/simapp"
|
||||
baseaccountv1 "cosmossdk.io/x/accounts/defaults/base/v1"
|
||||
@ -17,7 +18,6 @@ import (
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@ -3,12 +3,14 @@ package accounts
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/core/header"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
counterv1 "cosmossdk.io/x/accounts/testing/counter/v1"
|
||||
"cosmossdk.io/x/bank/testutil"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// TestDependencies aims to test wiring between different account components,
|
||||
|
||||
@ -138,7 +138,7 @@ func (m *MockBankKeeper) GetBalance(ctx context.Context, addr types.AccAddress,
|
||||
}
|
||||
|
||||
// GetBalance indicates an expected call of GetBalance.
|
||||
func (mr *MockBankKeeperMockRecorder) GetBalance(ctx, addr, denom any) *gomock.Call {
|
||||
func (mr *MockBankKeeperMockRecorder) GetBalance(ctx, addr, denom interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBalance", reflect.TypeOf((*MockBankKeeper)(nil).GetBalance), ctx, addr, denom)
|
||||
}
|
||||
@ -197,4 +197,4 @@ func (m *MockBankKeeper) SpendableCoins(ctx context.Context, addr types.AccAddre
|
||||
func (mr *MockBankKeeperMockRecorder) SpendableCoins(ctx, addr interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpendableCoins", reflect.TypeOf((*MockBankKeeper)(nil).SpendableCoins), ctx, addr)
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,7 +11,6 @@ import (
|
||||
"cosmossdk.io/collections"
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
"cosmossdk.io/store/prefix"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
"cosmossdk.io/x/staking/types"
|
||||
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
@ -429,14 +428,13 @@ func (k Querier) Redelegations(ctx context.Context, req *types.QueryRedelegation
|
||||
var pageRes *query.PageResponse
|
||||
var err error
|
||||
|
||||
store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx))
|
||||
switch {
|
||||
case req.DelegatorAddr != "" && req.SrcValidatorAddr != "" && req.DstValidatorAddr != "":
|
||||
redels, err = queryRedelegation(ctx, k, req)
|
||||
case req.DelegatorAddr == "" && req.SrcValidatorAddr != "" && req.DstValidatorAddr == "":
|
||||
redels, pageRes, err = queryRedelegationsFromSrcValidator(ctx, k, req)
|
||||
default:
|
||||
redels, pageRes, err = queryAllRedelegations(ctx, store, k, req)
|
||||
redels, pageRes, err = queryAllRedelegations(ctx, k, req)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
@ -557,7 +555,7 @@ func queryRedelegationsFromSrcValidator(ctx context.Context, k Querier, req *typ
|
||||
}, query.WithCollectionPaginationTriplePrefix[[]byte, []byte, []byte](valAddr))
|
||||
}
|
||||
|
||||
func queryAllRedelegations(ctx context.Context, store storetypes.KVStore, k Querier, req *types.QueryRedelegationsRequest) (redels types.Redelegations, res *query.PageResponse, err error) {
|
||||
func queryAllRedelegations(ctx context.Context, k Querier, req *types.QueryRedelegationsRequest) (redels types.Redelegations, res *query.PageResponse, err error) {
|
||||
delAddr, err := k.authKeeper.AddressCodec().StringToBytes(req.DelegatorAddr)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
||||
Loading…
Reference in New Issue
Block a user