From 35cacc53d35e61750aeee6ec91eeaebd43db1360 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 26 Apr 2024 08:49:13 -0400 Subject: [PATCH 01/38] defines config options --- test/e2e/testnet/setup.go | 47 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/test/e2e/testnet/setup.go b/test/e2e/testnet/setup.go index 343d803db0..0c2c290a66 100644 --- a/test/e2e/testnet/setup.go +++ b/test/e2e/testnet/setup.go @@ -12,7 +12,7 @@ import ( "github.com/tendermint/tendermint/p2p/pex" ) -func MakeConfig(node *Node) (*config.Config, error) { +func MakeConfig(node *Node, opts ...Option) (*config.Config, error) { cfg := config.DefaultConfig() cfg.Moniker = node.Name cfg.RPC.ListenAddress = "tcp://0.0.0.0:26657" @@ -23,9 +23,54 @@ func MakeConfig(node *Node) (*config.Config, error) { cfg.Consensus.TimeoutPropose = 1 * time.Second cfg.Consensus.TimeoutCommit = 1 * time.Second cfg.Instrumentation.Prometheus = true + + for _, opt := range opts { + opt(cfg) + } + return cfg, nil } +type Option func(*config.Config) + +func WithPerPeerBandwidth(bandwidth int64) Option { + return func(cfg *config.Config) { + cfg.P2P.SendRate = bandwidth + cfg.P2P.RecvRate = bandwidth + + } +} + +func WithTimeoutPropose(timeout time.Duration) Option { + return func(cfg *config.Config) { + cfg.Consensus.TimeoutPropose = timeout + } +} + +func WithTimeoutCommit(timeout time.Duration) Option { + return func(cfg *config.Config) { + cfg.Consensus.TimeoutCommit = timeout + } +} + +func WithPrometheus(prometheus bool) Option { + return func(cfg *config.Config) { + cfg.Instrumentation.Prometheus = prometheus + } +} + +func WithMempool(mempool string) Option { + return func(cfg *config.Config) { + cfg.Mempool.Version = mempool + } +} + +func BroadcastTxsOpt(broadcast bool) Option { + return func(cfg *config.Config) { + cfg.Mempool.Broadcast = broadcast + } +} + func WriteAddressBook(peers []string, file string) error { book := pex.NewAddrBook(file, false) for _, peer := range peers { From b1d6861525168d1a1dd5c40b0c9a3c119e57b3ca Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 26 Apr 2024 08:51:26 -0400 Subject: [PATCH 02/38] adds configOpts parameter to the Init func --- test/e2e/testnet/node.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/testnet/node.go b/test/e2e/testnet/node.go index 54c86a2fa6..795bc45a81 100644 --- a/test/e2e/testnet/node.go +++ b/test/e2e/testnet/node.go @@ -131,7 +131,7 @@ func NewNode( }, nil } -func (n *Node) Init(genesis *types.GenesisDoc, peers []string) error { +func (n *Node) Init(genesis *types.GenesisDoc, peers []string, configOptions ...Option) error { if len(peers) == 0 { return fmt.Errorf("no peers provided") } @@ -152,7 +152,7 @@ func (n *Node) Init(genesis *types.GenesisDoc, peers []string) error { } // Create and write the config file - cfg, err := MakeConfig(n) + cfg, err := MakeConfig(n, configOptions...) if err != nil { return fmt.Errorf("making config: %w", err) } From eb5d3796616393c024eb901b05f929d576006c17 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 26 Apr 2024 08:55:54 -0400 Subject: [PATCH 03/38] extends Setup parameter with config options --- test/e2e/testnet/testnet.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/testnet/testnet.go b/test/e2e/testnet/testnet.go index d7ccb2987d..64369cf004 100644 --- a/test/e2e/testnet/testnet.go +++ b/test/e2e/testnet/testnet.go @@ -221,7 +221,7 @@ func (t *Testnet) CreateNode(version string, startHeight, upgradeHeight int64, r return nil } -func (t *Testnet) Setup() error { +func (t *Testnet) Setup(configOpts ...Option) error { genesis, err := t.genesis.Export() if err != nil { return err @@ -237,7 +237,7 @@ func (t *Testnet) Setup() error { } } - err := node.Init(genesis, peers) + err := node.Init(genesis, peers, configOpts...) if err != nil { return err } From f4c81f741f06a853dd33a3912ef438ed7b3580bc Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 26 Apr 2024 08:56:13 -0400 Subject: [PATCH 04/38] passes options through setup method --- test/e2e/benchmark/throughput.go | 8 +++++++- test/e2e/testnet/setup.go | 8 ++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/test/e2e/benchmark/throughput.go b/test/e2e/benchmark/throughput.go index 55d2b6cbbf..b8f09f9d89 100644 --- a/test/e2e/benchmark/throughput.go +++ b/test/e2e/benchmark/throughput.go @@ -53,7 +53,13 @@ func E2EThroughput() error { // start the testnet log.Println("Setting up testnet") - testnet.NoError("failed to setup testnet", testNet.Setup()) + testnet.NoError("failed to setup testnet", testNet.Setup( + testnet.WithPerPeerBandwidth(5*1024*1024), + testnet.WithTimeoutPropose(1*time.Second), + testnet.WithTimeoutCommit(1*time.Second), + testnet.WithPrometheus(true), + //testnet.WithMempool("v1"), + )) log.Println("Starting testnet") testnet.NoError("failed to start testnet", testNet.Start()) diff --git a/test/e2e/testnet/setup.go b/test/e2e/testnet/setup.go index 0c2c290a66..c93c266b3c 100644 --- a/test/e2e/testnet/setup.go +++ b/test/e2e/testnet/setup.go @@ -18,10 +18,10 @@ func MakeConfig(node *Node, opts ...Option) (*config.Config, error) { cfg.RPC.ListenAddress = "tcp://0.0.0.0:26657" cfg.P2P.ExternalAddress = fmt.Sprintf("tcp://%v", node.AddressP2P(false)) cfg.P2P.PersistentPeers = strings.Join(node.InitialPeers, ",") - cfg.P2P.SendRate = 5 * 1024 * 1024 // 5MiB/s - cfg.P2P.RecvRate = 5 * 1024 * 1024 // 5MiB/s - cfg.Consensus.TimeoutPropose = 1 * time.Second - cfg.Consensus.TimeoutCommit = 1 * time.Second + //cfg.P2P.SendRate = 5 * 1024 * 1024 // 5MiB/s + //cfg.P2P.RecvRate = 5 * 1024 * 1024 // 5MiB/s + //cfg.Consensus.TimeoutPropose = 1 * time.Second + //cfg.Consensus.TimeoutCommit = 1 * time.Second cfg.Instrumentation.Prometheus = true for _, opt := range opts { From c4e0b3bd89fde2aaa639509ec55fcd53850f3048 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 26 Apr 2024 09:17:39 -0400 Subject: [PATCH 05/38] allows passing genesis modifiers and consensus parameters in the testnet creation --- test/e2e/benchmark/throughput.go | 28 +++++++++++++++++++++++++++- test/e2e/testnet/testnet.go | 6 ++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/test/e2e/benchmark/throughput.go b/test/e2e/benchmark/throughput.go index b8f09f9d89..59e14373c8 100644 --- a/test/e2e/benchmark/throughput.go +++ b/test/e2e/benchmark/throughput.go @@ -6,9 +6,15 @@ import ( "log" "time" + "github.com/celestiaorg/celestia-app/v2/app" + "github.com/celestiaorg/celestia-app/v2/app/encoding" "github.com/celestiaorg/celestia-app/v2/pkg/appconsts" "github.com/celestiaorg/celestia-app/v2/test/e2e/testnet" + "github.com/celestiaorg/celestia-app/v2/test/util/genesis" "github.com/celestiaorg/celestia-app/v2/test/util/testnode" + blobtypes "github.com/celestiaorg/celestia-app/v2/x/blob/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/tendermint/tendermint/types" ) const ( @@ -29,7 +35,9 @@ func E2EThroughput() error { log.Println("=== RUN E2EThroughput", "version:", latestVersion) // create a new testnet - testNet, err := testnet.New("E2EThroughput", seed, testnet.GetGrafanaInfoFromEnvVar()) + testNet, err := testnet.New("E2EThroughput", seed, + testnet.GetGrafanaInfoFromEnvVar(), "test-sanaz", + getGenesisModifiers(appconsts.DefaultGovMaxSquareSize), getConsensusParams(appconsts.DefaultMaxBytes)) testnet.NoError("failed to create testnet", err) defer func() { @@ -87,3 +95,21 @@ func E2EThroughput() error { log.Println("--- PASS ✅: E2EThroughput") return nil } + +func getGenesisModifiers(govMaxSquareSize uint64) []genesis.Modifier { + ecfg := encoding.MakeConfig(app.ModuleBasics) + var modifiers []genesis.Modifier + + blobParams := blobtypes.DefaultParams() + blobParams.GovMaxSquareSize = govMaxSquareSize + modifiers = append(modifiers, genesis.SetBlobParams(ecfg.Codec, blobParams)) + + return modifiers +} + +func getConsensusParams(maxBytes int64) *tmproto.ConsensusParams { + cparams := types.DefaultConsensusParams() + cparams.Block.MaxBytes = maxBytes + return cparams + +} diff --git a/test/e2e/testnet/testnet.go b/test/e2e/testnet/testnet.go index 64369cf004..1f5b0a5fde 100644 --- a/test/e2e/testnet/testnet.go +++ b/test/e2e/testnet/testnet.go @@ -26,7 +26,9 @@ type Testnet struct { txClients []*TxSim } -func New(name string, seed int64, grafana *GrafanaInfo) (*Testnet, error) { +func New(name string, seed int64, grafana *GrafanaInfo, chainID string, + genesisModifiers []genesis.Modifier, _ *tmproto.ConsensusParams) ( + *Testnet, error) { identifier := fmt.Sprintf("%s_%s", name, time.Now().Format("20060102_150405")) if err := knuu.InitializeWithScope(identifier); err != nil { return nil, err @@ -35,7 +37,7 @@ func New(name string, seed int64, grafana *GrafanaInfo) (*Testnet, error) { return &Testnet{ seed: seed, nodes: make([]*Node, 0), - genesis: genesis.NewDefaultGenesis().WithChainID("test"), + genesis: genesis.NewDefaultGenesis().WithChainID(chainID).WithModifiers(genesisModifiers...), keygen: newKeyGenerator(seed), grafana: grafana, }, nil From ed1fddf0052a1f7f27a3fead9ca890420be35396 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 26 Apr 2024 09:33:49 -0400 Subject: [PATCH 06/38] adds manifest struct --- test/e2e/benchmark/throughput.go | 52 +++++++++--------- test/e2e/testnet/defaults.go | 2 + test/e2e/testnet/manifest.go | 92 ++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+), 27 deletions(-) create mode 100644 test/e2e/testnet/manifest.go diff --git a/test/e2e/benchmark/throughput.go b/test/e2e/benchmark/throughput.go index 59e14373c8..863d65c351 100644 --- a/test/e2e/benchmark/throughput.go +++ b/test/e2e/benchmark/throughput.go @@ -6,20 +6,13 @@ import ( "log" "time" - "github.com/celestiaorg/celestia-app/v2/app" - "github.com/celestiaorg/celestia-app/v2/app/encoding" "github.com/celestiaorg/celestia-app/v2/pkg/appconsts" "github.com/celestiaorg/celestia-app/v2/test/e2e/testnet" - "github.com/celestiaorg/celestia-app/v2/test/util/genesis" "github.com/celestiaorg/celestia-app/v2/test/util/testnode" - blobtypes "github.com/celestiaorg/celestia-app/v2/x/blob/types" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/tendermint/tendermint/types" ) const ( - seed = 42 - txsimVersion = "a92de72" + seed = 42 ) func main() { @@ -34,10 +27,33 @@ func E2EThroughput() error { log.Println("=== RUN E2EThroughput", "version:", latestVersion) + manifest := testnet.TestManifest{ + ChainID: "test-sanaz", + Validators: 2, + ValidatorResource: testnet.DefaultResources, + TxClientsResource: testnet.DefaultResources, + SelfDelegation: 10000000, + CelestiaAppVersion: latestVersion, + TxClientVersion: testnet.TxsimVersion, + BlobsPerSeq: 1, + BlobSequences: 10, + BlobSizes: "100000", + PerPeerBandwidth: 5 * 1024 * 1024, + UpgradeHeight: 0, + TimeoutCommit: 1 * time.Second, + TimeoutPropose: 1 * time.Second, + Mempool: "v1", + BroadcastTxs: true, + Prometheus: true, + GovMaxSquareSize: appconsts.DefaultGovMaxSquareSize, + MaxBlockBytes: appconsts.DefaultMaxBytes, + TestDuration: 5 * time.Minute, + TxClientsNum: 2, + } // create a new testnet testNet, err := testnet.New("E2EThroughput", seed, testnet.GetGrafanaInfoFromEnvVar(), "test-sanaz", - getGenesisModifiers(appconsts.DefaultGovMaxSquareSize), getConsensusParams(appconsts.DefaultMaxBytes)) + manifest.GetGenesisModifiers(), manifest.GetConsensusParams()) testnet.NoError("failed to create testnet", err) defer func() { @@ -95,21 +111,3 @@ func E2EThroughput() error { log.Println("--- PASS ✅: E2EThroughput") return nil } - -func getGenesisModifiers(govMaxSquareSize uint64) []genesis.Modifier { - ecfg := encoding.MakeConfig(app.ModuleBasics) - var modifiers []genesis.Modifier - - blobParams := blobtypes.DefaultParams() - blobParams.GovMaxSquareSize = govMaxSquareSize - modifiers = append(modifiers, genesis.SetBlobParams(ecfg.Codec, blobParams)) - - return modifiers -} - -func getConsensusParams(maxBytes int64) *tmproto.ConsensusParams { - cparams := types.DefaultConsensusParams() - cparams.Block.MaxBytes = maxBytes - return cparams - -} diff --git a/test/e2e/testnet/defaults.go b/test/e2e/testnet/defaults.go index 2fda895240..06cc1d70d9 100644 --- a/test/e2e/testnet/defaults.go +++ b/test/e2e/testnet/defaults.go @@ -6,3 +6,5 @@ var DefaultResources = Resources{ CPU: "300m", Volume: "1Gi", } + +const TxsimVersion = "a92de72" diff --git a/test/e2e/testnet/manifest.go b/test/e2e/testnet/manifest.go new file mode 100644 index 0000000000..b2ea9ad4e7 --- /dev/null +++ b/test/e2e/testnet/manifest.go @@ -0,0 +1,92 @@ +package testnet + +import ( + "time" + + "github.com/celestiaorg/celestia-app/v2/app" + "github.com/celestiaorg/celestia-app/v2/app/encoding" + "github.com/celestiaorg/celestia-app/v2/test/util/genesis" + blobtypes "github.com/celestiaorg/celestia-app/v2/x/blob/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/tendermint/tendermint/types" +) + +// TestManifest defines the parameters for a testnet. +type TestManifest struct { + ChainID string + // Number of validators in the testnet + Validators int + // Resource requirements for a validator node + ValidatorResource Resources + // Resource requirements for a tx client + TxClientsResource Resources + // Self-delegation amount for validators + SelfDelegation int64 + // CelestiaAppVersion a specific version of the celestia-app container image within celestiaorg repository on GitHub's Container Registry i.e., https://github.com/celestiaorg/celestia-app/pkgs/container/celestia-app + CelestiaAppVersion string + // TxClientVersion a specific version of the txsim container image within celestiaorg repository on GitHub's Container Registry, i.e., https://github.com/celestiaorg/celestia-app/pkgs/container/txsim + TxClientVersion string + + // tx client settings + // Number of blobs per sequence + BlobsPerSeq int + // Number of blob sequences + BlobSequences int + // Size of blobs in bytes, e.g., "10000" (exact size) or "10000-20000" (min-max format) + BlobSizes string + + // p2p configs + // Bandwidth per peer in bytes per second + PerPeerBandwidth int64 + // consensus configs + // if TimeoutCommit is set to 0, it won't take effect and a default value will be used + TimeoutCommit time.Duration + // if TimeoutPropose is set to 0, it won't take effect and a default value will be used + TimeoutPropose time.Duration + + // Mempool configs + // Mempool version + // If Mempool is set to "", it won't take effect and a default value will be used + Mempool string + BroadcastTxs bool + + // prometheus configs + Prometheus bool + + // consensus manifest + // If MaxBlockBytes is set to 0, it won't take effect and a default value will be used + MaxBlockBytes int64 + + // other configs + UpgradeHeight int64 // Upgrade height + // if GovMaxSquareSize is set to 0, it won't take effect and a default value will be used + GovMaxSquareSize int64 + + TestDuration time.Duration + TxClientsNum int +} + +func (tm *TestManifest) GetGenesisModifiers() []genesis.Modifier { + return getGenesisModifiers(uint64(tm.GovMaxSquareSize)) +} + +func (tm *TestManifest) GetConsensusParams() *tmproto.ConsensusParams { + return getConsensusParams(tm.MaxBlockBytes) +} + +func getGenesisModifiers(govMaxSquareSize uint64) []genesis.Modifier { + ecfg := encoding.MakeConfig(app.ModuleBasics) + var modifiers []genesis.Modifier + + blobParams := blobtypes.DefaultParams() + blobParams.GovMaxSquareSize = govMaxSquareSize + modifiers = append(modifiers, genesis.SetBlobParams(ecfg.Codec, blobParams)) + + return modifiers +} + +func getConsensusParams(maxBytes int64) *tmproto.ConsensusParams { + cparams := types.DefaultConsensusParams() + cparams.Block.MaxBytes = maxBytes + return cparams +} From cb636649d9c65a634f38609012fa90e101527ed8 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 26 Apr 2024 09:41:23 -0400 Subject: [PATCH 07/38] defines BenchTest --- test/e2e/benchmark/throughput.go | 10 ++++++++-- test/e2e/testnet/manifest.go | 8 ++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/test/e2e/benchmark/throughput.go b/test/e2e/benchmark/throughput.go index 863d65c351..e23753bcd9 100644 --- a/test/e2e/benchmark/throughput.go +++ b/test/e2e/benchmark/throughput.go @@ -21,13 +21,18 @@ func main() { } } +type BenchTest struct { + testnet.Testnet + manifest testnet.Manifest +} + func E2EThroughput() error { latestVersion, err := testnet.GetLatestVersion() testnet.NoError("failed to get latest version", err) log.Println("=== RUN E2EThroughput", "version:", latestVersion) - manifest := testnet.TestManifest{ + manifest := testnet.Manifest{ ChainID: "test-sanaz", Validators: 2, ValidatorResource: testnet.DefaultResources, @@ -72,7 +77,8 @@ func E2EThroughput() error { // create txsim nodes and point them to the validators log.Println("Creating txsim nodes") - err = testNet.CreateTxClients(txsimVersion, 1, "10000-10000", testnet.DefaultResources, gRPCEndpoints) + err = testNet.CreateTxClients(testnet.TxsimVersion, 1, "10000-10000", + testnet.DefaultResources, gRPCEndpoints) testnet.NoError("failed to create tx clients", err) // start the testnet diff --git a/test/e2e/testnet/manifest.go b/test/e2e/testnet/manifest.go index b2ea9ad4e7..2763503ca9 100644 --- a/test/e2e/testnet/manifest.go +++ b/test/e2e/testnet/manifest.go @@ -11,8 +11,8 @@ import ( "github.com/tendermint/tendermint/types" ) -// TestManifest defines the parameters for a testnet. -type TestManifest struct { +// Manifest defines the parameters for a testnet. +type Manifest struct { ChainID string // Number of validators in the testnet Validators int @@ -66,11 +66,11 @@ type TestManifest struct { TxClientsNum int } -func (tm *TestManifest) GetGenesisModifiers() []genesis.Modifier { +func (tm *Manifest) GetGenesisModifiers() []genesis.Modifier { return getGenesisModifiers(uint64(tm.GovMaxSquareSize)) } -func (tm *TestManifest) GetConsensusParams() *tmproto.ConsensusParams { +func (tm *Manifest) GetConsensusParams() *tmproto.ConsensusParams { return getConsensusParams(tm.MaxBlockBytes) } From 05ecc53d30146bc1a329e1b9117d898f627f296b Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 26 Apr 2024 10:06:51 -0400 Subject: [PATCH 08/38] make consensus params effective --- test/e2e/testnet/testnet.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/testnet/testnet.go b/test/e2e/testnet/testnet.go index 1f5b0a5fde..e3e49c0d30 100644 --- a/test/e2e/testnet/testnet.go +++ b/test/e2e/testnet/testnet.go @@ -27,7 +27,7 @@ type Testnet struct { } func New(name string, seed int64, grafana *GrafanaInfo, chainID string, - genesisModifiers []genesis.Modifier, _ *tmproto.ConsensusParams) ( + genesisModifiers []genesis.Modifier, params *tmproto.ConsensusParams) ( *Testnet, error) { identifier := fmt.Sprintf("%s_%s", name, time.Now().Format("20060102_150405")) if err := knuu.InitializeWithScope(identifier); err != nil { @@ -37,7 +37,7 @@ func New(name string, seed int64, grafana *GrafanaInfo, chainID string, return &Testnet{ seed: seed, nodes: make([]*Node, 0), - genesis: genesis.NewDefaultGenesis().WithChainID(chainID).WithModifiers(genesisModifiers...), + genesis: genesis.NewDefaultGenesis().WithChainID(chainID).WithConsensusParams(params).WithModifiers(genesisModifiers...), keygen: newKeyGenerator(seed), grafana: grafana, }, nil From 80c26e9d61c8c81a62be6d8bca73f2e3cc1619e1 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 26 Apr 2024 10:51:39 -0400 Subject: [PATCH 09/38] fixes getConsensusParams --- test/e2e/testnet/manifest.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/e2e/testnet/manifest.go b/test/e2e/testnet/manifest.go index 2763503ca9..a742400979 100644 --- a/test/e2e/testnet/manifest.go +++ b/test/e2e/testnet/manifest.go @@ -8,7 +8,6 @@ import ( "github.com/celestiaorg/celestia-app/v2/test/util/genesis" blobtypes "github.com/celestiaorg/celestia-app/v2/x/blob/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/tendermint/tendermint/types" ) // Manifest defines the parameters for a testnet. @@ -86,7 +85,7 @@ func getGenesisModifiers(govMaxSquareSize uint64) []genesis.Modifier { } func getConsensusParams(maxBytes int64) *tmproto.ConsensusParams { - cparams := types.DefaultConsensusParams() + cparams := app.DefaultInitialConsensusParams() cparams.Block.MaxBytes = maxBytes return cparams } From 9af78d7ff349c8328b974412f5924d42dfe75cd8 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 26 Apr 2024 12:08:58 -0400 Subject: [PATCH 10/38] fixxes set consensus parameters by calling it after tesnet initiation --- test/e2e/benchmark/throughput.go | 5 +++-- test/e2e/testnet/manifest.go | 2 +- test/e2e/testnet/testnet.go | 10 ++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/test/e2e/benchmark/throughput.go b/test/e2e/benchmark/throughput.go index e23753bcd9..371b40e249 100644 --- a/test/e2e/benchmark/throughput.go +++ b/test/e2e/benchmark/throughput.go @@ -52,15 +52,16 @@ func E2EThroughput() error { Prometheus: true, GovMaxSquareSize: appconsts.DefaultGovMaxSquareSize, MaxBlockBytes: appconsts.DefaultMaxBytes, - TestDuration: 5 * time.Minute, + TestDuration: 1 * time.Minute, TxClientsNum: 2, } // create a new testnet testNet, err := testnet.New("E2EThroughput", seed, testnet.GetGrafanaInfoFromEnvVar(), "test-sanaz", - manifest.GetGenesisModifiers(), manifest.GetConsensusParams()) + manifest.GetGenesisModifiers()...) testnet.NoError("failed to create testnet", err) + testNet.SetConsensusParams(manifest.GetConsensusParams()) defer func() { log.Print("Cleaning up testnet") testNet.Cleanup() diff --git a/test/e2e/testnet/manifest.go b/test/e2e/testnet/manifest.go index a742400979..548e8be830 100644 --- a/test/e2e/testnet/manifest.go +++ b/test/e2e/testnet/manifest.go @@ -85,7 +85,7 @@ func getGenesisModifiers(govMaxSquareSize uint64) []genesis.Modifier { } func getConsensusParams(maxBytes int64) *tmproto.ConsensusParams { - cparams := app.DefaultInitialConsensusParams() + cparams := app.DefaultConsensusParams() cparams.Block.MaxBytes = maxBytes return cparams } diff --git a/test/e2e/testnet/testnet.go b/test/e2e/testnet/testnet.go index e3e49c0d30..b2b94be3c3 100644 --- a/test/e2e/testnet/testnet.go +++ b/test/e2e/testnet/testnet.go @@ -27,17 +27,19 @@ type Testnet struct { } func New(name string, seed int64, grafana *GrafanaInfo, chainID string, - genesisModifiers []genesis.Modifier, params *tmproto.ConsensusParams) ( + genesisModifiers ...genesis.Modifier) ( *Testnet, error) { identifier := fmt.Sprintf("%s_%s", name, time.Now().Format("20060102_150405")) if err := knuu.InitializeWithScope(identifier); err != nil { return nil, err } + gen := genesis.NewDefaultGenesis().WithChainID(chainID).WithModifiers(genesisModifiers...) + //gen.ConsensusParams.Block.MaxBytes = appconsts.DefaultMaxBytes return &Testnet{ seed: seed, nodes: make([]*Node, 0), - genesis: genesis.NewDefaultGenesis().WithChainID(chainID).WithConsensusParams(params).WithModifiers(genesisModifiers...), + genesis: gen, keygen: newKeyGenerator(seed), grafana: grafana, }, nil @@ -47,6 +49,10 @@ func (t *Testnet) SetConsensusParams(params *tmproto.ConsensusParams) { t.genesis.WithConsensusParams(params) } +func (t *Testnet) SetConsensusMaxBlockSize(size int64) { + t.genesis.ConsensusParams.Block.MaxBytes = size +} + func (t *Testnet) CreateGenesisNode(version string, selfDelegation, upgradeHeight int64, resources Resources) error { signerKey := t.keygen.Generate(ed25519Type) networkKey := t.keygen.Generate(ed25519Type) From 94f8ef0bc5b369c4deeeede04b46d99a04c3e3ca Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 26 Apr 2024 12:10:59 -0400 Subject: [PATCH 11/38] makes txsim image creation faster --- test/e2e/testnet/testnet.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/e2e/testnet/testnet.go b/test/e2e/testnet/testnet.go index b2b94be3c3..4bcc3c0aed 100644 --- a/test/e2e/testnet/testnet.go +++ b/test/e2e/testnet/testnet.go @@ -138,21 +138,21 @@ func (t *Testnet) CreateTxClient(name, Msg("error creating txsim") return err } - // copy over the keyring directory to the txsim instance - err = txsim.Instance.AddFolder(txsimKeyringDir, txsimRootDir, "10001:10001") + err = txsim.Instance.Commit() if err != nil { log.Err(err). - Str("directory", txsimKeyringDir). Str("name", name). - Msg("error adding keyring dir to txsim") + Msg("error committing txsim") return err } - err = txsim.Instance.Commit() + // copy over the keyring directory to the txsim instance + err = txsim.Instance.AddFolder(txsimKeyringDir, txsimRootDir, "10001:10001") if err != nil { log.Err(err). + Str("directory", txsimKeyringDir). Str("name", name). - Msg("error committing txsim") + Msg("error adding keyring dir to txsim") return err } From b4ae352d1108c6987e41176de61fac5cdcd377c4 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 26 Apr 2024 12:15:46 -0400 Subject: [PATCH 12/38] fixes changes to the order of AddFolder and Commit --- test/e2e/testnet/testnet.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/e2e/testnet/testnet.go b/test/e2e/testnet/testnet.go index 4bcc3c0aed..b0c8001c73 100644 --- a/test/e2e/testnet/testnet.go +++ b/test/e2e/testnet/testnet.go @@ -138,13 +138,6 @@ func (t *Testnet) CreateTxClient(name, Msg("error creating txsim") return err } - err = txsim.Instance.Commit() - if err != nil { - log.Err(err). - Str("name", name). - Msg("error committing txsim") - return err - } // copy over the keyring directory to the txsim instance err = txsim.Instance.AddFolder(txsimKeyringDir, txsimRootDir, "10001:10001") @@ -155,6 +148,13 @@ func (t *Testnet) CreateTxClient(name, Msg("error adding keyring dir to txsim") return err } + err = txsim.Instance.Commit() + if err != nil { + log.Err(err). + Str("name", name). + Msg("error committing txsim") + return err + } t.txClients = append(t.txClients, txsim) return nil From bd9fe319cc8043a283d6e8cbc5c8c43109cc0d93 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 26 Apr 2024 13:14:24 -0400 Subject: [PATCH 13/38] obtains parameters from manifest --- test/e2e/benchmark/throughput.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/e2e/benchmark/throughput.go b/test/e2e/benchmark/throughput.go index 371b40e249..f8573f7413 100644 --- a/test/e2e/benchmark/throughput.go +++ b/test/e2e/benchmark/throughput.go @@ -42,7 +42,7 @@ func E2EThroughput() error { TxClientVersion: testnet.TxsimVersion, BlobsPerSeq: 1, BlobSequences: 10, - BlobSizes: "100000", + BlobSizes: "100000-100000", PerPeerBandwidth: 5 * 1024 * 1024, UpgradeHeight: 0, TimeoutCommit: 1 * time.Second, @@ -57,7 +57,7 @@ func E2EThroughput() error { } // create a new testnet testNet, err := testnet.New("E2EThroughput", seed, - testnet.GetGrafanaInfoFromEnvVar(), "test-sanaz", + testnet.GetGrafanaInfoFromEnvVar(), manifest.ChainID, manifest.GetGenesisModifiers()...) testnet.NoError("failed to create testnet", err) @@ -68,7 +68,10 @@ func E2EThroughput() error { }() // add 2 validators - testnet.NoError("failed to create genesis nodes", testNet.CreateGenesisNodes(2, latestVersion, 10000000, 0, testnet.DefaultResources)) + testnet.NoError("failed to create genesis nodes", + testNet.CreateGenesisNodes(manifest.Validators, + manifest.CelestiaAppVersion, manifest.SelfDelegation, + manifest.UpgradeHeight, manifest.ValidatorResource)) // obtain the GRPC endpoints of the validators gRPCEndpoints, err := testNet.RemoteGRPCEndpoints() From 8fd5d1f0846d2e1f042dc8861b315246dc668c4d Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 26 Apr 2024 14:12:57 -0400 Subject: [PATCH 14/38] reads txClient pars from manifest --- test/e2e/benchmark/throughput.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/e2e/benchmark/throughput.go b/test/e2e/benchmark/throughput.go index f8573f7413..eb85e1e5c2 100644 --- a/test/e2e/benchmark/throughput.go +++ b/test/e2e/benchmark/throughput.go @@ -41,8 +41,8 @@ func E2EThroughput() error { CelestiaAppVersion: latestVersion, TxClientVersion: testnet.TxsimVersion, BlobsPerSeq: 1, - BlobSequences: 10, - BlobSizes: "100000-100000", + BlobSequences: 1, + BlobSizes: "10000-10000", PerPeerBandwidth: 5 * 1024 * 1024, UpgradeHeight: 0, TimeoutCommit: 1 * time.Second, @@ -81,8 +81,9 @@ func E2EThroughput() error { // create txsim nodes and point them to the validators log.Println("Creating txsim nodes") - err = testNet.CreateTxClients(testnet.TxsimVersion, 1, "10000-10000", - testnet.DefaultResources, gRPCEndpoints) + err = testNet.CreateTxClients(manifest.TxClientVersion, manifest.BlobSequences, + manifest.BlobSizes, + manifest.TxClientsResource, gRPCEndpoints) testnet.NoError("failed to create tx clients", err) // start the testnet @@ -102,7 +103,7 @@ func E2EThroughput() error { testnet.NoError("failed to start tx clients", testNet.StartTxClients()) // wait some time for the txsim to submit transactions - time.Sleep(1 * time.Minute) + time.Sleep(30 * time.Second) log.Println("Reading blockchain") blockchain, err := testnode.ReadBlockchain(context.Background(), testNet.Node(0).AddressRPC()) From 425b98f674bbaeba565ea9ab558a8287f3314f6d Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 26 Apr 2024 14:19:47 -0400 Subject: [PATCH 15/38] fixes stale comments --- test/e2e/benchmark/throughput.go | 6 ------ test/e2e/testnet/manifest.go | 9 ++------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/test/e2e/benchmark/throughput.go b/test/e2e/benchmark/throughput.go index eb85e1e5c2..ded4e2674e 100644 --- a/test/e2e/benchmark/throughput.go +++ b/test/e2e/benchmark/throughput.go @@ -21,11 +21,6 @@ func main() { } } -type BenchTest struct { - testnet.Testnet - manifest testnet.Manifest -} - func E2EThroughput() error { latestVersion, err := testnet.GetLatestVersion() testnet.NoError("failed to get latest version", err) @@ -67,7 +62,6 @@ func E2EThroughput() error { testNet.Cleanup() }() - // add 2 validators testnet.NoError("failed to create genesis nodes", testNet.CreateGenesisNodes(manifest.Validators, manifest.CelestiaAppVersion, manifest.SelfDelegation, diff --git a/test/e2e/testnet/manifest.go b/test/e2e/testnet/manifest.go index 548e8be830..d602988012 100644 --- a/test/e2e/testnet/manifest.go +++ b/test/e2e/testnet/manifest.go @@ -38,14 +38,11 @@ type Manifest struct { // Bandwidth per peer in bytes per second PerPeerBandwidth int64 // consensus configs - // if TimeoutCommit is set to 0, it won't take effect and a default value will be used - TimeoutCommit time.Duration - // if TimeoutPropose is set to 0, it won't take effect and a default value will be used + TimeoutCommit time.Duration TimeoutPropose time.Duration // Mempool configs // Mempool version - // If Mempool is set to "", it won't take effect and a default value will be used Mempool string BroadcastTxs bool @@ -53,12 +50,10 @@ type Manifest struct { Prometheus bool // consensus manifest - // If MaxBlockBytes is set to 0, it won't take effect and a default value will be used MaxBlockBytes int64 // other configs - UpgradeHeight int64 // Upgrade height - // if GovMaxSquareSize is set to 0, it won't take effect and a default value will be used + UpgradeHeight int64 GovMaxSquareSize int64 TestDuration time.Duration From dd96cdc0ea79bb2134ba55eee2866a0ddd9ee5f2 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 26 Apr 2024 14:21:56 -0400 Subject: [PATCH 16/38] removes private methods --- test/e2e/testnet/manifest.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/test/e2e/testnet/manifest.go b/test/e2e/testnet/manifest.go index d602988012..716713b68b 100644 --- a/test/e2e/testnet/manifest.go +++ b/test/e2e/testnet/manifest.go @@ -61,26 +61,18 @@ type Manifest struct { } func (tm *Manifest) GetGenesisModifiers() []genesis.Modifier { - return getGenesisModifiers(uint64(tm.GovMaxSquareSize)) -} - -func (tm *Manifest) GetConsensusParams() *tmproto.ConsensusParams { - return getConsensusParams(tm.MaxBlockBytes) -} - -func getGenesisModifiers(govMaxSquareSize uint64) []genesis.Modifier { ecfg := encoding.MakeConfig(app.ModuleBasics) var modifiers []genesis.Modifier blobParams := blobtypes.DefaultParams() - blobParams.GovMaxSquareSize = govMaxSquareSize + blobParams.GovMaxSquareSize = uint64(tm.GovMaxSquareSize) modifiers = append(modifiers, genesis.SetBlobParams(ecfg.Codec, blobParams)) return modifiers } -func getConsensusParams(maxBytes int64) *tmproto.ConsensusParams { +func (tm *Manifest) GetConsensusParams() *tmproto.ConsensusParams { cparams := app.DefaultConsensusParams() - cparams.Block.MaxBytes = maxBytes + cparams.Block.MaxBytes = tm.MaxBlockBytes return cparams } From a94467081963290727cf9775826be003c4734108 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 26 Apr 2024 14:27:17 -0400 Subject: [PATCH 17/38] fixes linter issues --- test/e2e/benchmark/throughput.go | 2 +- test/e2e/check_upgrades.go | 4 ++-- test/e2e/simple.go | 2 +- test/e2e/testnet/setup.go | 5 ----- test/e2e/testnet/testnet.go | 5 +++-- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/test/e2e/benchmark/throughput.go b/test/e2e/benchmark/throughput.go index ded4e2674e..b4e47679e9 100644 --- a/test/e2e/benchmark/throughput.go +++ b/test/e2e/benchmark/throughput.go @@ -87,7 +87,7 @@ func E2EThroughput() error { testnet.WithTimeoutPropose(1*time.Second), testnet.WithTimeoutCommit(1*time.Second), testnet.WithPrometheus(true), - //testnet.WithMempool("v1"), + // testnet.WithMempool("v1"), )) log.Println("Starting testnet") testnet.NoError("failed to start testnet", testNet.Start()) diff --git a/test/e2e/check_upgrades.go b/test/e2e/check_upgrades.go index 2f6b63643d..8fe509f215 100644 --- a/test/e2e/check_upgrades.go +++ b/test/e2e/check_upgrades.go @@ -32,7 +32,7 @@ func MinorVersionCompatibility(logger *log.Logger) error { r := rand.New(rand.NewSource(seed)) logger.Println("Running minor version compatibility test", "versions", versions) - testNet, err := testnet.New("runMinorVersionCompatibility", seed, nil) + testNet, err := testnet.New("runMinorVersionCompatibility", seed, nil, "test") testnet.NoError("failed to create testnet", err) defer testNet.Cleanup() @@ -138,7 +138,7 @@ func MajorUpgradeToV2(logger *log.Logger) error { defer cancel() logger.Println("Creating testnet") - testNet, err := testnet.New("runMajorUpgradeToV2", seed, nil) + testNet, err := testnet.New("runMajorUpgradeToV2", seed, nil, "test") testnet.NoError("failed to create testnet", err) defer testNet.Cleanup() diff --git a/test/e2e/simple.go b/test/e2e/simple.go index 9d147a290f..54e0f71a27 100644 --- a/test/e2e/simple.go +++ b/test/e2e/simple.go @@ -24,7 +24,7 @@ func E2ESimple(logger *log.Logger) error { logger.Println("Running simple e2e test", "version", latestVersion) - testNet, err := testnet.New("E2ESimple", seed, nil) + testNet, err := testnet.New("E2ESimple", seed, nil, "test") testnet.NoError("failed to create testnet", err) defer testNet.Cleanup() diff --git a/test/e2e/testnet/setup.go b/test/e2e/testnet/setup.go index c93c266b3c..668b6e07a7 100644 --- a/test/e2e/testnet/setup.go +++ b/test/e2e/testnet/setup.go @@ -18,10 +18,6 @@ func MakeConfig(node *Node, opts ...Option) (*config.Config, error) { cfg.RPC.ListenAddress = "tcp://0.0.0.0:26657" cfg.P2P.ExternalAddress = fmt.Sprintf("tcp://%v", node.AddressP2P(false)) cfg.P2P.PersistentPeers = strings.Join(node.InitialPeers, ",") - //cfg.P2P.SendRate = 5 * 1024 * 1024 // 5MiB/s - //cfg.P2P.RecvRate = 5 * 1024 * 1024 // 5MiB/s - //cfg.Consensus.TimeoutPropose = 1 * time.Second - //cfg.Consensus.TimeoutCommit = 1 * time.Second cfg.Instrumentation.Prometheus = true for _, opt := range opts { @@ -37,7 +33,6 @@ func WithPerPeerBandwidth(bandwidth int64) Option { return func(cfg *config.Config) { cfg.P2P.SendRate = bandwidth cfg.P2P.RecvRate = bandwidth - } } diff --git a/test/e2e/testnet/testnet.go b/test/e2e/testnet/testnet.go index b0c8001c73..5be07d673d 100644 --- a/test/e2e/testnet/testnet.go +++ b/test/e2e/testnet/testnet.go @@ -28,14 +28,15 @@ type Testnet struct { func New(name string, seed int64, grafana *GrafanaInfo, chainID string, genesisModifiers ...genesis.Modifier) ( - *Testnet, error) { + *Testnet, error, +) { identifier := fmt.Sprintf("%s_%s", name, time.Now().Format("20060102_150405")) if err := knuu.InitializeWithScope(identifier); err != nil { return nil, err } gen := genesis.NewDefaultGenesis().WithChainID(chainID).WithModifiers(genesisModifiers...) - //gen.ConsensusParams.Block.MaxBytes = appconsts.DefaultMaxBytes + // gen.ConsensusParams.Block.MaxBytes = appconsts.DefaultMaxBytes return &Testnet{ seed: seed, nodes: make([]*Node, 0), From 4e265052d1c8fcdbdbebb67a3f7f3ac4600ee172 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 26 Apr 2024 14:29:22 -0400 Subject: [PATCH 18/38] gets the remainder of the test parameters from the manifest --- test/e2e/benchmark/throughput.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/test/e2e/benchmark/throughput.go b/test/e2e/benchmark/throughput.go index b4e47679e9..f86ebec3bd 100644 --- a/test/e2e/benchmark/throughput.go +++ b/test/e2e/benchmark/throughput.go @@ -47,7 +47,7 @@ func E2EThroughput() error { Prometheus: true, GovMaxSquareSize: appconsts.DefaultGovMaxSquareSize, MaxBlockBytes: appconsts.DefaultMaxBytes, - TestDuration: 1 * time.Minute, + TestDuration: 30 * time.Second, TxClientsNum: 2, } // create a new testnet @@ -83,21 +83,20 @@ func E2EThroughput() error { // start the testnet log.Println("Setting up testnet") testnet.NoError("failed to setup testnet", testNet.Setup( - testnet.WithPerPeerBandwidth(5*1024*1024), - testnet.WithTimeoutPropose(1*time.Second), - testnet.WithTimeoutCommit(1*time.Second), - testnet.WithPrometheus(true), - // testnet.WithMempool("v1"), + testnet.WithPerPeerBandwidth(manifest.PerPeerBandwidth), + testnet.WithTimeoutPropose(manifest.TimeoutPropose), + testnet.WithTimeoutCommit(manifest.TimeoutCommit), + testnet.WithPrometheus(manifest.Prometheus), )) log.Println("Starting testnet") testnet.NoError("failed to start testnet", testNet.Start()) // once the testnet is up, start the txsim - log.Println("Starting txsim nodes") + log.Println("Starting tx clients") testnet.NoError("failed to start tx clients", testNet.StartTxClients()) // wait some time for the txsim to submit transactions - time.Sleep(30 * time.Second) + time.Sleep(manifest.TestDuration) log.Println("Reading blockchain") blockchain, err := testnode.ReadBlockchain(context.Background(), testNet.Node(0).AddressRPC()) From 25f4026ee1c6a89e464c621ebfa40939f66433f5 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 26 Apr 2024 14:49:36 -0400 Subject: [PATCH 19/38] some reordering and refactoring --- test/e2e/benchmark/throughput.go | 2 +- test/e2e/testnet/manifest.go | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/test/e2e/benchmark/throughput.go b/test/e2e/benchmark/throughput.go index f86ebec3bd..9792090b50 100644 --- a/test/e2e/benchmark/throughput.go +++ b/test/e2e/benchmark/throughput.go @@ -48,7 +48,7 @@ func E2EThroughput() error { GovMaxSquareSize: appconsts.DefaultGovMaxSquareSize, MaxBlockBytes: appconsts.DefaultMaxBytes, TestDuration: 30 * time.Second, - TxClientsNum: 2, + TxClients: 2, } // create a new testnet testNet, err := testnet.New("E2EThroughput", seed, diff --git a/test/e2e/testnet/manifest.go b/test/e2e/testnet/manifest.go index 716713b68b..c0f9897203 100644 --- a/test/e2e/testnet/manifest.go +++ b/test/e2e/testnet/manifest.go @@ -12,19 +12,21 @@ import ( // Manifest defines the parameters for a testnet. type Manifest struct { - ChainID string + ChainID string + TestDuration time.Duration // Number of validators in the testnet Validators int - // Resource requirements for a validator node - ValidatorResource Resources - // Resource requirements for a tx client - TxClientsResource Resources + TxClients int // Self-delegation amount for validators SelfDelegation int64 // CelestiaAppVersion a specific version of the celestia-app container image within celestiaorg repository on GitHub's Container Registry i.e., https://github.com/celestiaorg/celestia-app/pkgs/container/celestia-app CelestiaAppVersion string // TxClientVersion a specific version of the txsim container image within celestiaorg repository on GitHub's Container Registry, i.e., https://github.com/celestiaorg/celestia-app/pkgs/container/txsim TxClientVersion string + // Resource requirements for a validator node + ValidatorResource Resources + // Resource requirements for a tx client + TxClientsResource Resources // tx client settings // Number of blobs per sequence @@ -49,15 +51,12 @@ type Manifest struct { // prometheus configs Prometheus bool - // consensus manifest + // consensus parameters MaxBlockBytes int64 // other configs UpgradeHeight int64 GovMaxSquareSize int64 - - TestDuration time.Duration - TxClientsNum int } func (tm *Manifest) GetGenesisModifiers() []genesis.Modifier { From fe832f322d077162147f79c514d4ce227ad14cf6 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 26 Apr 2024 15:15:04 -0400 Subject: [PATCH 20/38] refactors the code --- test/e2e/benchmark/throughput.go | 114 +++++++++++++++++++------------ 1 file changed, 71 insertions(+), 43 deletions(-) diff --git a/test/e2e/benchmark/throughput.go b/test/e2e/benchmark/throughput.go index 9792090b50..d29ee91b67 100644 --- a/test/e2e/benchmark/throughput.go +++ b/test/e2e/benchmark/throughput.go @@ -21,6 +21,69 @@ func main() { } } +type BenchTest struct { + *testnet.Testnet + manifest *testnet.Manifest +} + +func NewBenchTest(name string, manifest *testnet.Manifest) (*BenchTest, error) { + // create a new testnet + testNet, err := testnet.New(name, seed, + testnet.GetGrafanaInfoFromEnvVar(), manifest.ChainID, + manifest.GetGenesisModifiers()...) + testnet.NoError("failed to create testnet", err) + + testNet.SetConsensusParams(manifest.GetConsensusParams()) + return &BenchTest{Testnet: testNet, manifest: manifest}, nil +} + +func (b *BenchTest) SetupNodes() error { + testnet.NoError("failed to create genesis nodes", + b.CreateGenesisNodes(b.manifest.Validators, + b.manifest.CelestiaAppVersion, b.manifest.SelfDelegation, + b.manifest.UpgradeHeight, b.manifest.ValidatorResource)) + + // obtain the GRPC endpoints of the validators + gRPCEndpoints, err := b.RemoteGRPCEndpoints() + testnet.NoError("failed to get validators GRPC endpoints", err) + log.Println("validators GRPC endpoints", gRPCEndpoints) + + // create txsim nodes and point them to the validators + log.Println("Creating txsim nodes") + + err = b.CreateTxClients(b.manifest.TxClientVersion, + b.manifest.BlobSequences, + b.manifest.BlobSizes, + b.manifest.TxClientsResource, gRPCEndpoints) + testnet.NoError("failed to create tx clients", err) + + // start the testnet + log.Println("Setting up testnet") + testnet.NoError("failed to setup testnet", b.Setup( + testnet.WithPerPeerBandwidth(b.manifest.PerPeerBandwidth), + testnet.WithTimeoutPropose(b.manifest.TimeoutPropose), + testnet.WithTimeoutCommit(b.manifest.TimeoutCommit), + testnet.WithPrometheus(b.manifest.Prometheus), + )) + return nil +} + +func (b *BenchTest) Run() { + log.Println("Starting testnet") + testnet.NoError("failed to start testnet", b.Start()) + + // once the testnet is up, start the txsim + log.Println("Starting tx clients") + testnet.NoError("failed to start tx clients", b.StartTxClients()) + + // wait some time for the txsim to submit transactions + time.Sleep(b.manifest.TestDuration) + + // TODO perhaps we can stop the nodes at this point for precise + // termination of the test + +} + func E2EThroughput() error { latestVersion, err := testnet.GetLatestVersion() testnet.NoError("failed to get latest version", err) @@ -50,56 +113,20 @@ func E2EThroughput() error { TestDuration: 30 * time.Second, TxClients: 2, } - // create a new testnet - testNet, err := testnet.New("E2EThroughput", seed, - testnet.GetGrafanaInfoFromEnvVar(), manifest.ChainID, - manifest.GetGenesisModifiers()...) - testnet.NoError("failed to create testnet", err) - - testNet.SetConsensusParams(manifest.GetConsensusParams()) + benchTest, _ := NewBenchTest("E2EThroughput", &manifest) defer func() { log.Print("Cleaning up testnet") - testNet.Cleanup() + benchTest.Cleanup() }() - testnet.NoError("failed to create genesis nodes", - testNet.CreateGenesisNodes(manifest.Validators, - manifest.CelestiaAppVersion, manifest.SelfDelegation, - manifest.UpgradeHeight, manifest.ValidatorResource)) + benchTest.SetupNodes() - // obtain the GRPC endpoints of the validators - gRPCEndpoints, err := testNet.RemoteGRPCEndpoints() - testnet.NoError("failed to get validators GRPC endpoints", err) - log.Println("validators GRPC endpoints", gRPCEndpoints) - - // create txsim nodes and point them to the validators - log.Println("Creating txsim nodes") - - err = testNet.CreateTxClients(manifest.TxClientVersion, manifest.BlobSequences, - manifest.BlobSizes, - manifest.TxClientsResource, gRPCEndpoints) - testnet.NoError("failed to create tx clients", err) - - // start the testnet - log.Println("Setting up testnet") - testnet.NoError("failed to setup testnet", testNet.Setup( - testnet.WithPerPeerBandwidth(manifest.PerPeerBandwidth), - testnet.WithTimeoutPropose(manifest.TimeoutPropose), - testnet.WithTimeoutCommit(manifest.TimeoutCommit), - testnet.WithPrometheus(manifest.Prometheus), - )) - log.Println("Starting testnet") - testnet.NoError("failed to start testnet", testNet.Start()) - - // once the testnet is up, start the txsim - log.Println("Starting tx clients") - testnet.NoError("failed to start tx clients", testNet.StartTxClients()) - - // wait some time for the txsim to submit transactions - time.Sleep(manifest.TestDuration) + benchTest.Run() + // log.Println("Reading blockchain") - blockchain, err := testnode.ReadBlockchain(context.Background(), testNet.Node(0).AddressRPC()) + blockchain, err := testnode.ReadBlockchain(context.Background(), + benchTest.Node(0).AddressRPC()) testnet.NoError("failed to read blockchain", err) totalTxs := 0 @@ -112,6 +139,7 @@ func E2EThroughput() error { if totalTxs < 10 { return fmt.Errorf("expected at least 10 transactions, got %d", totalTxs) } + log.Println("--- PASS ✅: E2EThroughput") return nil } From e1a6e2d9d139a85e6fc8639021b6d8fb56fd24b5 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 26 Apr 2024 15:46:00 -0400 Subject: [PATCH 21/38] resolves linter issues and returns error from benchTest methods --- test/e2e/benchmark/throughput.go | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/test/e2e/benchmark/throughput.go b/test/e2e/benchmark/throughput.go index d29ee91b67..cc973b4016 100644 --- a/test/e2e/benchmark/throughput.go +++ b/test/e2e/benchmark/throughput.go @@ -31,7 +31,7 @@ func NewBenchTest(name string, manifest *testnet.Manifest) (*BenchTest, error) { testNet, err := testnet.New(name, seed, testnet.GetGrafanaInfoFromEnvVar(), manifest.ChainID, manifest.GetGenesisModifiers()...) - testnet.NoError("failed to create testnet", err) + return nil, err testNet.SetConsensusParams(manifest.GetConsensusParams()) return &BenchTest{Testnet: testNet, manifest: manifest}, nil @@ -68,20 +68,25 @@ func (b *BenchTest) SetupNodes() error { return nil } -func (b *BenchTest) Run() { +func (b *BenchTest) Run() error { log.Println("Starting testnet") - testnet.NoError("failed to start testnet", b.Start()) + err := b.Start() + if err != nil { + return fmt.Errorf("failed to start testnet: %v", err) + } // once the testnet is up, start the txsim log.Println("Starting tx clients") - testnet.NoError("failed to start tx clients", b.StartTxClients()) + err = b.StartTxClients() + if err != nil { + return fmt.Errorf("failed to start tx clients: %v", err) + } // wait some time for the txsim to submit transactions time.Sleep(b.manifest.TestDuration) - // TODO perhaps we can stop the nodes at this point for precise - // termination of the test - + // TODO perhaps we can stop the nodes at this point to save resources + return nil } func E2EThroughput() error { @@ -113,17 +118,17 @@ func E2EThroughput() error { TestDuration: 30 * time.Second, TxClients: 2, } - benchTest, _ := NewBenchTest("E2EThroughput", &manifest) + benchTest, err := NewBenchTest("E2EThroughput", &manifest) + testnet.NoError("failed to create bench test", err) defer func() { log.Print("Cleaning up testnet") benchTest.Cleanup() }() - benchTest.SetupNodes() + testnet.NoError("failed to setup nodes", benchTest.SetupNodes()) - benchTest.Run() + testnet.NoError("failed to run the bench test", benchTest.Run()) - // log.Println("Reading blockchain") blockchain, err := testnode.ReadBlockchain(context.Background(), benchTest.Node(0).AddressRPC()) From c1e7d86e02e9673505c0d7c56b04fe8586771482 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 26 Apr 2024 15:46:59 -0400 Subject: [PATCH 22/38] removes early return --- test/e2e/benchmark/throughput.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/e2e/benchmark/throughput.go b/test/e2e/benchmark/throughput.go index cc973b4016..0e1b34e8ae 100644 --- a/test/e2e/benchmark/throughput.go +++ b/test/e2e/benchmark/throughput.go @@ -31,7 +31,9 @@ func NewBenchTest(name string, manifest *testnet.Manifest) (*BenchTest, error) { testNet, err := testnet.New(name, seed, testnet.GetGrafanaInfoFromEnvVar(), manifest.ChainID, manifest.GetGenesisModifiers()...) - return nil, err + if err != nil { + return nil, err + } testNet.SetConsensusParams(manifest.GetConsensusParams()) return &BenchTest{Testnet: testNet, manifest: manifest}, nil From 4ed25aa222be3ef43673dd932f4d0e788f1a12c3 Mon Sep 17 00:00:00 2001 From: sanaz Date: Tue, 30 Apr 2024 10:20:20 -0700 Subject: [PATCH 23/38] defines a separate go file for the BenchTest type and methods --- test/e2e/benchmark/benchTest.go | 79 ++++++++++++++++++++++++++++++++ test/e2e/benchmark/throughput.go | 70 ---------------------------- 2 files changed, 79 insertions(+), 70 deletions(-) create mode 100644 test/e2e/benchmark/benchTest.go diff --git a/test/e2e/benchmark/benchTest.go b/test/e2e/benchmark/benchTest.go new file mode 100644 index 0000000000..2dbe7c3be3 --- /dev/null +++ b/test/e2e/benchmark/benchTest.go @@ -0,0 +1,79 @@ +package main + +import ( + "fmt" + "log" + "time" + + "github.com/celestiaorg/celestia-app/v2/test/e2e/testnet" +) + +type BenchTest struct { + *testnet.Testnet + manifest *testnet.Manifest +} + +func NewBenchTest(name string, manifest *testnet.Manifest) (*BenchTest, error) { + // create a new testnet + testNet, err := testnet.New(name, seed, + testnet.GetGrafanaInfoFromEnvVar(), manifest.ChainID, + manifest.GetGenesisModifiers()...) + if err != nil { + return nil, err + } + + testNet.SetConsensusParams(manifest.GetConsensusParams()) + return &BenchTest{Testnet: testNet, manifest: manifest}, nil +} + +func (b *BenchTest) SetupNodes() error { + testnet.NoError("failed to create genesis nodes", + b.CreateGenesisNodes(b.manifest.Validators, + b.manifest.CelestiaAppVersion, b.manifest.SelfDelegation, + b.manifest.UpgradeHeight, b.manifest.ValidatorResource)) + + // obtain the GRPC endpoints of the validators + gRPCEndpoints, err := b.RemoteGRPCEndpoints() + testnet.NoError("failed to get validators GRPC endpoints", err) + log.Println("validators GRPC endpoints", gRPCEndpoints) + + // create txsim nodes and point them to the validators + log.Println("Creating txsim nodes") + + err = b.CreateTxClients(b.manifest.TxClientVersion, + b.manifest.BlobSequences, + b.manifest.BlobSizes, + b.manifest.TxClientsResource, gRPCEndpoints) + testnet.NoError("failed to create tx clients", err) + + // start the testnet + log.Println("Setting up testnet") + testnet.NoError("failed to setup testnet", b.Setup( + testnet.WithPerPeerBandwidth(b.manifest.PerPeerBandwidth), + testnet.WithTimeoutPropose(b.manifest.TimeoutPropose), + testnet.WithTimeoutCommit(b.manifest.TimeoutCommit), + testnet.WithPrometheus(b.manifest.Prometheus), + )) + return nil +} + +func (b *BenchTest) Run() error { + log.Println("Starting testnet") + err := b.Start() + if err != nil { + return fmt.Errorf("failed to start testnet: %v", err) + } + + // once the testnet is up, start the txsim + log.Println("Starting tx clients") + err = b.StartTxClients() + if err != nil { + return fmt.Errorf("failed to start tx clients: %v", err) + } + + // wait some time for the txsim to submit transactions + time.Sleep(b.manifest.TestDuration) + + // TODO perhaps we can stop the nodes at this point to save resources + return nil +} diff --git a/test/e2e/benchmark/throughput.go b/test/e2e/benchmark/throughput.go index 0e1b34e8ae..f5d3a63d02 100644 --- a/test/e2e/benchmark/throughput.go +++ b/test/e2e/benchmark/throughput.go @@ -21,76 +21,6 @@ func main() { } } -type BenchTest struct { - *testnet.Testnet - manifest *testnet.Manifest -} - -func NewBenchTest(name string, manifest *testnet.Manifest) (*BenchTest, error) { - // create a new testnet - testNet, err := testnet.New(name, seed, - testnet.GetGrafanaInfoFromEnvVar(), manifest.ChainID, - manifest.GetGenesisModifiers()...) - if err != nil { - return nil, err - } - - testNet.SetConsensusParams(manifest.GetConsensusParams()) - return &BenchTest{Testnet: testNet, manifest: manifest}, nil -} - -func (b *BenchTest) SetupNodes() error { - testnet.NoError("failed to create genesis nodes", - b.CreateGenesisNodes(b.manifest.Validators, - b.manifest.CelestiaAppVersion, b.manifest.SelfDelegation, - b.manifest.UpgradeHeight, b.manifest.ValidatorResource)) - - // obtain the GRPC endpoints of the validators - gRPCEndpoints, err := b.RemoteGRPCEndpoints() - testnet.NoError("failed to get validators GRPC endpoints", err) - log.Println("validators GRPC endpoints", gRPCEndpoints) - - // create txsim nodes and point them to the validators - log.Println("Creating txsim nodes") - - err = b.CreateTxClients(b.manifest.TxClientVersion, - b.manifest.BlobSequences, - b.manifest.BlobSizes, - b.manifest.TxClientsResource, gRPCEndpoints) - testnet.NoError("failed to create tx clients", err) - - // start the testnet - log.Println("Setting up testnet") - testnet.NoError("failed to setup testnet", b.Setup( - testnet.WithPerPeerBandwidth(b.manifest.PerPeerBandwidth), - testnet.WithTimeoutPropose(b.manifest.TimeoutPropose), - testnet.WithTimeoutCommit(b.manifest.TimeoutCommit), - testnet.WithPrometheus(b.manifest.Prometheus), - )) - return nil -} - -func (b *BenchTest) Run() error { - log.Println("Starting testnet") - err := b.Start() - if err != nil { - return fmt.Errorf("failed to start testnet: %v", err) - } - - // once the testnet is up, start the txsim - log.Println("Starting tx clients") - err = b.StartTxClients() - if err != nil { - return fmt.Errorf("failed to start tx clients: %v", err) - } - - // wait some time for the txsim to submit transactions - time.Sleep(b.manifest.TestDuration) - - // TODO perhaps we can stop the nodes at this point to save resources - return nil -} - func E2EThroughput() error { latestVersion, err := testnet.GetLatestVersion() testnet.NoError("failed to get latest version", err) From c2c7dfa917f55975e2b8ac07ab4c6e31fefb00c2 Mon Sep 17 00:00:00 2001 From: sanaz Date: Tue, 30 Apr 2024 10:22:42 -0700 Subject: [PATCH 24/38] moves manifest to the benchmark package --- test/e2e/benchmark/benchTest.go | 4 ++-- test/e2e/{testnet => benchmark}/manifest.go | 7 ++++--- test/e2e/benchmark/throughput.go | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) rename test/e2e/{testnet => benchmark}/manifest.go (93%) diff --git a/test/e2e/benchmark/benchTest.go b/test/e2e/benchmark/benchTest.go index 2dbe7c3be3..45c790a4aa 100644 --- a/test/e2e/benchmark/benchTest.go +++ b/test/e2e/benchmark/benchTest.go @@ -10,10 +10,10 @@ import ( type BenchTest struct { *testnet.Testnet - manifest *testnet.Manifest + manifest *Manifest } -func NewBenchTest(name string, manifest *testnet.Manifest) (*BenchTest, error) { +func NewBenchTest(name string, manifest *Manifest) (*BenchTest, error) { // create a new testnet testNet, err := testnet.New(name, seed, testnet.GetGrafanaInfoFromEnvVar(), manifest.ChainID, diff --git a/test/e2e/testnet/manifest.go b/test/e2e/benchmark/manifest.go similarity index 93% rename from test/e2e/testnet/manifest.go rename to test/e2e/benchmark/manifest.go index c0f9897203..e628113a79 100644 --- a/test/e2e/testnet/manifest.go +++ b/test/e2e/benchmark/manifest.go @@ -1,10 +1,11 @@ -package testnet +package main import ( "time" "github.com/celestiaorg/celestia-app/v2/app" "github.com/celestiaorg/celestia-app/v2/app/encoding" + "github.com/celestiaorg/celestia-app/v2/test/e2e/testnet" "github.com/celestiaorg/celestia-app/v2/test/util/genesis" blobtypes "github.com/celestiaorg/celestia-app/v2/x/blob/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -24,9 +25,9 @@ type Manifest struct { // TxClientVersion a specific version of the txsim container image within celestiaorg repository on GitHub's Container Registry, i.e., https://github.com/celestiaorg/celestia-app/pkgs/container/txsim TxClientVersion string // Resource requirements for a validator node - ValidatorResource Resources + ValidatorResource testnet.Resources // Resource requirements for a tx client - TxClientsResource Resources + TxClientsResource testnet.Resources // tx client settings // Number of blobs per sequence diff --git a/test/e2e/benchmark/throughput.go b/test/e2e/benchmark/throughput.go index f5d3a63d02..46165d6156 100644 --- a/test/e2e/benchmark/throughput.go +++ b/test/e2e/benchmark/throughput.go @@ -27,7 +27,7 @@ func E2EThroughput() error { log.Println("=== RUN E2EThroughput", "version:", latestVersion) - manifest := testnet.Manifest{ + manifest := Manifest{ ChainID: "test-sanaz", Validators: 2, ValidatorResource: testnet.DefaultResources, From b2ac5f3d50878a33a4e45ef01eff9c652cedd11f Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 17 May 2024 07:59:42 -0700 Subject: [PATCH 25/38] refactors the code to rename bench to benchmark --- test/e2e/benchmark/{benchTest.go => benchmark.go} | 11 +++++------ test/e2e/benchmark/throughput.go | 5 ++++- 2 files changed, 9 insertions(+), 7 deletions(-) rename test/e2e/benchmark/{benchTest.go => benchmark.go} (86%) diff --git a/test/e2e/benchmark/benchTest.go b/test/e2e/benchmark/benchmark.go similarity index 86% rename from test/e2e/benchmark/benchTest.go rename to test/e2e/benchmark/benchmark.go index 45c790a4aa..c374cb01f1 100644 --- a/test/e2e/benchmark/benchTest.go +++ b/test/e2e/benchmark/benchmark.go @@ -8,12 +8,12 @@ import ( "github.com/celestiaorg/celestia-app/v2/test/e2e/testnet" ) -type BenchTest struct { +type BenchmarkTest struct { *testnet.Testnet manifest *Manifest } -func NewBenchTest(name string, manifest *Manifest) (*BenchTest, error) { +func NewBenchmarkTest(name string, manifest *Manifest) (*BenchmarkTest, error) { // create a new testnet testNet, err := testnet.New(name, seed, testnet.GetGrafanaInfoFromEnvVar(), manifest.ChainID, @@ -23,10 +23,10 @@ func NewBenchTest(name string, manifest *Manifest) (*BenchTest, error) { } testNet.SetConsensusParams(manifest.GetConsensusParams()) - return &BenchTest{Testnet: testNet, manifest: manifest}, nil + return &BenchmarkTest{Testnet: testNet, manifest: manifest}, nil } -func (b *BenchTest) SetupNodes() error { +func (b *BenchmarkTest) SetupNodes() error { testnet.NoError("failed to create genesis nodes", b.CreateGenesisNodes(b.manifest.Validators, b.manifest.CelestiaAppVersion, b.manifest.SelfDelegation, @@ -57,7 +57,7 @@ func (b *BenchTest) SetupNodes() error { return nil } -func (b *BenchTest) Run() error { +func (b *BenchmarkTest) Run() error { log.Println("Starting testnet") err := b.Start() if err != nil { @@ -74,6 +74,5 @@ func (b *BenchTest) Run() error { // wait some time for the txsim to submit transactions time.Sleep(b.manifest.TestDuration) - // TODO perhaps we can stop the nodes at this point to save resources return nil } diff --git a/test/e2e/benchmark/throughput.go b/test/e2e/benchmark/throughput.go index 46165d6156..2cb0792d18 100644 --- a/test/e2e/benchmark/throughput.go +++ b/test/e2e/benchmark/throughput.go @@ -50,8 +50,10 @@ func E2EThroughput() error { TestDuration: 30 * time.Second, TxClients: 2, } - benchTest, err := NewBenchTest("E2EThroughput", &manifest) + + benchTest, err := NewBenchmarkTest("E2EThroughput", &manifest) testnet.NoError("failed to create bench test", err) + defer func() { log.Print("Cleaning up testnet") benchTest.Cleanup() @@ -61,6 +63,7 @@ func E2EThroughput() error { testnet.NoError("failed to run the bench test", benchTest.Run()) + // post test data collection and validation log.Println("Reading blockchain") blockchain, err := testnode.ReadBlockchain(context.Background(), benchTest.Node(0).AddressRPC()) From 193efd990fd43776e56a63bcfa56ca4e0ed5777a Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 17 May 2024 08:03:06 -0700 Subject: [PATCH 26/38] replaces txsim with txclient --- test/e2e/benchmark/benchmark.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/e2e/benchmark/benchmark.go b/test/e2e/benchmark/benchmark.go index c374cb01f1..a612c049bb 100644 --- a/test/e2e/benchmark/benchmark.go +++ b/test/e2e/benchmark/benchmark.go @@ -37,8 +37,8 @@ func (b *BenchmarkTest) SetupNodes() error { testnet.NoError("failed to get validators GRPC endpoints", err) log.Println("validators GRPC endpoints", gRPCEndpoints) - // create txsim nodes and point them to the validators - log.Println("Creating txsim nodes") + // create tx clients nodes and point them to the validators + log.Println("Creating tx clients") err = b.CreateTxClients(b.manifest.TxClientVersion, b.manifest.BlobSequences, @@ -64,14 +64,14 @@ func (b *BenchmarkTest) Run() error { return fmt.Errorf("failed to start testnet: %v", err) } - // once the testnet is up, start the txsim + // once the testnet is up, start tx clients log.Println("Starting tx clients") err = b.StartTxClients() if err != nil { return fmt.Errorf("failed to start tx clients: %v", err) } - // wait some time for the txsim to submit transactions + // wait some time for the tx client to submit transactions time.Sleep(b.manifest.TestDuration) return nil From db224b8950236e0e9b24e4dccd199dddee774517 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 17 May 2024 08:10:17 -0700 Subject: [PATCH 27/38] removes a redundant word --- test/e2e/benchmark/benchmark.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/benchmark/benchmark.go b/test/e2e/benchmark/benchmark.go index a612c049bb..7ecbb17bd7 100644 --- a/test/e2e/benchmark/benchmark.go +++ b/test/e2e/benchmark/benchmark.go @@ -37,7 +37,7 @@ func (b *BenchmarkTest) SetupNodes() error { testnet.NoError("failed to get validators GRPC endpoints", err) log.Println("validators GRPC endpoints", gRPCEndpoints) - // create tx clients nodes and point them to the validators + // create tx clients and point them to the validators log.Println("Creating tx clients") err = b.CreateTxClients(b.manifest.TxClientVersion, From e94ae4d6b6d88d10de6f5d8cd34431ebbaee60e5 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 17 May 2024 08:15:53 -0700 Subject: [PATCH 28/38] adds godoc for the BenchmarkTest methods --- test/e2e/benchmark/benchmark.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/e2e/benchmark/benchmark.go b/test/e2e/benchmark/benchmark.go index 7ecbb17bd7..1fb65e9812 100644 --- a/test/e2e/benchmark/benchmark.go +++ b/test/e2e/benchmark/benchmark.go @@ -26,6 +26,9 @@ func NewBenchmarkTest(name string, manifest *Manifest) (*BenchmarkTest, error) { return &BenchmarkTest{Testnet: testNet, manifest: manifest}, nil } +// SetupNodes creates genesis nodes and tx clients based on the manifest. +// There will be manifest.Validators validators and manifest.TxClients tx clients. +// Each tx client connects to one validator. If TxClients are fewer than Validators, some validators will not have a tx client. func (b *BenchmarkTest) SetupNodes() error { testnet.NoError("failed to create genesis nodes", b.CreateGenesisNodes(b.manifest.Validators, @@ -57,6 +60,7 @@ func (b *BenchmarkTest) SetupNodes() error { return nil } +// Run runs the benchmark test for the specified duration in the manifest. func (b *BenchmarkTest) Run() error { log.Println("Starting testnet") err := b.Start() @@ -71,7 +75,7 @@ func (b *BenchmarkTest) Run() error { return fmt.Errorf("failed to start tx clients: %v", err) } - // wait some time for the tx client to submit transactions + // wait some time for the tx clients to submit transactions time.Sleep(b.manifest.TestDuration) return nil From a45e048c593e7a716223a81ec4264c7fe87de275 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 17 May 2024 08:19:26 -0700 Subject: [PATCH 29/38] deletes old manifest file under the testnet package --- test/e2e/benchmark/manifest.go | 12 +++--- test/e2e/testnet/manifest.go | 79 ---------------------------------- 2 files changed, 7 insertions(+), 84 deletions(-) delete mode 100644 test/e2e/testnet/manifest.go diff --git a/test/e2e/benchmark/manifest.go b/test/e2e/benchmark/manifest.go index e628113a79..e4700da0b3 100644 --- a/test/e2e/benchmark/manifest.go +++ b/test/e2e/benchmark/manifest.go @@ -17,7 +17,9 @@ type Manifest struct { TestDuration time.Duration // Number of validators in the testnet Validators int - TxClients int + // Number of tx clients (txsim for now) in the testnet; there will be 1 txclient per validator + // if TXClients is less than Validators, the remaining validators will not have any txclients + TxClients int // Self-delegation amount for validators SelfDelegation int64 // CelestiaAppVersion a specific version of the celestia-app container image within celestiaorg repository on GitHub's Container Registry i.e., https://github.com/celestiaorg/celestia-app/pkgs/container/celestia-app @@ -60,19 +62,19 @@ type Manifest struct { GovMaxSquareSize int64 } -func (tm *Manifest) GetGenesisModifiers() []genesis.Modifier { +func (m *Manifest) GetGenesisModifiers() []genesis.Modifier { ecfg := encoding.MakeConfig(app.ModuleBasics) var modifiers []genesis.Modifier blobParams := blobtypes.DefaultParams() - blobParams.GovMaxSquareSize = uint64(tm.GovMaxSquareSize) + blobParams.GovMaxSquareSize = uint64(m.GovMaxSquareSize) modifiers = append(modifiers, genesis.SetBlobParams(ecfg.Codec, blobParams)) return modifiers } -func (tm *Manifest) GetConsensusParams() *tmproto.ConsensusParams { +func (m *Manifest) GetConsensusParams() *tmproto.ConsensusParams { cparams := app.DefaultConsensusParams() - cparams.Block.MaxBytes = tm.MaxBlockBytes + cparams.Block.MaxBytes = m.MaxBlockBytes return cparams } diff --git a/test/e2e/testnet/manifest.go b/test/e2e/testnet/manifest.go deleted file mode 100644 index cd2c083f6d..0000000000 --- a/test/e2e/testnet/manifest.go +++ /dev/null @@ -1,79 +0,0 @@ -package testnet - -import ( - "time" - - "github.com/celestiaorg/celestia-app/v2/app" - "github.com/celestiaorg/celestia-app/v2/app/encoding" - "github.com/celestiaorg/celestia-app/v2/test/util/genesis" - blobtypes "github.com/celestiaorg/celestia-app/v2/x/blob/types" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" -) - -// Manifest defines the parameters for a testnet. -type Manifest struct { - ChainID string - TestDuration time.Duration - // Number of validators in the testnet - Validators int - // Number of tx clients (txsim for now) in the testnet; there will be 1 txclient per validator - // if TXClients is less than Validators, the remaining validators will not have any txclients - TxClients int - // Self-delegation amount for validators - SelfDelegation int64 - // CelestiaAppVersion a specific version of the celestia-app container image within celestiaorg repository on GitHub's Container Registry i.e., https://github.com/celestiaorg/celestia-app/pkgs/container/celestia-app - CelestiaAppVersion string - // TxClientVersion a specific version of the txsim container image within celestiaorg repository on GitHub's Container Registry, i.e., https://github.com/celestiaorg/celestia-app/pkgs/container/txsim - TxClientVersion string - // Resource requirements for a validator node - ValidatorResource Resources - // Resource requirements for a tx client - TxClientsResource Resources - - // tx client settings - // Number of blobs per sequence - BlobsPerSeq int - // Number of blob sequences - BlobSequences int - // Size of blobs in bytes, e.g., "10000" (exact size) or "10000-20000" (min-max format) - BlobSizes string - - // p2p configs - // Bandwidth per peer in bytes per second - PerPeerBandwidth int64 - // consensus configs - TimeoutCommit time.Duration - TimeoutPropose time.Duration - - // Mempool configs - // Mempool version - Mempool string - BroadcastTxs bool - - // prometheus configs - Prometheus bool - - // consensus parameters - MaxBlockBytes int64 - - // other configs - UpgradeHeight int64 - GovMaxSquareSize int64 -} - -func (m *Manifest) GetGenesisModifiers() []genesis.Modifier { - ecfg := encoding.MakeConfig(app.ModuleBasics) - var modifiers []genesis.Modifier - - blobParams := blobtypes.DefaultParams() - blobParams.GovMaxSquareSize = uint64(m.GovMaxSquareSize) - modifiers = append(modifiers, genesis.SetBlobParams(ecfg.Codec, blobParams)) - - return modifiers -} - -func (m *Manifest) GetConsensusParams() *tmproto.ConsensusParams { - cparams := app.DefaultConsensusParams() - cparams.Block.MaxBytes = m.MaxBlockBytes - return cparams -} From 15b200c5924254abcfa6390aaa9ed22cb12e3140 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 17 May 2024 09:20:53 -0700 Subject: [PATCH 30/38] fixes chain ID --- test/e2e/benchmark/throughput.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/benchmark/throughput.go b/test/e2e/benchmark/throughput.go index 2cb0792d18..9ca03fe347 100644 --- a/test/e2e/benchmark/throughput.go +++ b/test/e2e/benchmark/throughput.go @@ -28,7 +28,7 @@ func E2EThroughput() error { log.Println("=== RUN E2EThroughput", "version:", latestVersion) manifest := Manifest{ - ChainID: "test-sanaz", + ChainID: "test-e2e-throughput", Validators: 2, ValidatorResource: testnet.DefaultResources, TxClientsResource: testnet.DefaultResources, From 4ddedd0cee28b61c2fee3ebae1cdf993c4ef1015 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 17 May 2024 09:44:25 -0700 Subject: [PATCH 31/38] adds LatencyParams to the manifest --- test/e2e/benchmark/manifest.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/e2e/benchmark/manifest.go b/test/e2e/benchmark/manifest.go index e4700da0b3..471883bf58 100644 --- a/test/e2e/benchmark/manifest.go +++ b/test/e2e/benchmark/manifest.go @@ -11,6 +11,13 @@ import ( tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) +type LatencyParams struct { + // Latency in milliseconds + Latency int64 + // Jitter in milliseconds + Jitter int64 +} + // Manifest defines the parameters for a testnet. type Manifest struct { ChainID string @@ -30,6 +37,8 @@ type Manifest struct { ValidatorResource testnet.Resources // Resource requirements for a tx client TxClientsResource testnet.Resources + // LatencyParams for the validators + LatencyParams LatencyParams // tx client settings // Number of blobs per sequence From c8978b9be32f7d82899475b8f03c203de84d9b1f Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 17 May 2024 09:45:54 -0700 Subject: [PATCH 32/38] adds ForwardBitTwisterPort --- test/e2e/testnet/util.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/e2e/testnet/util.go b/test/e2e/testnet/util.go index 443f342986..f3d8427ff3 100644 --- a/test/e2e/testnet/util.go +++ b/test/e2e/testnet/util.go @@ -1,10 +1,13 @@ package testnet import ( + "fmt" "io" "math/rand" "os" + "github.com/celestiaorg/knuu/pkg/knuu" + "github.com/rs/zerolog/log" "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/crypto/secp256k1" @@ -56,3 +59,14 @@ func GetGrafanaInfoFromEnvVar() *GrafanaInfo { Token: os.Getenv("GRAFANA_TOKEN"), } } + +func ForwardBitTwisterPort(i *knuu.Instance) error { + fwdBtPort, err := i.PortForwardTCP(i.BitTwister.Port()) + if err != nil { + return err + } + i.BitTwister.SetPort(fwdBtPort) + i.BitTwister.SetNewClientByIPAddr("http://localhost") + log.Info().Str("address", fmt.Sprintf("http://localhost:%d", fwdBtPort)).Msg("BitTwister is listening") + return nil +} From 2d5855de5089349acbe9b647055dd907aed753f6 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 17 May 2024 09:55:33 -0700 Subject: [PATCH 33/38] moves ForwardBittwisterPort to the node file --- test/e2e/testnet/node.go | 11 +++++++++++ test/e2e/testnet/util.go | 14 -------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/test/e2e/testnet/node.go b/test/e2e/testnet/node.go index ec48e4e141..26abb448ec 100644 --- a/test/e2e/testnet/node.go +++ b/test/e2e/testnet/node.go @@ -312,6 +312,17 @@ func (n *Node) forwardPorts() error { return nil } +func (n *Node) ForwardBitTwisterPort() error { + fwdBtPort, err := n.Instance.PortForwardTCP(n.Instance.BitTwister.Port()) + if err != nil { + return err + } + n.Instance.BitTwister.SetPort(fwdBtPort) + n.Instance.BitTwister.SetNewClientByIPAddr("http://localhost") + log.Info().Str("address", fmt.Sprintf("http://localhost:%d", fwdBtPort)).Msg("BitTwister is listening") + return nil +} + func DockerImageName(version string) string { return fmt.Sprintf("%s:%s", dockerSrcURL, version) } diff --git a/test/e2e/testnet/util.go b/test/e2e/testnet/util.go index f3d8427ff3..443f342986 100644 --- a/test/e2e/testnet/util.go +++ b/test/e2e/testnet/util.go @@ -1,13 +1,10 @@ package testnet import ( - "fmt" "io" "math/rand" "os" - "github.com/celestiaorg/knuu/pkg/knuu" - "github.com/rs/zerolog/log" "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/crypto/secp256k1" @@ -59,14 +56,3 @@ func GetGrafanaInfoFromEnvVar() *GrafanaInfo { Token: os.Getenv("GRAFANA_TOKEN"), } } - -func ForwardBitTwisterPort(i *knuu.Instance) error { - fwdBtPort, err := i.PortForwardTCP(i.BitTwister.Port()) - if err != nil { - return err - } - i.BitTwister.SetPort(fwdBtPort) - i.BitTwister.SetNewClientByIPAddr("http://localhost") - log.Info().Str("address", fmt.Sprintf("http://localhost:%d", fwdBtPort)).Msg("BitTwister is listening") - return nil -} From eedc2e8d487ac16a3c2f3675e0173dd198e1a0f7 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 17 May 2024 09:55:46 -0700 Subject: [PATCH 34/38] adds EnableLatency flag to the manifest --- test/e2e/benchmark/manifest.go | 1 + 1 file changed, 1 insertion(+) diff --git a/test/e2e/benchmark/manifest.go b/test/e2e/benchmark/manifest.go index 471883bf58..728efd2745 100644 --- a/test/e2e/benchmark/manifest.go +++ b/test/e2e/benchmark/manifest.go @@ -38,6 +38,7 @@ type Manifest struct { // Resource requirements for a tx client TxClientsResource testnet.Resources // LatencyParams for the validators + EnableLatency bool LatencyParams LatencyParams // tx client settings From 44f7ce816d182c514f27068e06813c92f10143a5 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 17 May 2024 09:56:00 -0700 Subject: [PATCH 35/38] sets up nodes with latency --- test/e2e/benchmark/benchmark.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/e2e/benchmark/benchmark.go b/test/e2e/benchmark/benchmark.go index 1fb65e9812..4d99a5bdc2 100644 --- a/test/e2e/benchmark/benchmark.go +++ b/test/e2e/benchmark/benchmark.go @@ -35,6 +35,12 @@ func (b *BenchmarkTest) SetupNodes() error { b.manifest.CelestiaAppVersion, b.manifest.SelfDelegation, b.manifest.UpgradeHeight, b.manifest.ValidatorResource)) + // enable latency if specified in the manifest + if b.manifest.EnableLatency { + for _, node := range b.Nodes() { + node.Instance.EnableBitTwister() + } + } // obtain the GRPC endpoints of the validators gRPCEndpoints, err := b.RemoteGRPCEndpoints() testnet.NoError("failed to get validators GRPC endpoints", err) @@ -68,6 +74,13 @@ func (b *BenchmarkTest) Run() error { return fmt.Errorf("failed to start testnet: %v", err) } + if b.manifest.EnableLatency { + for _, node := range b.Nodes() { + node.ForwardBitTwisterPort() + node.Instance.AddLa(b.manifest.LatencyParams.Latency, b.manifest.LatencyParams.Jitter) + } + } + // once the testnet is up, start tx clients log.Println("Starting tx clients") err = b.StartTxClients() From 2469df91b796507c13b123a663fc9b2428de7a2b Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 17 May 2024 10:00:32 -0700 Subject: [PATCH 36/38] adds network latency to the nodes after being started --- test/e2e/benchmark/benchmark.go | 10 ++++++++-- test/e2e/benchmark/throughput.go | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/test/e2e/benchmark/benchmark.go b/test/e2e/benchmark/benchmark.go index 4d99a5bdc2..60699c8ff3 100644 --- a/test/e2e/benchmark/benchmark.go +++ b/test/e2e/benchmark/benchmark.go @@ -74,10 +74,16 @@ func (b *BenchmarkTest) Run() error { return fmt.Errorf("failed to start testnet: %v", err) } + // add latency if specified in the manifest if b.manifest.EnableLatency { for _, node := range b.Nodes() { - node.ForwardBitTwisterPort() - node.Instance.AddLa(b.manifest.LatencyParams.Latency, b.manifest.LatencyParams.Jitter) + if err = node.ForwardBitTwisterPort(); err != nil { + return fmt.Errorf("failed to forward bit twister port: %v", err) + } + if err = node.Instance.SetLatencyAndJitter(b.manifest.LatencyParams. + Latency, b.manifest.LatencyParams.Jitter); err != nil { + return fmt.Errorf("failed to set latency and jitter: %v", err) + } } } diff --git a/test/e2e/benchmark/throughput.go b/test/e2e/benchmark/throughput.go index 9ca03fe347..2d5c2b1f66 100644 --- a/test/e2e/benchmark/throughput.go +++ b/test/e2e/benchmark/throughput.go @@ -35,6 +35,8 @@ func E2EThroughput() error { SelfDelegation: 10000000, CelestiaAppVersion: latestVersion, TxClientVersion: testnet.TxsimVersion, + EnableLatency: true, + LatencyParams: LatencyParams{100, 10}, // in milliseconds BlobsPerSeq: 1, BlobSequences: 1, BlobSizes: "10000-10000", From 049048d556b01e14c3d4436d65988083748e5a4d Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 17 May 2024 10:06:01 -0700 Subject: [PATCH 37/38] checks the error from enabling bit twister --- test/e2e/benchmark/benchmark.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/e2e/benchmark/benchmark.go b/test/e2e/benchmark/benchmark.go index 60699c8ff3..266b419c02 100644 --- a/test/e2e/benchmark/benchmark.go +++ b/test/e2e/benchmark/benchmark.go @@ -38,7 +38,9 @@ func (b *BenchmarkTest) SetupNodes() error { // enable latency if specified in the manifest if b.manifest.EnableLatency { for _, node := range b.Nodes() { - node.Instance.EnableBitTwister() + if err := node.Instance.EnableBitTwister(); err != nil { + return fmt.Errorf("failed to enable bit twister: %v", err) + } } } // obtain the GRPC endpoints of the validators From 9e3c437a72d989c145257995eafef083660d2c28 Mon Sep 17 00:00:00 2001 From: sanaz Date: Fri, 17 May 2024 12:23:37 -0700 Subject: [PATCH 38/38] adds clarifying comments about latency params --- test/e2e/benchmark/manifest.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/e2e/benchmark/manifest.go b/test/e2e/benchmark/manifest.go index 728efd2745..d7068025bd 100644 --- a/test/e2e/benchmark/manifest.go +++ b/test/e2e/benchmark/manifest.go @@ -37,8 +37,9 @@ type Manifest struct { ValidatorResource testnet.Resources // Resource requirements for a tx client TxClientsResource testnet.Resources - // LatencyParams for the validators + // EnableLatency enables network latency for the validators EnableLatency bool + // LatencyParams defines the network latency parameters LatencyParams LatencyParams // tx client settings