make the rest of the code compile

This commit is contained in:
Callum Waters
2021-08-24 13:26:01 +02:00
parent dcf91478f8
commit 68c54f0676
283 changed files with 3874 additions and 3906 deletions

View File

@@ -9,8 +9,8 @@ import (
"strconv"
"github.com/tendermint/tendermint/abci/example/code"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/pkg/abci"
"github.com/tendermint/tendermint/version"
)

View File

@@ -11,7 +11,7 @@ import (
"path/filepath"
"sync"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/pkg/abci"
)
const (

View File

@@ -6,8 +6,8 @@ import (
"sort"
"strings"
"github.com/tendermint/tendermint/pkg/consensus"
e2e "github.com/tendermint/tendermint/test/e2e/pkg"
"github.com/tendermint/tendermint/types"
)
var (
@@ -45,7 +45,7 @@ var (
evidence = uniformChoice{0, 1, 10}
txSize = uniformChoice{1024, 10240} // either 1kb or 10kb
ipv6 = uniformChoice{false, true}
keyType = uniformChoice{types.ABCIPubKeyTypeEd25519, types.ABCIPubKeyTypeSecp256k1}
keyType = uniformChoice{consensus.ABCIPubKeyTypeEd25519, consensus.ABCIPubKeyTypeSecp256k1}
)
// Generate generates random testnets using the given RNG.

View File

@@ -16,8 +16,8 @@ import (
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
"github.com/tendermint/tendermint/crypto/secp256k1"
"github.com/tendermint/tendermint/pkg/consensus"
rpchttp "github.com/tendermint/tendermint/rpc/client/http"
"github.com/tendermint/tendermint/types"
)
const (
@@ -295,7 +295,7 @@ func (t Testnet) Validate() error {
return errors.New("network has no nodes")
}
switch t.KeyType {
case "", types.ABCIPubKeyTypeEd25519, types.ABCIPubKeyTypeSecp256k1:
case "", consensus.ABCIPubKeyTypeEd25519, consensus.ABCIPubKeyTypeSecp256k1:
default:
return errors.New("unsupported KeyType")
}

View File

@@ -8,8 +8,8 @@ import (
"path/filepath"
"time"
"github.com/tendermint/tendermint/pkg/block"
e2e "github.com/tendermint/tendermint/test/e2e/pkg"
"github.com/tendermint/tendermint/types"
)
// Benchmark is a simple function for fetching, calculating and printing
@@ -63,7 +63,7 @@ func Benchmark(testnet *e2e.Testnet, benchmarkLength int64) error {
return nil
}
func (t *testnetStats) populateTxns(blocks []*types.BlockMeta) {
func (t *testnetStats) populateTxns(blocks []*block.BlockMeta) {
t.numtxns = 0
for _, b := range blocks {
t.numtxns += int64(b.NumTxs)
@@ -126,8 +126,8 @@ func (t *testnetStats) String() string {
// fetchBlockChainSample waits for `benchmarkLength` amount of blocks to pass, fetching
// all of the headers for these blocks from an archive node and returning it.
func fetchBlockChainSample(testnet *e2e.Testnet, benchmarkLength int64) ([]*types.BlockMeta, error) {
var blocks []*types.BlockMeta
func fetchBlockChainSample(testnet *e2e.Testnet, benchmarkLength int64) ([]*block.BlockMeta, error) {
var blocks []*block.BlockMeta
// Find the first archive node
archiveNode := testnet.ArchiveNodes()[0]
@@ -174,7 +174,7 @@ func fetchBlockChainSample(testnet *e2e.Testnet, benchmarkLength int64) ([]*type
return blocks, nil
}
func splitIntoBlockIntervals(blocks []*types.BlockMeta) []time.Duration {
func splitIntoBlockIntervals(blocks []*block.BlockMeta) []time.Duration {
intervals := make([]time.Duration, len(blocks)-1)
lastTime := blocks[0].Header.Time
for i, block := range blocks {

View File

@@ -13,10 +13,13 @@ import (
"github.com/tendermint/tendermint/crypto/tmhash"
"github.com/tendermint/tendermint/internal/test/factory"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/pkg/consensus"
"github.com/tendermint/tendermint/pkg/evidence"
"github.com/tendermint/tendermint/pkg/light"
"github.com/tendermint/tendermint/pkg/metadata"
"github.com/tendermint/tendermint/privval"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
e2e "github.com/tendermint/tendermint/test/e2e/pkg"
"github.com/tendermint/tendermint/types"
"github.com/tendermint/tendermint/version"
)
@@ -52,7 +55,7 @@ func InjectEvidence(testnet *e2e.Testnet, amount int) error {
return err
}
valSet, err := types.ValidatorSetFromExistingValidators(valRes.Validators)
valSet, err := consensus.ValidatorSetFromExistingValidators(valRes.Validators)
if err != nil {
return err
}
@@ -70,7 +73,7 @@ func InjectEvidence(testnet *e2e.Testnet, amount int) error {
return err
}
var ev types.Evidence
var ev evidence.Evidence
for i := 1; i <= amount; i++ {
if i%lightClientEvidenceRatio == 0 {
ev, err = generateLightClientAttackEvidence(
@@ -103,8 +106,8 @@ func InjectEvidence(testnet *e2e.Testnet, amount int) error {
return nil
}
func getPrivateValidatorKeys(testnet *e2e.Testnet) ([]types.MockPV, error) {
privVals := []types.MockPV{}
func getPrivateValidatorKeys(testnet *e2e.Testnet) ([]consensus.MockPV, error) {
privVals := []consensus.MockPV{}
for _, node := range testnet.Nodes {
if node.Mode == e2e.ModeValidator {
@@ -115,7 +118,7 @@ func getPrivateValidatorKeys(testnet *e2e.Testnet) ([]types.MockPV, error) {
}
// Create mock private validators from the validators private key. MockPV is
// stateless which means we can double vote and do other funky stuff
privVals = append(privVals, types.NewMockPVWithParams(privKey, false, false))
privVals = append(privVals, consensus.NewMockPVWithParams(privKey, false, false))
}
}
@@ -125,12 +128,12 @@ func getPrivateValidatorKeys(testnet *e2e.Testnet) ([]types.MockPV, error) {
// creates evidence of a lunatic attack. The height provided is the common height.
// The forged height happens 2 blocks later.
func generateLightClientAttackEvidence(
privVals []types.MockPV,
privVals []consensus.MockPV,
height int64,
vals *types.ValidatorSet,
vals *consensus.ValidatorSet,
chainID string,
evTime time.Time,
) (*types.LightClientAttackEvidence, error) {
) (*evidence.LightClientAttackEvidence, error) {
// forge a random header
forgedHeight := height + 2
forgedTime := evTime.Add(1 * time.Second)
@@ -148,15 +151,15 @@ func generateLightClientAttackEvidence(
// create a commit for the forged header
blockID := makeBlockID(header.Hash(), 1000, []byte("partshash"))
voteSet := types.NewVoteSet(chainID, forgedHeight, 0, tmproto.SignedMsgType(2), conflictingVals)
voteSet := consensus.NewVoteSet(chainID, forgedHeight, 0, tmproto.SignedMsgType(2), conflictingVals)
commit, err := factory.MakeCommit(blockID, forgedHeight, 0, voteSet, pv, forgedTime)
if err != nil {
return nil, err
}
ev := &types.LightClientAttackEvidence{
ConflictingBlock: &types.LightBlock{
SignedHeader: &types.SignedHeader{
ev := &evidence.LightClientAttackEvidence{
ConflictingBlock: &light.LightBlock{
SignedHeader: &metadata.SignedHeader{
Header: header,
Commit: commit,
},
@@ -166,7 +169,7 @@ func generateLightClientAttackEvidence(
TotalVotingPower: vals.TotalVotingPower(),
Timestamp: evTime,
}
ev.ByzantineValidators = ev.GetByzantineValidators(vals, &types.SignedHeader{
ev.ByzantineValidators = ev.GetByzantineValidators(vals, &metadata.SignedHeader{
Header: makeHeaderRandom(chainID, forgedHeight),
})
return ev, nil
@@ -175,12 +178,12 @@ func generateLightClientAttackEvidence(
// generateDuplicateVoteEvidence picks a random validator from the val set and
// returns duplicate vote evidence against the validator
func generateDuplicateVoteEvidence(
privVals []types.MockPV,
privVals []consensus.MockPV,
height int64,
vals *types.ValidatorSet,
vals *consensus.ValidatorSet,
chainID string,
time time.Time,
) (*types.DuplicateVoteEvidence, error) {
) (*evidence.DuplicateVoteEvidence, error) {
// nolint:gosec // G404: Use of weak random number generator
privVal := privVals[rand.Intn(len(privVals))]
@@ -193,7 +196,7 @@ func generateDuplicateVoteEvidence(
if err != nil {
return nil, err
}
ev := types.NewDuplicateVoteEvidence(voteA, voteB, time, vals)
ev := evidence.NewDuplicateVoteEvidence(voteA, voteB, time, vals)
if ev == nil {
return nil, fmt.Errorf("could not generate evidence a=%v b=%v vals=%v", voteA, voteB, vals)
}
@@ -215,8 +218,8 @@ func readPrivKey(keyFilePath string) (crypto.PrivKey, error) {
return pvKey.PrivKey, nil
}
func makeHeaderRandom(chainID string, height int64) *types.Header {
return &types.Header{
func makeHeaderRandom(chainID string, height int64) *metadata.Header {
return &metadata.Header{
Version: version.Consensus{Block: version.BlockProtocol, App: 1},
ChainID: chainID,
Height: height,
@@ -234,42 +237,42 @@ func makeHeaderRandom(chainID string, height int64) *types.Header {
}
}
func makeRandomBlockID() types.BlockID {
func makeRandomBlockID() metadata.BlockID {
return makeBlockID(crypto.CRandBytes(tmhash.Size), 100, crypto.CRandBytes(tmhash.Size))
}
func makeBlockID(hash []byte, partSetSize uint32, partSetHash []byte) types.BlockID {
func makeBlockID(hash []byte, partSetSize uint32, partSetHash []byte) metadata.BlockID {
var (
h = make([]byte, tmhash.Size)
psH = make([]byte, tmhash.Size)
)
copy(h, hash)
copy(psH, partSetHash)
return types.BlockID{
return metadata.BlockID{
Hash: h,
PartSetHeader: types.PartSetHeader{
PartSetHeader: metadata.PartSetHeader{
Total: partSetSize,
Hash: psH,
},
}
}
func mutateValidatorSet(privVals []types.MockPV, vals *types.ValidatorSet,
) ([]types.PrivValidator, *types.ValidatorSet, error) {
func mutateValidatorSet(privVals []consensus.MockPV, vals *consensus.ValidatorSet,
) ([]consensus.PrivValidator, *consensus.ValidatorSet, error) {
newVal, newPrivVal := factory.RandValidator(false, 10)
var newVals *types.ValidatorSet
var newVals *consensus.ValidatorSet
if vals.Size() > 2 {
newVals = types.NewValidatorSet(append(vals.Copy().Validators[:vals.Size()-1], newVal))
newVals = consensus.NewValidatorSet(append(vals.Copy().Validators[:vals.Size()-1], newVal))
} else {
newVals = types.NewValidatorSet(append(vals.Copy().Validators, newVal))
newVals = consensus.NewValidatorSet(append(vals.Copy().Validators, newVal))
}
// we need to sort the priv validators with the same index as the validator set
pv := make([]types.PrivValidator, newVals.Size())
pv := make([]consensus.PrivValidator, newVals.Size())
for idx, val := range newVals.Validators {
found := false
for _, p := range append(privVals, newPrivVal.(types.MockPV)) {
for _, p := range append(privVals, newPrivVal.(consensus.MockPV)) {
if bytes.Equal(p.PrivKey.PubKey().Address(), val.Address) {
pv[idx] = p
found = true

View File

@@ -8,9 +8,9 @@ import (
"math"
"time"
"github.com/tendermint/tendermint/pkg/mempool"
rpchttp "github.com/tendermint/tendermint/rpc/client/http"
e2e "github.com/tendermint/tendermint/test/e2e/pkg"
"github.com/tendermint/tendermint/types"
)
// Load generates transactions against the network until the given context is
@@ -29,8 +29,8 @@ func Load(ctx context.Context, testnet *e2e.Testnet, multiplier int) error {
initialTimeout := 1 * time.Minute
stallTimeout := 30 * time.Second
chTx := make(chan types.Tx)
chSuccess := make(chan types.Tx)
chTx := make(chan mempool.Tx)
chSuccess := make(chan mempool.Tx)
ctx, cancel := context.WithCancel(ctx)
defer cancel()
@@ -66,7 +66,7 @@ func Load(ctx context.Context, testnet *e2e.Testnet, multiplier int) error {
}
// loadGenerate generates jobs until the context is canceled
func loadGenerate(ctx context.Context, chTx chan<- types.Tx, multiplier int, size int64) {
func loadGenerate(ctx context.Context, chTx chan<- mempool.Tx, multiplier int, size int64) {
for i := 0; i < math.MaxInt64; i++ {
// We keep generating the same 100 keys over and over, with different values.
// This gives a reasonable load without putting too much data in the app.
@@ -77,7 +77,7 @@ func loadGenerate(ctx context.Context, chTx chan<- types.Tx, multiplier int, siz
if err != nil {
panic(fmt.Sprintf("Failed to read random bytes: %v", err))
}
tx := types.Tx(fmt.Sprintf("load-%X=%x", id, bz))
tx := mempool.Tx(fmt.Sprintf("load-%X=%x", id, bz))
select {
case chTx <- tx:
@@ -92,7 +92,7 @@ func loadGenerate(ctx context.Context, chTx chan<- types.Tx, multiplier int, siz
}
// loadProcess processes transactions
func loadProcess(ctx context.Context, testnet *e2e.Testnet, chTx <-chan types.Tx, chSuccess chan<- types.Tx) {
func loadProcess(ctx context.Context, testnet *e2e.Testnet, chTx <-chan mempool.Tx, chSuccess chan<- mempool.Tx) {
// Each worker gets its own client to each node, which allows for some
// concurrency while still bounding it.
clients := map[string]*rpchttp.HTTP{}

View File

@@ -6,16 +6,17 @@ import (
"fmt"
"time"
"github.com/tendermint/tendermint/pkg/block"
"github.com/tendermint/tendermint/pkg/metadata"
rpchttp "github.com/tendermint/tendermint/rpc/client/http"
rpctypes "github.com/tendermint/tendermint/rpc/core/types"
e2e "github.com/tendermint/tendermint/test/e2e/pkg"
"github.com/tendermint/tendermint/types"
)
// waitForHeight waits for the network to reach a certain height (or above),
// returning the highest height seen. Errors if the network is not making
// progress at all.
func waitForHeight(testnet *e2e.Testnet, height int64) (*types.Block, *types.BlockID, error) {
func waitForHeight(testnet *e2e.Testnet, height int64) (*block.Block, *metadata.BlockID, error) {
var (
err error
maxResult *rpctypes.ResultBlock

View File

@@ -20,9 +20,10 @@ import (
"github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/crypto/ed25519"
"github.com/tendermint/tendermint/pkg/consensus"
"github.com/tendermint/tendermint/pkg/p2p"
"github.com/tendermint/tendermint/privval"
e2e "github.com/tendermint/tendermint/test/e2e/pkg"
"github.com/tendermint/tendermint/types"
)
const (
@@ -105,7 +106,7 @@ func Setup(testnet *e2e.Testnet) error {
return err
}
err = (&types.NodeKey{PrivKey: node.NodeKey}).SaveAs(filepath.Join(nodeDir, "config", "node_key.json"))
err = (&p2p.NodeKey{PrivKey: node.NodeKey}).SaveAs(filepath.Join(nodeDir, "config", "node_key.json"))
if err != nil {
return err
}
@@ -185,24 +186,24 @@ services:
}
// MakeGenesis generates a genesis document.
func MakeGenesis(testnet *e2e.Testnet) (types.GenesisDoc, error) {
genesis := types.GenesisDoc{
func MakeGenesis(testnet *e2e.Testnet) (consensus.GenesisDoc, error) {
genesis := consensus.GenesisDoc{
GenesisTime: time.Now(),
ChainID: testnet.Name,
ConsensusParams: types.DefaultConsensusParams(),
ConsensusParams: consensus.DefaultConsensusParams(),
InitialHeight: testnet.InitialHeight,
}
switch testnet.KeyType {
case "", types.ABCIPubKeyTypeEd25519, types.ABCIPubKeyTypeSecp256k1:
case "", consensus.ABCIPubKeyTypeEd25519, consensus.ABCIPubKeyTypeSecp256k1:
genesis.ConsensusParams.Validator.PubKeyTypes =
append(genesis.ConsensusParams.Validator.PubKeyTypes, types.ABCIPubKeyTypeSecp256k1)
append(genesis.ConsensusParams.Validator.PubKeyTypes, consensus.ABCIPubKeyTypeSecp256k1)
default:
return genesis, errors.New("unsupported KeyType")
}
genesis.ConsensusParams.Evidence.MaxAgeNumBlocks = e2e.EvidenceAgeHeight
genesis.ConsensusParams.Evidence.MaxAgeDuration = e2e.EvidenceAgeTime
for validator, power := range testnet.Validators {
genesis.Validators = append(genesis.Validators, types.GenesisValidator{
genesis.Validators = append(genesis.Validators, consensus.GenesisValidator{
Name: validator.Name,
Address: validator.PrivvalKey.PubKey().Address(),
PubKey: validator.PrivvalKey.PubKey(),

View File

@@ -10,8 +10,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/pkg/mempool"
e2e "github.com/tendermint/tendermint/test/e2e/pkg"
"github.com/tendermint/tendermint/types"
)
// Tests that any initial state given in genesis has made it into the app.
@@ -80,7 +80,7 @@ func TestApp_Tx(t *testing.T) {
key := fmt.Sprintf("testapp-tx-%v", node.Name)
value := fmt.Sprintf("%x", bz)
tx := types.Tx(fmt.Sprintf("%v=%v", key, value))
tx := mempool.Tx(fmt.Sprintf("%v=%v", key, value))
_, err = client.BroadcastTxSync(ctx, tx)
require.NoError(t, err)

View File

@@ -9,10 +9,10 @@ import (
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/pkg/block"
rpchttp "github.com/tendermint/tendermint/rpc/client/http"
rpctypes "github.com/tendermint/tendermint/rpc/core/types"
e2e "github.com/tendermint/tendermint/test/e2e/pkg"
"github.com/tendermint/tendermint/types"
)
func init() {
@@ -26,7 +26,7 @@ var (
ctx = context.Background()
testnetCache = map[string]e2e.Testnet{}
testnetCacheMtx = sync.Mutex{}
blocksCache = map[string][]*types.Block{}
blocksCache = map[string][]*block.Block{}
blocksCacheMtx = sync.Mutex{}
)
@@ -84,7 +84,7 @@ func loadTestnet(t *testing.T) e2e.Testnet {
// fetchBlockChain fetches a complete, up-to-date block history from
// the freshest testnet archive node.
func fetchBlockChain(t *testing.T) []*types.Block {
func fetchBlockChain(t *testing.T) []*block.Block {
t.Helper()
testnet := loadTestnet(t)
@@ -115,7 +115,7 @@ func fetchBlockChain(t *testing.T) []*types.Block {
to := status.SyncInfo.LatestBlockHeight
blocks, ok := blocksCache[testnet.Name]
if !ok {
blocks = make([]*types.Block, 0, to-from+1)
blocks = make([]*block.Block, 0, to-from+1)
}
if len(blocks) > 0 {
from = blocks[len(blocks)-1].Height + 1

View File

@@ -6,8 +6,8 @@ import (
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/pkg/consensus"
e2e "github.com/tendermint/tendermint/test/e2e/pkg"
"github.com/tendermint/tendermint/types"
)
// Tests that validator sets are available and correct according to
@@ -35,7 +35,7 @@ func TestValidator_Sets(t *testing.T) {
valSchedule.Increment(first - node.Testnet.InitialHeight)
for h := first; h <= last; h++ {
validators := []*types.Validator{}
validators := []*consensus.Validator{}
perPage := 100
for page := 1; ; page++ {
resp, err := client.Validators(ctx, &(h), &(page), &perPage)
@@ -126,7 +126,7 @@ func TestValidator_Sign(t *testing.T) {
// validatorSchedule is a validator set iterator, which takes into account
// validator set updates.
type validatorSchedule struct {
Set *types.ValidatorSet
Set *consensus.ValidatorSet
height int64
updates map[int64]map[*e2e.Node]int64
}
@@ -138,7 +138,7 @@ func newValidatorSchedule(testnet e2e.Testnet) *validatorSchedule {
}
return &validatorSchedule{
height: testnet.InitialHeight,
Set: types.NewValidatorSet(makeVals(valMap)),
Set: consensus.NewValidatorSet(makeVals(valMap)),
updates: testnet.ValidatorUpdates,
}
}
@@ -159,10 +159,10 @@ func (s *validatorSchedule) Increment(heights int64) {
}
}
func makeVals(valMap map[*e2e.Node]int64) []*types.Validator {
vals := make([]*types.Validator, 0, len(valMap))
func makeVals(valMap map[*e2e.Node]int64) []*consensus.Validator {
vals := make([]*consensus.Validator, 0, len(valMap))
for node, power := range valMap {
vals = append(vals, types.NewValidator(node.PrivvalKey.PubKey(), power))
vals = append(vals, consensus.NewValidator(node.PrivvalKey.PubKey(), power))
}
return vals
}

View File

@@ -13,7 +13,7 @@ import (
"github.com/tendermint/tendermint/crypto/ed25519"
"github.com/tendermint/tendermint/internal/p2p"
"github.com/tendermint/tendermint/types"
types "github.com/tendermint/tendermint/pkg/p2p"
)
func main() {

View File

@@ -13,8 +13,8 @@ import (
"github.com/tendermint/tendermint/crypto/ed25519"
"github.com/tendermint/tendermint/internal/p2p"
"github.com/tendermint/tendermint/internal/p2p/pex"
types "github.com/tendermint/tendermint/pkg/p2p"
tmp2p "github.com/tendermint/tendermint/proto/tendermint/p2p"
"github.com/tendermint/tendermint/types"
)
func main() {

View File

@@ -9,7 +9,7 @@ import (
"github.com/tendermint/tendermint/internal/p2p/pex"
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/libs/service"
"github.com/tendermint/tendermint/types"
types "github.com/tendermint/tendermint/pkg/p2p"
"github.com/tendermint/tendermint/version"
)