chore: downgrade to tendermint v0.34.x (#12958)
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package mock
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
@@ -25,12 +23,12 @@ func NewPV() PV {
|
||||
}
|
||||
|
||||
// GetPubKey implements PrivValidator interface
|
||||
func (pv PV) GetPubKey(_ context.Context) (crypto.PubKey, error) {
|
||||
func (pv PV) GetPubKey() (crypto.PubKey, error) {
|
||||
return cryptocodec.ToTmPubKeyInterface(pv.PrivKey.PubKey())
|
||||
}
|
||||
|
||||
// SignVote implements PrivValidator interface
|
||||
func (pv PV) SignVote(_ context.Context, chainID string, vote *tmproto.Vote) error {
|
||||
func (pv PV) SignVote(chainID string, vote *tmproto.Vote) error {
|
||||
signBytes := tmtypes.VoteSignBytes(chainID, vote)
|
||||
sig, err := pv.PrivKey.Sign(signBytes)
|
||||
if err != nil {
|
||||
@@ -41,7 +39,7 @@ func (pv PV) SignVote(_ context.Context, chainID string, vote *tmproto.Vote) err
|
||||
}
|
||||
|
||||
// SignProposal implements PrivValidator interface
|
||||
func (pv PV) SignProposal(_ context.Context, chainID string, proposal *tmproto.Proposal) error {
|
||||
func (pv PV) SignProposal(chainID string, proposal *tmproto.Proposal) error {
|
||||
signBytes := tmtypes.ProposalSignBytes(chainID, proposal)
|
||||
sig, err := pv.PrivKey.Sign(signBytes)
|
||||
if err != nil {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package mock
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -10,7 +9,7 @@ import (
|
||||
|
||||
func TestGetPubKey(t *testing.T) {
|
||||
pv := NewPV()
|
||||
pb, err := pv.GetPubKey(context.Background())
|
||||
pb, err := pv.GetPubKey()
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, pb)
|
||||
}
|
||||
@@ -18,7 +17,7 @@ func TestGetPubKey(t *testing.T) {
|
||||
func TestSignVote(t *testing.T) {
|
||||
pv := NewPV()
|
||||
v := tmproto.Vote{}
|
||||
err := pv.SignVote(context.Background(), "chain-id", &v)
|
||||
err := pv.SignVote("chain-id", &v)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, v.Signature)
|
||||
}
|
||||
@@ -26,7 +25,7 @@ func TestSignVote(t *testing.T) {
|
||||
func TestSignProposal(t *testing.T) {
|
||||
pv := NewPV()
|
||||
p := tmproto.Proposal{}
|
||||
err := pv.SignProposal(context.Background(), "chain-id", &p)
|
||||
err := pv.SignProposal("chain-id", &p)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, p.Signature)
|
||||
}
|
||||
|
||||
@@ -17,9 +17,8 @@ import (
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/tendermint/tendermint/config"
|
||||
tmrand "github.com/tendermint/tendermint/libs/rand"
|
||||
"github.com/tendermint/tendermint/libs/service"
|
||||
"github.com/tendermint/tendermint/node"
|
||||
tmclient "github.com/tendermint/tendermint/rpc/client"
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
"google.golang.org/grpc"
|
||||
@@ -234,7 +233,7 @@ type (
|
||||
ValAddress sdk.ValAddress
|
||||
RPCClient tmclient.Client
|
||||
|
||||
tmNode service.Service
|
||||
tmNode *node.Node
|
||||
api *api.Server
|
||||
grpc *grpc.Server
|
||||
grpcWeb *http.Server
|
||||
@@ -321,7 +320,6 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
|
||||
ctx := server.NewDefaultContext()
|
||||
tmCfg := ctx.Config
|
||||
tmCfg.Consensus.TimeoutCommit = cfg.TimeoutCommit
|
||||
tmCfg.Mode = config.ModeValidator
|
||||
|
||||
// Only allow the first validator to expose an RPC, API and gRPC
|
||||
// server/client due to Tendermint in-process constraints.
|
||||
|
||||
+18
-19
@@ -2,22 +2,22 @@ package network
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
abciclient "github.com/tendermint/tendermint/abci/client"
|
||||
tmos "github.com/tendermint/tendermint/libs/os"
|
||||
tmtime "github.com/tendermint/tendermint/libs/time"
|
||||
"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/tendermint/tendermint/types"
|
||||
tmtime "github.com/tendermint/tendermint/types/time"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/server/api"
|
||||
servergrpc "github.com/cosmos/cosmos-sdk/server/grpc"
|
||||
srvtypes "github.com/cosmos/cosmos-sdk/server/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/errors"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
@@ -33,36 +33,35 @@ func startInProcess(cfg Config, val *Validator) error {
|
||||
return err
|
||||
}
|
||||
|
||||
app := cfg.AppConstructor(*val)
|
||||
|
||||
genDoc, err := types.GenesisDocFromFile(tmCfg.GenesisFile())
|
||||
nodeKey, err := p2p.LoadOrGenNodeKey(tmCfg.NodeKeyFile())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
val.tmNode, err = node.New(
|
||||
app := cfg.AppConstructor(*val)
|
||||
genDocProvider := node.DefaultGenesisDocProviderFunc(tmCfg)
|
||||
|
||||
tmNode, err := node.NewNode(
|
||||
tmCfg,
|
||||
pvm.LoadOrGenFilePV(tmCfg.PrivValidatorKeyFile(), tmCfg.PrivValidatorStateFile()),
|
||||
nodeKey,
|
||||
proxy.NewLocalClientCreator(app),
|
||||
genDocProvider,
|
||||
node.DefaultDBProvider,
|
||||
node.DefaultMetricsProvider(tmCfg.Instrumentation),
|
||||
logger.With("module", val.Moniker),
|
||||
abciclient.NewLocalCreator(app),
|
||||
genDoc,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := val.tmNode.Start(); err != nil {
|
||||
if err := tmNode.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
val.tmNode = tmNode
|
||||
|
||||
if val.RPCAddress != "" {
|
||||
node, ok := val.tmNode.(local.NodeService)
|
||||
if !ok {
|
||||
return fmt.Errorf("failed to cast %T to NodeService", val.tmNode)
|
||||
}
|
||||
val.RPCClient, err = local.New(node)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to create a local node")
|
||||
}
|
||||
val.RPCClient = local.New(tmNode)
|
||||
}
|
||||
|
||||
// We'll need a RPC client if the validator exposes a gRPC or REST endpoint.
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package sims
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
@@ -37,8 +36,8 @@ const (
|
||||
|
||||
// DefaultConsensusParams defines the default Tendermint consensus params used in
|
||||
// SimApp testing.
|
||||
var DefaultConsensusParams = &tmproto.ConsensusParams{
|
||||
Block: &tmproto.BlockParams{
|
||||
var DefaultConsensusParams = &abci.ConsensusParams{
|
||||
Block: &abci.BlockParams{
|
||||
MaxBytes: 200000,
|
||||
MaxGas: 2000000,
|
||||
},
|
||||
@@ -57,7 +56,7 @@ var DefaultConsensusParams = &tmproto.ConsensusParams{
|
||||
// CreateRandomValidatorSet creates a validator set with one random validator
|
||||
func CreateRandomValidatorSet() (*tmtypes.ValidatorSet, error) {
|
||||
privVal := mock.NewPV()
|
||||
pubKey, err := privVal.GetPubKey(context.TODO())
|
||||
pubKey, err := privVal.GetPubKey()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get pub key: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user