-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: v3 e2e upgrade #3910
base: main
Are you sure you want to change the base?
test: v3 e2e upgrade #3910
Changes from 28 commits
f917483
e0ed8c2
2e88e7d
3be733f
d22d7db
f3b91cb
b3d47e2
30eb9f5
0433ddc
e518b95
9e9a659
465c1a1
15ce3dc
f2396b5
e88b6d7
937d57f
0d9aceb
acbf9cc
0a17009
f5d6b44
135e5e3
c015c07
8990155
57648aa
762978e
713bd50
acc95b0
9641129
6e4fa05
11a01b0
ad88e29
eaa98a1
ae45da4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
"time" | ||
|
||
"github.com/celestiaorg/celestia-app/v3/app" | ||
v2 "github.com/celestiaorg/celestia-app/v3/pkg/appconsts/v2" | ||
v3 "github.com/celestiaorg/celestia-app/v3/pkg/appconsts/v3" | ||
"github.com/celestiaorg/celestia-app/v3/test/e2e/testnet" | ||
) | ||
|
||
func MajorUpgradeToV3(logger *log.Logger) error { | ||
numNodes := 4 | ||
upgradeHeightV3 := int64(20) | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
defer cancel() | ||
|
||
logger.Println("Creating testnet") | ||
testNet, err := testnet.New(ctx, "MajorUpgradeToV3", seed, nil, "test") | ||
rootulp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
testnet.NoError("failed to create testnet", err) | ||
|
||
defer testNet.Cleanup(ctx) | ||
|
||
// HACKHACK: use a version of celestia-app built from a commit on this PR. | ||
// This can be removed after the PR is merged to main. | ||
version := "pr-3910" | ||
rootulp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
logger.Println("Running major upgrade to v3 test", "version", version) | ||
|
||
consensusParams := app.DefaultConsensusParams() | ||
consensusParams.Version.AppVersion = v2.Version // Start the test on v2 | ||
rootulp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
testNet.SetConsensusParams(consensusParams) | ||
|
||
preloader, err := testNet.NewPreloader() | ||
testnet.NoError("failed to create preloader", err) | ||
|
||
err = preloader.AddImage(ctx, testnet.DockerImageName(version)) | ||
testnet.NoError("failed to add image", err) | ||
defer func() { _ = preloader.EmptyImages(ctx) }() | ||
|
||
logger.Println("Creating genesis nodes") | ||
for i := 0; i < numNodes; i++ { | ||
err := testNet.CreateGenesisNode(ctx, version, 10000000, 0, testnet.DefaultResources, true) | ||
testnet.NoError("failed to create genesis node", err) | ||
} | ||
|
||
logger.Println("Creating txsim") | ||
endpoints, err := testNet.RemoteGRPCEndpoints(ctx) | ||
testnet.NoError("failed to get remote gRPC endpoints", err) | ||
upgradeSchedule := map[int64]uint64{ | ||
upgradeHeightV3: v3.Version, | ||
} | ||
|
||
err = testNet.CreateTxClient(ctx, "txsim", version, 1, "100-2000", 100, testnet.DefaultResources, endpoints[0], upgradeSchedule) | ||
testnet.NoError("failed to create tx client", err) | ||
|
||
logger.Println("Setting up testnet") | ||
testnet.NoError("Failed to setup testnet", testNet.Setup(ctx)) | ||
logger.Println("Starting testnet") | ||
testnet.NoError("Failed to start testnet", testNet.Start(ctx)) | ||
|
||
timer := time.NewTimer(10 * time.Minute) | ||
defer timer.Stop() | ||
ticker := time.NewTicker(3 * time.Second) | ||
defer ticker.Stop() | ||
|
||
logger.Println("waiting for upgrade") | ||
for _, node := range testNet.Nodes() { | ||
client, err := node.Client() | ||
testnet.NoError("failed to get client", err) | ||
|
||
upgradeComplete := false | ||
lastHeight := int64(0) | ||
for !upgradeComplete { | ||
select { | ||
case <-timer.C: | ||
return fmt.Errorf("failed to upgrade to v3, last height: %d", lastHeight) | ||
case <-ticker.C: | ||
resp, err := client.Header(ctx, nil) | ||
testnet.NoError("failed to get header", err) | ||
if resp.Header.Version.App == v3.Version { | ||
Comment on lines
+84
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure error handling after retrieving the header. When calling Modify the code to handle the error appropriately: resp, err := client.Header(ctx, nil)
if err != nil {
testnet.NoError("failed to get header", err)
continue
} Make sure that |
||
upgradeComplete = true | ||
} | ||
fmt.Println("height", resp.Header.Height) | ||
rootulp marked this conversation as resolved.
Show resolved
Hide resolved
rootulp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
lastHeight = resp.Header.Height | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Handle timeouts and errors for each node individually. The current implementation shares the same timer across all nodes. If one node delays the upgrade, it could cause the entire test to fail, even if others have succeeded. Consider refactoring the code to handle timeouts and errors on a per-node basis to isolate issues and provide more detailed feedback. |
||
|
||
return nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package testnet | ||
|
||
import ( | ||
"io" | ||
"math/rand" | ||
|
||
"github.com/tendermint/tendermint/crypto" | ||
"github.com/tendermint/tendermint/crypto/ed25519" | ||
"github.com/tendermint/tendermint/crypto/secp256k1" | ||
) | ||
|
||
type keyGenerator struct { | ||
random *rand.Rand | ||
} | ||
|
||
func newKeyGenerator(seed int64) *keyGenerator { | ||
return &keyGenerator{ | ||
random: rand.New(rand.NewSource(seed)), //nolint:gosec | ||
} | ||
} | ||
|
||
func (g *keyGenerator) Generate(keyType string) crypto.PrivKey { | ||
seed := make([]byte, ed25519.SeedSize) | ||
|
||
_, err := io.ReadFull(g.random, seed) | ||
if err != nil { | ||
panic(err) // this shouldn't happen | ||
} | ||
switch keyType { | ||
case "secp256k1": | ||
return secp256k1.GenPrivKeySecp256k1(seed) | ||
case "", "ed25519": | ||
return ed25519.GenPrivKeyFromSecret(seed) | ||
default: | ||
panic("KeyType not supported") // should not make it this far | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the only remaining thing on this PR is to revert this change and plumb an override for the upgrade height via build flags (or something else).
cc: @cmwaters b/c I think you already have ideas for that via
celestia-app/Makefile
Line 16 in c7f26d6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can fix this after the PR merges in #3947