fix: remove rosetta from server start (#14062)
* delete: rosetta from server start * update: go.sum * CHANGELOG * update: changelog
This commit is contained in:
parent
f96072d9a8
commit
6679ee0eea
@ -58,6 +58,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
### Improvements
|
||||
|
||||
* (server) [#14062](https://github.com/cosmos/cosmos-sdk/pull/14062) Remove rosetta from server start.
|
||||
* [13882] (https://github.com/cosmos/cosmos-sdk/pull/13882) Add tx `encode` and `decode` endpoints to amino tx service.
|
||||
> Note: These endpoints encodes and decodes only amino txs.
|
||||
* (config) [#13894](https://github.com/cosmos/cosmos-sdk/pull/13894) Support state streaming configuration in `app.toml` template and default configuration.
|
||||
|
||||
4
go.mod
4
go.mod
@ -8,7 +8,6 @@ require (
|
||||
cosmossdk.io/depinject v1.0.0-alpha.3
|
||||
cosmossdk.io/errors v1.0.0-beta.7
|
||||
cosmossdk.io/math v1.0.0-beta.4
|
||||
cosmossdk.io/tools/rosetta v0.1.0
|
||||
github.com/99designs/keyring v1.2.1
|
||||
github.com/armon/go-metrics v0.4.1
|
||||
github.com/bgentry/speakeasy v0.1.0
|
||||
@ -78,7 +77,6 @@ require (
|
||||
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
|
||||
github.com/cespare/xxhash v1.1.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/coinbase/rosetta-sdk-go v0.8.1 // indirect
|
||||
github.com/cosmos/gorocksdb v1.2.0 // indirect
|
||||
github.com/creachadair/taskgroup v0.3.2 // indirect
|
||||
github.com/danieljoos/wincred v1.1.2 // indirect
|
||||
@ -169,8 +167,6 @@ replace (
|
||||
cosmossdk.io/tools/rosetta => ./tools/rosetta
|
||||
|
||||
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
|
||||
// Update to rosetta-sdk-go temporarly to have `check:spec` passing. See https://github.com/coinbase/rosetta-sdk-go/issues/449
|
||||
github.com/coinbase/rosetta-sdk-go => github.com/coinbase/rosetta-sdk-go v0.8.2-0.20221007214527-e03849ba430a
|
||||
// dgrijalva/jwt-go is deprecated and doesn't receive security updates.
|
||||
// TODO: remove it: https://github.com/cosmos/cosmos-sdk/issues/13134
|
||||
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2
|
||||
|
||||
2
go.sum
2
go.sum
@ -159,8 +159,6 @@ github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOG
|
||||
github.com/cockroachdb/apd/v3 v3.1.0 h1:MK3Ow7LH0W8zkd5GMKA1PvS9qG3bWFI95WaVNfyZJ/w=
|
||||
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
|
||||
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
|
||||
github.com/coinbase/rosetta-sdk-go v0.8.2-0.20221007214527-e03849ba430a h1:tAQukG4KWS+9jBQs/lkFfKfONI01QJ1YoxnjzHAEh88=
|
||||
github.com/coinbase/rosetta-sdk-go v0.8.2-0.20221007214527-e03849ba430a/go.mod h1:tXPR6AIW9ogsH4tYIaFOKOgfJNanCvcyl7JKLd4DToc=
|
||||
github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4=
|
||||
github.com/confio/ics23/go v0.9.0/go.mod h1:4LPZ2NYqnYIVRklaozjNR1FScgDJ2s5Xrp+e/mYVRak=
|
||||
github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg=
|
||||
|
||||
@ -7,7 +7,6 @@ import (
|
||||
|
||||
"github.com/spf13/viper"
|
||||
|
||||
clientflags "github.com/cosmos/cosmos-sdk/client/flags"
|
||||
pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types"
|
||||
"github.com/cosmos/cosmos-sdk/telemetry"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@ -127,38 +126,6 @@ type APIConfig struct {
|
||||
// Ref: https://github.com/cosmos/cosmos-sdk/issues/6420
|
||||
}
|
||||
|
||||
// RosettaConfig defines the Rosetta API listener configuration.
|
||||
type RosettaConfig struct {
|
||||
// Address defines the API server to listen on
|
||||
Address string `mapstructure:"address"`
|
||||
|
||||
// Blockchain defines the blockchain name
|
||||
// defaults to DefaultBlockchain
|
||||
Blockchain string `mapstructure:"blockchain"`
|
||||
|
||||
// Network defines the network name
|
||||
Network string `mapstructure:"network"`
|
||||
|
||||
// Retries defines the maximum number of retries
|
||||
// rosetta will do before quitting
|
||||
Retries int `mapstructure:"retries"`
|
||||
|
||||
// Enable defines if the API server should be enabled.
|
||||
Enable bool `mapstructure:"enable"`
|
||||
|
||||
// Offline defines if the server must be run in offline mode
|
||||
Offline bool `mapstructure:"offline"`
|
||||
|
||||
// EnableFeeSuggestion defines if the server should suggest fee by default
|
||||
EnableFeeSuggestion bool `mapstructure:"enable-fee-suggestion"`
|
||||
|
||||
// GasToSuggest defines gas limit when calculating the fee
|
||||
GasToSuggest int `mapstructure:"gas-to-suggest"`
|
||||
|
||||
// DenomToSuggest defines the defult denom for fee suggestion
|
||||
DenomToSuggest string `mapstructure:"denom-to-suggest"`
|
||||
}
|
||||
|
||||
// GRPCConfig defines configuration for the gRPC server.
|
||||
type GRPCConfig struct {
|
||||
// Enable defines if the gRPC server should be enabled.
|
||||
@ -229,7 +196,6 @@ type Config struct {
|
||||
Telemetry telemetry.Config `mapstructure:"telemetry"`
|
||||
API APIConfig `mapstructure:"api"`
|
||||
GRPC GRPCConfig `mapstructure:"grpc"`
|
||||
Rosetta RosettaConfig `mapstructure:"rosetta"`
|
||||
GRPCWeb GRPCWebConfig `mapstructure:"grpc-web"`
|
||||
StateSync StateSyncConfig `mapstructure:"state-sync"`
|
||||
Store StoreConfig `mapstructure:"store"`
|
||||
@ -296,17 +262,6 @@ func DefaultConfig() *Config {
|
||||
MaxRecvMsgSize: DefaultGRPCMaxRecvMsgSize,
|
||||
MaxSendMsgSize: DefaultGRPCMaxSendMsgSize,
|
||||
},
|
||||
Rosetta: RosettaConfig{
|
||||
Enable: false,
|
||||
Address: ":8080",
|
||||
Blockchain: "app",
|
||||
Network: "network",
|
||||
Retries: 3,
|
||||
Offline: false,
|
||||
EnableFeeSuggestion: false,
|
||||
GasToSuggest: clientflags.DefaultGasLimit,
|
||||
DenomToSuggest: "uatom",
|
||||
},
|
||||
GRPCWeb: GRPCWebConfig{
|
||||
Enable: true,
|
||||
Address: DefaultGRPCWebAddress,
|
||||
|
||||
@ -149,42 +149,6 @@ rpc-max-body-bytes = {{ .API.RPCMaxBodyBytes }}
|
||||
# EnableUnsafeCORS defines if CORS should be enabled (unsafe - use it at your own risk).
|
||||
enabled-unsafe-cors = {{ .API.EnableUnsafeCORS }}
|
||||
|
||||
###############################################################################
|
||||
### Rosetta Configuration ###
|
||||
###############################################################################
|
||||
|
||||
[rosetta]
|
||||
|
||||
# Enable defines if the Rosetta API server should be enabled.
|
||||
enable = {{ .Rosetta.Enable }}
|
||||
|
||||
# Address defines the Rosetta API server to listen on.
|
||||
address = "{{ .Rosetta.Address }}"
|
||||
|
||||
# Network defines the name of the blockchain that will be returned by Rosetta.
|
||||
blockchain = "{{ .Rosetta.Blockchain }}"
|
||||
|
||||
# Network defines the name of the network that will be returned by Rosetta.
|
||||
network = "{{ .Rosetta.Network }}"
|
||||
|
||||
# Retries defines the number of retries when connecting to the node before failing.
|
||||
retries = {{ .Rosetta.Retries }}
|
||||
|
||||
# Offline defines if Rosetta server should run in offline mode.
|
||||
offline = {{ .Rosetta.Offline }}
|
||||
|
||||
# EnableDefaultSuggestedFee defines if the server should suggest fee by default.
|
||||
# If 'construction/medata' is called without gas limit and gas price,
|
||||
# suggested fee based on gas-to-suggest and denom-to-suggest will be given.
|
||||
enable-fee-suggestion = {{ .Rosetta.EnableFeeSuggestion }}
|
||||
|
||||
# GasToSuggest defines gas limit when calculating the fee
|
||||
gas-to-suggest = {{ .Rosetta.GasToSuggest }}
|
||||
|
||||
# DenomToSuggest defines the defult denom for fee suggestion.
|
||||
# Price must be in minimum-gas-prices.
|
||||
denom-to-suggest = "{{ .Rosetta.DenomToSuggest }}"
|
||||
|
||||
###############################################################################
|
||||
### gRPC Configuration ###
|
||||
###############################################################################
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
@ -20,8 +19,6 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
|
||||
"cosmossdk.io/tools/rosetta"
|
||||
crgserver "cosmossdk.io/tools/rosetta/lib/server"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
@ -31,7 +28,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/server/types"
|
||||
pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types"
|
||||
"github.com/cosmos/cosmos-sdk/telemetry"
|
||||
sdktypes "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -454,62 +450,12 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App
|
||||
}
|
||||
|
||||
// At this point it is safe to block the process if we're in gRPC only mode as
|
||||
// we do not need to start Rosetta or handle any Tendermint related processes.
|
||||
// we do not need to handle any Tendermint related processes.
|
||||
if gRPCOnly {
|
||||
// wait for signal capture and gracefully return
|
||||
return WaitForQuitSignals()
|
||||
}
|
||||
|
||||
var rosettaSrv crgserver.Server
|
||||
if config.Rosetta.Enable {
|
||||
offlineMode := config.Rosetta.Offline
|
||||
|
||||
// If GRPC is not enabled rosetta cannot work in online mode, so we throw an error.
|
||||
if !config.GRPC.Enable && !offlineMode {
|
||||
return errors.New("'grpc' must be enable in online mode for Rosetta to work")
|
||||
}
|
||||
|
||||
minGasPrices, err := sdktypes.ParseDecCoins(config.MinGasPrices)
|
||||
if err != nil {
|
||||
ctx.Logger.Error("failed to parse minimum-gas-prices: ", err)
|
||||
return err
|
||||
}
|
||||
|
||||
conf := &rosetta.Config{
|
||||
Blockchain: config.Rosetta.Blockchain,
|
||||
Network: config.Rosetta.Network,
|
||||
TendermintRPC: ctx.Config.RPC.ListenAddress,
|
||||
GRPCEndpoint: config.GRPC.Address,
|
||||
Addr: config.Rosetta.Address,
|
||||
Retries: config.Rosetta.Retries,
|
||||
Offline: offlineMode,
|
||||
GasToSuggest: config.Rosetta.GasToSuggest,
|
||||
EnableFeeSuggestion: config.Rosetta.EnableFeeSuggestion,
|
||||
GasPrices: minGasPrices.Sort(),
|
||||
Codec: clientCtx.Codec.(*codec.ProtoCodec),
|
||||
InterfaceRegistry: clientCtx.InterfaceRegistry,
|
||||
}
|
||||
|
||||
rosettaSrv, err = rosetta.ServerFromConfig(conf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
errCh := make(chan error)
|
||||
go func() {
|
||||
if err := rosettaSrv.Start(); err != nil {
|
||||
errCh <- err
|
||||
}
|
||||
}()
|
||||
|
||||
select {
|
||||
case err := <-errCh:
|
||||
return err
|
||||
|
||||
case <-time.After(types.ServerStartTime): // assume server started successfully
|
||||
}
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if tmNode != nil && tmNode.IsRunning() {
|
||||
_ = tmNode.Stop()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user