Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(e2e benchmark): introduces test manifest and its related utilities #3391

Merged
merged 28 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
35cacc5
defines config options
staheri14 Apr 26, 2024
b1d6861
adds configOpts parameter to the Init func
staheri14 Apr 26, 2024
eb5d379
extends Setup parameter with config options
staheri14 Apr 26, 2024
f4c81f7
passes options through setup method
staheri14 Apr 26, 2024
c4e0b3b
allows passing genesis modifiers and consensus parameters in the test…
staheri14 Apr 26, 2024
ed1fddf
adds manifest struct
staheri14 Apr 26, 2024
cb63664
defines BenchTest
staheri14 Apr 26, 2024
05ecc53
make consensus params effective
staheri14 Apr 26, 2024
80c26e9
fixes getConsensusParams
staheri14 Apr 26, 2024
9af78d7
fixxes set consensus parameters by calling it after tesnet initiation
staheri14 Apr 26, 2024
94f8ef0
makes txsim image creation faster
staheri14 Apr 26, 2024
b4ae352
fixes changes to the order of AddFolder and Commit
staheri14 Apr 26, 2024
bd9fe31
obtains parameters from manifest
staheri14 Apr 26, 2024
8fd5d1f
reads txClient pars from manifest
staheri14 Apr 26, 2024
425b98f
fixes stale comments
staheri14 Apr 26, 2024
dd96cdc
removes private methods
staheri14 Apr 26, 2024
a944670
fixes linter issues
staheri14 Apr 26, 2024
4e26505
gets the remainder of the test parameters from the manifest
staheri14 Apr 26, 2024
25f4026
some reordering and refactoring
staheri14 Apr 26, 2024
2a978b8
Merge remote-tracking branch 'origin/main' into sanaz/manifest-first-…
staheri14 Apr 26, 2024
6f8c4f2
Merge remote-tracking branch 'origin/main' into sanaz/manifest-first-…
staheri14 Apr 29, 2024
5eea754
addresses first round of comments
staheri14 Apr 30, 2024
35ebdf3
Merge branch 'main' into sanaz/manifest-first-part
staheri14 Apr 30, 2024
79ee4f6
Merge branch 'main' into sanaz/manifest-first-part
staheri14 May 9, 2024
c3b5b56
Merge branch 'main' into sanaz/manifest-first-part
staheri14 May 9, 2024
3044f70
explains the usage of TxClients
staheri14 May 9, 2024
b1ab656
fixes a method name
staheri14 May 9, 2024
92f304c
trims grpcEndpoints based on the number of txclients in the manifest
staheri14 May 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 47 additions & 13 deletions test/e2e/benchmark/throughput.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import (
)

const (
seed = 42
txsimVersion = "a92de72"
seed = 42
)

func main() {
Expand All @@ -28,41 +27,76 @@ func E2EThroughput() error {

log.Println("=== RUN E2EThroughput", "version:", latestVersion)

manifest := testnet.Manifest{
ChainID: "test-e2e-throughput",
Validators: 2,
ValidatorResource: testnet.DefaultResources,
TxClientsResource: testnet.DefaultResources,
SelfDelegation: 10000000,
CelestiaAppVersion: latestVersion,
TxClientVersion: testnet.TxsimVersion,
BlobsPerSeq: 1,
BlobSequences: 1,
BlobSizes: "10000-10000",
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: 30 * time.Second,
TxClients: 2,
}
// create a new testnet
testNet, err := testnet.New("E2EThroughput", seed, testnet.GetGrafanaInfoFromEnvVar())
testNet, err := testnet.New("E2EThroughput", seed,
testnet.GetGrafanaInfoFromEnvVar(), manifest.ChainID,
manifest.GetGenesisModifiers()...)
testnet.NoError("failed to create testnet", err)

testNet.SetConsensusParams(manifest.GetConsensusParams())
defer func() {
log.Print("Cleaning up testnet")
testNet.Cleanup()
}()

// 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()
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 and point them to the validators
log.Println("Creating tx clients")

err = testNet.CreateTxClients(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
log.Println("Setting up testnet")
testnet.NoError("failed to setup testnet", testNet.Setup())
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 txsim nodes")
// once the testnet is up, start the tx clients
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(1 * time.Minute)
// wait some time for the tx clients to submit transactions
time.Sleep(manifest.TestDuration)

log.Println("Reading blockchain")
blockchain, err := testnode.ReadBlockchain(context.Background(), testNet.Node(0).AddressRPC())
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/check_upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/testnet/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ var DefaultResources = Resources{
CPU: "300m",
Volume: "1Gi",
}

const TxsimVersion = "a92de72"
77 changes: 77 additions & 0 deletions test/e2e/testnet/manifest.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
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
TxClients int
staheri14 marked this conversation as resolved.
Show resolved Hide resolved
// 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
staheri14 marked this conversation as resolved.
Show resolved Hide resolved
// 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
}
4 changes: 2 additions & 2 deletions test/e2e/testnet/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand All @@ -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)
}
Expand Down
50 changes: 45 additions & 5 deletions test/e2e/testnet/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,60 @@ 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"
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 {
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 {
Expand Down
17 changes: 12 additions & 5 deletions test/e2e/testnet/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ 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) (
*Testnet, error,
) {
identifier := fmt.Sprintf("%s_%s", name, time.Now().Format("20060102_150405"))
if err := knuu.InitializeWithScope(identifier); err != nil {
return nil, err
Expand All @@ -35,7 +38,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
Expand All @@ -45,6 +48,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)
Expand Down Expand Up @@ -130,6 +137,7 @@ 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")
if err != nil {
Expand All @@ -139,7 +147,6 @@ func (t *Testnet) CreateTxClient(name,
Msg("error adding keyring dir to txsim")
return err
}

err = txsim.Instance.Commit()
if err != nil {
log.Err(err).
Expand Down Expand Up @@ -221,7 +228,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
Expand All @@ -237,7 +244,7 @@ func (t *Testnet) Setup() error {
}
}

err := node.Init(genesis, peers)
err := node.Init(genesis, peers, configOpts...)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/testnet/txsimNode.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ func CreateTxClient(
log.Info().
Str("name", name).
Str("image", image).
Msg("setting image for txsim node")
Msg("setting image for tx client")
err = instance.SetImage(image)
if err != nil {
log.Err(err).
Str("name", name).
Str("image", image).
Msg("failed to set image for txsim node")
Msg("failed to set image for tx client")
return nil, err
}
err = instance.SetMemory(resources.MemoryRequest, resources.MemoryLimit)
Expand Down
Loading