mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-19 06:31:57 +00:00
e2e: remove maverick (#9148)
This commit is contained in:
committed by
Sam Ricotta
parent
2ff667ff8e
commit
d015f5e5ff
+1
-6
@@ -8,11 +8,6 @@ docker:
|
||||
# ABCI testing).
|
||||
node:
|
||||
go build -o build/node -tags badgerdb,boltdb,cleveldb,rocksdb ./node
|
||||
|
||||
# To be used primarily by the e2e docker instance. If you want to produce this binary
|
||||
# elsewhere, then run go build in the maverick directory.
|
||||
maverick:
|
||||
go build -o build/maverick -tags badgerdb,boltdb,cleveldb,rocksdb ../maverick
|
||||
|
||||
generator:
|
||||
go build -o build/generator ./generator
|
||||
@@ -20,4 +15,4 @@ generator:
|
||||
runner:
|
||||
go build -o build/runner ./runner
|
||||
|
||||
.PHONY: all node docker generator maverick runner
|
||||
.PHONY: all node docker generator runner
|
||||
|
||||
@@ -18,7 +18,6 @@ RUN go mod download
|
||||
COPY . .
|
||||
RUN make build && cp build/tendermint /usr/bin/tendermint
|
||||
COPY test/e2e/docker/entrypoint* /usr/bin/
|
||||
RUN cd test/e2e && make maverick && cp build/maverick /usr/bin/maverick
|
||||
RUN cd test/e2e && make node && cp build/node /usr/bin/app
|
||||
|
||||
# Set up runtime directory. We don't use a separate runtime image since we need
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Forcibly remove any stray UNIX sockets left behind from previous runs
|
||||
rm -rf /var/run/privval.sock /var/run/app.sock
|
||||
|
||||
/usr/bin/app /tendermint/config/app.toml &
|
||||
|
||||
sleep 1
|
||||
|
||||
/usr/bin/maverick "$@"
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
e2e "github.com/tendermint/tendermint/test/e2e/pkg"
|
||||
@@ -42,13 +41,6 @@ var (
|
||||
"kill": 0.1,
|
||||
"restart": 0.1,
|
||||
}
|
||||
nodeMisbehaviors = weightedChoice{
|
||||
// FIXME: evidence disabled due to node panicing when not
|
||||
// having sufficient block history to process evidence.
|
||||
// https://github.com/tendermint/tendermint/issues/5617
|
||||
// misbehaviorOption{"double-prevote"}: 1,
|
||||
misbehaviorOption{}: 9,
|
||||
}
|
||||
)
|
||||
|
||||
// Generate generates random testnets using the given RNG.
|
||||
@@ -226,17 +218,6 @@ func generateNode(
|
||||
node.SnapshotInterval = 3
|
||||
}
|
||||
|
||||
if node.Mode == string(e2e.ModeValidator) {
|
||||
misbehaveAt := startAt + 5 + int64(r.Intn(10))
|
||||
if startAt == 0 {
|
||||
misbehaveAt += initialHeight - 1
|
||||
}
|
||||
node.Misbehaviors = nodeMisbehaviors.Choose(r).(misbehaviorOption).atHeight(misbehaveAt)
|
||||
if len(node.Misbehaviors) != 0 {
|
||||
node.PrivvalProtocol = "file"
|
||||
}
|
||||
}
|
||||
|
||||
// If a node which does not persist state also does not retain blocks, randomly
|
||||
// choose to either persist state or retain all blocks.
|
||||
if node.PersistInterval != nil && *node.PersistInterval == 0 && node.RetainBlocks > 0 {
|
||||
@@ -274,16 +255,3 @@ func generateLightNode(r *rand.Rand, startAt int64, providers []string) *e2e.Man
|
||||
func ptrUint64(i uint64) *uint64 {
|
||||
return &i
|
||||
}
|
||||
|
||||
type misbehaviorOption struct {
|
||||
misbehavior string
|
||||
}
|
||||
|
||||
func (m misbehaviorOption) atHeight(height int64) map[string]string {
|
||||
misbehaviorMap := make(map[string]string)
|
||||
if m.misbehavior == "" {
|
||||
return misbehaviorMap
|
||||
}
|
||||
misbehaviorMap[strconv.Itoa(int(height))] = m.misbehavior
|
||||
return misbehaviorMap
|
||||
}
|
||||
|
||||
@@ -56,28 +56,6 @@ func (uc uniformChoice) Choose(r *rand.Rand) interface{} {
|
||||
return uc[r.Intn(len(uc))]
|
||||
}
|
||||
|
||||
// weightedChoice chooses a single random key from a map of keys and weights.
|
||||
type weightedChoice map[interface{}]uint
|
||||
|
||||
func (wc weightedChoice) Choose(r *rand.Rand) interface{} {
|
||||
total := 0
|
||||
choices := make([]interface{}, 0, len(wc))
|
||||
for choice, weight := range wc {
|
||||
total += int(weight)
|
||||
choices = append(choices, choice)
|
||||
}
|
||||
|
||||
rem := r.Intn(total)
|
||||
for _, choice := range choices {
|
||||
rem -= int(wc[choice])
|
||||
if rem <= 0 {
|
||||
return choice
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// probSetChoice picks a set of strings based on each string's probability (0-1).
|
||||
type probSetChoice map[string]float64
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ seeds = ["seed01"]
|
||||
seeds = ["seed01"]
|
||||
snapshot_interval = 5
|
||||
perturb = ["disconnect"]
|
||||
misbehaviors = { 1018 = "double-prevote" }
|
||||
|
||||
[node.validator02]
|
||||
seeds = ["seed02"]
|
||||
|
||||
+3
-47
@@ -7,7 +7,6 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -30,8 +29,6 @@ import (
|
||||
rpcserver "github.com/tendermint/tendermint/rpc/jsonrpc/server"
|
||||
"github.com/tendermint/tendermint/test/e2e/app"
|
||||
e2e "github.com/tendermint/tendermint/test/e2e/pkg"
|
||||
mcs "github.com/tendermint/tendermint/test/maverick/consensus"
|
||||
maverick "github.com/tendermint/tendermint/test/maverick/node"
|
||||
)
|
||||
|
||||
var logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout))
|
||||
@@ -75,14 +72,10 @@ func run(configFile string) error {
|
||||
case "socket", "grpc":
|
||||
err = startApp(cfg)
|
||||
case "builtin":
|
||||
if len(cfg.Misbehaviors) == 0 {
|
||||
if cfg.Mode == string(e2e.ModeLight) {
|
||||
err = startLightClient(cfg)
|
||||
} else {
|
||||
err = startNode(cfg)
|
||||
}
|
||||
if cfg.Mode == string(e2e.ModeLight) {
|
||||
err = startLightClient(cfg)
|
||||
} else {
|
||||
err = startMaverick(cfg)
|
||||
err = startNode(cfg)
|
||||
}
|
||||
default:
|
||||
err = fmt.Errorf("invalid protocol %q", cfg.Protocol)
|
||||
@@ -202,43 +195,6 @@ func startLightClient(cfg *Config) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// FIXME: Temporarily disconnected maverick until it is redesigned
|
||||
// startMaverick starts a Maverick node that runs the application directly. It assumes the Tendermint
|
||||
// configuration is in $TMHOME/config/tendermint.toml.
|
||||
func startMaverick(cfg *Config) error {
|
||||
app, err := app.NewApplication(cfg.App())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tmcfg, logger, nodeKey, err := setupNode()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to setup config: %w", err)
|
||||
}
|
||||
|
||||
misbehaviors := make(map[int64]mcs.Misbehavior, len(cfg.Misbehaviors))
|
||||
for heightString, misbehaviorString := range cfg.Misbehaviors {
|
||||
height, _ := strconv.ParseInt(heightString, 10, 64)
|
||||
misbehaviors[height] = mcs.MisbehaviorList[misbehaviorString]
|
||||
}
|
||||
|
||||
n, err := maverick.NewNode(tmcfg,
|
||||
maverick.LoadOrGenFilePV(tmcfg.PrivValidatorKeyFile(), tmcfg.PrivValidatorStateFile()),
|
||||
nodeKey,
|
||||
proxy.NewLocalClientCreator(app),
|
||||
maverick.DefaultGenesisDocProviderFunc(tmcfg),
|
||||
maverick.DefaultDBProvider,
|
||||
maverick.DefaultMetricsProvider(tmcfg.Instrumentation),
|
||||
logger,
|
||||
misbehaviors,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return n.Start()
|
||||
}
|
||||
|
||||
// startSigner starts a signer server connecting to the given endpoint.
|
||||
func startSigner(cfg *Config) error {
|
||||
filePV := privval.LoadFilePV(cfg.PrivValKey, cfg.PrivValState)
|
||||
|
||||
@@ -124,16 +124,6 @@ type ManifestNode struct {
|
||||
// pause: temporarily pauses (freezes) the node
|
||||
// restart: restarts the node, shutting it down with SIGTERM
|
||||
Perturb []string `toml:"perturb"`
|
||||
|
||||
// Misbehaviors sets how a validator behaves during consensus at a
|
||||
// certain height. Multiple misbehaviors at different heights can be used
|
||||
//
|
||||
// An example of misbehaviors
|
||||
// { 10 = "double-prevote", 20 = "double-prevote"}
|
||||
//
|
||||
// For more information, look at the readme in the maverick folder.
|
||||
// A list of all behaviors can be found in ../maverick/consensus/behavior.go
|
||||
Misbehaviors map[string]string `toml:"misbehaviors"`
|
||||
}
|
||||
|
||||
// Save saves the testnet manifest to a file.
|
||||
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
"github.com/tendermint/tendermint/crypto/secp256k1"
|
||||
rpchttp "github.com/tendermint/tendermint/rpc/client/http"
|
||||
mcs "github.com/tendermint/tendermint/test/maverick/consensus"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -85,7 +84,6 @@ type Node struct {
|
||||
Seeds []*Node
|
||||
PersistentPeers []*Node
|
||||
Perturbations []Perturbation
|
||||
Misbehaviors map[int64]string
|
||||
}
|
||||
|
||||
// LoadTestnet loads a testnet from a manifest file, using the filename to
|
||||
@@ -164,7 +162,6 @@ func LoadTestnet(file string) (*Testnet, error) {
|
||||
SnapshotInterval: nodeManifest.SnapshotInterval,
|
||||
RetainBlocks: nodeManifest.RetainBlocks,
|
||||
Perturbations: []Perturbation{},
|
||||
Misbehaviors: make(map[int64]string),
|
||||
}
|
||||
if node.StartAt == testnet.InitialHeight {
|
||||
node.StartAt = 0 // normalize to 0 for initial nodes, since code expects this
|
||||
@@ -187,13 +184,6 @@ func LoadTestnet(file string) (*Testnet, error) {
|
||||
for _, p := range nodeManifest.Perturb {
|
||||
node.Perturbations = append(node.Perturbations, Perturbation(p))
|
||||
}
|
||||
for heightString, misbehavior := range nodeManifest.Misbehaviors {
|
||||
height, err := strconv.ParseInt(heightString, 10, 64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to parse height %s to int64: %w", heightString, err)
|
||||
}
|
||||
node.Misbehaviors[height] = misbehavior
|
||||
}
|
||||
testnet.Nodes = append(testnet.Nodes, node)
|
||||
}
|
||||
|
||||
@@ -362,30 +352,6 @@ func (n Node) Validate(testnet Testnet) error {
|
||||
}
|
||||
}
|
||||
|
||||
if (n.PrivvalProtocol != "file" || n.Mode != "validator") && len(n.Misbehaviors) != 0 {
|
||||
return errors.New("must be using \"file\" privval protocol to implement misbehaviors")
|
||||
}
|
||||
|
||||
for height, misbehavior := range n.Misbehaviors {
|
||||
if height < n.StartAt {
|
||||
return fmt.Errorf("misbehavior height %d is below node start height %d",
|
||||
height, n.StartAt)
|
||||
}
|
||||
if height < testnet.InitialHeight {
|
||||
return fmt.Errorf("misbehavior height %d is below network initial height %d",
|
||||
height, testnet.InitialHeight)
|
||||
}
|
||||
exists := false
|
||||
for possibleBehaviors := range mcs.MisbehaviorList {
|
||||
if possibleBehaviors == misbehavior {
|
||||
exists = true
|
||||
}
|
||||
}
|
||||
if !exists {
|
||||
return fmt.Errorf("misbehavior %s does not exist", misbehavior)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -437,19 +403,6 @@ func (t Testnet) HasPerturbations() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// LastMisbehaviorHeight returns the height of the last misbehavior.
|
||||
func (t Testnet) LastMisbehaviorHeight() int64 {
|
||||
lastHeight := int64(0)
|
||||
for _, node := range t.Nodes {
|
||||
for height := range node.Misbehaviors {
|
||||
if height > lastHeight {
|
||||
lastHeight = height
|
||||
}
|
||||
}
|
||||
}
|
||||
return lastHeight
|
||||
}
|
||||
|
||||
// Address returns a P2P endpoint address for the node.
|
||||
func (n Node) AddressP2P(withID bool) string {
|
||||
ip := n.IP.String()
|
||||
|
||||
@@ -71,14 +71,6 @@ func NewCLI() *CLI {
|
||||
return err
|
||||
}
|
||||
|
||||
if lastMisbehavior := cli.testnet.LastMisbehaviorHeight(); lastMisbehavior > 0 {
|
||||
// wait for misbehaviors before starting perturbations. We do a separate
|
||||
// wait for another 5 blocks, since the last misbehavior height may be
|
||||
// in the past depending on network startup ordering.
|
||||
if err := WaitUntil(cli.testnet, lastMisbehavior); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := Wait(cli.testnet, 5); err != nil { // allow some txs to go through
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -168,9 +168,6 @@ services:
|
||||
image: tendermint/e2e-node
|
||||
{{- if eq .ABCIProtocol "builtin" }}
|
||||
entrypoint: /usr/bin/entrypoint-builtin
|
||||
{{- else if .Misbehaviors }}
|
||||
entrypoint: /usr/bin/entrypoint-maverick
|
||||
command: ["node", "--misbehaviors", "{{ misbehaviorsToString .Misbehaviors }}"]
|
||||
{{- end }}
|
||||
init: true
|
||||
ports:
|
||||
@@ -369,12 +366,6 @@ func MakeAppConfig(node *e2e.Node) ([]byte, error) {
|
||||
}
|
||||
}
|
||||
|
||||
misbehaviors := make(map[string]string)
|
||||
for height, misbehavior := range node.Misbehaviors {
|
||||
misbehaviors[strconv.Itoa(int(height))] = misbehavior
|
||||
}
|
||||
cfg["misbehaviors"] = misbehaviors
|
||||
|
||||
if len(node.Testnet.ValidatorUpdates) > 0 {
|
||||
validatorUpdates := map[string]map[string]int64{}
|
||||
for height, validators := range node.Testnet.ValidatorUpdates {
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
package e2e_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
e2e "github.com/tendermint/tendermint/test/e2e/pkg"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
// assert that all nodes that have blocks at the height of a misbehavior has evidence
|
||||
// for that misbehavior
|
||||
func TestEvidence_Misbehavior(t *testing.T) {
|
||||
blocks := fetchBlockChain(t)
|
||||
testNode(t, func(t *testing.T, node e2e.Node) {
|
||||
seenEvidence := make(map[int64]struct{})
|
||||
for _, block := range blocks {
|
||||
// Find any evidence blaming this node in this block
|
||||
var nodeEvidence types.Evidence
|
||||
for _, evidence := range block.Evidence.Evidence {
|
||||
switch evidence := evidence.(type) {
|
||||
case *types.DuplicateVoteEvidence:
|
||||
if bytes.Equal(evidence.VoteA.ValidatorAddress, node.PrivvalKey.PubKey().Address()) {
|
||||
nodeEvidence = evidence
|
||||
}
|
||||
default:
|
||||
t.Fatalf("unexpected evidence type %T", evidence)
|
||||
}
|
||||
}
|
||||
if nodeEvidence == nil {
|
||||
continue // no evidence for the node at this height
|
||||
}
|
||||
|
||||
// Check that evidence was as expected
|
||||
misbehavior, ok := node.Misbehaviors[nodeEvidence.Height()]
|
||||
require.True(t, ok, "found unexpected evidence %v in height %v",
|
||||
nodeEvidence, block.Height)
|
||||
|
||||
switch misbehavior {
|
||||
case "double-prevote":
|
||||
require.IsType(t, &types.DuplicateVoteEvidence{}, nodeEvidence, "unexpected evidence type")
|
||||
default:
|
||||
t.Fatalf("unknown misbehavior %v", misbehavior)
|
||||
}
|
||||
|
||||
seenEvidence[nodeEvidence.Height()] = struct{}{}
|
||||
}
|
||||
// see if there is any evidence that we were expecting but didn't see
|
||||
for height, misbehavior := range node.Misbehaviors {
|
||||
_, ok := seenEvidence[height]
|
||||
require.True(t, ok, "expected evidence for %v misbehavior at height %v by node but was never found",
|
||||
misbehavior, height)
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user