chore: bump TM to v0.35.0 release candidate (#10210)

Integrate Tendermint v0.35.0, including changes to build and test
plumbing necessary to make everything build. This change does not
update any SDK APIs to make use of new features.

Co-authored-by: marbar3778 <marbar3778@yahoo.com>
Co-authored-by: tycho garen <garen@tychoish.com>
Co-authored-by: M. J. Fromberger <michael.j.fromberger@gmail.com>
Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
Co-authored-by: Callum Waters <cmwaters19@gmail.com>
This commit is contained in:
Aleksandr Bezobchuk
2021-11-16 11:24:38 -08:00
committed by GitHub
co-authored by marbar3778 tycho garen M. J. Fromberger Amaury Callum Waters
parent 3f368577ed
commit af8ad3d20d
83 changed files with 1465 additions and 623 deletions
+1 -1
View File
@@ -99,7 +99,7 @@ func (s *Server) Start(cfg config.Config) error {
tmCfg.WriteTimeout = time.Duration(cfg.API.RPCWriteTimeout) * time.Second
tmCfg.MaxBodyBytes = int64(cfg.API.RPCMaxBodyBytes)
listener, err := tmrpcserver.Listen(cfg.API.Address, tmCfg)
listener, err := tmrpcserver.Listen(cfg.API.Address, tmCfg.MaxOpenConnections)
if err != nil {
return err
}
+2 -2
View File
@@ -5,8 +5,8 @@ import (
"github.com/rs/zerolog"
"github.com/spf13/cobra"
tmcfg "github.com/tendermint/tendermint/config"
tmcli "github.com/tendermint/tendermint/libs/cli"
tmlog "github.com/tendermint/tendermint/libs/log"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
@@ -30,7 +30,7 @@ func Execute(rootCmd *cobra.Command, defaultHome string) error {
ctx = context.WithValue(ctx, server.ServerContextKey, srvCtx)
rootCmd.PersistentFlags().String(flags.FlagLogLevel, zerolog.InfoLevel.String(), "The logging level (trace|debug|info|warn|error|fatal|panic)")
rootCmd.PersistentFlags().String(flags.FlagLogFormat, tmcfg.LogFormatPlain, "The logging format (json|plain)")
rootCmd.PersistentFlags().String(flags.FlagLogFormat, tmlog.LogFormatPlain, "The logging format (json|plain)")
executor := tmcli.PrepareBaseCmd(rootCmd, "", defaultHome)
return executor.ExecuteContext(ctx)
+11 -2
View File
@@ -2,10 +2,12 @@ package config
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"text/template"
"github.com/spf13/viper"
tmos "github.com/tendermint/tendermint/libs/os"
)
const DefaultConfigTemplate = `# This is a TOML config file.
@@ -245,5 +247,12 @@ func WriteConfigFile(configFilePath string, config interface{}) {
panic(err)
}
tmos.MustWriteFile(configFilePath, buffer.Bytes(), 0644)
mustWriteFile(configFilePath, buffer.Bytes(), 0644)
}
func mustWriteFile(filePath string, contents []byte, mode os.FileMode) {
if err := ioutil.WriteFile(filePath, contents, mode); err != nil {
fmt.Printf(fmt.Sprintf("failed to write file: %v", err) + "\n")
os.Exit(1)
}
}
+6 -8
View File
@@ -8,7 +8,6 @@ import (
"github.com/spf13/cobra"
tmjson "github.com/tendermint/tendermint/libs/json"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmtypes "github.com/tendermint/tendermint/types"
"github.com/cosmos/cosmos-sdk/client/flags"
@@ -80,18 +79,17 @@ func ExportCmd(appExporter types.AppExporter, defaultNodeHome string) *cobra.Com
doc.AppState = exported.AppState
doc.Validators = exported.Validators
doc.InitialHeight = exported.Height
doc.ConsensusParams = &tmproto.ConsensusParams{
Block: tmproto.BlockParams{
MaxBytes: exported.ConsensusParams.Block.MaxBytes,
MaxGas: exported.ConsensusParams.Block.MaxGas,
TimeIotaMs: doc.ConsensusParams.Block.TimeIotaMs,
doc.ConsensusParams = &tmtypes.ConsensusParams{
Block: tmtypes.BlockParams{
MaxBytes: exported.ConsensusParams.Block.MaxBytes,
MaxGas: exported.ConsensusParams.Block.MaxGas,
},
Evidence: tmproto.EvidenceParams{
Evidence: tmtypes.EvidenceParams{
MaxAgeNumBlocks: exported.ConsensusParams.Evidence.MaxAgeNumBlocks,
MaxAgeDuration: exported.ConsensusParams.Evidence.MaxAgeDuration,
MaxBytes: exported.ConsensusParams.Evidence.MaxBytes,
},
Validator: tmproto.ValidatorParams{
Validator: tmtypes.ValidatorParams{
PubKeyTypes: exported.ConsensusParams.Validator.PubKeyTypes,
},
}
+2 -3
View File
@@ -31,7 +31,7 @@ import (
func TestExportCmd_ConsensusParams(t *testing.T) {
tempDir := t.TempDir()
_, ctx, genDoc, cmd := setupApp(t, tempDir)
_, ctx, _, cmd := setupApp(t, tempDir)
output := &bytes.Buffer{}
cmd.SetOut(output)
@@ -44,7 +44,6 @@ func TestExportCmd_ConsensusParams(t *testing.T) {
t.Fatalf("error unmarshaling exported genesis doc: %s", err)
}
require.Equal(t, genDoc.ConsensusParams.Block.TimeIotaMs, exportedGenDoc.ConsensusParams.Block.TimeIotaMs)
require.Equal(t, simapp.DefaultConsensusParams.Block.MaxBytes, exportedGenDoc.ConsensusParams.Block.MaxBytes)
require.Equal(t, simapp.DefaultConsensusParams.Block.MaxGas, exportedGenDoc.ConsensusParams.Block.MaxGas)
@@ -127,7 +126,7 @@ func setupApp(t *testing.T, tempDir string) (*simapp.SimApp, context.Context, *t
t.Fatalf("error creating config folder: %s", err)
}
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
logger, _ := log.NewDefaultLogger("plain", "info", false)
db := dbm.NewMemDB()
encCfg := simapp.MakeTestEncodingConfig()
app := simapp.NewSimApp(logger, db, nil, true, map[int64]bool{}, tempDir, 0, encCfg, simapp.EmptyAppOptions{})
+14 -4
View File
@@ -2,18 +2,28 @@ package mock
import (
"fmt"
"io/ioutil"
"os"
"github.com/rs/zerolog"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
tmlog "github.com/tendermint/tendermint/libs/log"
"github.com/cosmos/cosmos-sdk/server"
)
// SetupApp returns an application as well as a clean-up function
// to be used to quickly setup a test case with an app
func SetupApp() (abci.Application, func(), error) {
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)).
With("module", "mock")
rootDir, err := os.MkdirTemp("", "mock-sdk")
var logger tmlog.Logger
logWriter := zerolog.ConsoleWriter{Out: os.Stderr}
logger = server.ZeroLogWrapper{
Logger: zerolog.New(logWriter).Level(zerolog.InfoLevel).With().Timestamp().Logger(),
}
logger = logger.With("module", "mock")
rootDir, err := ioutil.TempDir("", "mock-sdk")
if err != nil {
return nil, nil, err
}
+8 -17
View File
@@ -11,32 +11,26 @@ import (
"strconv"
"time"
"github.com/cosmos/cosmos-sdk/version"
abcitypes "github.com/tendermint/tendermint/abci/types"
rosettatypes "github.com/coinbase/rosetta-sdk-go/types"
"google.golang.org/grpc/metadata"
abcitypes "github.com/tendermint/tendermint/abci/types"
tmrpc "github.com/tendermint/tendermint/rpc/client"
"github.com/tendermint/tendermint/rpc/client/http"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
crgerrs "github.com/cosmos/cosmos-sdk/server/rosetta/lib/errors"
crgtypes "github.com/cosmos/cosmos-sdk/server/rosetta/lib/types"
sdk "github.com/cosmos/cosmos-sdk/types"
grpctypes "github.com/cosmos/cosmos-sdk/types/grpc"
"github.com/cosmos/cosmos-sdk/version"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
auth "github.com/cosmos/cosmos-sdk/x/auth/types"
bank "github.com/cosmos/cosmos-sdk/x/bank/types"
tmrpc "github.com/tendermint/tendermint/rpc/client"
)
// interface assertion
var _ crgtypes.Client = (*Client)(nil)
const tmWebsocketPath = "/websocket"
const defaultNodeTimeout = 15 * time.Second
// Client implements a single network client to interact with cosmos based chains
@@ -104,7 +98,7 @@ func (c *Client) Bootstrap() error {
return err
}
tmRPC, err := http.New(c.config.TendermintRPC, tmWebsocketPath)
tmRPC, err := http.New(c.config.TendermintRPC)
if err != nil {
return err
}
@@ -501,18 +495,15 @@ func (c *Client) getHeight(ctx context.Context, height *int64) (realHeight *int6
return
}
var initialHeightRE = regexp.MustCompile(`"initial_height":"(\d+)"`)
func extractInitialHeightFromGenesisChunk(genesisChunk string) (int64, error) {
firstChunk, err := base64.StdEncoding.DecodeString(genesisChunk)
if err != nil {
return 0, err
}
re, err := regexp.Compile("\"initial_height\":\"(\\d+)\"") //nolint:gocritic
if err != nil {
return 0, err
}
matches := re.FindStringSubmatch(string(firstChunk))
matches := initialHeightRE.FindStringSubmatch(string(firstChunk))
if len(matches) != 2 {
return 0, errors.New("failed to fetch initial_height")
}
+14 -20
View File
@@ -6,30 +6,24 @@ import (
"fmt"
"reflect"
auth "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/tendermint/tendermint/crypto"
"github.com/btcsuite/btcd/btcec"
tmcoretypes "github.com/tendermint/tendermint/rpc/core/types"
crgtypes "github.com/cosmos/cosmos-sdk/server/rosetta/lib/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
rosettatypes "github.com/coinbase/rosetta-sdk-go/types"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
tmcoretypes "github.com/tendermint/tendermint/rpc/coretypes"
tmtypes "github.com/tendermint/tendermint/types"
crgerrs "github.com/cosmos/cosmos-sdk/server/rosetta/lib/errors"
sdkclient "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
crgerrs "github.com/cosmos/cosmos-sdk/server/rosetta/lib/errors"
crgtypes "github.com/cosmos/cosmos-sdk/server/rosetta/lib/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
auth "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
)
@@ -345,11 +339,11 @@ func sdkEventToBalanceOperations(status string, event abci.Event) (operations []
default:
return nil, false
case banktypes.EventTypeCoinSpent:
spender, err := sdk.AccAddressFromBech32((string)(event.Attributes[0].Value))
spender, err := sdk.AccAddressFromBech32(event.Attributes[0].Value)
if err != nil {
panic(err)
}
coins, err := sdk.ParseCoinsNormalized((string)(event.Attributes[1].Value))
coins, err := sdk.ParseCoinsNormalized(event.Attributes[1].Value)
if err != nil {
panic(err)
}
@@ -359,11 +353,11 @@ func sdkEventToBalanceOperations(status string, event abci.Event) (operations []
accountIdentifier = spender.String()
case banktypes.EventTypeCoinReceived:
receiver, err := sdk.AccAddressFromBech32((string)(event.Attributes[0].Value))
receiver, err := sdk.AccAddressFromBech32(event.Attributes[0].Value)
if err != nil {
panic(err)
}
coins, err := sdk.ParseCoinsNormalized((string)(event.Attributes[1].Value))
coins, err := sdk.ParseCoinsNormalized(event.Attributes[1].Value)
if err != nil {
panic(err)
}
@@ -375,7 +369,7 @@ func sdkEventToBalanceOperations(status string, event abci.Event) (operations []
// rosetta does not have the concept of burning coins, so we need to mock
// the burn as a send to an address that cannot be resolved to anything
case banktypes.EventTypeCoinBurn:
coins, err := sdk.ParseCoinsNormalized((string)(event.Attributes[1].Value))
coins, err := sdk.ParseCoinsNormalized(event.Attributes[1].Value)
if err != nil {
panic(err)
}
@@ -571,9 +565,9 @@ func (c converter) Peers(peers []tmcoretypes.Peer) []*rosettatypes.Peer {
for i, peer := range peers {
converted[i] = &rosettatypes.Peer{
PeerID: peer.NodeInfo.Moniker,
PeerID: string(peer.ID),
Metadata: map[string]interface{}{
"addr": peer.NodeInfo.ListenAddr,
"addr": peer.URL,
},
}
}
+20 -21
View File
@@ -9,28 +9,24 @@ import (
"runtime/pprof"
"time"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/spf13/cobra"
"google.golang.org/grpc"
abciclient "github.com/tendermint/tendermint/abci/client"
"github.com/tendermint/tendermint/abci/server"
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
tmos "github.com/tendermint/tendermint/libs/os"
"github.com/tendermint/tendermint/node"
"github.com/tendermint/tendermint/p2p"
pvm "github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/proxy"
"github.com/tendermint/tendermint/rpc/client/local"
"github.com/cosmos/cosmos-sdk/server/rosetta"
crgserver "github.com/cosmos/cosmos-sdk/server/rosetta/lib/server"
tmtypes "github.com/tendermint/tendermint/types"
"google.golang.org/grpc"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
servergrpc "github.com/cosmos/cosmos-sdk/server/grpc"
"github.com/cosmos/cosmos-sdk/server/rosetta"
crgserver "github.com/cosmos/cosmos-sdk/server/rosetta/lib/server"
"github.com/cosmos/cosmos-sdk/server/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
)
@@ -252,21 +248,16 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App
app := appCreator(ctx.Logger, db, traceWriter, ctx.Viper)
nodeKey, err := p2p.LoadOrGenNodeKey(cfg.NodeKeyFile())
genDoc, err := tmtypes.GenesisDocFromFile(cfg.GenesisFile())
if err != nil {
return err
}
genDocProvider := node.DefaultGenesisDocProviderFunc(cfg)
tmNode, err := node.NewNode(
tmNode, err := node.New(
cfg,
pvm.LoadOrGenFilePV(cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile()),
nodeKey,
proxy.NewLocalClientCreator(app),
genDocProvider,
node.DefaultDBProvider,
node.DefaultMetricsProvider(cfg.Instrumentation),
ctx.Logger,
abciclient.NewLocalCreator(app),
genDoc,
)
if err != nil {
return err
@@ -282,7 +273,15 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App
// service if API or gRPC is enabled, and avoid doing so in the general
// case, because it spawns a new local tendermint RPC client.
if config.API.Enable || config.GRPC.Enable {
clientCtx = clientCtx.WithClient(local.New(tmNode))
node, ok := tmNode.(local.NodeService)
if !ok {
panic("unable to set node type. Please try reinstalling the binary.")
}
localNode, err := local.New(node)
if err != nil {
panic(err)
}
clientCtx = clientCtx.WithClient(localNode)
app.RegisterTxService(clientCtx)
app.RegisterTendermintService(clientCtx)
@@ -290,7 +289,7 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App
var apiSrv *api.Server
if config.API.Enable {
genDoc, err := genDocProvider()
genDoc, err := tmtypes.GenesisDocFromFile(cfg.GenesisFile())
if err != nil {
return err
}
+13 -8
View File
@@ -7,7 +7,6 @@ import (
"github.com/spf13/cobra"
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
"github.com/tendermint/tendermint/p2p"
pvm "github.com/tendermint/tendermint/privval"
tversion "github.com/tendermint/tendermint/version"
"sigs.k8s.io/yaml"
@@ -26,11 +25,11 @@ func ShowNodeIDCmd() *cobra.Command {
serverCtx := GetServerContextFromCmd(cmd)
cfg := serverCtx.Config
nodeKey, err := p2p.LoadNodeKey(cfg.NodeKeyFile())
nodeKey, err := cfg.LoadNodeKeyID()
if err != nil {
return err
}
fmt.Println(nodeKey.ID())
fmt.Println(nodeKey)
return nil
},
}
@@ -45,8 +44,11 @@ func ShowValidatorCmd() *cobra.Command {
serverCtx := GetServerContextFromCmd(cmd)
cfg := serverCtx.Config
privValidator := pvm.LoadFilePV(cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile())
pk, err := privValidator.GetPubKey()
privValidator, err := pvm.LoadFilePV(cfg.PrivValidator.KeyFile(), cfg.PrivValidator.StateFile())
if err != nil {
return err
}
pk, err := privValidator.GetPubKey(cmd.Context())
if err != nil {
return err
}
@@ -76,7 +78,10 @@ func ShowAddressCmd() *cobra.Command {
serverCtx := GetServerContextFromCmd(cmd)
cfg := serverCtx.Config
privValidator := pvm.LoadFilePV(cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile())
privValidator, err := pvm.LoadFilePV(cfg.PrivValidator.Key, cfg.PrivValidator.State)
if err != nil {
return err
}
valConsAddr := (sdk.ConsAddress)(privValidator.GetAddress())
fmt.Println(valConsAddr.String())
return nil
@@ -101,7 +106,7 @@ against which this app has been compiled.
BlockProtocol uint64
P2PProtocol uint64
}{
Tendermint: tversion.TMCoreSemVer,
Tendermint: tversion.TMVersion,
ABCI: tversion.ABCIVersion,
BlockProtocol: tversion.BlockProtocol,
P2PProtocol: tversion.P2PProtocol,
@@ -125,7 +130,7 @@ func UnsafeResetAllCmd() *cobra.Command {
serverCtx := GetServerContextFromCmd(cmd)
cfg := serverCtx.Config
tcmd.ResetAll(cfg.DBDir(), cfg.P2P.AddrBookFile(), cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile(), serverCtx.Logger)
tcmd.ResetAll(cfg.DBDir(), cfg.P2P.AddrBookFile(), cfg.PrivValidator.Key, cfg.PrivValidator.State, serverCtx.Logger)
return nil
},
}
+2 -1
View File
@@ -9,6 +9,7 @@ import (
"github.com/spf13/cobra"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmtypes "github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tm-db"
@@ -70,7 +71,7 @@ type (
// Height is the app's latest block height.
Height int64
// ConsensusParams are the exported consensus params for ABCI.
ConsensusParams *abci.ConsensusParams
ConsensusParams *tmproto.ConsensusParams
}
// AppExporter is a function that dumps all app state to
+2 -2
View File
@@ -138,7 +138,7 @@ func InterceptConfigsPreRunHandler(cmd *cobra.Command, customAppConfigTemplate s
}
var logWriter io.Writer
if strings.ToLower(serverCtx.Viper.GetString(flags.FlagLogFormat)) == tmcfg.LogFormatPlain {
if strings.ToLower(serverCtx.Viper.GetString(flags.FlagLogFormat)) == tmlog.LogFormatPlain {
logWriter = zerolog.ConsoleWriter{Out: os.Stderr}
} else {
logWriter = os.Stderr
@@ -203,7 +203,7 @@ func interceptConfigs(rootViper *viper.Viper, customAppTemplate string, customCo
conf.P2P.RecvRate = 5120000
conf.P2P.SendRate = 5120000
conf.Consensus.TimeoutCommit = 5 * time.Second
tmcfg.WriteConfigFile(tmCfgFile, conf)
tmcfg.WriteConfigFile(rootDir, conf)
case err != nil:
return nil, err
+2 -2
View File
@@ -104,7 +104,7 @@ func TestInterceptConfigsPreRunHandlerReadsConfigToml(t *testing.T) {
t.Fatalf("creating config.toml file failed: %v", err)
}
_, err = writer.WriteString(fmt.Sprintf("db_backend = '%s'\n", testDbBackend))
_, err = writer.WriteString(fmt.Sprintf("db-backend = '%s'\n", testDbBackend))
if err != nil {
t.Fatalf("Failed writing string to config.toml: %v", err)
}
@@ -128,7 +128,7 @@ func TestInterceptConfigsPreRunHandlerReadsConfigToml(t *testing.T) {
}
if testDbBackend != serverCtx.Config.DBBackend {
t.Error("DBPath was not set from config.toml")
t.Error("backend was not set from config.toml")
}
}