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: rename limits from tx to msg #3984

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

rootulp
Copy link
Collaborator

@rootulp rootulp commented Oct 16, 2024

Motivation: celestiaorg/CIPs#220 (comment)

IMO we should either include this in v3.0.0-rc0 or close it b/c not worth it to break these constant names after that.

Copy link
Contributor

coderabbitai bot commented Oct 16, 2024

📝 Walkthrough

Walkthrough

The changes in this pull request involve renaming constants and updating logic related to transaction limits in the context of message handling. Specifically, constants PFBTransactionCap and NonPFBTransactionCap have been renamed to MaxPFBMessages and MaxNonPFBMessages, respectively. The test file prepare_proposal_test.go has been updated to reflect these changes, ensuring that the tests accurately assert the number of messages against the new limits. Additionally, the transaction filtering logic in validate_txs.go has been modified to align with the new naming conventions.

Changes

File Path Change Summary
app/test/prepare_proposal_test.go Renamed constants related to transaction limits; updated TestPrepareProposalCappingNumberOfMessages to use new constants.
app/validate_txs.go Renamed variables in filterStdTxs and filterBlobTxs functions; updated logic to use new constants for message counts.
pkg/appconsts/global_consts.go Renamed constants NonPFBTransactionCap to MaxNonPFBMessages and PFBTransactionCap to MaxPFBMessages; updated comments.

Possibly related PRs

  • feat: limit the number of messages in prepare proposal #3942: This PR directly relates to the main PR as it also modifies the app/test/prepare_proposal_test.go file to add new tests for capping the number of messages in proposals, which aligns with the changes made in the main PR regarding transaction limits.
  • refactor: cap tx size flups #3967: This PR is relevant because it involves renaming MaxTxBytes to MaxTxSize in multiple files, including app/test/prepare_proposal_test.go, which reflects the changes made in the main PR regarding transaction limit constants.

Suggested labels

WS: Maintenance 🔧, external

Suggested reviewers

  • evan-forbes
  • ninabarbakadze
  • liamsi
  • staheri14

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 (3)
app/validate_txs.go (2)

48-48: LGTM! Consider updating the error message for consistency.

The changes correctly implement the new message-based limit and align with the PR objectives. The variable renaming and logic updates improve clarity and consistency.

Consider updating the error message on line 61 for consistency:

-			logger.Debug("skipping tx because the max non PFB message count was reached", "tx", tmbytes.HexBytes(coretypes.Tx(tx).Hash()))
+			logger.Debug("skipping tx because the max non-PFB message count was reached", "tx", tmbytes.HexBytes(coretypes.Tx(tx).Hash()))

This change makes the error message consistent with the new terminology and improves readability.

Also applies to: 60-61, 64-64


93-93: LGTM! Consider minor improvements for consistency.

The changes correctly implement the new message-based limit and align with the PR objectives. The variable renaming and logic updates improve clarity and consistency.

Consider the following minor improvements for consistency:

  1. Update the error message on line 105:
-			logger.Debug("skipping tx because the max pfb message count was reached", "tx", tmbytes.HexBytes(coretypes.Tx(tx.Tx).Hash()))
+			logger.Debug("skipping tx because the max PFB message count was reached", "tx", tmbytes.HexBytes(coretypes.Tx(tx.Tx).Hash()))
  1. For consistency with the non-PFB case, consider adding a hyphen:
-			logger.Debug("skipping tx because the max PFB message count was reached", "tx", tmbytes.HexBytes(coretypes.Tx(tx.Tx).Hash()))
+			logger.Debug("skipping tx because the max PFB-message count was reached", "tx", tmbytes.HexBytes(coretypes.Tx(tx.Tx).Hash()))

These changes improve consistency in terminology and readability across the codebase.

Also applies to: 104-105, 108-108

app/test/prepare_proposal_test.go (1)

362-363: LGTM: Test case updated correctly, minor improvement suggested

The test case has been properly updated to use appconsts.MaxPFBMessages. The division by numberOfMsgsPerTx correctly accounts for multiple messages per transaction.

For improved clarity, consider adding a comment explaining the division:

// Divide by numberOfMsgsPerTx to ensure the total number of messages doesn't exceed MaxPFBMessages
expectedTransactions: multiPFBsPerTxs[:appconsts.MaxPFBMessages/numberOfMsgsPerTx],
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c2d14d9 and 17b3a72.

📒 Files selected for processing (3)
  • app/test/prepare_proposal_test.go (5 hunks)
  • app/validate_txs.go (4 hunks)
  • pkg/appconsts/global_consts.go (1 hunks)
🧰 Additional context used
🔇 Additional comments (7)
pkg/appconsts/global_consts.go (1)

71-79: Approve the renaming of constants for improved clarity.

The renaming of NonPFBTransactionCap to MaxNonPFBMessages and PFBTransactionCap to MaxPFBMessages improves code clarity and aligns with the PR objectives. The updated comments accurately reflect the new constant names.

Let's verify the impact of these changes on the rest of the codebase:

✅ Verification successful

Verified the renaming of constants and ensured no remaining references to old names. The new constants are used appropriately across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to the old constant names and verify the usage of new constant names.

# Test 1: Search for any remaining references to the old constant names
echo "Searching for remaining references to old constant names:"
rg --type go "NonPFBTransactionCap|PFBTransactionCap"

# Test 2: Verify the usage of new constant names
echo "Verifying usage of new constant names:"
rg --type go "MaxNonPFBMessages|MaxPFBMessages"

Length of output: 2031

app/validate_txs.go (1)

Line range hint 1-150: Overall changes look good. Verify related tests and documentation.

The changes successfully implement the PR objectives by renaming limits from "tx" to "msg" and updating the associated logic. These modifications improve code clarity and consistency across the file.

To ensure completeness, please run the following script to check for any related tests or documentation that might need updating:

Please review the output of this script and update any related tests or documentation as necessary to maintain consistency with the changes made in this file.

✅ Verification successful

Related tests and documentation are up to date. No further action required.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for related tests and documentation that might need updating

# Search for test files that might need updating
echo "Searching for related test files:"
fd --type f --extension go --exec grep -l 'PFBTransactionCap|NonPFBTransactionCap' {}

# Search for documentation files that might need updating
echo "Searching for related documentation files:"
fd --type f --extension md --exec grep -l 'PFBTransactionCap|NonPFBTransactionCap' {}

# Search for any remaining occurrences of old terminology
echo "Searching for any remaining occurrences of old terminology:"
rg 'PFBTransactionCap|NonPFBTransactionCap'

Length of output: 526


Script:

#!/bin/bash
# Description: Enhanced search for related tests and documentation that might need updating

# Define search patterns with case insensitivity and possible variations
PATTERNS='(?i)PFBTransactionCap|NonPFBTransactionCap|PFB Msg Cap|NonPFB Msg Cap'

# Search for test files that might need updating
echo "Searching for related test files with enhanced patterns:"
fd --type f --extension go --exec grep -Ei -l "$PATTERNS" {}

# Search for documentation files that might need updating
echo "Searching for related documentation files with enhanced patterns:"
fd --type f --extension md --exec grep -Ei -l "$PATTERNS" {}

# Search for any remaining occurrences of old or varied terminology
echo "Searching for any remaining occurrences of old or varied terminology:"
rg -i 'PFBTransactionCap|NonPFBTransactionCap|PFB Msg Cap|NonPFB Msg Cap'

Length of output: 18301


Script:

#!/bin/bash
# Description: Corrected search for related tests and documentation that might need updating

# Define search patterns without inline case-insensitivity
PATTERNS='PFBTransactionCap|NonPFBTransactionCap|PFB Msg Cap|NonPFB Msg Cap'

# Search for test files that might need updating
echo "Searching for related test files with corrected patterns:"
fd --type f --extension go --exec grep -Ei -l "$PATTERNS" {}

# Search for documentation files that might need updating
echo "Searching for related documentation files with corrected patterns:"
fd --type f --extension md --exec grep -Ei -l "$PATTERNS" {}

# Search for any remaining occurrences of old or varied terminology
echo "Searching for any remaining occurrences of old or varied terminology:"
rg -i 'PFBTransactionCap|NonPFBTransactionCap|PFB Msg Cap|NonPFB Msg Cap'

Length of output: 813

app/test/prepare_proposal_test.go (5)

300-302: LGTM: Constant renamed and test case improved

The change from PFBTransactionCap to MaxPFBMessages aligns with the PR objective. Additionally, creating 500 more PFBs than the maximum allowed improves the test case by ensuring the capping behavior is properly tested.


336-338: LGTM: Constant renamed and test case improved

The change from NonPFBTransactionCap to MaxNonPFBMessages aligns with the PR objective. The test case is improved by creating 500 more MsgSends than the maximum allowed, ensuring thorough testing of the capping behavior.


357-358: LGTM: Test case updated to use new constant

The test case has been correctly updated to use appconsts.MaxPFBMessages, ensuring consistency with the renamed constant. The capping behavior is properly tested by checking that the number of transactions is limited to the maximum allowed.


367-368: LGTM: Test cases updated consistently

All test cases have been correctly updated to use the new constants appconsts.MaxNonPFBMessages and appconsts.MaxPFBMessages. The changes are consistent across different scenarios, ensuring comprehensive testing of the capping behavior for both PFB and non-PFB messages.

Also applies to: 379-380, 394-396


Line range hint 300-396: Summary: Successful implementation of constant renaming and test improvements

The changes in this file successfully implement the renaming of constants from "tx" to "msg" as per the PR objectives. Additionally, the test cases have been improved to better validate the capping behavior for both PFB and non-PFB messages. The modifications ensure that the PrepareProposal function is thoroughly tested with the new message-based limits.

Key improvements:

  1. Consistent use of MaxPFBMessages and MaxNonPFBMessages constants.
  2. Test cases now create more messages than the maximum allowed, ensuring proper capping.
  3. Correct handling of scenarios with multiple messages per transaction.

These changes enhance the test coverage and align the code with the intended terminology shift from transactions to messages.

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.

I think it's okay if we do this as an rc-1

@rootulp
Copy link
Collaborator Author

rootulp commented Oct 17, 2024

Thoughts @evan-forbes ? It's technically breaking but it's a really small constant rename and there are no downstream users of the old constants (yet).

@evan-forbes evan-forbes merged commit f217064 into celestiaorg:main Oct 18, 2024
35 checks passed
@evan-forbes
Copy link
Member

I think its fine to include

@rootulp rootulp deleted the rp/rename-msg-limit-consts branch October 18, 2024 20:47
rach-id pushed a commit that referenced this pull request Nov 26, 2024
Motivation:
celestiaorg/CIPs#220 (comment)

IMO we should either include this in v3.0.0-rc0 or close it b/c not
worth it to break these constant names after that.

(cherry picked from commit f217064)
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.

4 participants