diff --git a/test/e2e/benchmark/benchmark.go b/test/e2e/benchmark/benchmark.go index 1a22dbf8a9..8304048daf 100644 --- a/test/e2e/benchmark/benchmark.go +++ b/test/e2e/benchmark/benchmark.go @@ -35,6 +35,14 @@ 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() { + if err := node.Instance.EnableBitTwister(); err != nil { + return fmt.Errorf("failed to enable bit twister: %v", err) + } + } + } // obtain the GRPC endpoints of the validators gRPCEndpoints, err := b.RemoteGRPCEndpoints() testnet.NoError("failed to get validators GRPC endpoints", err) @@ -49,7 +57,6 @@ func (b *BenchmarkTest) SetupNodes() error { b.manifest.TxClientsResource, gRPCEndpoints) testnet.NoError("failed to create tx clients", err) - // set up the testnet log.Println("Setting up testnet") testnet.NoError("failed to setup testnet", b.Setup( testnet.WithPerPeerBandwidth(b.manifest.PerPeerBandwidth), @@ -68,6 +75,19 @@ 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() { + 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) + } + } + } + // once the testnet is up, start tx clients log.Println("Starting tx clients") err = b.StartTxClients() diff --git a/test/e2e/benchmark/manifest.go b/test/e2e/benchmark/manifest.go index e4700da0b3..d7068025bd 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,10 @@ type Manifest struct { ValidatorResource testnet.Resources // Resource requirements for a tx client TxClientsResource testnet.Resources + // EnableLatency enables network latency for the validators + EnableLatency bool + // LatencyParams defines the network latency parameters + LatencyParams LatencyParams // tx client settings // Number of blobs per sequence diff --git a/test/e2e/benchmark/throughput.go b/test/e2e/benchmark/throughput.go index 3142afc18d..81e00ea233 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", 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) }