8000 Add sleep times (`VoteExtension` and `Finalizeblock`) to e2e app by sergio-mena · Pull Request #515 · cometbft/cometbft · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add sleep times (VoteExtension and Finalizeblock) to e2e app #515

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

Merged
merged 3 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 11 additions & 1 deletion test/e2e/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ type Config struct {
ProcessProposalDelay time.Duration `toml:"process_proposal_delay"`
CheckTxDelay time.Duration `toml:"check_tx_delay"`
FinalizeBlockDelay time.Duration `toml:"finalize_block_delay"`
// TODO: add vote extension delays once completed (@cmwaters)
VoteExtensionDelay time.Duration `toml:"vote_extension_delay"`
}

func DefaultConfig(dir string) *Config {
Expand Down Expand Up @@ -416,6 +416,11 @@ func (app *Application) ExtendVote(_ context.Context, req *abci.RequestExtendVot
//nolint:gosec // G404: Use of weak random number generator
num := rand.Int63n(voteExtensionMaxVal)
extLen := binary.PutVarint(ext, num)

if app.cfg.VoteExtensionDelay != 0 {
time.Sleep(app.cfg.VoteExtensionDelay)
}

app.logger.Info("generated vote extension", "num", num, "ext", fmt.Sprintf("%x", ext[:extLen]), "state.Height", app.state.Height)
return &abci.ResponseExtendVote{
VoteExtension: ext[:extLen],
Expand Down Expand Up @@ -446,6 +451,11 @@ func (app *Application) VerifyVoteExtension(_ context.Context, req *abci.Request
Status: abci.ResponseVerifyVoteExtension_REJECT,
}, nil
}

if app.cfg.VoteExtensionDelay != 0 {
time.Sleep(app.cfg.VoteExtensionDelay)
}

app.logger.Info("verified vote extension value", "req", req, "num", num)
return &abci.ResponseVerifyVoteExtension{
Status: abci.ResponseVerifyVoteExtension_ACCEPT,
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/generator/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,14 @@ func generateTestnet(r *rand.Rand, opt map[string]interface{}, upgradeVersion st
case "small":
manifest.PrepareProposalDelay = 100 * time.Millisecond
manifest.ProcessProposalDelay = 100 * time.Millisecond
manifest.VoteExtensionDelay = 20 * time.Millisecond
manifest.FinalizeBlockDelay = 200 * time.Millisecond
case "large":
manifest.PrepareProposalDelay = 200 * time.Millisecond
manifest.ProcessProposalDelay = 200 * time.Millisecond
manifest.CheckTxDelay = 20 * time.Millisecond
manifest.VoteExtensionDelay = 100 * time.Millisecond
manifest.FinalizeBlockDelay = 500 * time.Millisecond
}

if voteExtensionEnabled.Choose(r).(bool) {
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/pkg/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ type Manifest struct {
PrepareProposalDelay time.Duration `toml:"prepare_proposal_delay"`
ProcessProposalDelay time.Duration `toml:"process_proposal_delay"`
CheckTxDelay time.Duration `toml:"check_tx_delay"`
// TODO: add vote extension and finalize block delay (@cmwaters)
VoteExtensionDelay time.Duration `toml:"vote_extension_delay"`
FinalizeBlockDelay time.Duration `toml:"finalize_block_delay"`

// UpgradeVersion specifies to which version nodes need to upgrade.
// Currently only uncoordinated upgrade is supported
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/pkg/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ type Testnet struct {
PrepareProposalDelay time.Duration
ProcessProposalDelay time.Duration
CheckTxDelay time.Duration
VoteExtensionDelay time.Duration
FinalizeBlockDelay time.Duration
UpgradeVersion string
Prometheus bool
VoteExtensionsEnableHeight int64
Expand Down Expand Up @@ -154,6 +156,8 @@ func NewTestnetFromManifest(manifest Manifest, file string, ifd InfrastructureDa
PrepareProposalDelay: manifest.PrepareProposalDelay,
ProcessProposalDelay: manifest.ProcessProposalDelay,
CheckTxDelay: manifest.CheckTxDelay,
VoteExtensionDelay: manifest.VoteExtensionDelay,
FinalizeBlockDelay: manifest.FinalizeBlockDelay,
UpgradeVersion: manifest.UpgradeVersion,
Prometheus: manifest.Prometheus,
}
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/runner/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ func MakeAppConfig(node *e2e.Node) ([]byte, error) {
"prepare_proposal_delay": node.Testnet.PrepareProposalDelay,
"process_proposal_delay": node.Testnet.ProcessProposalDelay,
"check_tx_delay": node.Testnet.CheckTxDelay,
"vote_extension_delay": node.Testnet.VoteExtensionDelay,
"finalize_block_delay": node.Testnet.FinalizeBlockDelay,
}
switch node.ABCIProtocol {
case e2e.ProtocolUNIX:
Expand Down
0