diff --git a/test/e2e/app/app.go b/test/e2e/app/app.go index 9b3f68192d5..a2b786f9744 100644 --- a/test/e2e/app/app.go +++ b/test/e2e/app/app.go @@ -139,6 +139,17 @@ type Config struct { // -1 denotes it is set at genesis. // 0 denotes it is set at InitChain. PbtsUpdateHeight int64 `toml:"pbts_update_height"` + + // If true, disables the use of lanes by the application. + // Used to simulate networks that do not want to use lanes, running + // on top of CometBFT with lane support. + NoLanes bool `toml:"no_lanes"` + + // Optional custom definition of lanes to be used by the application + // If not used the application has a default set of lanes: + // {"foo"= 9,"bar"=4,"default"= 1} + // Note that the default key has to be present in your list of custom lanes. + Lanes map[string]uint32 `toml:"lanes"` } func DefaultConfig(dir string) *Config { @@ -150,13 +161,15 @@ func DefaultConfig(dir string) *Config { } // LaneDefinitions returns the (constant) list of lanes and their priorities. -func LaneDefinitions() (map[string]uint32, []uint32) { +func LaneDefinitions(lanes map[string]uint32) (map[string]uint32, []uint32) { // Map from lane name to its priority. Priority 0 is reserved. The higher // the value, the higher the priority. - lanes := map[string]uint32{ - "foo": 9, - "bar": 4, - defaultLane: 1, + if len(lanes) == 0 { + lanes = map[string]uint32{ + "foo": 9, + "bar": 4, + defaultLane: 1, + } } // List of lane priorities @@ -178,11 +191,18 @@ func NewApplication(cfg *Config) (*Application, error) { if err != nil { return nil, err } - lanes, lanePriorities := LaneDefinitions() - logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)) logger.Info("Application started!") + if cfg.NoLanes { + return &Application{ + logger: logger, + state: state, + snapshots: snapshots, + cfg: cfg, + }, nil + } + lanes, lanePriorities := LaneDefinitions(cfg.Lanes) return &Application{ logger: logger, state: state, @@ -201,6 +221,14 @@ func (app *Application) Info(context.Context, *abci.InfoRequest) (*abci.InfoResp } height, hash := app.state.Info() + if app.cfg.NoLanes { + return &abci.InfoResponse{ + Version: version.ABCIVersion, + AppVersion: appVersion, + LastBlockHeight: int64(height), + LastBlockAppHash: hash, + }, nil + } return &abci.InfoResponse{ Version: version.ABCIVersion, AppVersion: appVersion, @@ -324,8 +352,10 @@ func (app *Application) CheckTx(_ context.Context, req *abci.CheckTxRequest) (*a time.Sleep(app.cfg.CheckTxDelay) } + if app.cfg.NoLanes { + return &abci.CheckTxResponse{Code: kvstore.CodeTypeOK, GasWanted: 1}, nil + } lane := extractLane(value) - return &abci.CheckTxResponse{Code: kvstore.CodeTypeOK, GasWanted: 1, Lane: lane}, nil } diff --git a/test/e2e/generator/generate.go b/test/e2e/generator/generate.go index 6e65a8efb45..07fba6165df 100644 --- a/test/e2e/generator/generate.go +++ b/test/e2e/generator/generate.go @@ -31,6 +31,7 @@ var ( map[string]string{"initial01": "a", "initial02": "b", "initial03": "c"}, }, "validators": {"genesis", "initchain"}, + "no_lanes": {true, false}, } nodeVersions = weightedChoice{ "": 2, @@ -320,6 +321,8 @@ func generateTestnet(r *rand.Rand, opt map[string]any, upgradeVersion string, pr ) } + manifest.NoLanes = opt["no_lanes"].(bool) + return manifest, nil } diff --git a/test/e2e/node/config.go b/test/e2e/node/config.go index 97cb26b8c6a..84c516b5fd6 100644 --- a/test/e2e/node/config.go +++ b/test/e2e/node/config.go @@ -50,6 +50,10 @@ type Config struct { PbtsEnableHeight int64 `toml:"pbts_enable_height"` PbtsUpdateHeight int64 `toml:"pbts_update_height"` + + NoLanes bool `toml:"no_lanes"` + + Lanes map[string]uint32 `toml:"lanes"` } // App extracts out the application specific configuration parameters. @@ -72,6 +76,8 @@ func (cfg *Config) App() *app.Config { ABCIRequestsLoggingEnabled: cfg.ABCIRequestsLoggingEnabled, PbtsEnableHeight: cfg.PbtsEnableHeight, PbtsUpdateHeight: cfg.PbtsUpdateHeight, + NoLanes: cfg.NoLanes, + Lanes: cfg.Lanes, } } diff --git a/test/e2e/pkg/manifest.go b/test/e2e/pkg/manifest.go index 6063a3b7674..86fc3e19216 100644 --- a/test/e2e/pkg/manifest.go +++ b/test/e2e/pkg/manifest.go @@ -90,6 +90,8 @@ type Manifest struct { // Weight for each lane defined by the app. The transaction loader will // assign lanes to generated transactions proportionally to their weights. + // Note that the lanes are sorted by priority in descending order, thus the + // first weight in the array will be the weight of the highest priority lane. LoadLaneWeights []uint `toml:"load_lane_weights"` // LogLevel specifies the log level to be set on all nodes. @@ -146,6 +148,17 @@ type Manifest struct { // 0 denotes it is set at InitChain. PbtsUpdateHeight int64 `toml:"pbts_update_height"` + // Used to disable lanes for testing behavior of + // networks that upgrade to a version of CometBFT + // that supports lanes but do not opt for using them. + NoLanes bool `toml:"no_lanes"` + + // Optional custom definition of lanes to be used by the application + // If not used the application has a default set of lanes: + // {"foo"= 9,"bar"=4,"default"= 1} + // Note that the default key has to be present in your list of custom lanes. + Lanes map[string]uint32 `toml:"lanes"` + // Genesis is a set of key-value config entries to write to the // produced genesis file. The format is "key = value". // Example: "consensus_params.evidence.max_bytes = 1024". diff --git a/test/e2e/pkg/testnet.go b/test/e2e/pkg/testnet.go index d8df65649f7..f2903b3a021 100644 --- a/test/e2e/pkg/testnet.go +++ b/test/e2e/pkg/testnet.go @@ -145,8 +145,7 @@ func NewTestnetFromManifest(manifest Manifest, file string, ifd InfrastructureDa return nil, fmt.Errorf("invalid IP network address %q: %w", ifd.Network, err) } // Pre-load hard-coded lane values from app. - _, lanePriorities := app.LaneDefinitions() - + _, lanePriorities := app.LaneDefinitions(manifest.Lanes) testnet := &Testnet{ Manifest: manifest, @@ -182,15 +181,15 @@ func NewTestnetFromManifest(manifest Manifest, file string, ifd InfrastructureDa if testnet.LoadTxSizeBytes == 0 { testnet.LoadTxSizeBytes = defaultTxSizeBytes } - if len(testnet.LoadLaneWeights) == 0 { + if len(testnet.Manifest.LoadLaneWeights) == 0 { // Assign same weight to all lanes. - testnet.LoadLaneWeights = make([]uint, len(testnet.lanePriorities)) + testnet.Manifest.LoadLaneWeights = make([]uint, len(testnet.lanePriorities)) for i := 0; i < len(testnet.lanePriorities); i++ { - testnet.LoadLaneWeights[i] = 1 + testnet.Manifest.LoadLaneWeights[i] = 1 } } // Pre-calculate the sum of all lane weights. - for _, w := range testnet.LoadLaneWeights { + for _, w := range testnet.Manifest.LoadLaneWeights { testnet.sumWeights += w } @@ -414,13 +413,13 @@ func (t Testnet) Validate() error { ) } } - if len(t.LoadLaneWeights) != len(t.lanePriorities) { + if len(t.Manifest.LoadLaneWeights) != len(t.lanePriorities) { return fmt.Errorf("number of lane weights (%d) must be equal to "+ "the number of lanes defined by the app (%d)", len(t.LoadLaneWeights), len(t.lanePriorities), ) } - for _, w := range t.LoadLaneWeights { + for _, w := range t.Manifest.LoadLaneWeights { if w <= 0 { return fmt.Errorf("weight must be greater than 0: %v", w) } @@ -650,7 +649,7 @@ func weightedRandomIndex(weights []uint, sumWeights uint) int { // NextLane returns the next element in the list of lanes, according to a // predefined weight for each lane in the list. func (t *Testnet) NextLane() uint32 { - return t.lanePriorities[weightedRandomIndex(t.LoadLaneWeights, t.sumWeights)] + return t.lanePriorities[weightedRandomIndex(t.Manifest.LoadLaneWeights, t.sumWeights)] } //go:embed templates/prometheus-yaml.tmpl diff --git a/test/e2e/runner/setup.go b/test/e2e/runner/setup.go index 6863fbc2e46..137e5c463e6 100644 --- a/test/e2e/runner/setup.go +++ b/test/e2e/runner/setup.go @@ -382,6 +382,8 @@ func MakeAppConfig(node *e2e.Node) ([]byte, error) { "abci_requests_logging_enabled": node.Testnet.ABCITestsEnabled, "pbts_enable_height": node.Testnet.PbtsEnableHeight, "pbts_update_height": node.Testnet.PbtsUpdateHeight, + "no_lanes": node.Testnet.Manifest.NoLanes, + "lanes": node.Testnet.Manifest.Lanes, } switch node.ABCIProtocol { case e2e.ProtocolUNIX: