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

feat!: version UpgradeHeightDelay #3980

Merged

Conversation

evan-forbes
Copy link
Member

Overview

closes #3978 #3979

this is just a nice to have for v3. If we're worried about this causing issues at all, we should just postpone this imo.

@evan-forbes evan-forbes added WS: Maintenance 🔧 includes bugs, refactors, flakes, and tech debt etc WS: V3 3️⃣ item is directly relevant to the v3 hardfork labels Oct 16, 2024
@evan-forbes evan-forbes self-assigned this Oct 16, 2024
@evan-forbes evan-forbes requested review from rach-id and a team as code owners October 16, 2024 02:56
@evan-forbes evan-forbes changed the base branch from main to sanaz/modify-timeouts October 16, 2024 02:57
Copy link
Contributor

coderabbitai bot commented Oct 16, 2024

📝 Walkthrough

Walkthrough

The pull request introduces several modifications across multiple files, primarily focusing on the application's initialization, upgrade handling, and timeout configurations. Key changes include the removal of the DefaultUpgradeHeightDelay constant, updates to method signatures in the App struct, and the introduction of new timeout constants in versioned packages. Additionally, the docker-compose.yml file has been updated to specify Dockerfile locations for services, and various test files have been adjusted to reflect these changes in functionality and structure.

Changes

File Change Summary
app/app.go Updated SignalKeeper initialization, modified EndBlocker, InitChain, and Info method signatures.
app/default_overrides.go Changed DefaultConsensusConfig to use dynamic timeout retrieval.
app/module/configurator_test.go Modified keeper instantiation in TestConfigurator.
app/test/upgrade_test.go Adjusted upgrade logic to utilize dynamic timeout parameters.
go.mod Updated several dependencies and their versions.
local_devnet/docker-compose.yml Added dockerfile specifications for services and set dependencies among them.
pkg/appconsts/global_consts.go Removed DefaultUpgradeHeightDelay constant and UpgradeHeightDelay function.
pkg/appconsts/v1/app_consts.go Added new constants: TimeoutPropose, TimeoutCommit, UpgradeHeightDelay.
pkg/appconsts/v2/app_consts.go Added new constants: TimeoutPropose, TimeoutCommit, UpgradeHeightDelay.
pkg/appconsts/v3/app_consts.go Added new constants: TimeoutPropose, TimeoutCommit, UpgradeHeightDelay.
pkg/appconsts/versioned_consts.go Added methods for dynamic timeout and upgrade height retrieval based on versioning.
test/e2e/benchmark/benchmark.go Introduced NewBenchmarkTest function and modified comments.
test/e2e/benchmark/manifest.go Added GenesisAppVersion field to Manifest struct.
test/e2e/major_upgrade_v3.go Updated version string and timer duration in MajorUpgradeToV3.
test/e2e/simple.go Clarified comment for E2ESimple function.
test/e2e/testnet/testnet.go Added variadic parameters to multiple methods in Testnet struct.
test/util/testnode/app_wrapper.go Introduced wrapEndBlocker function.
test/util/testnode/config.go Modified DefaultAppCreator and CustomAppCreator functions for end blocker configuration.
test/util/testnode/network.go Assigned tmNode variable to cctx context object.
test/util/testnode/node_interaction_api.go Added tmNode field and GetTMNode() method to Context struct.
x/blobstream/integration_test.go Added wait for blocks in SetupSuite method.
x/signal/integration_test.go Modified block height adjustment logic in TestUpgradeIntegration.
x/signal/keeper.go Removed upgradeHeightDelayBlocks field and updated NewKeeper function.
x/signal/keeper_test.go Adjusted keeper instantiation and upgrade logic in tests.

Assessment against linked issues

Objective Addressed Explanation
Stop requiring TestAppUpgradeV3 to produce enough blocks (3978)

Possibly related issues

Possibly related PRs

Suggested labels

required

Suggested reviewers

  • staheri14
  • ninabarbakadze
  • rootulp
  • cmwaters

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Inline review comments failed to post

Actionable comments posted: 11

🧹 Outside diff range and nitpick comments (14)
pkg/appconsts/v1/app_consts.go (1)

3-14: Overall assessment: Changes align with PR objectives and enhance configuration options.

The additions to this file successfully introduce new configuration constants that align with the PR objectives. The UpgradeHeightDelay constant, in particular, addresses the concerns raised in issue #3978 by providing a configurable delay for upgrades.

These changes enhance the flexibility of the system and should allow for easier testing and configuration in various environments. The clear comments and logical values chosen for the constants contribute to the maintainability of the code.

To ensure these changes are fully integrated:

  1. Verify that these new constants are used appropriately throughout the codebase.
  2. Update any relevant documentation to reflect these new configuration options.
  3. Consider adding tests that utilize these new constants to ensure they behave as expected in different scenarios.
test/util/testnode/app_wrapper.go (2)

11-13: Enhance function documentation for clarity.

While the current comment provides a basic explanation, it could be more informative. Consider expanding the documentation to include:

  1. The purpose of modifying the timeout commit.
  2. When this wrapper should be used.
  3. Any potential side effects or considerations when using this wrapper.

This additional information would help developers understand when and how to use this function effectively.


14-21: LGTM with a minor suggestion: Consider adding parameter validation.

The implementation correctly wraps the original end blocker, preserving its behavior while modifying only the timeout. This approach is clean and unlikely to introduce bugs.

To further improve robustness, consider adding validation for the timeoutCommit parameter. For example:

if timeoutCommit < 0 {
    panic("timeoutCommit must be non-negative")
}

This would prevent potential issues with negative timeout values.

pkg/appconsts/v3/app_consts.go (1)

14-17: LGTM: UpgradeHeightDelay constant added with clear explanation.

The addition of the UpgradeHeightDelay constant with its explanatory comment is excellent. The calculation is correct and the 7-day delay seems reasonable for allowing network participants to prepare for an upgrade.

Suggestion for improved clarity:

Consider updating the comment to explicitly mention the 6-second block time assumption:

 // UpgradeHeightDelay is the number of blocks after a quorum has been
 // reached that the chain should upgrade to the new version. Assuming a block
-// interval of 12 seconds, this is 7 days.
+// interval of 6 seconds, this is 7 days.
 UpgradeHeightDelay = int64(7 * 24 * 60 * 60 / 6) // 7 days * 24 hours * 60 minutes * 60 seconds / 6 seconds per block = 100,800 blocks.
test/util/genesis/genesis.go (2)

76-79: Approved: Method rename improves clarity

The renaming of WithModifier to WithModifiers accurately reflects that the method can accept multiple modifiers. This change enhances code readability and self-documentation.

Consider updating the comment to reflect the plural form:

-// WithModifiers adds a genesis modifier to the genesis.
+// WithModifiers adds one or more genesis modifiers to the genesis.

Line range hint 100-108: Approved: Method rename clarifies functionality

The renaming of WithAccounts to WithValidators more accurately describes the method's purpose, which is to add validators to the genesis. This change enhances code clarity and reduces potential confusion.

Consider updating the comment to provide more detail:

-// WithValidators adds the given validators to the genesis.
+// WithValidators adds the given validators to the genesis, creating new validator accounts.
test/e2e/benchmark/benchmark.go (1)

Line range hint 25-56: LGTM! Consider enhancing error handling.

The NewBenchmarkTest function is well-implemented, properly initializing the benchmark test environment. It correctly uses the provided manifest for configuration and sets up the necessary components.

Consider wrapping the error returned from testnet.New with additional context:

 testNet, err := testnet.New(kn, testnet.Options{
     Grafana:          testnet.GetGrafanaInfoFromEnvVar(),
     ChainID:          manifest.ChainID,
     GenesisModifiers: manifest.GetGenesisModifiers(),
 })
-testnet.NoError("failed to create testnet", err)
+if err != nil {
+    return nil, fmt.Errorf("failed to create testnet: %w", err)
+}

This change would provide more context in case of an error, making debugging easier.

test/util/testnode/config.go (3)

Line range hint 177-188: Approve changes with a suggestion for the timeout duration.

The addition of SetEndBlocker with a wrapper function is a good improvement as it adds a timeout mechanism to prevent long-running end blocker operations from blocking the chain. However, the 30ms timeout seems quite short and might be too restrictive for some operations.

Consider making the timeout duration configurable or increasing it to a more lenient value (e.g., 100ms or 200ms) to accommodate potentially longer-running operations while still preventing excessive delays.


Line range hint 195-206: Address inconsistency in end blocker timeout.

The CustomAppCreator function sets the end blocker timeout to 0 milliseconds, which effectively disables the timeout mechanism. This is inconsistent with the DefaultAppCreator function and might lead to unexpected behavior.

Consider one of the following options:

  1. Align the timeout with DefaultAppCreator (30ms).
  2. Make the timeout configurable through a parameter.
  3. If there's a specific reason for disabling the timeout in CustomAppCreator, please add a comment explaining the rationale.

Line range hint 1-206: Approve changes with suggestions for documentation.

The updates to DefaultTendermintConfig introduce several important changes:

  1. TimeoutCommit is set to 1ms, which might be too aggressive for slower environments.
  2. MaxTxBytes and MaxBodyBytes are set to allow very large transactions and responses.
  3. TimeoutBroadcastTxCommit is set to 1 minute.

While these changes may be suitable for specific test scenarios, they could pose risks if used in production environments.

Please add comments explaining:

  1. The rationale behind these configurations.
  2. Potential risks associated with these settings.
  3. Why these values were chosen and in which scenarios they are appropriate.

This documentation will help future developers understand the purpose and implications of these configurations.

test/util/testnode/node_interaction_api.go (1)

55-57: Add nil check and documentation to GetTMNode() method

The GetTMNode() method is a good addition for accessing the tmNode field. However, it lacks a nil check and documentation.

Consider modifying the method as follows:

+// GetTMNode returns the Tendermint node associated with this context.
+// It returns nil if no node has been set.
 func (c *Context) GetTMNode() *node.Node {
+    if c.tmNode == nil {
+        return nil
+    }
     return c.tmNode
 }

This change adds documentation and ensures that the method doesn't panic if tmNode is nil.

app/default_overrides.go (1)

Line range hint 1-290: Consider reviewing overall configuration settings

While not directly related to the changes in this PR, this file contains critical settings that significantly impact the blockchain's behavior. It might be beneficial to conduct a broader review of these configuration settings to ensure they align with the current project goals and performance expectations.

Key areas to consider:

  1. Consensus parameters (e.g., block size, gas limits)
  2. Module-specific configurations (e.g., staking, slashing, governance)
  3. IBC and ICA settings
  4. Performance-related settings (e.g., mempool configuration, state sync)

Would you like assistance in identifying any potential areas for optimization or adjustment in these configurations?

go.mod (1)

Line range hint 1-263: Overall dependency management strategy

The go.mod file shows several important updates and replacements:

  1. Tendermint updated to v1.43.0-tm-v0.34.35
  2. cosmos-sdk replaced with a fork
  3. ledger-cosmos-go pinned to v0.12.4
  4. gogo/protobuf replaced with a fork
  5. syndtr/goleveldb pinned to a specific commit

While these changes likely address specific needs or avoid known issues, they also introduce potential challenges in terms of long-term maintenance and compatibility.

Consider implementing a dependency management strategy that includes:

  1. Regular reviews of pinned dependencies to check for important updates or security patches.
  2. A process for evaluating and incorporating upstream changes into forked repositories.
  3. Documentation of the reasons for each fork or pin, and the conditions under which you would consider reverting to the official versions.
  4. Automated dependency update checks and security scans to proactively identify when updates are needed.

This strategy will help balance the need for stability with the importance of staying current and secure.

app/test/upgrade_test.go (1)

109-114: Suggestion: Move appVersion assignment outside the loop

The variable appVersion is assigned v2.Version at each iteration but does not change within the loop. Consider moving the assignment outside the loop to improve readability and avoid redundant assignments.

Apply this diff to move appVersion out of the loop:

+	appVersion := v2.Version
	for height := initialHeight; height < initialHeight+appconsts.UpgradeHeightDelay(v2.Version); height++ {
-		appVersion := v2.Version
		_ = testApp.BeginBlock(abci.RequestBeginBlock{
			Header: tmproto.Header{
				Height:  height,
				Version: tmversion.Consensus{App: appVersion},
			},
		})
🛑 Comments failed to post (11)
pkg/appconsts/v2/app_consts.go (1)

9-9: 💡 Codebase verification

TimeoutPropose is defined but not used

The TimeoutPropose constant in pkg/appconsts/v2/app_consts.go is currently not used anywhere in the codebase. Please review its necessity and consider removing it if it's not required.

🔗 Analysis chain

Verify the TimeoutPropose value.

The TimeoutPropose constant is well-named and follows Go conventions. However, please ensure that 10 seconds is the appropriate duration for this timeout in your system's context.

To verify if this timeout is used consistently across the codebase, run:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for uses of TimeoutPropose
rg --type go 'TimeoutPropose'

Length of output: 2649

test/e2e/benchmark/manifest.go (1)

83-84: 💡 Codebase verification

GenesisAppVersion is not set in Manifest instantiations

The GenesisAppVersion field is declared and assigned in manifest.go but is not provided when creating Manifest instances in test/e2e/benchmark/throughput.go. Please ensure that all instances of Manifest set the GenesisAppVersion field appropriately.

  • File: test/e2e/benchmark/throughput.go
🔗 Analysis chain

Verify usage of GenesisAppVersion in the codebase

While the addition of GenesisAppVersion and its usage in GetConsensusParams is good, it's important to ensure that this new field is properly utilized throughout the codebase. Please verify:

  1. That all code creating Manifest instances provides a value for GenesisAppVersion.
  2. Whether GetGenesisModifiers or other methods of Manifest should use this new field.
  3. Any other parts of the codebase that might need updates to accommodate this new field.

To help with this verification, you can run the following script:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for Manifest struct instantiations
echo "Searching for Manifest struct instantiations:"
rg --type go 'Manifest\s*{' -A 10

# Search for GenesisAppVersion usage
echo "\nSearching for GenesisAppVersion usage:"
rg --type go 'GenesisAppVersion'

# Search for potential places where GenesisAppVersion might be needed
echo "\nSearching for potential places where GenesisAppVersion might be needed:"
rg --type go 'GetGenesisModifiers|NewManifest|CreateManifest'

Length of output: 884


Script:

#!/bin/bash
# Corrected search for Manifest struct instantiations
echo "Searching for Manifest struct instantiations:"
rg --type go 'Manifest\s*\{' -A 10

# Search for GenesisAppVersion usage
echo "\nSearching for GenesisAppVersion usage:"
rg --type go 'GenesisAppVersion'

# Search for potential places where GenesisAppVersion might be needed
echo "\nSearching for potential places where GenesisAppVersion might be needed:"
rg --type go 'GetGenesisModifiers|NewManifest|CreateManifest'

Length of output: 2296

test/util/testnode/node_interaction_api.go (2)

37-37: ⚠️ Potential issue

Consider initializing the tmNode field in the NewContext function

The addition of the tmNode field is a good way to store a reference to the Tendermint node. However, it's not initialized in the NewContext function, which could lead to nil pointer dereferences if GetTMNode() is called before the field is set.

Consider modifying the NewContext function to accept a *node.Node parameter and initialize the tmNode field. For example:

-func NewContext(goContext context.Context, keyring keyring.Keyring, tmConfig *tmconfig.Config, chainID, apiAddress string) Context {
+func NewContext(goContext context.Context, keyring keyring.Keyring, tmConfig *tmconfig.Config, chainID, apiAddress string, tmNode *node.Node) Context {
    // ... existing code ...
-   return Context{goContext: goContext, Context: clientContext, apiAddress: apiAddress}
+   return Context{goContext: goContext, Context: clientContext, apiAddress: apiAddress, tmNode: tmNode}
}

This change ensures that tmNode is properly initialized when creating a new Context.

Committable suggestion was skipped due to low confidence.


37-37: 💡 Codebase verification

Issues Found: Missing Initialization of tmNode in Context Instances

The tmNode field has been successfully added to the Context struct in node_interaction_api.go. However, several instances where Context is instantiated do not initialize the tmNode field. This omission can lead to potential nil pointer dereferences and unexpected behavior.

Action Items:

  • Review all Context instantiations and ensure that the tmNode field is properly initialized.
  • Update the following locations to include tmNode where necessary:
    • test/util/testnode/node_interaction_api.go
    • x/tokenfilter/ibc_middleware_test.go
    • x/signal/keeper_test.go
    • x/blob/ante/blob_share_decorator_test.go
    • x/blob/ante/max_total_blob_size_ante_test.go
    • pkg/proof/proof_test.go
    • cmd/celestia-appd/cmd/root.go
    • app/ante/tx_size_gas_test.go
    • app/ante/panic_test.go
    • app/ante/gov_test.go
    • app/module/versioned_ibc_module_test.go
    • app/module/manager_test.go

Ensure that each Context initialization includes the tmNode field, either by passing a valid *node.Node instance or handling it appropriately based on the specific context of usage.

🔗 Analysis chain

Verify impact on existing codebase

The addition of the tmNode field and GetTMNode() method enhances the Context struct without directly impacting existing functionality. However, it's important to ensure that these changes are properly integrated across the codebase.

Please run the following script to identify potential areas that might need updates:

Review the results to ensure that:

  1. All NewContext calls are updated if you modify its signature.
  2. Consider if any of the found locations could benefit from using GetTMNode().

Also applies to: 55-57


Further Verification Needed

To ensure that the tmNode field is correctly integrated into all Context instances, please run the following script:

Review the results to ensure that:

  1. The Context struct definition includes the tmNode *node.Node field.
  2. All instances where Context is instantiated appropriately initialize the tmNode field.

Action Required: Correct and Re-run Verification Script

The previous script successfully found the tmNode field in the Context struct. However, there was an error in searching for Context struct initializations due to an unescaped { in the regex pattern. Please rerun the following corrected script to identify all Context initializations and ensure the tmNode field is properly set:

Review the results to ensure that:

  1. The Context struct definition includes the tmNode *node.Node field.
  2. All instances where Context is instantiated appropriately initialize the tmNode field.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find usages of Context creation and potential places where GetTMNode() might be useful.

# Find Context creations
echo "Searching for Context creations:"
rg --type go "NewContext\(" -A 3

# Find potential places where GetTMNode() might be useful
echo "\nSearching for potential GetTMNode() usage:"
rg --type go "Context.*\.(Client|Block|Status)"

Length of output: 16403


Script:

# 
#!/bin/bash
# Description: Verify the inclusion of the tmNode field in Context struct and its initializations.

# 1. Check the Context struct definition for tmNode
echo "Checking Context struct definition for tmNode field:"
rg --type go "type Context struct" -A 10 | grep "tmNode"

# 2. Find all Context struct initializations to verify tmNode is being set
echo -e "\nSearching for Context struct initializations:"
rg --type go "Context{" --context 2

Length of output: 462


Script:

# 
#!/bin/bash
# Description: Verify the inclusion of the tmNode field in Context struct and its initializations.

# 1. Check the Context struct definition for tmNode
echo "Checking Context struct definition for tmNode field:"
rg --type go "type Context struct" -A 10 | grep "tmNode"

# 2. Find all Context struct initializations to verify tmNode is being set
echo -e "\nSearching for Context struct initializations:"
rg --type go "Context\{" --context 2

Length of output: 6129

test/e2e/major_upgrade_v3.go (2)

140-142: ⚠️ Potential issue

Ensure blockTimes is not empty before accessing its elements

The code assumes that blockTimes has at least one element when accessing blockTimes[0] and blockTimes[len(blockTimes)-1]. If blockTimes is empty, this will cause an index out of range panic.

Add a check to ensure that blockTimes is not empty before accessing its elements to prevent potential runtime errors.

Apply this diff to add the safety check:

+if len(blockTimes) == 0 {
+	return fmt.Errorf("no block durations recorded to validate")
+}
 startDur := blockTimes[0]
 endDur := blockTimes[len(blockTimes)-1]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

	if len(blockTimes) == 0 {
		return fmt.Errorf("no block durations recorded to validate")
	}
	startDur := blockTimes[0]
	endDur := blockTimes[len(blockTimes)-1]

143-149: ⚠️ Potential issue

Improve error handling by directly returning errors

In the block duration validation at lines 143-149, using testnet.NoError with a newly constructed error and an empty message is inappropriate. The testnet.NoError function is intended to check for unexpected errors, not to handle expected test failures.

Consider directly returning the formatted error to make the test failure explicit and improve code readability.

Apply this diff to improve error handling:

 if startDur < time.Second*10 {
-	testnet.NoError("", fmt.Errorf("blocks for v2 are too short %v", len(blockTimes)))
+	return fmt.Errorf("blocks for v2 are too short, number of blocks checked: %v", len(blockTimes))
 }
 
 if endDur > time.Second*7 {
-	testnet.NoError("", fmt.Errorf("blocks for v3 are too long %v", len(blockTimes)))
+	return fmt.Errorf("blocks for v3 are too long, number of blocks checked: %v", len(blockTimes))
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

	if startDur < time.Second*10 {
		return fmt.Errorf("blocks for v2 are too short, number of blocks checked: %v", len(blockTimes))
	}

	if endDur > time.Second*7 {
		return fmt.Errorf("blocks for v3 are too long, number of blocks checked: %v", len(blockTimes))
	}
app/test/upgrade_test.go (1)

119-120: ⚠️ Potential issue

Issue: Inconsistent Height parameter in EndBlock call

Within the loop, EndBlock is called with a constant Height of 3 + appconsts.UpgradeHeightDelay(v2.Version), which doesn't correspond to the current height in the loop. This may lead to incorrect block processing and test inaccuracies. Consider using the loop variable height as the Height parameter.

Apply this diff to fix the Height parameter:

		endBlockResp = testApp.EndBlock(abci.RequestEndBlock{
-			Height: 3 + appconsts.UpgradeHeightDelay(v2.Version),
+			Height: height,
		})
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

			Height: height,
		})
test/e2e/testnet/testnet.go (3)

396-399: ⚠️ Potential issue

Correct indexing in the loop over 'filteredGenesisNodes'

The variable i in for i, node := range filteredGenesisNodes does not correspond to the original indices of t.nodes or genesisNodes. This makes the check isInIndices(i, indices) inaccurate. Since filteredGenesisNodes is already filtered, this additional check is unnecessary.

As above, removing the redundant check will resolve this issue.


428-435: 🛠️ Refactor suggestion

Optimize 'isInIndices' function for efficiency

The isInIndices function performs a linear search, which could become inefficient with larger index lists. Consider using a map for constant-time lookups.

Optimized version:

func isInIndices(i int, indices []int) bool {
  indexMap := make(map[int]struct{}, len(indices))
  for _, index := range indices {
    indexMap[index] = struct{}{}
  }
  _, exists := indexMap[i]
  return exists
}

215-219: ⚠️ Potential issue

Ensure consistent filtering when waiting for txClients to start

While StartTxClients correctly filters and starts txClients based on the provided indices, the subsequent loop that waits for the txClients to be running does not apply this filtering. This could lead to waiting on txClients that were not started in this invocation.

Apply this diff to fix the issue:

  // wait for txsims to start
- for _, txsim := range t.txClients {
+ for i, txsim := range t.txClients {
+   if len(indices) != 0 && !isInIndices(i, indices) {
+     continue
+   }
    err := txsim.Instance.Execution().WaitInstanceIsRunning(ctx)
    if err != nil {
      return fmt.Errorf("txsim %s failed to run: %w", txsim.Name, err)
    }
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

func (t *Testnet) StartTxClients(ctx context.Context, indices ...int) error {
	for i, txsim := range t.txClients {
		if len(indices) != 0 && !isInIndices(i, indices) {
			continue
		}
		// Start txsim code (not shown in the original snippet)
	}

	// wait for txsims to start
	for i, txsim := range t.txClients {
		if len(indices) != 0 && !isInIndices(i, indices) {
			continue
		}
		err := txsim.Instance.Execution().WaitInstanceIsRunning(ctx)
		if err != nil {
			return fmt.Errorf("txsim %s failed to run: %w", txsim.Name, err)
		}
	}

	return nil
}
x/signal/keeper_test.go (1)

72-72: ⚠️ Potential issue

Passing nil as storeKey in NewKeeper may cause issues

At line 72, signal.NewKeeper is called with nil for the storeKey parameter. If storeKey is required for the keeper's functionality, passing nil may lead to runtime errors or unexpected behavior. Consider providing a valid sdk.StoreKey, similar to how signalStore is used at line 455.

@cmwaters
Copy link
Contributor

Another option is to set a time instead of a number of blocks, which becomes the delay. This makes it easier to know when exactly the switch to vX will happen

@evan-forbes
Copy link
Member Author

Another option is to set a time instead of a number of blocks, which becomes the delay. This makes it easier to know when exactly the switch to vX will happen

I like that the most!

if we postpone to v4, then I definitely think we should do that and bother with the migration etc

Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +15 to +16
// reached that the chain should upgrade to the new version. Assuming a block
// interval of 12 seconds, this is 7 days.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// reached that the chain should upgrade to the new version. Assuming a block
// interval of 12 seconds, this is 7 days.
// reached that the chain should upgrade to the new version. Assuming a block
// interval of 6 seconds, this is 7 days.

@evan-forbes
Copy link
Member Author

merging now but I'm assigning myself the flups

thanks everyone!!

@evan-forbes evan-forbes merged commit d969f68 into sanaz/modify-timeouts Oct 16, 2024
35 checks passed
@evan-forbes evan-forbes deleted the evan/version-default-upgrade-height branch October 16, 2024 15:58
@coderabbitai coderabbitai bot mentioned this pull request Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WS: Maintenance 🔧 includes bugs, refactors, flakes, and tech debt etc WS: V3 3️⃣ item is directly relevant to the v3 hardfork
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stop requiring TestAppUpgradeV3 produce enough blocks to hit the DefaultUpgradeHeightDelay
3 participants