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 1/3] 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< Date: Wed, 11 Dec 2024 18:38:23 +0100 Subject: [PATCH 2/3] fix: reject BlobTxs larger than 2 MiB (#4084) ## Overview Directly checks transaction sizes even before they're decoded and removes them if they exceed configured threshold. We should add MaxTxSize constraint in ProcessProposal directly and consider removing the AnteHandler in v4. Issue tracking this work: https://github.com/celestiaorg/celestia-app/issues/4087 ## Testing - Check tx test asserts with logs that the expected error gets hit - Getting logs from prepare proposal was more challenging so i'm inserting a screenshot of application logs when the tests are run. Screenshot 2024-12-06 at 12 27 03 Screenshot 2024-12-06 at 12 27 20 ## Proposal for improving robustness of our test suites - [ ] Open an issue to assert all logs in our integration tests. --------- Co-authored-by: Rootul P --- app/check_tx.go | 11 ++++++ app/errors/errors.go | 12 ++++++ app/test/big_blob_test.go | 42 +++++++++++++++++++-- app/test/check_tx_test.go | 33 ++++++++++++++-- app/test/consistent_apphash_test.go | 8 +++- app/test/prepare_proposal_test.go | 22 +---------- app/test/process_proposal_test.go | 41 -------------------- test/util/blobfactory/payforblob_factory.go | 3 +- test/util/blobfactory/test_util.go | 2 +- 9 files changed, 102 insertions(+), 72 deletions(-) create mode 100644 app/errors/errors.go diff --git a/app/check_tx.go b/app/check_tx.go index f76b37880f..68ff288caa 100644 --- a/app/check_tx.go +++ b/app/check_tx.go @@ -3,6 +3,9 @@ package app import ( "fmt" + "cosmossdk.io/errors" + + apperr "github.com/celestiaorg/celestia-app/v3/app/errors" "github.com/celestiaorg/celestia-app/v3/pkg/appconsts" blobtypes "github.com/celestiaorg/celestia-app/v3/x/blob/types" blobtx "github.com/celestiaorg/go-square/v2/tx" @@ -15,6 +18,14 @@ import ( // transactions that contain blobs. func (app *App) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx { tx := req.Tx + + // all txs must be less than or equal to the max tx size limit + maxTxSize := appconsts.MaxTxSize(app.AppVersion()) + currentTxSize := len(tx) + if currentTxSize > maxTxSize { + return sdkerrors.ResponseCheckTxWithEvents(errors.Wrapf(apperr.ErrTxExceedsMaxSize, "tx size %d bytes is larger than the application's configured MaxTxSize of %d bytes for version %d", currentTxSize, maxTxSize, app.AppVersion()), 0, 0, []abci.Event{}, false) + } + // check if the transaction contains blobs btx, isBlob, err := blobtx.UnmarshalBlobTx(tx) if isBlob && err != nil { diff --git a/app/errors/errors.go b/app/errors/errors.go new file mode 100644 index 0000000000..9bbff18b42 --- /dev/null +++ b/app/errors/errors.go @@ -0,0 +1,12 @@ +package errors + +import ( + "cosmossdk.io/errors" +) + +const AppErrorsCodespace = "app" + +// general application errors +var ( + ErrTxExceedsMaxSize = errors.Register(AppErrorsCodespace, 11142, "exceeds max tx size limit") +) diff --git a/app/test/big_blob_test.go b/app/test/big_blob_test.go index cede1ae65d..bbce473016 100644 --- a/app/test/big_blob_test.go +++ b/app/test/big_blob_test.go @@ -7,6 +7,7 @@ import ( "github.com/celestiaorg/celestia-app/v3/app" "github.com/celestiaorg/celestia-app/v3/app/encoding" + apperrors "github.com/celestiaorg/celestia-app/v3/app/errors" "github.com/celestiaorg/celestia-app/v3/pkg/appconsts" "github.com/celestiaorg/celestia-app/v3/pkg/user" "github.com/celestiaorg/celestia-app/v3/test/util/testfactory" @@ -55,7 +56,7 @@ func (s *BigBlobSuite) SetupSuite() { require.NoError(t, cctx.WaitForNextBlock()) } -// TestErrBlobsTooLarge verifies that submitting a 2 MiB blob hits ErrBlobsTooLarge. +// TestErrBlobsTooLarge verifies that submitting a ~1.9 MiB blob hits ErrBlobsTooLarge. func (s *BigBlobSuite) TestErrBlobsTooLarge() { t := s.T() @@ -67,8 +68,8 @@ func (s *BigBlobSuite) TestErrBlobsTooLarge() { } testCases := []testCase{ { - name: "2 mebibyte blob", - blob: newBlobWithSize(2 * mebibyte), + name: "~ 1.9 MiB blob", + blob: newBlobWithSize(2_000_000), want: blobtypes.ErrBlobsTooLarge.ABCICode(), }, } @@ -88,3 +89,38 @@ func (s *BigBlobSuite) TestErrBlobsTooLarge() { }) } } + +// TestBlobExceedsMaxTxSize verifies that submitting a 2 MiB blob hits ErrTxExceedsMaxSize. +func (s *BigBlobSuite) TestBlobExceedsMaxTxSize() { + t := s.T() + + type testCase struct { + name string + blob *share.Blob + expectedCode uint32 + expectedErr string + } + testCases := []testCase{ + { + name: "2 MiB blob", + blob: newBlobWithSize(2097152), + expectedCode: apperrors.ErrTxExceedsMaxSize.ABCICode(), + expectedErr: apperrors.ErrTxExceedsMaxSize.Error(), + }, + } + + txClient, err := testnode.NewTxClientFromContext(s.cctx) + require.NoError(t, err) + + for _, tc := range testCases { + s.Run(tc.name, func() { + subCtx, cancel := context.WithTimeout(s.cctx.GoContext(), 30*time.Second) + defer cancel() + res, err := txClient.SubmitPayForBlob(subCtx, []*share.Blob{tc.blob}, user.SetGasLimitAndGasPrice(1e9, appconsts.DefaultMinGasPrice)) + require.Error(t, err) + require.Nil(t, res) + code := err.(*user.BroadcastTxError).Code + require.Equal(t, tc.expectedCode, code, err.Error(), tc.expectedErr) + }) + } +} diff --git a/app/test/check_tx_test.go b/app/test/check_tx_test.go index aba7720547..87c7cc9e01 100644 --- a/app/test/check_tx_test.go +++ b/app/test/check_tx_test.go @@ -11,6 +11,7 @@ import ( "github.com/celestiaorg/celestia-app/v3/app" "github.com/celestiaorg/celestia-app/v3/app/encoding" + apperr "github.com/celestiaorg/celestia-app/v3/app/errors" "github.com/celestiaorg/celestia-app/v3/pkg/appconsts" "github.com/celestiaorg/celestia-app/v3/pkg/user" testutil "github.com/celestiaorg/celestia-app/v3/test/util" @@ -32,7 +33,7 @@ func TestCheckTx(t *testing.T) { ns1, err := share.NewV0Namespace(bytes.Repeat([]byte{1}, share.NamespaceVersionZeroIDSize)) require.NoError(t, err) - accs := []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k"} + accs := []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"} testApp, kr := testutil.SetupTestAppWithGenesisValSet(app.DefaultConsensusParams(), accs...) testApp.Commit() @@ -173,11 +174,11 @@ func TestCheckTx(t *testing.T) { expectedABCICode: abci.CodeTypeOK, }, { - name: "10,000,000 byte blob", + name: "2,000,000 byte blob", checkType: abci.CheckTxType_New, getTx: func() []byte { signer := createSigner(t, kr, accs[9], encCfg.TxConfig, 10) - _, blobs := blobfactory.RandMsgPayForBlobsWithSigner(tmrand.NewRand(), signer.Account(accs[9]).Address().String(), 10_000_000, 1) + _, blobs := blobfactory.RandMsgPayForBlobsWithSigner(tmrand.NewRand(), signer.Account(accs[9]).Address().String(), 2_000_000, 1) tx, _, err := signer.CreatePayForBlobs(accs[9], blobs, opts...) require.NoError(t, err) return tx @@ -217,6 +218,32 @@ func TestCheckTx(t *testing.T) { }, expectedABCICode: abci.CodeTypeOK, }, + { + name: "v1 blob over 2MiB", + checkType: abci.CheckTxType_New, + getTx: func() []byte { + signer := createSigner(t, kr, accs[11], encCfg.TxConfig, 12) + blob, err := share.NewV1Blob(share.RandomBlobNamespace(), bytes.Repeat([]byte{1}, 2097152), signer.Account(accs[11]).Address()) + require.NoError(t, err) + blobTx, _, err := signer.CreatePayForBlobs(accs[11], []*share.Blob{blob}, opts...) + require.NoError(t, err) + return blobTx + }, + expectedABCICode: apperr.ErrTxExceedsMaxSize.ABCICode(), + }, + { + name: "v0 blob over 2MiB", + checkType: abci.CheckTxType_New, + getTx: func() []byte { + signer := createSigner(t, kr, accs[12], encCfg.TxConfig, 13) + blob, err := share.NewV0Blob(share.RandomBlobNamespace(), bytes.Repeat([]byte{1}, 2097152)) + require.NoError(t, err) + blobTx, _, err := signer.CreatePayForBlobs(accs[12], []*share.Blob{blob}, opts...) + require.NoError(t, err) + return blobTx + }, + expectedABCICode: apperr.ErrTxExceedsMaxSize.ABCICode(), + }, } for _, tt := range tests { diff --git a/app/test/consistent_apphash_test.go b/app/test/consistent_apphash_test.go index 9a108e4dd1..2acc1030ae 100644 --- a/app/test/consistent_apphash_test.go +++ b/app/test/consistent_apphash_test.go @@ -62,6 +62,10 @@ type appHashTest struct { expectedAppHash []byte } +func DefaultTxOpts() []user.TxOption { + return blobfactory.FeeTxOpts(10_000_000) +} + // TestConsistentAppHash executes all state machine messages on all app versions, generates an app hash, // and compares it against a previously generated hash from the same set of transactions. // App hashes across different commits should be consistent. @@ -377,7 +381,7 @@ func createEncodedBlobTx(t *testing.T, signer *user.Signer, accountAddresses []s blobTx := blobTx{ author: senderAcc.Name(), blobs: []*share.Blob{blob}, - txOptions: blobfactory.DefaultTxOpts(), + txOptions: DefaultTxOpts(), } encodedBlobTx, _, err := signer.CreatePayForBlobs(blobTx.author, blobTx.blobs, blobTx.txOptions...) require.NoError(t, err) @@ -429,7 +433,7 @@ func deterministicKeyRing(cdc codec.Codec) (keyring.Keyring, []types.PubKey) { func processSdkMessages(signer *user.Signer, sdkMessages []sdk.Msg) ([][]byte, error) { encodedTxs := make([][]byte, 0, len(sdkMessages)) for _, msg := range sdkMessages { - encodedTx, err := signer.CreateTx([]sdk.Msg{msg}, blobfactory.DefaultTxOpts()...) + encodedTx, err := signer.CreateTx([]sdk.Msg{msg}, DefaultTxOpts()...) if err != nil { return nil, err } diff --git a/app/test/prepare_proposal_test.go b/app/test/prepare_proposal_test.go index f274d9da6a..b167419a15 100644 --- a/app/test/prepare_proposal_test.go +++ b/app/test/prepare_proposal_test.go @@ -51,7 +51,6 @@ func TestPrepareProposalPutsPFBsAtEnd(t *testing.T) { accnts[:numBlobTxs], infos[:numBlobTxs], testfactory.Repeat([]*share.Blob{protoBlob}, numBlobTxs), - blobfactory.DefaultTxOpts()..., ) normalTxs := testutil.SendTxsWithAccounts( @@ -109,7 +108,6 @@ func TestPrepareProposalFiltering(t *testing.T) { testfactory.RandomBlobNamespaces(tmrand.NewRand(), 3), [][]int{{100}, {1000}, {420}}, ), - blobfactory.DefaultTxOpts()..., ) // create 3 MsgSend transactions that are signed with valid account numbers @@ -173,22 +171,6 @@ func TestPrepareProposalFiltering(t *testing.T) { // 3 transactions over MaxTxSize limit largeTxs := coretypes.Txs(testutil.SendTxsWithAccounts(t, testApp, encConf.TxConfig, kr, 1000, accounts[0], accounts[:3], testutil.ChainID, user.SetMemo(largeString))).ToSliceOfBytes() - // 3 blobTxs over MaxTxSize limit - largeBlobTxs := blobfactory.ManyMultiBlobTx( - t, - encConf.TxConfig, - kr, - testutil.ChainID, - accounts[:3], - infos[:3], - blobfactory.NestedBlobs( - t, - testfactory.RandomBlobNamespaces(tmrand.NewRand(), 3), - [][]int{{100}, {1000}, {420}}, - ), - user.SetMemo(largeString), - ) - type test struct { name string txs func() [][]byte @@ -243,9 +225,9 @@ func TestPrepareProposalFiltering(t *testing.T) { { name: "blobTxs and sendTxs that exceed MaxTxSize limit", txs: func() [][]byte { - return append(largeTxs, largeBlobTxs...) // All txs are over MaxTxSize limit + return largeTxs // All txs are over MaxTxSize limit }, - prunedTxs: append(largeTxs, largeBlobTxs...), + prunedTxs: largeTxs, }, } diff --git a/app/test/process_proposal_test.go b/app/test/process_proposal_test.go index 33b1d406c5..093116a85b 100644 --- a/app/test/process_proposal_test.go +++ b/app/test/process_proposal_test.go @@ -3,7 +3,6 @@ package app_test import ( "bytes" "fmt" - "strings" "testing" "time" @@ -51,26 +50,6 @@ func TestProcessProposal(t *testing.T) { testfactory.RandomBlobNamespaces(tmrand.NewRand(), 4), [][]int{{100}, {1000}, {420}, {300}}, ), - blobfactory.DefaultTxOpts()..., - ) - - largeMemo := strings.Repeat("a", appconsts.MaxTxSize(appconsts.LatestVersion)) - - // create 2 single blobTxs that include a large memo making the transaction - // larger than the configured max tx size - largeBlobTxs := blobfactory.ManyMultiBlobTx( - t, enc, kr, testutil.ChainID, accounts[3:], infos[3:], - blobfactory.NestedBlobs( - t, - testfactory.RandomBlobNamespaces(tmrand.NewRand(), 4), - [][]int{{100}, {1000}, {420}, {300}}, - ), - user.SetMemo(largeMemo)) - - // create 1 large sendTx that includes a large memo making the - // transaction over the configured max tx size limit - largeSendTx := testutil.SendTxsWithAccounts( - t, testApp, enc, kr, 1000, accounts[0], accounts[1:2], testutil.ChainID, user.SetMemo(largeMemo), ) // create 3 MsgSend transactions that are signed with valid account numbers @@ -349,26 +328,6 @@ func TestProcessProposal(t *testing.T) { appVersion: v3.Version, expectedResult: abci.ResponseProcessProposal_REJECT, }, - { - name: "blob txs larger than configured max tx size", - input: validData(), - mutator: func(d *tmproto.Data) { - d.Txs = append(d.Txs, largeBlobTxs...) - d.Hash = calculateNewDataHash(t, d.Txs) - }, - appVersion: appconsts.LatestVersion, - expectedResult: abci.ResponseProcessProposal_REJECT, - }, - { - name: "send tx larger than configured max tx size", - input: validData(), - mutator: func(d *tmproto.Data) { - d.Txs = append(coretypes.Txs(largeSendTx).ToSliceOfBytes(), d.Txs...) - d.Hash = calculateNewDataHash(t, d.Txs) - }, - appVersion: appconsts.LatestVersion, - expectedResult: abci.ResponseProcessProposal_REJECT, - }, } for _, tt := range tests { diff --git a/test/util/blobfactory/payforblob_factory.go b/test/util/blobfactory/payforblob_factory.go index f9b05359bc..d15e7ca0fe 100644 --- a/test/util/blobfactory/payforblob_factory.go +++ b/test/util/blobfactory/payforblob_factory.go @@ -245,14 +245,13 @@ func ManyMultiBlobTx( accounts []string, accInfos []AccountInfo, blobs [][]*share.Blob, - opts ...user.TxOption, ) [][]byte { t.Helper() txs := make([][]byte, len(accounts)) for i, acc := range accounts { signer, err := user.NewSigner(kr, enc, chainid, appconsts.LatestVersion, user.NewAccount(acc, accInfos[i].AccountNum, accInfos[i].Sequence)) require.NoError(t, err) - txs[i], _, err = signer.CreatePayForBlobs(acc, blobs[i], opts...) + txs[i], _, err = signer.CreatePayForBlobs(acc, blobs[i], DefaultTxOpts()...) require.NoError(t, err) } return txs diff --git a/test/util/blobfactory/test_util.go b/test/util/blobfactory/test_util.go index 0496ba1735..90a0697d1b 100644 --- a/test/util/blobfactory/test_util.go +++ b/test/util/blobfactory/test_util.go @@ -11,7 +11,7 @@ import ( ) func DefaultTxOpts() []user.TxOption { - return FeeTxOpts(10_000_000) + return FeeTxOpts(10_000_000_000) } func FeeTxOpts(gas uint64) []user.TxOption { From 6164b0e2f1d6a4d32a8e45bf770f50eb0328ae82 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Dec 2024 18:38:52 +0100 Subject: [PATCH 3/3] chore(deps): Bump k8s.io/apimachinery from 0.31.3 to 0.31.4 (#4108) Bumps [k8s.io/apimachinery](https://github.com/kubernetes/apimachinery) from 0.31.3 to 0.31.4.
Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=k8s.io/apimachinery&package-manager=go_modules&previous-version=0.31.3&new-version=0.31.4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f0840355c2..f6064dc553 100644 --- a/go.mod +++ b/go.mod @@ -36,7 +36,7 @@ require ( google.golang.org/grpc v1.68.0 google.golang.org/protobuf v1.35.2 gopkg.in/yaml.v2 v2.4.0 - k8s.io/apimachinery v0.31.3 + k8s.io/apimachinery v0.31.4 ) require ( diff --git a/go.sum b/go.sum index 9948c0323d..b0e0e7784c 100644 --- a/go.sum +++ b/go.sum @@ -2065,8 +2065,8 @@ honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= k8s.io/api v0.30.2 h1:+ZhRj+28QT4UOH+BKznu4CBgPWgkXO7XAvMcMl0qKvI= k8s.io/api v0.30.2/go.mod h1:ULg5g9JvOev2dG0u2hig4Z7tQ2hHIuS+m8MNZ+X6EmI= -k8s.io/apimachinery v0.31.3 h1:6l0WhcYgasZ/wk9ktLq5vLaoXJJr5ts6lkaQzgeYPq4= -k8s.io/apimachinery v0.31.3/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= +k8s.io/apimachinery v0.31.4 h1:8xjE2C4CzhYVm9DGf60yohpNUh5AEBnPxCryPBECmlM= +k8s.io/apimachinery v0.31.4/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= k8s.io/client-go v0.30.2 h1:sBIVJdojUNPDU/jObC+18tXWcTJVcwyqS9diGdWHk50= k8s.io/client-go v0.30.2/go.mod h1:JglKSWULm9xlJLx4KCkfLLQ7XwtlbflV6uFFSHTMgVs= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=