refactor(server/v2/grpc): simplify node service (backport #22728) (#22735)

Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
mergify[bot] 2024-12-03 22:09:43 +01:00 committed by GitHub
parent 7911d732d4
commit 43af640664
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 16 additions and 36 deletions

View File

@ -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;
}

View File

@ -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)

View File

@ -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
}

View File

@ -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.

View File

@ -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"},