Skip to content

Commit

Permalink
node service
Browse files Browse the repository at this point in the history
  • Loading branch information
hieuvubk committed Dec 9, 2024
1 parent 1bfe31a commit 3110801
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
25 changes: 24 additions & 1 deletion server/v2/cometbft/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"cosmossdk.io/core/event"
"cosmossdk.io/core/server"
"cosmossdk.io/core/store"
"cosmossdk.io/core/transaction"
errorsmod "cosmossdk.io/errors/v2"
"cosmossdk.io/log"
"cosmossdk.io/schema/appdata"
Expand All @@ -36,6 +35,8 @@ import (
consensustypes "cosmossdk.io/x/consensus/types"

addresscodec "cosmossdk.io/core/address"
coreserver "cosmossdk.io/core/server"
"cosmossdk.io/core/transaction"
rpchttp "github.com/cometbft/cometbft/rpc/client/http"
"github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
"github.com/cosmos/cosmos-sdk/codec"
Expand Down Expand Up @@ -92,6 +93,7 @@ type consensus[T transaction.Tx] struct {
queryHandlersMap map[string]appmodulev2.Handler
getProtoRegistry func() (*protoregistry.Files, error)
consensusAddressCodec addresscodec.Codec
cfgMap coreserver.ConfigMap
}

// CheckTx implements types.Application.
Expand Down Expand Up @@ -282,7 +284,28 @@ func (c *consensus[T]) maybeRunGRPCQuery(ctx context.Context, req *abci.QueryReq

res, err := queryResponse(resp, req.Height)
return res, true, err
}

// Handle node service
if strings.Contains(req.Path, "/cosmos.base.node.v1beta1.Service") {
nodeQService := nodeServer[transaction.Tx]{c.cfgMap, c.cfg.AppTomlConfig, c}
paths := strings.Split(req.Path, "/")

var resp transaction.Msg
var err error
switch paths[2] {
case "Config":
resp, err = handleCometService(ctx, req, nodeQService.Config)
case "Status":
resp, err = handleCometService(ctx, req, nodeQService.Status)
}

if err != nil {
return nil, true, err
}

res, err := queryResponse(resp, req.Height)
return res, true, err
}

// special case for simulation as it is an external gRPC registered on the grpc server component
Expand Down
3 changes: 2 additions & 1 deletion server/v2/cometbft/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ import (
"cosmossdk.io/server/v2/cometbft/types"
"cosmossdk.io/store/v2/snapshots"

addresscodec "cosmossdk.io/core/address"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
addresscodec "cosmossdk.io/core/address"
)

const ServerName = "comet"
Expand Down Expand Up @@ -191,6 +191,7 @@ func New[T transaction.Tx](
getProtoRegistry: sync.OnceValues(gogoproto.MergedRegistry),
addrPeerFilter: srv.serverOptions.AddrPeerFilter,
idPeerFilter: srv.serverOptions.IdPeerFilter,
cfgMap: cfg,
}

c.optimisticExec = oe.NewOptimisticExecution(
Expand Down

0 comments on commit 3110801

Please sign in to comment.