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

refactor: override the upgrade height for chain-id test to 3 #4065

Conversation

rootulp
Copy link
Collaborator

@rootulp rootulp commented Nov 27, 2024

Closes #4053

Description

  1. Override the upgrade height for chain-id test to 3 so that there are still a few blocks of delay in tests
  2. Remove OverrideUpgradeHeightDelayStr because it was confusing to have multiple ways to override the upgrade height (1) chain-id and (2) via ENV variables

@rootulp rootulp self-assigned this Nov 27, 2024
@rootulp rootulp requested a review from a team as a code owner November 27, 2024 20:43
@rootulp rootulp requested review from cmwaters and evan-forbes and removed request for a team November 27, 2024 20:43
@celestia-bot celestia-bot requested a review from a team November 27, 2024 20:44
@rootulp rootulp marked this pull request as draft November 27, 2024 20:45
Copy link
Contributor

coderabbitai bot commented Nov 27, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request involves several modifications across multiple files, primarily focused on the removal of the OVERRIDE_UPGRADE_HEIGHT_DELAY variable and its associated usage in the build and upgrade process. Changes include updates to the Makefile, adjustments in the upgrade test cases, and simplifications in the application constants related to upgrade height delays. The overall control flow and logic remain intact, with no new commands introduced or existing commands altered beyond the specified removals.

Changes

File Change Summary
Makefile Removed OVERRIDE_UPGRADE_HEIGHT_DELAY variable and its usage in linker flags.
app/test/upgrade_test.go Updated TestAppUpgradeV3 to remove the override for appconsts.OverrideUpgradeHeightDelayStr; modified SetupTestAppWithUpgradeHeight to include a chain ID in genesis configuration.
pkg/appconsts/overrides.go Removed variable OverrideUpgradeHeightDelayStr.
pkg/appconsts/versioned_consts.go Modified UpgradeHeightDelay function to return 3 for chain ID "test" instead of using an override string.
pkg/appconsts/versioned_consts_test.go Added test cases for chain ID "test" to verify upgrade height delay is consistently 3.

Assessment against linked issues

Objective Addressed Explanation
Override upgrade height delay for local devnets (#4053) The removal of the override variable does not meet the proposal for local devnets.

Possibly related PRs

Suggested labels

bug, enhancement, required

Suggested reviewers

  • evan-forbes
  • cmwaters
  • staheri14
  • ninabarbakadze

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.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (4)
pkg/appconsts/versioned_consts.go (1)

83-84: LGTM! Consider minor improvements for maintainability.

The implementation correctly addresses the PR objective by setting a fixed upgrade height delay of 3 blocks for the test chain-id.

Consider these improvements:

+ // TestChainID is the chain ID used for testing environments
+ const TestChainID = "test"
+ // TestUpgradeHeightDelay is the number of blocks to wait before upgrading in test environments
+ const TestUpgradeHeightDelay = 3
+
  func UpgradeHeightDelay(chainID string, v uint64) int64 {
-   if chainID == "test" {
-     return 3
+   if chainID == TestChainID {
+     return TestUpgradeHeightDelay
pkg/appconsts/versioned_consts_test.go (1)

121-132: Differentiate the test case names

The two test cases have identical names which could cause confusion when a test fails. Consider making the names more specific to each version being tested.

Apply this diff to make the test names more distinct:

-			name:                       "the upgrade delay for chainID 'test' should be 3 regardless of the version",
+			name:                       "the upgrade delay for chainID 'test' should be 3 for version 3",
...
-			name:                       "the upgrade delay for chainID 'test' should be 3 regardless of the version",
+			name:                       "the upgrade delay for chainID 'test' should be 3 for version 4",
app/test/upgrade_test.go (2)

258-258: LGTM, but consider adding explicit verification.

The addition of chain ID "test" aligns with the PR objectives. However, consider adding explicit assertions to verify that the upgrade height delay is correctly overridden to 3 for this chain ID.

Add assertions like:

 genesis := genesis.NewDefaultGenesis().
   WithChainID("test").
   WithValidators(genesis.NewDefaultValidator(testnode.DefaultValidatorAccountName)).
   WithConsensusParams(app.DefaultInitialConsensusParams())
+// Verify upgrade height override for chain-id "test"
+require.Equal(t, int64(3), appconsts.UpgradeHeightDelay("test", v2.Version))

Line range hint 89-92: Make upgrade height delay expectations explicit.

The test implicitly validates the upgrade height delay through the loop, but it would be clearer if the expectations were explicit.

Consider adding:

+expectedDelay := int64(3) // explicit expectation for chain-id "test"
+require.Equal(t, expectedDelay, appconsts.UpgradeHeightDelay(testApp.GetChainID(), v2.Version))
 for height := initialHeight; height < initialHeight+appconsts.UpgradeHeightDelay(testApp.GetChainID(), v2.Version); height++ {
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2ca0feb and b9e1043.

📒 Files selected for processing (5)
  • Makefile (1 hunks)
  • app/test/upgrade_test.go (1 hunks)
  • pkg/appconsts/overrides.go (0 hunks)
  • pkg/appconsts/versioned_consts.go (1 hunks)
  • pkg/appconsts/versioned_consts_test.go (1 hunks)
💤 Files with no reviewable changes (1)
  • pkg/appconsts/overrides.go
🔇 Additional comments (3)
pkg/appconsts/versioned_consts.go (1)

83-84: Verify chain-id usage in tests and local development.

Let's ensure this change only affects test environments and doesn't impact production chains.

✅ Verification successful

Chain-id "test" usage is properly isolated to test environments

The verification confirms that:

  • The "test" chain-id is only used in test files (*_test.go) and local development scripts
  • The production chain logic is separate and handles other chain IDs (like "arabica") differently
  • The change only affects the upgrade height delay for test environments, returning a fixed value of 3 blocks
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check usage of chain-ids in tests and configuration files
# Expected: Only test-related files should use chain-id "test"

echo "Checking for chain-id usage in test files:"
rg -g '**/*_test.go' '"test"' -C 2

echo "Checking for chain-id usage in configuration and script files:"
rg -g '*.{sh,json,toml,yaml,yml}' '"test"' -C 2

echo "Checking for other chain-ids to ensure they're not affected:"
rg 'chainID == "(?!test)' -C 2

Length of output: 10876


Script:

#!/bin/bash
# Let's check for other chain IDs with a simpler pattern
echo "Checking for chainID comparisons in the codebase:"
rg 'chainID ==' -C 2

# Let's also check the specific function implementation
echo -e "\nChecking the UpgradeHeightDelay implementation:"
ast-grep --pattern 'func UpgradeHeightDelay($_, $_) $$$'

Length of output: 2259

pkg/appconsts/versioned_consts_test.go (1)

121-132: LGTM! The test cases effectively verify the new upgrade height delay behavior.

The added test cases properly verify that:

  1. The chain-id "test" consistently returns an upgrade height delay of 3
  2. This behavior is version-independent (tested with versions 3 and 4)

This aligns well with the PR objective of providing shorter upgrade delays for testing environments.

Makefile (1)

37-37: LGTM! Clean removal of the upgrade height delay override.

The removal of the OverrideUpgradeHeightDelayStr linker flag aligns with the PR objective to simplify upgrade height overrides by removing one of the multiple override methods.

Let's verify no other references to the removed variable exist:

✅ Verification successful

Verified: No remaining references to the removed variable in the codebase

The search results confirm that there are no remaining references to OverrideUpgradeHeightDelayStr in the codebase. The only matches found are:

  • A documentation file (adr-018-network-upgrades.md) discussing the general concept of upgrade height delays
  • A comment in Dockerfile about build args, which is unrelated to the specific variable
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any remaining references to the removed variable
# Test: Expect no matches for OverrideUpgradeHeightDelayStr

# Search in all files
rg -i "OverrideUpgradeHeightDelayStr"

# Search specifically in go files for any upgrade height delay related code
rg "upgrade.*height.*delay"

Length of output: 1702

@rootulp
Copy link
Collaborator Author

rootulp commented Nov 27, 2024

make test-e2e doesn't pass locally before or after this change so idk if this change broke it any more.

@rootulp rootulp marked this pull request as ready for review November 27, 2024 21:10
@rootulp rootulp requested a review from liamsi as a code owner November 27, 2024 21:10
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.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
docs/architecture/adr-015-namespace-id-size.md (1)

53-53: Fix grammar issues in the sentence

The sentence has two grammar issues:

  1. Subject-verb agreement: "it fail" should be "it fails"
  2. Number agreement: "this criteria" should be "this criterion" (since referring to Criteria 1)
-The namespace ID must provide at least 72 bits of randomness to satisfy criteria 1. Since an 8 byte namespace ID can only provide 64 bits of randomness, it fail to meet this criteria.
+The namespace ID must provide at least 72 bits of randomness to satisfy criteria 1. Since an 8 byte namespace ID can only provide 64 bits of randomness, it fails to meet this criterion.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~53-~53: This verb does not appear to agree with the subject. Consider using a different form.
Context: ... only provide 64 bits of randomness, it fail to meet this criteria. | Namespace ID ...

(AI_EN_LECTOR_REPLACEMENT_VERB_AGREEMENT)


[grammar] ~53-~53: The singular determiner ‘this’ may not agree with the plural noun ‘criteria’. Did you mean “these”?
Context: ... 64 bits of randomness, it fail to meet this criteria. | Namespace ID size (bytes) ...

(THIS_NNS)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b9e1043 and 152e870.

📒 Files selected for processing (1)
  • docs/architecture/adr-015-namespace-id-size.md (1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/architecture/adr-015-namespace-id-size.md

[uncategorized] ~53-~53: This verb does not appear to agree with the subject. Consider using a different form.
Context: ... only provide 64 bits of randomness, it fail to meet this criteria. | Namespace ID ...

(AI_EN_LECTOR_REPLACEMENT_VERB_AGREEMENT)


[grammar] ~53-~53: The singular determiner ‘this’ may not agree with the plural noun ‘criteria’. Did you mean “these”?
Context: ... 64 bits of randomness, it fail to meet this criteria. | Namespace ID size (bytes) ...

(THIS_NNS)

Copy link
Contributor

@cmwaters cmwaters left a comment

Choose a reason for hiding this comment

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

👍 - thanks for removing the override. Yes there's no need for it. I think there may still be reference to the override in the Dockerfile

panic("Invalid OverrideUpgradeHeightDelayStr value")
}
return parsedValue
if chainID == "test" {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit can we use a constant name (that can also be used in tests)

Copy link
Member

@evan-forbes evan-forbes left a comment

Choose a reason for hiding this comment

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

nice! thanks for pushing this through

@rootulp rootulp merged commit 5463787 into celestiaorg:main Dec 2, 2024
29 checks passed
@rootulp rootulp deleted the rp/override-upgrade-height-delay-for-test-chains branch December 2, 2024 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Override upgrade height delay for local devnets
3 participants