From 76d6c530cbd2053d467108b6ec164c80c30abf79 Mon Sep 17 00:00:00 2001 From: smuu <18609909+smuu@users.noreply.github.com> Date: Wed, 11 Dec 2024 15:45:02 +0100 Subject: [PATCH] feat(e2e/knuu): use latest release and prepare for node knuu tests (#4086) Closes https://github.com/celestiaorg/celestia-app/issues/4075 ## Overview This PR: - Uses the latest release of knuu with fixes - Prepares the testnet to be used by celestia-node --------- Signed-off-by: Smuu <18609909+Smuu@users.noreply.github.com> --- go.mod | 14 +- go.sum | 32 ++--- test/e2e/benchmark/benchmark.go | 8 +- test/e2e/benchmark/throughput.go | 6 +- test/e2e/major_upgrade_v2.go | 4 +- test/e2e/major_upgrade_v3.go | 4 +- test/e2e/minor_version_compatibility.go | 4 +- test/e2e/simple.go | 4 +- test/e2e/testnet/node.go | 68 ++++------ test/e2e/testnet/setup.go | 6 +- test/e2e/testnet/testnet.go | 165 +++++++++++++----------- test/e2e/testnet/txsimNode.go | 19 +-- test/e2e/testnet/util.go | 11 +- 13 files changed, 170 insertions(+), 175 deletions(-) diff --git a/go.mod b/go.mod index 6ddc9b7eb3..f0840355c2 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/celestiaorg/blobstream-contracts/v3 v3.1.0 github.com/celestiaorg/go-square v1.1.1 github.com/celestiaorg/go-square/v2 v2.1.0 - github.com/celestiaorg/knuu v0.16.1 + github.com/celestiaorg/knuu v0.16.2 github.com/celestiaorg/nmt v0.22.2 github.com/celestiaorg/rsmt2d v0.14.0 github.com/cometbft/cometbft-db v1.0.1 @@ -227,13 +227,13 @@ require ( go.opentelemetry.io/otel/trace v1.30.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/crypto v0.27.0 // indirect - golang.org/x/net v0.29.0 // indirect + golang.org/x/crypto v0.29.0 // indirect + golang.org/x/net v0.31.0 // indirect golang.org/x/oauth2 v0.23.0 // indirect - golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.25.0 // indirect - golang.org/x/term v0.24.0 // indirect - golang.org/x/text v0.18.0 // indirect + golang.org/x/sync v0.9.0 // indirect + golang.org/x/sys v0.27.0 // indirect + golang.org/x/term v0.26.0 // indirect + golang.org/x/text v0.20.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/api v0.169.0 // indirect google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect diff --git a/go.sum b/go.sum index dc62f3ea98..9948c0323d 100644 --- a/go.sum +++ b/go.sum @@ -325,8 +325,8 @@ github.com/celestiaorg/go-square v1.1.1 h1:Cy3p8WVspVcyOqHM8BWFuuYPwMitO1pYGe+Im github.com/celestiaorg/go-square v1.1.1/go.mod h1:1EXMErhDrWJM8B8V9hN7dqJ2kUTClfwdqMOmF9yQUa0= github.com/celestiaorg/go-square/v2 v2.1.0 h1:ECIvYEeHIWiIJGDCJxQNtzqm5DmnBly7XGhSpLsl+Lw= github.com/celestiaorg/go-square/v2 v2.1.0/go.mod h1:n3ztrh8CBjWOD6iWYMo3pPOlQIgzLK9yrnqMPcNo6g8= -github.com/celestiaorg/knuu v0.16.1 h1:EOR/c9kvc0jZet/mma2qwAdlvEbl94bW9cC8FItkyBE= -github.com/celestiaorg/knuu v0.16.1/go.mod h1:y20nUmVWVgbzxBKHqmbwp3C0ZJ9J9ovCg1ylHo85hdQ= +github.com/celestiaorg/knuu v0.16.2 h1:OOl2xMf+5ryWtPcSF+M6gmw4YQPEh6lsCA/lTDl8fwI= +github.com/celestiaorg/knuu v0.16.2/go.mod h1:nB7IGCR984YKEDW+j5xHPOidYfbO4DoZI1rDKijvF5E= github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4 h1:CJdIpo8n5MFP2MwK0gSRcOVlDlFdQJO1p+FqdxYzmvc= github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4/go.mod h1:fzuHnhzj1pUygGz+1ZkB3uQbEUL4htqCGJ4Qs2LwMZA= github.com/celestiaorg/nmt v0.22.2 h1:JmOMtZL9zWAed1hiwb9DDs+ELcKp/ZQZ3rPverge/V8= @@ -1405,8 +1405,8 @@ golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWP golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= -golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= +golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ= +golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1514,8 +1514,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= -golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= +golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= +golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1557,8 +1557,8 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= +golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1669,14 +1669,14 @@ golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= -golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= -golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= +golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU= +golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1687,8 +1687,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= -golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= +golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1761,8 +1761,8 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.25.0 h1:oFU9pkj/iJgs+0DT+VMHrx+oBKs/LJMV+Uvg78sl+fE= -golang.org/x/tools v0.25.0/go.mod h1:/vtpO8WL1N9cQC3FN5zPqb//fRXskFHbLKk4OW1Q7rg= +golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o= +golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/test/e2e/benchmark/benchmark.go b/test/e2e/benchmark/benchmark.go index 5af7b8539e..95e713bd69 100644 --- a/test/e2e/benchmark/benchmark.go +++ b/test/e2e/benchmark/benchmark.go @@ -24,7 +24,7 @@ type BenchmarkTest struct { // NewBenchmarkTest wraps around testnet.New to create a new benchmark test. // It may modify genesis consensus parameters based on manifest. -func NewBenchmarkTest(name string, manifest *Manifest) (*BenchmarkTest, error) { +func NewBenchmarkTest(logger *log.Logger, name string, manifest *Manifest) (*BenchmarkTest, error) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -42,8 +42,8 @@ func NewBenchmarkTest(name string, manifest *Manifest) (*BenchmarkTest, error) { log.Printf("Knuu initialized with scope %s", kn.Scope) - testNet, err := testnet.New(kn, testnet.Options{ - Grafana: testnet.GetGrafanaInfoFromEnvVar(), + testNet, err := testnet.New(logger, kn, testnet.Options{ + Grafana: testnet.GetGrafanaInfoFromEnvVar(logger), ChainID: manifest.ChainID, GenesisModifiers: manifest.GetGenesisModifiers(), }) @@ -70,7 +70,7 @@ func (b *BenchmarkTest) SetupNodes() error { } } // obtain the GRPC endpoints of the validators - gRPCEndpoints, err := b.RemoteGRPCEndpoints(ctx) + gRPCEndpoints, err := b.RemoteGRPCEndpoints() testnet.NoError("failed to get validators GRPC endpoints", err) log.Println("validators GRPC endpoints", gRPCEndpoints) diff --git a/test/e2e/benchmark/throughput.go b/test/e2e/benchmark/throughput.go index 75bf1bdf6c..e3f83d49c8 100644 --- a/test/e2e/benchmark/throughput.go +++ b/test/e2e/benchmark/throughput.go @@ -90,7 +90,7 @@ func TwoNodeSimple(logger *log.Logger) error { DisableBBR: true, } - benchTest, err := NewBenchmarkTest(testName, &manifest) + benchTest, err := NewBenchmarkTest(logger, testName, &manifest) testnet.NoError("failed to create benchmark test", err) ctx, cancel := context.WithCancel(context.Background()) @@ -113,8 +113,8 @@ func TwoNodeSimple(logger *log.Logger) error { func runBenchmarkTest(logger *log.Logger, testName string, manifest Manifest) error { logger.Println("Running", testName) manifest.ChainID = manifest.summary() - log.Println("ChainID: ", manifest.ChainID) - benchTest, err := NewBenchmarkTest(testName, &manifest) + logger.Println("ChainID: ", manifest.ChainID) + benchTest, err := NewBenchmarkTest(logger, testName, &manifest) testnet.NoError("failed to create benchmark test", err) ctx, cancel := context.WithCancel(context.Background()) diff --git a/test/e2e/major_upgrade_v2.go b/test/e2e/major_upgrade_v2.go index 3e44eb0bc3..03383124ae 100644 --- a/test/e2e/major_upgrade_v2.go +++ b/test/e2e/major_upgrade_v2.go @@ -35,7 +35,7 @@ func MajorUpgradeToV2(logger *log.Logger) error { logger.Printf("Knuu initialized with scope %s", kn.Scope) logger.Println("Creating testnet") - testNet, err := testnet.New(kn, testnet.Options{}) + testNet, err := testnet.New(logger, kn, testnet.Options{}) testnet.NoError("failed to create testnet", err) defer testNet.Cleanup(ctx) @@ -60,7 +60,7 @@ func MajorUpgradeToV2(logger *log.Logger) error { } logger.Println("Creating txsim") - endpoints, err := testNet.RemoteGRPCEndpoints(ctx) + endpoints, err := testNet.RemoteGRPCEndpoints() testnet.NoError("failed to get remote gRPC endpoints", err) upgradeSchedule := map[int64]uint64{} err = testNet.CreateTxClient(ctx, "txsim", testnet.TxsimVersion, 1, "100-2000", 100, testnet.DefaultResources, endpoints[0], upgradeSchedule) diff --git a/test/e2e/major_upgrade_v3.go b/test/e2e/major_upgrade_v3.go index 35cb79b045..910022a22b 100644 --- a/test/e2e/major_upgrade_v3.go +++ b/test/e2e/major_upgrade_v3.go @@ -34,7 +34,7 @@ func MajorUpgradeToV3(logger *log.Logger) error { logger.Printf("Knuu initialized with scope %s", kn.Scope) logger.Println("Creating testnet") - testNet, err := testnet.New(kn, testnet.Options{}) + testNet, err := testnet.New(logger, kn, testnet.Options{}) testnet.NoError("failed to create testnet", err) defer testNet.Cleanup(ctx) @@ -60,7 +60,7 @@ func MajorUpgradeToV3(logger *log.Logger) error { } logger.Println("Creating txsim") - endpoints, err := testNet.RemoteGRPCEndpoints(ctx) + endpoints, err := testNet.RemoteGRPCEndpoints() testnet.NoError("failed to get remote gRPC endpoints", err) upgradeSchedule := map[int64]uint64{ upgradeHeightV3: v3.Version, diff --git a/test/e2e/minor_version_compatibility.go b/test/e2e/minor_version_compatibility.go index bb81d5e021..ab9b0580e4 100644 --- a/test/e2e/minor_version_compatibility.go +++ b/test/e2e/minor_version_compatibility.go @@ -50,7 +50,7 @@ func MinorVersionCompatibility(logger *log.Logger) error { kn.HandleStopSignal(ctx) logger.Printf("Knuu initialized with scope %s", kn.Scope) - testNet, err := testnet.New(kn, testnet.Options{Seed: seed}) + testNet, err := testnet.New(logger, kn, testnet.Options{Seed: seed}) testnet.NoError("failed to create testnet", err) defer testNet.Cleanup(ctx) @@ -76,7 +76,7 @@ func MinorVersionCompatibility(logger *log.Logger) error { } logger.Println("Creating txsim") - endpoints, err := testNet.RemoteGRPCEndpoints(ctx) + endpoints, err := testNet.RemoteGRPCEndpoints() testnet.NoError("failed to get remote gRPC endpoints", err) upgradeSchedule := map[int64]uint64{} err = testNet.CreateTxClient(ctx, "txsim", testnet.TxsimVersion, 1, "100-2000", 100, testnet.DefaultResources, endpoints[0], upgradeSchedule) diff --git a/test/e2e/simple.go b/test/e2e/simple.go index 8dab0278eb..50a0faab46 100644 --- a/test/e2e/simple.go +++ b/test/e2e/simple.go @@ -30,7 +30,7 @@ func E2ESimple(logger *log.Logger) error { kn.HandleStopSignal(ctx) logger.Printf("Knuu initialized with scope %s", kn.Scope) - testNet, err := testnet.New(kn, testnet.Options{}) + testNet, err := testnet.New(logger, kn, testnet.Options{}) testnet.NoError("failed to create testnet", err) defer testNet.Cleanup(ctx) @@ -44,7 +44,7 @@ func E2ESimple(logger *log.Logger) error { testNet.CreateGenesisNodes(ctx, 4, latestVersion, 10000000, 0, testnet.DefaultResources, true)) logger.Println("Creating txsim") - endpoints, err := testNet.RemoteGRPCEndpoints(ctx) + endpoints, err := testNet.RemoteGRPCEndpoints() testnet.NoError("failed to get remote gRPC endpoints", err) upgradeSchedule := map[int64]uint64{} err = testNet.CreateTxClient(ctx, "txsim", testnet.TxsimVersion, 10, "100-2000", 100, testnet.DefaultResources, endpoints[0], upgradeSchedule) diff --git a/test/e2e/testnet/node.go b/test/e2e/testnet/node.go index cf96ee905d..e640fa97cb 100644 --- a/test/e2e/testnet/node.go +++ b/test/e2e/testnet/node.go @@ -4,11 +4,11 @@ package testnet import ( "context" "fmt" + "log" "os" "path/filepath" serverconfig "github.com/cosmos/cosmos-sdk/server/config" - "github.com/rs/zerolog/log" "github.com/tendermint/tendermint/config" "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/p2p" @@ -55,13 +55,15 @@ type Node struct { // FIXME: This does not work currently with the reverse proxy // grpcProxyHost string traceProxyHost string + + logger *log.Logger } // PullRoundStateTraces retrieves the round state traces from a node. // It will save them to the provided path. func (n *Node) PullRoundStateTraces(path string) ([]trace.Event[schema.RoundState], error) { addr := n.AddressTracing() - log.Info().Str("Address", addr).Msg("Pulling round state traces") + n.logger.Println("Pulling round state traces", "address", addr) err := trace.GetTable(addr, schema.RoundState{}.Table(), path) if err != nil { @@ -74,7 +76,7 @@ func (n *Node) PullRoundStateTraces(path string) ([]trace.Event[schema.RoundStat // It will save them to the provided path. func (n *Node) PullBlockSummaryTraces(path string) ([]trace.Event[schema.BlockSummary], error) { addr := n.AddressTracing() - log.Info().Str("Address", addr).Msg("Pulling block summary traces") + n.logger.Println("Pulling block summary traces", "address", addr) err := trace.GetTable(addr, schema.BlockSummary{}.Table(), path) if err != nil { @@ -97,6 +99,7 @@ type Resources struct { func NewNode( ctx context.Context, + logger *log.Logger, name string, version string, startHeight int64, @@ -178,6 +181,7 @@ func NewNode( NetworkKey: networkKey, SelfDelegation: selfDelegation, sidecars: sidecars, + logger: logger, }, nil } @@ -199,11 +203,13 @@ func (n *Node) Init(ctx context.Context, genesis *types.GenesisDoc, peers []stri } // Initialize file directories - rootDir := os.TempDir() - nodeDir := filepath.Join(rootDir, n.Name) - log.Info().Str("name", n.Name). - Str("directory", nodeDir). - Msg("Creating validator's config and data directories") + tmpDir, err := os.MkdirTemp("", "e2e_test_") + if err != nil { + return fmt.Errorf("failed to create temp dir: %w", err) + } + defer os.RemoveAll(tmpDir) + nodeDir := filepath.Join(tmpDir, n.Name) + n.logger.Println("Creating validator's config and data directories", "name", n.Name, "directory", nodeDir) for _, dir := range []string{ filepath.Join(nodeDir, "config"), filepath.Join(nodeDir, "data"), @@ -214,7 +220,7 @@ func (n *Node) Init(ctx context.Context, genesis *types.GenesisDoc, peers []stri } // Create and write the config file - cfg, err := MakeConfig(ctx, n, configOptions...) + cfg, err := MakeConfig(n, peers, configOptions...) if err != nil { return fmt.Errorf("making config: %w", err) } @@ -253,12 +259,6 @@ func (n *Node) Init(ctx context.Context, genesis *types.GenesisDoc, peers []stri pvStatePath := filepath.Join(nodeDir, "data", "priv_validator_state.json") (privval.NewFilePV(n.SignerKey, pvKeyPath, pvStatePath)).Save() - addrBookFile := filepath.Join(nodeDir, "config", "addrbook.json") - err = WriteAddressBook(peers, addrBookFile) - if err != nil { - return fmt.Errorf("writing address book: %w", err) - } - if err := n.Instance.Build().Commit(ctx); err != nil { return fmt.Errorf("committing instance: %w", err) } @@ -278,12 +278,9 @@ func (n *Node) Init(ctx context.Context, genesis *types.GenesisDoc, peers []stri // AddressP2P returns a P2P endpoint address for the node. This is used for // populating the address book. This will look something like: // 3314051954fc072a0678ec0cbac690ad8676ab98@61.108.66.220:26656 -func (n Node) AddressP2P(ctx context.Context, withID bool) string { - ip, err := n.Instance.Network().GetIP(ctx) - if err != nil { - panic(err) - } - addr := fmt.Sprintf("%v:%d", ip, p2pPort) +func (n Node) AddressP2P(withID bool) string { + hostName := n.Instance.Network().HostName() + addr := fmt.Sprintf("%v:%d", hostName, p2pPort) if withID { addr = fmt.Sprintf("%x@%v", n.NetworkKey.PubKey().Address().Bytes(), addr) } @@ -304,33 +301,24 @@ func (n Node) AddressRPC() string { // } // RemoteAddressGRPC retrieves the gRPC endpoint address of a node within the cluster. -func (n Node) RemoteAddressGRPC(ctx context.Context) (string, error) { - ip, err := n.Instance.Network().GetIP(ctx) - if err != nil { - return "", err - } - return fmt.Sprintf("%s:%d", ip, grpcPort), nil +func (n Node) RemoteAddressGRPC() (string, error) { + hostName := n.Instance.Network().HostName() + return fmt.Sprintf("%s:%d", hostName, grpcPort), nil } // RemoteAddressRPC retrieves the RPC endpoint address of a node within the cluster. -func (n Node) RemoteAddressRPC(ctx context.Context) (string, error) { - ip, err := n.Instance.Network().GetIP(ctx) - if err != nil { - return "", err - } - return fmt.Sprintf("%s:%d", ip, rpcPort), nil +func (n Node) RemoteAddressRPC() (string, error) { + hostName := n.Instance.Network().HostName() + return fmt.Sprintf("%s:%d", hostName, rpcPort), nil } func (n Node) AddressTracing() string { return n.traceProxyHost } -func (n Node) RemoteAddressTracing(ctx context.Context) (string, error) { - ip, err := n.Instance.Network().GetIP(ctx) - if err != nil { - return "", err - } - return fmt.Sprintf("http://%s:26661", ip), nil +func (n Node) RemoteAddressTracing() (string, error) { + hostName := n.Instance.Network().HostName() + return fmt.Sprintf("http://%s:26661", hostName), nil } func (n Node) IsValidator() bool { @@ -338,7 +326,7 @@ func (n Node) IsValidator() bool { } func (n Node) Client() (*http.HTTP, error) { - log.Debug().Str("RPC Address", n.AddressRPC()).Msg("Creating HTTP client for node") + n.logger.Println("Creating HTTP client for node", "rpc_address", n.AddressRPC()) return http.New(n.AddressRPC(), "/websocket") } diff --git a/test/e2e/testnet/setup.go b/test/e2e/testnet/setup.go index d7db215c34..33b64973c6 100644 --- a/test/e2e/testnet/setup.go +++ b/test/e2e/testnet/setup.go @@ -1,7 +1,6 @@ package testnet import ( - "context" "fmt" "strings" "time" @@ -13,15 +12,14 @@ import ( "github.com/tendermint/tendermint/p2p/pex" ) -func MakeConfig(ctx context.Context, node *Node, opts ...Option) (*config.Config, error) { +func MakeConfig(node *Node, peers []string, opts ...Option) (*config.Config, error) { cfg := app.DefaultConsensusConfig() cfg.TxIndex.Indexer = "kv" cfg.Consensus.TimeoutPropose = config.DefaultConsensusConfig().TimeoutPropose cfg.Consensus.TimeoutCommit = config.DefaultConsensusConfig().TimeoutCommit cfg.Moniker = node.Name cfg.RPC.ListenAddress = "tcp://0.0.0.0:26657" - cfg.P2P.ExternalAddress = fmt.Sprintf("tcp://%v", node.AddressP2P(ctx, false)) - cfg.P2P.PersistentPeers = strings.Join(node.InitialPeers, ",") + cfg.P2P.PersistentPeers = strings.Join(peers, ",") cfg.Instrumentation.Prometheus = true for _, opt := range opts { diff --git a/test/e2e/testnet/testnet.go b/test/e2e/testnet/testnet.go index 7cc74fb011..31ff18cabf 100644 --- a/test/e2e/testnet/testnet.go +++ b/test/e2e/testnet/testnet.go @@ -5,6 +5,7 @@ import ( "context" "errors" "fmt" + "log" "os" "path/filepath" "time" @@ -16,7 +17,6 @@ import ( "github.com/celestiaorg/knuu/pkg/preloader" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" - "github.com/rs/zerolog/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) @@ -26,13 +26,17 @@ const ( ) type Testnet struct { - seed int64 - nodes []*Node - genesis *genesis.Genesis - keygen *keyGenerator - grafana *GrafanaInfo - txClients []*TxSim - knuu *knuu.Knuu + seed int64 + nodes []*Node + genesis *genesis.Genesis + keygen *keyGenerator + grafana *GrafanaInfo + txClients []*TxSim + knuu *knuu.Knuu + chainID string + genesisHash string + + logger *log.Logger } type Options struct { @@ -42,15 +46,18 @@ type Options struct { GenesisModifiers []genesis.Modifier } -func New(knuu *knuu.Knuu, opts Options) (*Testnet, error) { +func New(logger *log.Logger, knuu *knuu.Knuu, opts Options) (*Testnet, error) { opts.setDefaults() return &Testnet{ - seed: opts.Seed, - nodes: make([]*Node, 0), - genesis: genesis.NewDefaultGenesis().WithChainID(opts.ChainID).WithModifiers(opts.GenesisModifiers...), - keygen: newKeyGenerator(opts.Seed), - grafana: opts.Grafana, - knuu: knuu, + seed: opts.Seed, + nodes: make([]*Node, 0), + genesis: genesis.NewDefaultGenesis().WithChainID(opts.ChainID).WithModifiers(opts.GenesisModifiers...), + keygen: newKeyGenerator(opts.Seed), + grafana: opts.Grafana, + knuu: knuu, + chainID: opts.ChainID, + genesisHash: "", + logger: logger, }, nil } @@ -74,7 +81,7 @@ func (t *Testnet) SetConsensusMaxBlockSize(size int64) { func (t *Testnet) CreateGenesisNode(ctx context.Context, version string, selfDelegation, upgradeHeightV2 int64, resources Resources, disableBBR bool) error { signerKey := t.keygen.Generate(ed25519Type) networkKey := t.keygen.Generate(ed25519Type) - node, err := NewNode(ctx, fmt.Sprintf("val%d", len(t.nodes)), version, 0, selfDelegation, nil, signerKey, networkKey, upgradeHeightV2, resources, t.grafana, t.knuu, disableBBR) + node, err := NewNode(ctx, t.logger, fmt.Sprintf("val%d", len(t.nodes)), version, 0, selfDelegation, nil, signerKey, networkKey, upgradeHeightV2, resources, t.grafana, t.knuu, disableBBR) if err != nil { return err } @@ -107,15 +114,10 @@ func (t *Testnet) CreateTxClients(ctx context.Context, name := fmt.Sprintf("txsim%d", i) err := t.CreateTxClient(ctx, name, version, sequences, blobRange, blobPerSequence, resources, grpcEndpoint, upgradeSchedule) if err != nil { - log.Err(err).Str("name", name). - Str("grpc endpoint", grpcEndpoint). - Msg("txsim creation failed") + t.logger.Println("txsim creation failed", "name", name, "grpc_endpoint", grpcEndpoint, "error", err) return err } - log.Info(). - Str("name", name). - Str("grpc endpoint", grpcEndpoint). - Msg("txsim created") + t.logger.Println("txsim created", "name", name, "grpc_endpoint", grpcEndpoint) } return nil } @@ -143,8 +145,12 @@ func (t *Testnet) CreateTxClient( grpcEndpoint string, upgradeSchedule map[int64]uint64, ) error { - txsimKeyringDir := filepath.Join(os.TempDir(), name) - defer os.RemoveAll(txsimKeyringDir) + tmpDir, err := os.MkdirTemp("", "e2e_test_") + if err != nil { + return fmt.Errorf("failed to create temp dir: %w", err) + } + defer os.RemoveAll(tmpDir) + txsimKeyringDir := filepath.Join(tmpDir, name) config := encoding.MakeConfig(app.ModuleEncodingRegisters...).Codec txsimKeyring, err := keyring.New(app.Name, keyring.BackendTest, txsimKeyringDir, nil, config) @@ -182,29 +188,22 @@ func (t *Testnet) CreateTxClient( } } - txsim, err := CreateTxClient(ctx, name, version, grpcEndpoint, t.seed, blobSequences, blobRange, blobPerSequence, 1, resources, txsimKeyringDir, t.knuu, upgradeSchedule) + txsim, err := CreateTxClient(ctx, t.logger, name, version, grpcEndpoint, t.seed, blobSequences, blobRange, blobPerSequence, 1, resources, remoteRootDir, t.knuu, upgradeSchedule) if err != nil { - log.Err(err). - Str("name", name). - Msg("error creating txsim") + t.logger.Println("error creating txsim", "name", name, "error", err) return err } err = txsim.Instance.Build().Commit(ctx) if err != nil { - log.Err(err). - Str("name", name). - Msg("error committing txsim") + t.logger.Println("error committing txsim", "name", name, "error", err) return err } // copy over the keyring directory to the txsim instance - err = txsim.Instance.Storage().AddFolder(txsimKeyringDir, txsimKeyringDir, "10001:10001") + err = txsim.Instance.Storage().AddFolder(txsimKeyringDir, remoteRootDir, "10001:10001") if err != nil { - log.Err(err). - Str("directory", txsimKeyringDir). - Str("name", name). - Msg("error adding keyring dir to txsim") + t.logger.Println("error adding keyring dir to txsim", "directory", txsimKeyringDir, "name", name, "error", err) return err } @@ -216,14 +215,10 @@ func (t *Testnet) StartTxClients(ctx context.Context) error { for _, txsim := range t.txClients { err := txsim.Instance.Execution().StartAsync(ctx) if err != nil { - log.Err(err). - Str("name", txsim.Name). - Msg("txsim failed to start") + t.logger.Println("txsim failed to start", "name", txsim.Name, "error", err) return err } - log.Info(). - Str("name", txsim.Name). - Msg("txsim started") + t.logger.Println("txsim started", "name", txsim.Name) } // wait for txsims to start for _, txsim := range t.txClients { @@ -271,17 +266,14 @@ func (t *Testnet) CreateAccount(name string, tokens int64, txsimKeyringDir strin return nil, err } - log.Info(). - Str("name", name). - Str("pk", pk.String()). - Msg("txsim account created and added to genesis") + t.logger.Println("txsim account created and added to genesis", "name", name, "pk", pk.String()) return kr, nil } func (t *Testnet) CreateNode(ctx context.Context, version string, startHeight, upgradeHeight int64, resources Resources, disableBBR bool) error { signerKey := t.keygen.Generate(ed25519Type) networkKey := t.keygen.Generate(ed25519Type) - node, err := NewNode(ctx, fmt.Sprintf("val%d", len(t.nodes)), version, startHeight, 0, nil, signerKey, networkKey, upgradeHeight, resources, t.grafana, t.knuu, disableBBR) + node, err := NewNode(ctx, t.logger, fmt.Sprintf("val%d", len(t.nodes)), version, startHeight, 0, nil, signerKey, networkKey, upgradeHeight, resources, t.grafana, t.knuu, disableBBR) if err != nil { return err } @@ -297,11 +289,11 @@ func (t *Testnet) Setup(ctx context.Context, configOpts ...Option) error { for _, node := range t.nodes { // nodes are initialized with the addresses of all other - // nodes in their addressbook + // nodes as trusted peers peers := make([]string, 0, len(t.nodes)-1) for _, peer := range t.nodes { if peer.Name != node.Name { - peers = append(peers, peer.AddressP2P(ctx, true)) + peers = append(peers, peer.AddressP2P(true)) } } @@ -333,10 +325,10 @@ func (t *Testnet) RPCEndpoints() []string { // RemoteGRPCEndpoints retrieves the gRPC endpoint addresses of the // testnet's validator nodes. -func (t *Testnet) RemoteGRPCEndpoints(ctx context.Context) ([]string, error) { +func (t *Testnet) RemoteGRPCEndpoints() ([]string, error) { grpcEndpoints := make([]string, len(t.nodes)) for idx, node := range t.nodes { - grpcEP, err := node.RemoteAddressGRPC(ctx) + grpcEP, err := node.RemoteAddressGRPC() if err != nil { return nil, err } @@ -355,10 +347,10 @@ func (t *Testnet) GetGenesisValidators() []genesis.Validator { // RemoteRPCEndpoints retrieves the RPC endpoint addresses of the testnet's // validator nodes. -func (t *Testnet) RemoteRPCEndpoints(ctx context.Context) ([]string, error) { +func (t *Testnet) RemoteRPCEndpoints() ([]string, error) { rpcEndpoints := make([]string, len(t.nodes)) for idx, node := range t.nodes { - grpcEP, err := node.RemoteAddressRPC(ctx) + grpcEP, err := node.RemoteAddressRPC() if err != nil { return nil, err } @@ -367,6 +359,8 @@ func (t *Testnet) RemoteRPCEndpoints(ctx context.Context) ([]string, error) { return rpcEndpoints, nil } +const maxSyncAttempts = 20 + // WaitToSync waits for the started nodes to sync with the network and move // past the genesis block. func (t *Testnet) WaitToSync(ctx context.Context) error { @@ -378,29 +372,28 @@ func (t *Testnet) WaitToSync(ctx context.Context) error { } for _, node := range genesisNodes { - log.Info().Str("name", node.Name).Msg( - "waiting for node to sync") + t.logger.Println("waiting for node to sync", "name", node.Name) client, err := node.Client() if err != nil { return fmt.Errorf("failed to initialize client for node %s: %w", node.Name, err) } - for i := 0; i < 10; i++ { + var lastErr error + for i := 0; i < maxSyncAttempts; i++ { resp, err := client.Status(ctx) + lastErr = err if err == nil { - if resp.SyncInfo.LatestBlockHeight > 0 { - log.Info().Int("attempts", i).Str("name", node.Name).Msg( - "node has synced") + if resp != nil && resp.SyncInfo.LatestBlockHeight > 0 { + t.logger.Println("node has synced", "name", node.Name, "attempts", i, "latest_block_height", resp.SyncInfo.LatestBlockHeight) break } + t.logger.Println("node status retrieved but not synced yet, waiting...", "name", node.Name, "attempt", i) } else { - err = errors.New("error getting status") + t.logger.Println("error getting status, retrying...", "name", node.Name, "attempt", i, "error", err) } - if i == 9 { - return fmt.Errorf("failed to start node %s: %w", node.Name, err) + if i == maxSyncAttempts-1 { + return fmt.Errorf("timed out waiting for node %s to sync: %w", node.Name, lastErr) } - log.Info().Str("name", node.Name).Int("attempt", i).Msg( - "node is not synced yet, waiting...") - time.Sleep(time.Duration(i) * time.Second) + time.Sleep(time.Second * time.Duration(1<