From 43af6406643d99067e9c8cb1c694e604f20c050b Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 22:09:43 +0100 Subject: [PATCH] refactor(server/v2/grpc): simplify node service (backport #22728) (#22735) Co-authored-by: Julien Robert --- proto/cosmos/base/node/v2/query.proto | 22 ---------------------- scripts/build/protobuf.mk | 2 +- server/v2/cometbft/grpc.go | 11 +++++++++-- tools/confix/data/v2-app.toml | 15 ++++++--------- tools/confix/migrations.go | 2 -- 5 files changed, 16 insertions(+), 36 deletions(-) delete mode 100644 proto/cosmos/base/node/v2/query.proto diff --git a/proto/cosmos/base/node/v2/query.proto b/proto/cosmos/base/node/v2/query.proto deleted file mode 100644 index 24de6fd212..0000000000 --- a/proto/cosmos/base/node/v2/query.proto +++ /dev/null @@ -1,22 +0,0 @@ -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; -} \ No newline at end of file diff --git a/scripts/build/protobuf.mk b/scripts/build/protobuf.mk index d269e62433..25d98b3f95 100644 --- a/scripts/build/protobuf.mk +++ b/scripts/build/protobuf.mk @@ -1,4 +1,4 @@ -protoVer=0.15.1 +protoVer=0.15.2 protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer) protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) diff --git a/server/v2/cometbft/grpc.go b/server/v2/cometbft/grpc.go index 5a2d64d7d2..66bbc86731 100644 --- a/server/v2/cometbft/grpc.go +++ b/server/v2/cometbft/grpc.go @@ -2,6 +2,7 @@ package cometbft import ( "context" + "fmt" abci "github.com/cometbft/cometbft/abci/types" abciproto "github.com/cometbft/cometbft/api/cometbft/abci/v1" @@ -15,6 +16,7 @@ import ( "cosmossdk.io/core/server" corestore "cosmossdk.io/core/store" "cosmossdk.io/core/transaction" + storeserver "cosmossdk.io/server/v2/store" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" @@ -208,10 +210,15 @@ func (s nodeServer[T]) Config(ctx context.Context, _ *nodeservice.ConfigRequest) minGasPricesStr = minGasPrices.(string) } + storeCfg, err := storeserver.UnmarshalConfig(s.cfg) + if err != nil { + return nil, err + } + return &nodeservice.ConfigResponse{ MinimumGasPrice: minGasPricesStr, - PruningKeepRecent: "ambiguous in v2", - PruningInterval: "ambiguous in v2", + PruningKeepRecent: fmt.Sprintf("%d", storeCfg.Options.SCPruningOption.KeepRecent), + PruningInterval: fmt.Sprintf("%d", storeCfg.Options.SCPruningOption.Interval), HaltHeight: s.cometBFTAppConfig.HaltHeight, }, nil } diff --git a/tools/confix/data/v2-app.toml b/tools/confix/data/v2-app.toml index 394cc41e7b..2f9ed9e734 100644 --- a/tools/confix/data/v2-app.toml +++ b/tools/confix/data/v2-app.toml @@ -41,6 +41,12 @@ max-recv-msg-size = 10485760 # The default value is math.MaxInt32. max-send-msg-size = 2147483647 +[grpc-gateway] +# Enable defines if the gRPC-gateway should be enabled. +enable = true +# Address defines the address the gRPC-gateway server binds to. +address = 'localhost:1317' + [rest] # Enable defines if the REST server should be enabled. enable = true @@ -56,18 +62,9 @@ minimum-gas-prices = '0stake' app-db-backend = 'goleveldb' [store.options] -# State storage database type. Currently we support: "pebble" and "rocksdb" -ss-type = 'pebble' # State commitment database type. Currently we support: "iavl" and "iavl-v2" sc-type = 'iavl' -# Pruning options for state storage -[store.options.ss-pruning-option] -# Number of recent heights to keep on disk. -keep-recent = 2 -# Height interval at which pruned heights are removed from disk. -interval = 100 - # Pruning options for state commitment [store.options.sc-pruning-option] # Number of recent heights to keep on disk. diff --git a/tools/confix/migrations.go b/tools/confix/migrations.go index 77fc4a671c..3589124c73 100644 --- a/tools/confix/migrations.go +++ b/tools/confix/migrations.go @@ -46,11 +46,9 @@ var v2KeyChanges = v2KeyChangesMap{ "halt-time": []string{"comet.halt-time"}, "app-db-backend": []string{"store.app-db-backend"}, "pruning-keep-recent": []string{ - "store.options.ss-pruning-option.keep-recent", "store.options.sc-pruning-option.keep-recent", }, "pruning-interval": []string{ - "store.options.ss-pruning-option.interval", "store.options.sc-pruning-option.interval", }, "iavl-cache-size": []string{"store.options.iavl-config.cache-size"},