p2p: delete legacy stack initial pass (#7035)

A few notes:

- this is not all the deletion that we can do, but this is the most
  "simple" case: it leaves in shims, and there's some trivial
  additional cleanup to the transport that can happen but that
  requires writing more code, and I wanted this to be easy to review
  above all else.
  
- This should land *after* we cut the branch for 0.35, but I'm
  anticipating that to happen soon, and I wanted to run this through
  CI.
This commit is contained in:
Sam Kleinman
2021-10-05 13:40:32 +00:00
committed by GitHub
parent f5b9c210ca
commit 03ad7d6f20
54 changed files with 127 additions and 10207 deletions
+1 -90
View File
@@ -15,7 +15,6 @@ var (
// separate testnet for each combination (Cartesian product) of options.
testnetCombinations = map[string][]interface{}{
"topology": {"single", "quad", "large"},
"p2p": {NewP2PMode, LegacyP2PMode, HybridP2PMode},
"queueType": {"priority"}, // "fifo", "wdrr"
"initialHeight": {0, 1000},
"initialState": {
@@ -71,19 +70,6 @@ var (
// Generate generates random testnets using the given RNG.
func Generate(r *rand.Rand, opts Options) ([]e2e.Manifest, error) {
manifests := []e2e.Manifest{}
switch opts.P2P {
case NewP2PMode, LegacyP2PMode, HybridP2PMode:
defer func() {
// avoid modifying the global state.
original := make([]interface{}, len(testnetCombinations["p2p"]))
copy(original, testnetCombinations["p2p"])
testnetCombinations["p2p"] = original
}()
testnetCombinations["p2p"] = []interface{}{opts.P2P}
case MixedP2PMode:
testnetCombinations["p2p"] = []interface{}{NewP2PMode, LegacyP2PMode, HybridP2PMode}
}
for _, opt := range combinations(testnetCombinations) {
manifest, err := generateTestnet(r, opt)
@@ -95,12 +81,6 @@ func Generate(r *rand.Rand, opts Options) ([]e2e.Manifest, error) {
continue
}
if len(manifest.Nodes) == 1 {
if opt["p2p"] == HybridP2PMode {
continue
}
}
if opts.MaxNetworkSize > 0 && len(manifest.Nodes) >= opts.MaxNetworkSize {
continue
}
@@ -116,20 +96,9 @@ type Options struct {
MaxNetworkSize int
NumGroups int
Directory string
P2P P2PMode
Reverse bool
}
type P2PMode string
const (
NewP2PMode P2PMode = "new"
LegacyP2PMode P2PMode = "legacy"
HybridP2PMode P2PMode = "hybrid"
// mixed means that all combination are generated
MixedP2PMode P2PMode = "mixed"
)
// generateTestnet generates a single testnet with the given options.
func generateTestnet(r *rand.Rand, opt map[string]interface{}) (e2e.Manifest, error) {
manifest := e2e.Manifest{
@@ -145,13 +114,6 @@ func generateTestnet(r *rand.Rand, opt map[string]interface{}) (e2e.Manifest, er
TxSize: int64(txSize.Choose(r).(int)),
}
p2pMode := opt["p2p"].(P2PMode)
switch p2pMode {
case NewP2PMode, LegacyP2PMode, HybridP2PMode:
default:
return manifest, fmt.Errorf("unknown p2p mode %s", p2pMode)
}
var numSeeds, numValidators, numFulls, numLightClients int
switch opt["topology"].(string) {
case "single":
@@ -168,27 +130,13 @@ func generateTestnet(r *rand.Rand, opt map[string]interface{}) (e2e.Manifest, er
return manifest, fmt.Errorf("unknown topology %q", opt["topology"])
}
const legacyP2PFactor float64 = 0.5
// First we generate seed nodes, starting at the initial height.
for i := 1; i <= numSeeds; i++ {
node := generateNode(r, manifest, e2e.ModeSeed, 0, false)
switch p2pMode {
case LegacyP2PMode:
node.UseLegacyP2P = true
case HybridP2PMode:
node.UseLegacyP2P = r.Float64() < legacyP2PFactor
}
manifest.Nodes[fmt.Sprintf("seed%02d", i)] = node
}
var (
numSyncingNodes = 0
hybridNumNew = 0
hybridNumLegacy = 0
)
var numSyncingNodes = 0
// Next, we generate validators. We make sure a BFT quorum of validators start
// at the initial height, and that we have two archive nodes. We also set up
@@ -205,29 +153,6 @@ func generateTestnet(r *rand.Rand, opt map[string]interface{}) (e2e.Manifest, er
name := fmt.Sprintf("validator%02d", i)
node := generateNode(r, manifest, e2e.ModeValidator, startAt, i <= 2)
switch p2pMode {
case LegacyP2PMode:
node.UseLegacyP2P = true
case HybridP2PMode:
node.UseLegacyP2P = r.Float64() < legacyP2PFactor
if node.UseLegacyP2P {
hybridNumLegacy++
if hybridNumNew == 0 {
hybridNumNew++
hybridNumLegacy--
node.UseLegacyP2P = false
}
} else {
hybridNumNew++
if hybridNumLegacy == 0 {
hybridNumNew--
hybridNumLegacy++
node.UseLegacyP2P = true
}
}
}
manifest.Nodes[name] = node
if startAt == 0 {
@@ -259,13 +184,6 @@ func generateTestnet(r *rand.Rand, opt map[string]interface{}) (e2e.Manifest, er
}
node := generateNode(r, manifest, e2e.ModeFull, startAt, false)
switch p2pMode {
case LegacyP2PMode:
node.UseLegacyP2P = true
case HybridP2PMode:
node.UseLegacyP2P = r.Float64() > legacyP2PFactor
}
manifest.Nodes[fmt.Sprintf("full%02d", i)] = node
}
@@ -336,13 +254,6 @@ func generateTestnet(r *rand.Rand, opt map[string]interface{}) (e2e.Manifest, er
r, startAt+(5*int64(i)), lightProviders,
)
switch p2pMode {
case LegacyP2PMode:
node.UseLegacyP2P = true
case HybridP2PMode:
node.UseLegacyP2P = r.Float64() < legacyP2PFactor
}
manifest.Nodes[fmt.Sprintf("light%02d", i)] = node
}
+2 -70
View File
@@ -5,15 +5,14 @@ import (
"math/rand"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
e2e "github.com/tendermint/tendermint/test/e2e/pkg"
)
func TestGenerator(t *testing.T) {
manifests, err := Generate(rand.New(rand.NewSource(randomSeed)), Options{P2P: MixedP2PMode})
manifests, err := Generate(rand.New(rand.NewSource(randomSeed)), Options{})
require.NoError(t, err)
require.True(t, len(manifests) >= 64, "insufficient combinations")
require.True(t, len(manifests) >= 24, "insufficient combinations %d", len(manifests))
// this just means that the numbers reported by the test
// failures map to the test cases that you'd see locally.
@@ -41,71 +40,4 @@ func TestGenerator(t *testing.T) {
require.True(t, numStateSyncs <= 2)
})
}
t.Run("Hybrid", func(t *testing.T) {
manifests, err := Generate(rand.New(rand.NewSource(randomSeed)), Options{P2P: HybridP2PMode})
require.NoError(t, err)
require.True(t, len(manifests) >= 16, "insufficient combinations: %d", len(manifests))
// failures map to the test cases that you'd see locally.
e2e.SortManifests(manifests, false /* ascending */)
for idx, m := range manifests {
t.Run(fmt.Sprintf("Case%04d", idx), func(t *testing.T) {
require.True(t, len(m.Nodes) > 1)
var numLegacy, numNew int
for _, node := range m.Nodes {
if node.UseLegacyP2P {
numLegacy++
} else {
numNew++
}
}
assert.True(t, numLegacy >= 1, "not enough legacy nodes [%d/%d]",
numLegacy, len(m.Nodes))
assert.True(t, numNew >= 1, "not enough new nodes [%d/%d]",
numNew, len(m.Nodes))
})
}
})
t.Run("UnmixedP2P", func(t *testing.T) {
t.Run("New", func(t *testing.T) {
manifests, err := Generate(rand.New(rand.NewSource(randomSeed)), Options{P2P: NewP2PMode})
require.NoError(t, err)
require.True(t, len(manifests) >= 16, "insufficient combinations: %d", len(manifests))
// failures map to the test cases that you'd see locally.
e2e.SortManifests(manifests, false /* ascending */)
for idx, m := range manifests {
t.Run(fmt.Sprintf("Case%04d", idx), func(t *testing.T) {
for name, node := range m.Nodes {
t.Run(name, func(t *testing.T) {
require.False(t, node.UseLegacyP2P)
})
}
})
}
})
t.Run("Legacy", func(t *testing.T) {
manifests, err := Generate(rand.New(rand.NewSource(randomSeed)), Options{P2P: LegacyP2PMode})
require.NoError(t, err)
require.True(t, len(manifests) >= 16, "insufficient combinations: %d", len(manifests))
// failures map to the test cases that you'd see locally.
e2e.SortManifests(manifests, false /* ascending */)
for idx, m := range manifests {
t.Run(fmt.Sprintf("Case%04d", idx), func(t *testing.T) {
for name, node := range m.Nodes {
t.Run(name, func(t *testing.T) {
require.True(t, node.UseLegacyP2P)
})
}
})
}
})
})
}
-16
View File
@@ -38,20 +38,6 @@ func NewCLI() *CLI {
SilenceUsage: true,
SilenceErrors: true, // we'll output them ourselves in Run()
RunE: func(cmd *cobra.Command, args []string) error {
var err error
p2pMode, err := cmd.Flags().GetString("p2p")
if err != nil {
return err
}
switch mode := P2PMode(p2pMode); mode {
case NewP2PMode, LegacyP2PMode, HybridP2PMode, MixedP2PMode:
cli.opts.P2P = mode
default:
return fmt.Errorf("p2p mode must be either new, legacy, hybrid or mixed got %s", p2pMode)
}
return cli.generate()
},
}
@@ -60,8 +46,6 @@ func NewCLI() *CLI {
_ = cli.root.MarkPersistentFlagRequired("dir")
cli.root.Flags().BoolVarP(&cli.opts.Reverse, "reverse", "r", false, "Reverse sort order")
cli.root.PersistentFlags().IntVarP(&cli.opts.NumGroups, "groups", "g", 0, "Number of groups")
cli.root.PersistentFlags().StringP("p2p", "p", string(MixedP2PMode),
"P2P typology to be generated [\"new\", \"legacy\", \"hybrid\" or \"mixed\" ]")
cli.root.PersistentFlags().IntVarP(&cli.opts.MinNetworkSize, "min-size", "", 1,
"Minimum network size (nodes)")
cli.root.PersistentFlags().IntVarP(&cli.opts.MaxNetworkSize, "max-size", "", 0,
-1
View File
@@ -1,7 +1,6 @@
# This testnet is run by CI, and attempts to cover a broad range of
# functionality with a single network.
disable_legacy_p2p = false
evidence = 5
initial_height = 1000
initial_state = {initial01 = "a", initial02 = "b", initial03 = "c"}
-3
View File
@@ -145,9 +145,6 @@ type ManifestNode struct {
// This is helpful when debugging a specific problem. This overrides the network
// level.
LogLevel string `toml:"log_level"`
// UseLegacyP2P enables use of the legacy p2p layer for this node.
UseLegacyP2P bool `toml:"use_legacy_p2p"`
}
// Stateless reports whether m is a node that does not own state, including light and seed nodes.
-2
View File
@@ -96,7 +96,6 @@ type Node struct {
PersistentPeers []*Node
Perturbations []Perturbation
LogLevel string
UseLegacyP2P bool
QueueType string
HasStarted bool
}
@@ -182,7 +181,6 @@ func LoadTestnet(file string) (*Testnet, error) {
Perturbations: []Perturbation{},
LogLevel: manifest.LogLevel,
QueueType: manifest.QueueType,
UseLegacyP2P: nodeManifest.UseLegacyP2P,
}
if node.StartAt == testnet.InitialHeight {
-2
View File
@@ -238,7 +238,6 @@ func MakeConfig(node *e2e.Node) (*config.Config, error) {
cfg.RPC.PprofListenAddress = ":6060"
cfg.P2P.ExternalAddress = fmt.Sprintf("tcp://%v", node.AddressP2P(false))
cfg.P2P.AddrBookStrict = false
cfg.P2P.UseLegacy = node.UseLegacyP2P
cfg.P2P.QueueType = node.QueueType
cfg.DBBackend = node.Database
cfg.StateSync.DiscoveryTime = 5 * time.Second
@@ -354,7 +353,6 @@ func MakeAppConfig(node *e2e.Node) ([]byte, error) {
"snapshot_interval": node.SnapshotInterval,
"retain_blocks": node.RetainBlocks,
"key_type": node.PrivvalKey.Type(),
"use_legacy_p2p": node.UseLegacyP2P,
}
switch node.ABCIProtocol {
case e2e.ProtocolUNIX: