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

test: reduce testnode overrides #4066

Merged
merged 2 commits into from
Dec 2, 2024
Merged

Conversation

rootulp
Copy link
Collaborator

@rootulp rootulp commented Nov 27, 2024

Closes #3775

Motivation

The default testnode config should closely match the mainnet config. If we have one-off tests that require overrides for certain values then they should be overridden at the test level not at the default testnode config level.

@rootulp rootulp self-assigned this Nov 27, 2024
@rootulp rootulp marked this pull request as ready for review November 27, 2024 22:41
@rootulp rootulp requested a review from a team as a code owner November 27, 2024 22:41
@rootulp rootulp requested review from cmwaters and staheri14 and removed request for a team November 27, 2024 22:41
Copy link
Contributor

coderabbitai bot commented Nov 27, 2024

📝 Walkthrough

Walkthrough

The pull request introduces a new function, customTendermintConfig, in the comet_node_test.go file to create a customized Tendermint configuration for testing. This function modifies settings related to transaction sizes and timeouts. Additionally, the DefaultTendermintConfig function in config.go has been altered to remove specific configurations for the mempool and RPC settings, reducing the ability to handle larger transactions. The updates enhance the test environment but do not change method signatures or the overall structure of the test suite.

Changes

File Path Change Summary
test/util/testnode/comet_node_test.go Added customTendermintConfig function to customize Tendermint configuration for testing. Updated SetupSuite to integrate this new configuration.
test/util/testnode/config.go Modified DefaultTendermintConfig by removing configurations for MaxTxBytes, MaxBodyBytes, and TimeoutBroadcastTxCommit.

Assessment against linked issues

Objective Addressed Explanation
Use the same configuration as mainnet (#3775) The changes do not align with mainnet defaults as they modify transaction size handling.

Possibly related PRs

Suggested reviewers

  • staheri14
  • cmwaters
  • evan-forbes
  • 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: 2

🧹 Outside diff range and nitpick comments (2)
test/util/testnode/comet_node_test.go (1)

46-50: Replace magic number with a named constant

The 200 MiB value should be defined as a constant with a meaningful name to improve maintainability and clarity.

+const maxRPCBodyBytes = 200 * mebibyte // 200 MiB for large transactions and responses

func customTendermintConfig() *tmconfig.Config {
    // ...
-   tmCfg.RPC.MaxBodyBytes = 200 * mebibyte
+   tmCfg.RPC.MaxBodyBytes = maxRPCBodyBytes
test/util/testnode/config.go (1)

Line range hint 147-152: Consider documenting the timeout commit configuration.

While the 1ms timeout commit is retained for faster test execution, it would be helpful to add a comment explaining why this differs from mainnet configuration, as it's one of the few remaining overrides.

 func DefaultTendermintConfig() *tmconfig.Config {
 	tmCfg := tmconfig.DefaultConfig()
+	// Note: This timeout differs from mainnet configuration to speed up test execution.
+	// This is an acceptable override as it doesn't affect the functional behavior being tested.
 	// Reduce the timeout commit to 1ms to speed up the rate at which the test
 	// node produces blocks.
 	tmCfg.Consensus.TimeoutCommit = 1 * time.Millisecond
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

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

📒 Files selected for processing (2)
  • test/util/testnode/comet_node_test.go (3 hunks)
  • test/util/testnode/config.go (1 hunks)
🔇 Additional comments (3)
test/util/testnode/comet_node_test.go (3)

19-19: LGTM: Import addition is appropriate

The new import is necessary for the configuration customization and follows Go naming conventions.


43-44: LGTM: MaxTxBytes configuration aligns with PR objectives

The override for MaxTxBytes is well-documented and correctly uses the appconsts.DefaultUpperBoundMaxBytes constant.


65-66: LGTM: Test setup changes are appropriate

The modifications correctly integrate the blob parameters and custom Tendermint configuration, aligning with the PR objective of handling specific test requirements at the individual test level.

Comment on lines +38 to +53
func customTendermintConfig() *tmconfig.Config {
tmCfg := DefaultTendermintConfig()
// Override the mempool's MaxTxBytes to allow the testnode to accept a
// transaction that fills the entire square. Any blob transaction larger
// than the square size will still fail no matter what.
maxTxBytes := appconsts.DefaultUpperBoundMaxBytes
tmCfg.Mempool.MaxTxBytes = maxTxBytes

// Override the MaxBodyBytes to allow the testnode to accept very large
// transactions and respond to queries with large responses (200 MiB was
// chosen only as an arbitrary large number).
tmCfg.RPC.MaxBodyBytes = 200 * mebibyte

tmCfg.RPC.TimeoutBroadcastTxCommit = time.Minute
return tmCfg
}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Based on the results, I can now provide a final response since we have found the mainnet configuration values in app/default_overrides.go.

Adjust test configuration values to match mainnet settings

The test configuration values significantly differ from mainnet settings and should be aligned:

  • MaxBodyBytes: Test uses 200 MiB vs mainnet's 8 MiB
  • TimeoutBroadcastTxCommit: Test uses 60s vs mainnet's 50s

Please update these values in customTendermintConfig() to match the mainnet configuration from app/default_overrides.go.

🔗 Analysis chain

Verify configuration values against mainnet

According to the PR objectives, these configurations should align with mainnet values. Let's verify these settings.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for mainnet configuration references
rg -A 5 "MaxBodyBytes|TimeoutBroadcastTxCommit" --type go

# Search for any other test configurations
ast-grep --pattern 'func $_()*Config() *tmconfig.Config {
  $$$
}'

Length of output: 2080

Comment on lines +153 to 156
// Set all the ports to random open ones.
tmCfg.RPC.ListenAddress = fmt.Sprintf("tcp://127.0.0.1:%d", mustGetFreePort())
tmCfg.P2P.ListenAddress = fmt.Sprintf("tcp://127.0.0.1:%d", mustGetFreePort())
tmCfg.RPC.GRPCListenAddress = fmt.Sprintf("tcp://127.0.0.1:%d", mustGetFreePort())
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Caution: Configuration removal requires test adjustments

The removed configurations are actively used in test files and serve specific purposes:

  • test/util/testnode/comet_node_test.go uses these settings to handle large transactions and responses
  • test/e2e/testnet/setup.go and test/e2e/benchmark/benchmark.go configure mempool size for test scenarios

These test-specific configurations should be preserved or alternative approaches should be implemented to maintain test functionality.

🔗 Analysis chain

LGTM! Configuration simplification aligns with mainnet.

The removal of custom mempool and RPC configurations while keeping only the necessary network address settings aligns well with the PR objective of matching mainnet configuration. This change ensures that tests run with settings closer to production.

Let's verify that no other tests rely on the removed configurations:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for tests that might be affected by the removal of MaxTxBytes, MaxBodyBytes, and TimeoutBroadcastTxCommit configs
rg -l "MaxTxBytes|MaxBodyBytes|TimeoutBroadcastTxCommit" --type go test/

Length of output: 170


Script:

#!/bin/bash
# Let's check the actual usage of these configurations in the found files
echo "=== test/util/testnode/comet_node_test.go ==="
rg -A 5 "MaxTxBytes|MaxBodyBytes|TimeoutBroadcastTxCommit" test/util/testnode/comet_node_test.go

echo -e "\n=== test/e2e/testnet/setup.go ==="
rg -A 5 "MaxTxBytes|MaxBodyBytes|TimeoutBroadcastTxCommit" test/e2e/testnet/setup.go

echo -e "\n=== test/e2e/benchmark/benchmark.go ==="
rg -A 5 "MaxTxBytes|MaxBodyBytes|TimeoutBroadcastTxCommit" test/e2e/benchmark/benchmark.go

Length of output: 1674

@rootulp rootulp enabled auto-merge (squash) November 29, 2024 18:23
@rootulp rootulp merged commit e6d659e into celestiaorg:main Dec 2, 2024
28 of 29 checks passed
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.

Use the same configuration as mainnet
3 participants