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: update default mempool config #3961

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rootulp
Copy link
Collaborator

@rootulp rootulp commented Oct 10, 2024

Motivation in the Mempool TTL duration section of #3959 (comment)

Description

Modify the default consensus node config for mempools so that:

  • TTLNumBlocks from 5 to 12 because 12 six second blocks = 72 seconds which is comparable to the existing 75 second TTLDuration.
  • MaxTxBytes from ~7.5 MiB to 8 MiB because it's easier to understand and communicate
  • MaxTxsBytes from ~37.6 MiB to 40 MiB because it's easier to understand and communicate

Testing

make install && ./scripts/single-node.sh then cat the config

version = "v1"
max_txs_bytes = 41943040
max_tx_bytes = 8388608
ttl-duration = "1m15s"
ttl-num-blocks = 12

@rootulp rootulp self-assigned this Oct 10, 2024
@rootulp rootulp requested a review from a team as a code owner October 10, 2024 19:21
@rootulp rootulp requested review from cmwaters and evan-forbes and removed request for a team October 10, 2024 19:21
@celestia-bot celestia-bot requested a review from a team October 10, 2024 19:21
Comment on lines -268 to -272
// Given that there is a stateful transaction size check in CheckTx,
// We set a loose upper bound on what we expect the transaction to
// be based on the upper bound size of the entire block for the given
// version. This acts as a first line of DoS protection
upperBoundBytes := appconsts.DefaultSquareSizeUpperBound * appconsts.DefaultSquareSizeUpperBound * share.ContinuationSparseShareContentSize
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

part of this PR is motivated by a desire to remove this.

@rootulp rootulp added the WS: V3 3️⃣ item is directly relevant to the v3 hardfork label Oct 10, 2024
Copy link
Contributor

coderabbitai bot commented Oct 10, 2024

📝 Walkthrough

Walkthrough

The changes involve modifications to the app/default_overrides.go and app/default_overrides_test.go files. The default_overrides.go file introduces a new constant for mebibyte and updates the default genesis states for several modules, particularly enhancing parameters in the slashingModule. The DefaultConsensusConfig function has also been revised to adjust transaction limits and durations. Correspondingly, the default_overrides_test.go file has been updated to reflect these changes in the test cases, ensuring that the new configurations are validated correctly.

Changes

File Change Summary
app/default_overrides.go - Added constant mebibyte = 1024 * 1024.
- Updated DefaultGenesis methods for multiple modules.
- Revised DefaultConsensusConfig with new values for TTLNumBlocks, TTLDuration, MaxTxBytes, and MaxTxsBytes.
- Removed commented-out code regarding mempool upper bound bytes.
app/default_overrides_test.go - Modified TestDefaultConsensusConfig to validate new values for MaxTxBytes, MaxTxsBytes, TTLNumBlocks, and TTLDuration.

Suggested reviewers

  • cmwaters
  • staheri14
  • ninabarbakadze
  • evan-forbes
  • rach-id

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: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between a7476c6 and 751782e.

📒 Files selected for processing (2)
  • app/default_overrides.go (2 hunks)
  • app/default_overrides_test.go (1 hunks)
🧰 Additional context used
🪛 GitHub Check: lint / golangci-lint
app/default_overrides.go

[failure] 267-267:
unnecessary conversion (unconvert)

🔇 Additional comments (4)
app/default_overrides_test.go (1)

83-87: LGTM! Changes align with PR objectives.

The modifications to the MempoolConfig structure in the TestDefaultConsensusConfig function are consistent with the PR objectives:

  1. TTLNumBlocks is updated to 12, aligning with the 75-second TTLDuration.
  2. MaxTxBytes is set to 8 MiB (8 * mebibyte).
  3. MaxTxsBytes is set to 40 MiB (40 * mebibyte).

The use of the mebibyte constant improves code readability and maintainability.

To ensure consistency across the codebase, let's verify these changes:

✅ Verification successful

Verification Successful! All mempool configuration changes are consistent across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the mempool configuration changes in other files

# Test 1: Check for TTLNumBlocks value
echo "Checking for TTLNumBlocks value:"
rg --type go "TTLNumBlocks.*12" --glob '!app/default_overrides_test.go'

# Test 2: Check for MaxTxBytes value
echo "Checking for MaxTxBytes value:"
rg --type go "MaxTxBytes.*8.*mebibyte" --glob '!app/default_overrides_test.go'

# Test 3: Check for MaxTxsBytes value
echo "Checking for MaxTxsBytes value:"
rg --type go "MaxTxsBytes.*40.*mebibyte" --glob '!app/default_overrides_test.go'

# Test 4: Check for TTLDuration value
echo "Checking for TTLDuration value:"
rg --type go "TTLDuration.*75.*time\.Second" --glob '!app/default_overrides_test.go'

Length of output: 907

app/default_overrides.go (3)

39-39: Definition of mebibyte constant improves readability

Defining mebibyte as 1024 * 1024 enhances code clarity by eliminating magic numbers when specifying sizes in mebibytes.


266-266: Increase of TTLNumBlocks aligns with TTLDuration

Updating cfg.Mempool.TTLNumBlocks to 12 ensures consistency with TTLDuration of 75 seconds, as 12 blocks × 6 seconds per block equals 72 seconds, closely matching the duration.


268-269: Usage of mebibyte constant enhances clarity in size configurations

Setting MaxTxBytes and MaxTxsBytes using the mebibyte constant improves readability and maintains consistency in how memory sizes are defined throughout the code.

cfg.Mempool.MaxTxsBytes = int64(upperBoundBytes) * cfg.Mempool.TTLNumBlocks
cfg.Mempool.Version = "v1" // prioritized mempool
cfg.Mempool.TTLNumBlocks = 12
cfg.Mempool.TTLDuration = time.Duration(75 * time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Unnecessary conversion in TTLDuration assignment

The assignment to cfg.Mempool.TTLDuration unnecessarily wraps the multiplication in time.Duration(). Since time.Second is already a time.Duration, multiplying it by 75 yields a time.Duration, making the explicit conversion redundant.

Apply this diff to remove the unnecessary conversion:

-	cfg.Mempool.TTLDuration = time.Duration(75 * time.Second)
+	cfg.Mempool.TTLDuration = 75 * time.Second
📝 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.

Suggested change
cfg.Mempool.TTLDuration = time.Duration(75 * time.Second)
cfg.Mempool.TTLDuration = 75 * time.Second
🧰 Tools
🪛 GitHub Check: lint / golangci-lint

[failure] 267-267:
unnecessary conversion (unconvert)

TTLDuration: 75 * time.Second,
TTLNumBlocks: 5,
MaxTxBytes: 8 * mebibyte,
MaxTxsBytes: 40 * mebibyte,
Copy link
Member

Choose a reason for hiding this comment

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

Per sync discussions elsewhere I think we can increase this to 1 GB

TTLDuration: 75 * time.Second,
TTLNumBlocks: 5,
MaxTxBytes: 8 * mebibyte,
Copy link
Member

Choose a reason for hiding this comment

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

I don't see the harm in keeping this at 8, but it might be less confusing to keep it at 2MiB since that will be the hard coded limit

Copy link
Member

Choose a reason for hiding this comment

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

yes! let's change this and I'll approve @rootulp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WS: V3 3️⃣ item is directly relevant to the v3 hardfork
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants