mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-15 09:12:50 +00:00
Compare commits
8 Commits
wb/simul-q
...
e2e-extend
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
542ad92bf7 | ||
|
|
58550fd5e0 | ||
|
|
c847de83e5 | ||
|
|
b519ba86fb | ||
|
|
ff54b9bd2b | ||
|
|
d5247ef88e | ||
|
|
5f7be78066 | ||
|
|
e73c772e38 |
@@ -33,14 +33,10 @@ func InjectEvidence(ctx context.Context, r *rand.Rand, testnet *e2e.Testnet, amo
|
||||
var targetNode *e2e.Node
|
||||
|
||||
for _, idx := range r.Perm(len(testnet.Nodes)) {
|
||||
targetNode = testnet.Nodes[idx]
|
||||
|
||||
if targetNode.Mode == e2e.ModeSeed || targetNode.Mode == e2e.ModeLight {
|
||||
targetNode = nil
|
||||
continue
|
||||
if !testnet.Nodes[idx].Stateless() {
|
||||
targetNode = testnet.Nodes[idx]
|
||||
break
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
if targetNode == nil {
|
||||
@@ -55,15 +51,14 @@ func InjectEvidence(ctx context.Context, r *rand.Rand, testnet *e2e.Testnet, amo
|
||||
}
|
||||
|
||||
// request the latest block and validator set from the node
|
||||
blockRes, err := client.Block(context.Background(), nil)
|
||||
blockRes, err := client.Block(ctx, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
evidenceHeight := blockRes.Block.Height
|
||||
waitHeight := blockRes.Block.Height + 3
|
||||
evidenceHeight := blockRes.Block.Height - 3
|
||||
|
||||
nValidators := 100
|
||||
valRes, err := client.Validators(context.Background(), &evidenceHeight, nil, &nValidators)
|
||||
valRes, err := client.Validators(ctx, &evidenceHeight, nil, &nValidators)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -79,12 +74,8 @@ func InjectEvidence(ctx context.Context, r *rand.Rand, testnet *e2e.Testnet, amo
|
||||
return err
|
||||
}
|
||||
|
||||
wctx, cancel := context.WithTimeout(ctx, time.Minute)
|
||||
defer cancel()
|
||||
|
||||
// wait for the node to reach the height above the forged height so that
|
||||
// it is able to validate the evidence
|
||||
_, err = waitForNode(wctx, targetNode, waitHeight)
|
||||
// request the latest block and validator set from the node
|
||||
blockRes, err = client.Block(ctx, &evidenceHeight)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -104,24 +95,28 @@ func InjectEvidence(ctx context.Context, r *rand.Rand, testnet *e2e.Testnet, amo
|
||||
return err
|
||||
}
|
||||
|
||||
_, err := client.BroadcastEvidence(context.Background(), ev)
|
||||
_, err := client.BroadcastEvidence(ctx, ev)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
wctx, cancel = context.WithTimeout(ctx, 30*time.Second)
|
||||
logger.Info("Finished sending evidence",
|
||||
"node", testnet.Name,
|
||||
"amount", amount,
|
||||
"height", evidenceHeight,
|
||||
)
|
||||
|
||||
wctx, cancel := context.WithTimeout(ctx, time.Minute)
|
||||
defer cancel()
|
||||
|
||||
// wait for the node to reach the height above the forged height so that
|
||||
// it is able to validate the evidence
|
||||
_, err = waitForNode(wctx, targetNode, blockRes.Block.Height+2)
|
||||
// wait for the node to make progress after submitting
|
||||
// evidence (3 (forged height) + 1 (progress))
|
||||
_, err = waitForNode(wctx, targetNode, evidenceHeight+4)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Info(fmt.Sprintf("Finished sending evidence (height %d)", blockRes.Block.Height+2))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ func waitForHeight(ctx context.Context, testnet *e2e.Testnet, height int64) (*ty
|
||||
clients[node.Name] = client
|
||||
}
|
||||
|
||||
wctx, cancel := context.WithTimeout(ctx, 10*time.Second)
|
||||
wctx, cancel := context.WithTimeout(ctx, 30*time.Second)
|
||||
defer cancel()
|
||||
result, err := client.Status(wctx)
|
||||
if err != nil {
|
||||
@@ -111,7 +111,7 @@ func waitForHeight(ctx context.Context, testnet *e2e.Testnet, height int64) (*ty
|
||||
if len(clients) == 0 {
|
||||
return nil, nil, errors.New("unable to connect to any network nodes")
|
||||
}
|
||||
if time.Since(lastIncrease) >= time.Minute {
|
||||
if time.Since(lastIncrease) >= 2*time.Minute {
|
||||
if lastHeight == 0 {
|
||||
return nil, nil, errors.New("chain stalled at unknown height (most likely upon starting)")
|
||||
}
|
||||
@@ -133,6 +133,7 @@ func waitForNode(ctx context.Context, node *e2e.Node, height int64) (*rpctypes.R
|
||||
if node.Mode == e2e.ModeSeed {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
client, err := node.Client()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -168,7 +169,7 @@ func waitForNode(ctx context.Context, node *e2e.Node, height int64) (*rpctypes.R
|
||||
case errors.Is(err, context.DeadlineExceeded):
|
||||
return nil, fmt.Errorf("timed out waiting for %v to reach height %v", node.Name, height)
|
||||
case errors.Is(err, context.Canceled):
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("cancellation while waiting for %v", node.Name, err)
|
||||
case err == nil && status.SyncInfo.LatestBlockHeight >= height:
|
||||
return status, nil
|
||||
case counter%500 == 0:
|
||||
|
||||
@@ -48,13 +48,13 @@ func Start(ctx context.Context, testnet *e2e.Testnet) error {
|
||||
}
|
||||
|
||||
if err := func() error {
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Minute)
|
||||
ctx, cancel := context.WithTimeout(ctx, 2*time.Minute)
|
||||
defer cancel()
|
||||
|
||||
_, err := waitForNode(ctx, node, 0)
|
||||
return err
|
||||
}(); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("problem starting node %q: %w", node.Name, err)
|
||||
}
|
||||
node.HasStarted = true
|
||||
logger.Info(fmt.Sprintf("Node %v up on http://127.0.0.1:%v", node.Name, node.ProxyPort))
|
||||
@@ -93,7 +93,8 @@ func Start(ctx context.Context, testnet *e2e.Testnet) error {
|
||||
|
||||
block, blockID, err = waitForHeight(ctx, testnet, networkHeight)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("waiting for node %q to get to %q: %w",
|
||||
node.Name, networkHeight, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,14 +107,22 @@ func Start(ctx context.Context, testnet *e2e.Testnet) error {
|
||||
}
|
||||
|
||||
if err := execCompose(testnet.Dir, "up", "-d", node.Name); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("starting node %q: %w", node.Name, err)
|
||||
}
|
||||
|
||||
if node.Mode == e2e.ModeLight {
|
||||
logger.Info(fmt.Sprintf("Light node %q up on http://127.0.0.1:%v",
|
||||
node.Name, node.ProxyPort, status.SyncInfo.LatestBlockHeight))
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
wctx, wcancel := context.WithTimeout(ctx, 8*time.Minute)
|
||||
status, err := waitForNode(wctx, node, node.StartAt)
|
||||
if err != nil {
|
||||
wcancel()
|
||||
return err
|
||||
return fmt.Errorf("waiting for %q to progress to %d: %w",
|
||||
node.Name, node.StartAt, err)
|
||||
}
|
||||
wcancel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user