-
Notifications
You must be signed in to change notification settings - Fork 283
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
base: main
Are you sure you want to change the base?
Conversation
// 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 |
There was a problem hiding this comment.
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.
📝 WalkthroughWalkthroughThe changes involve modifications to the Changes
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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
📒 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 theTestDefaultConsensusConfig
function are consistent with the PR objectives:
TTLNumBlocks
is updated to 12, aligning with the 75-secondTTLDuration
.MaxTxBytes
is set to 8 MiB (8 * mebibyte).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 ofmebibyte
constant improves readabilityDefining
mebibyte
as1024 * 1024
enhances code clarity by eliminating magic numbers when specifying sizes in mebibytes.
266-266
: Increase ofTTLNumBlocks
aligns withTTLDuration
Updating
cfg.Mempool.TTLNumBlocks
to 12 ensures consistency withTTLDuration
of 75 seconds, as 12 blocks × 6 seconds per block equals 72 seconds, closely matching the duration.
268-269
: Usage ofmebibyte
constant enhances clarity in size configurationsSetting
MaxTxBytes
andMaxTxsBytes
using themebibyte
constant improves readability and maintains consistency in how memory sizes are defined throughout the code.
app/default_overrides.go
Outdated
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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, |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Motivation in the Mempool TTL duration section of #3959 (comment)
Description
Modify the default consensus node config for mempools so that:
Testing
make install && ./scripts/single-node.sh
then cat the config