Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/limit-number-of-transactions-in-…
Browse files Browse the repository at this point in the history
…prepare-proposal' into limit-number-of-transactions-in-prepare-proposal
  • Loading branch information
rach-id committed Oct 14, 2024
2 parents c5071a3 + 415bcaa commit ba58bb8
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 50 deletions.
27 changes: 23 additions & 4 deletions test/e2e/benchmark/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,41 @@ import (
"github.com/celestiaorg/celestia-app/v3/pkg/appconsts"
"github.com/celestiaorg/celestia-app/v3/test/e2e/testnet"
"github.com/celestiaorg/celestia-app/v3/test/util/testnode"
"github.com/celestiaorg/knuu/pkg/knuu"
)

const timeFormat = "20060102_150405"

type BenchmarkTest struct {
*testnet.Testnet
manifest *Manifest
}

func NewBenchmarkTest(name string, manifest *Manifest) (*BenchmarkTest, error) {
// create a new testnet
testNet, err := testnet.New(context.Background(), name, seed,
testnet.GetGrafanaInfoFromEnvVar(), manifest.ChainID,
manifest.GetGenesisModifiers()...)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

scope := fmt.Sprintf("%s_%s", name, time.Now().Format(timeFormat))
kn, err := knuu.New(ctx, knuu.Options{
Scope: scope,
ProxyEnabled: true,
})
if err != nil {
return nil, err
}

// context.Background() is used to allow the stopSignal to be functional even after this function returns
kn.HandleStopSignal(context.Background())

log.Printf("Knuu initialized with scope %s", kn.Scope)

testNet, err := testnet.New(kn, testnet.Options{
Grafana: testnet.GetGrafanaInfoFromEnvVar(),
ChainID: manifest.ChainID,
GenesisModifiers: manifest.GetGenesisModifiers(),
})
testnet.NoError("failed to create testnet", err)

testNet.SetConsensusParams(manifest.GetConsensusParams())
return &BenchmarkTest{Testnet: testNet, manifest: manifest}, nil
}
Expand Down
4 changes: 0 additions & 4 deletions test/e2e/benchmark/throughput.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
)

const (
seed = 42
)

var bigBlockManifest = Manifest{
ChainID: "test",
Validators: 2,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

const (
seed = 42
timeFormat = "20060102_150405"
)

type TestFunc func(logger *log.Logger) error
Expand Down
22 changes: 16 additions & 6 deletions test/e2e/major_upgrade_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,38 @@ import (
v1 "github.com/celestiaorg/celestia-app/v3/pkg/appconsts/v1"
v2 "github.com/celestiaorg/celestia-app/v3/pkg/appconsts/v2"
"github.com/celestiaorg/celestia-app/v3/test/e2e/testnet"
"github.com/celestiaorg/knuu/pkg/knuu"
"github.com/tendermint/tendermint/rpc/client/http"
)

func MajorUpgradeToV2(logger *log.Logger) error {
var (
numNodes = 4
upgradeHeight = int64(10)
)
testName := "MajorUpgradeToV2"
numNodes := 4
upgradeHeight := int64(10)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

scope := fmt.Sprintf("%s_%s", testName, time.Now().Format(timeFormat))
kn, err := knuu.New(ctx, knuu.Options{
Scope: scope,
ProxyEnabled: true,
})
testnet.NoError("failed to initialize Knuu", err)

kn.HandleStopSignal(ctx)
logger.Printf("Knuu initialized with scope %s", kn.Scope)

logger.Println("Creating testnet")
testNet, err := testnet.New(ctx, "MajorUpgradeToV2", seed, nil, "test")
testNet, err := testnet.New(kn, testnet.Options{})
testnet.NoError("failed to create testnet", err)

defer testNet.Cleanup(ctx)

latestVersion, err := testnet.GetLatestVersion()
testnet.NoError("failed to get latest version", err)

logger.Println("Running major upgrade to v2 test", "version", latestVersion)
logger.Printf("Running %s test with version %s", testName, latestVersion)

testNet.SetConsensusParams(app.DefaultInitialConsensusParams())

Expand Down
17 changes: 15 additions & 2 deletions test/e2e/major_upgrade_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,29 @@ import (
v2 "github.com/celestiaorg/celestia-app/v3/pkg/appconsts/v2"
v3 "github.com/celestiaorg/celestia-app/v3/pkg/appconsts/v3"
"github.com/celestiaorg/celestia-app/v3/test/e2e/testnet"
"github.com/celestiaorg/knuu/pkg/knuu"
)

func MajorUpgradeToV3(logger *log.Logger) error {
testName := "MajorUpgradeToV3"
numNodes := 4
upgradeHeightV3 := int64(20)
upgradeHeightV3 := int64(10)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

scope := fmt.Sprintf("%s_%s", testName, time.Now().Format(timeFormat))
kn, err := knuu.New(ctx, knuu.Options{
Scope: scope,
ProxyEnabled: true,
})
testnet.NoError("failed to initialize Knuu", err)

kn.HandleStopSignal(ctx)
logger.Printf("Knuu initialized with scope %s", kn.Scope)

logger.Println("Creating testnet")
testNet, err := testnet.New(ctx, "MajorUpgradeToV3", seed, nil, "test")
testNet, err := testnet.New(kn, testnet.Options{})
testnet.NoError("failed to create testnet", err)

defer testNet.Cleanup(ctx)
Expand Down
21 changes: 18 additions & 3 deletions test/e2e/minor_version_compatibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ import (
v1 "github.com/celestiaorg/celestia-app/v3/pkg/appconsts/v1"
v2 "github.com/celestiaorg/celestia-app/v3/pkg/appconsts/v2"
"github.com/celestiaorg/celestia-app/v3/test/e2e/testnet"
"github.com/celestiaorg/knuu/pkg/knuu"
)

func MinorVersionCompatibility(logger *log.Logger) error {
const numNodes = 4
const (
testName = "MinorVersionCompatibility"
numNodes = 4
)

versionStr, err := getAllVersions()
testnet.NoError("failed to get versions", err)
Expand All @@ -29,13 +33,24 @@ func MinorVersionCompatibility(logger *log.Logger) error {
if len(versions) == 0 {
logger.Fatal("no versions to test")
}
seed := testnet.DefaultSeed
r := rand.New(rand.NewSource(seed))
logger.Println("Running minor version compatibility test", "versions", versions)
logger.Printf("Running %s test with versions %s", testName, versions)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

testNet, err := testnet.New(ctx, "MinorVersionCompatibility", seed, nil, "test")
identifier := fmt.Sprintf("%s_%s", testName, time.Now().Format(timeFormat))
kn, err := knuu.New(ctx, knuu.Options{
Scope: identifier,
ProxyEnabled: true,
})
testnet.NoError("failed to initialize Knuu", err)

kn.HandleStopSignal(ctx)
logger.Printf("Knuu initialized with scope %s", kn.Scope)

testNet, err := testnet.New(kn, testnet.Options{Seed: seed})
testnet.NoError("failed to create testnet", err)

defer testNet.Cleanup(ctx)
Expand Down
17 changes: 14 additions & 3 deletions test/e2e/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,35 @@ import (
"github.com/celestiaorg/celestia-app/v3/pkg/appconsts"
"github.com/celestiaorg/celestia-app/v3/test/e2e/testnet"
"github.com/celestiaorg/celestia-app/v3/test/util/testnode"
"github.com/celestiaorg/knuu/pkg/knuu"
)

// This test runs a simple testnet with 4 validators. It submits both MsgPayForBlobs
// and MsgSends over 30 seconds and then asserts that at least 10 transactions were
// committed.
func E2ESimple(logger *log.Logger) error {
const testName = "E2ESimple"

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

testNet, err := testnet.New(ctx, "E2ESimple", seed, nil, "test")
identifier := fmt.Sprintf("%s_%s", testName, time.Now().Format(timeFormat))
kn, err := knuu.New(ctx, knuu.Options{
Scope: identifier,
ProxyEnabled: true,
})
testnet.NoError("failed to initialize Knuu", err)
kn.HandleStopSignal(ctx)
logger.Printf("Knuu initialized with scope %s", kn.Scope)

testNet, err := testnet.New(kn, testnet.Options{})
testnet.NoError("failed to create testnet", err)

defer testNet.Cleanup(ctx)

latestVersion, err := testnet.GetLatestVersion()
testnet.NoError("failed to get latest version", err)

logger.Println("Running E2ESimple test", "version", latestVersion)
logger.Printf("Running %s test with version %s", testName, latestVersion)

logger.Println("Creating testnet validators")
testnet.NoError("failed to create genesis nodes",
Expand Down
54 changes: 27 additions & 27 deletions test/e2e/testnet/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ import (
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
)

const (
DefaultSeed int64 = 42
DefaultChainID = "test-chain-id"
)

type Testnet struct {
seed int64
nodes []*Node
Expand All @@ -30,39 +35,25 @@ type Testnet struct {
knuu *knuu.Knuu
}

func New(ctx context.Context, name string, seed int64, grafana *GrafanaInfo, chainID string, genesisModifiers ...genesis.Modifier) (*Testnet, error) {
identifier := fmt.Sprintf("%s_%s", name, time.Now().Format("20060102_150405"))
kn, err := knuu.New(ctx, knuu.Options{
Scope: identifier,
ProxyEnabled: true,
// if the tests timeout, pass the timeout option
// Timeout: 120 * time.Minute,
})
if err != nil {
return nil, err
}

log.Info().
Str("scope", kn.Scope).
Str("TestName", name).
Msg("Knuu initialized")

kn.HandleStopSignal(ctx)
type Options struct {
Seed int64
Grafana *GrafanaInfo
ChainID string
GenesisModifiers []genesis.Modifier
}

func New(knuu *knuu.Knuu, opts Options) (*Testnet, error) {
opts.setDefaults()
return &Testnet{
seed: seed,
seed: opts.Seed,
nodes: make([]*Node, 0),
genesis: genesis.NewDefaultGenesis().WithChainID(chainID).WithModifiers(genesisModifiers...),
keygen: newKeyGenerator(seed),
grafana: grafana,
knuu: kn,
genesis: genesis.NewDefaultGenesis().WithChainID(opts.ChainID).WithModifiers(opts.GenesisModifiers...),
keygen: newKeyGenerator(opts.Seed),
grafana: opts.Grafana,
knuu: knuu,
}, nil
}

func (t *Testnet) Knuu() *knuu.Knuu {
return t.knuu
}

func (t *Testnet) NewPreloader() (*preloader.Preloader, error) {
if t.knuu == nil {
return nil, errors.New("knuu is not initialized")
Expand Down Expand Up @@ -479,3 +470,12 @@ func (t *Testnet) Nodes() []*Node {
func (t *Testnet) Genesis() *genesis.Genesis {
return t.genesis
}

func (o *Options) setDefaults() {
if o.ChainID == "" {
o.ChainID = DefaultChainID
}
if o.Seed == 0 {
o.Seed = DefaultSeed
}
}

0 comments on commit ba58bb8

Please sign in to comment.