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: cap tx size flups #3967

Merged
merged 2 commits into from
Oct 11, 2024
Merged

refactor: cap tx size flups #3967

merged 2 commits into from
Oct 11, 2024

Conversation

ninabarbakadze
Copy link
Member

Overview

  • MaxTxBytes to MaxTxSize in order to better distinguish between the mempool and the application param
  • Removed the logic setting ctx.WithTxBytes for the transaction twice in one function due to two prs working on similar changes

@ninabarbakadze ninabarbakadze requested review from liamsi and a team as code owners October 11, 2024 17:51
@ninabarbakadze ninabarbakadze requested review from staheri14 and evan-forbes and removed request for a team October 11, 2024 17:51
@celestia-bot celestia-bot requested a review from a team October 11, 2024 17:51
Copy link

PR Preview Action v1.4.8
🚀 Deployed preview to https://celestiaorg.github.io/celestia-app/pr-preview/pr-3967/
on branch gh-pages at 2024-10-11 17:51 UTC

@ninabarbakadze ninabarbakadze enabled auto-merge (squash) October 11, 2024 17:55
Copy link
Contributor

coderabbitai bot commented Oct 11, 2024

📝 Walkthrough

Walkthrough

The changes in this pull request involve renaming the transaction size constant from MaxTxBytes to MaxTxSize across multiple files, including the main application logic, test cases, and documentation. This update affects how the maximum transaction size is referenced and validated in the application, ensuring consistency in terminology. The modifications include changes to method names, variable names, and test case assertions, while the overall logic and structure of the affected methods and tests remain unchanged.

Changes

File Change Summary
app/ante/max_tx_size.go Renamed variable maxTxBytes to maxTxSize in AnteHandle method to reflect new constant.
app/ante/max_tx_size_test.go Updated test cases in TestMaxTxSizeDecorator to use MaxTxSize instead of MaxTxBytes.
app/test/prepare_proposal_test.go Updated comments and variable names in TestPrepareProposalFiltering to reflect MaxTxSize.
app/test/process_proposal_test.go Updated comments and variable names in TestProcessProposal to reflect MaxTxSize.
app/validate_txs.go Removed setting of transaction bytes in context in filterStdTxs and filterBlobTxs functions.
pkg/appconsts/v3/app_consts.go Renamed constant MaxTxBytes to MaxTxSize.
pkg/appconsts/versioned_consts.go Renamed function MaxTxBytes to MaxTxSize.
pkg/appconsts/versioned_consts_test.go Updated test cases to use MaxTxSize instead of MaxTxBytes.
specs/src/ante_handler_v3.md Updated documentation to reflect the change from MaxTxBytes to MaxTxSize.

Possibly related PRs

  • feat!: limit the max tx size to 2 MiB #3909: This PR introduces a new MaxTxSizeDecorator that enforces transaction size limits, directly related to the changes made in the MaxTxSizeDecorator and AnteHandle method in the main PR.

Suggested labels

WS: Maintenance 🔧, optimization

Suggested reviewers

  • rootulp
  • evan-forbes
  • liamsi

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 (5)
app/ante/max_tx_size.go (1)

27-30: LGTM! Consider a minor improvement in the error message.

The changes are consistent with the PR objectives. The renaming from MaxTxBytes to MaxTxSize improves clarity by distinguishing between the mempool and application parameters.

Consider updating the error message to be more specific:

- return ctx, fmt.Errorf("tx size %d bytes is larger than the application's configured threshold of %d bytes. Please reduce the size by %d bytes", currentTxSize, maxTxSize, bytesOverLimit)
+ return ctx, fmt.Errorf("tx size %d bytes exceeds the maximum allowed size of %d bytes. Please reduce the size by %d bytes", currentTxSize, maxTxSize, bytesOverLimit)

This change makes the error message more direct and easier to understand.

pkg/appconsts/versioned_consts.go (1)

45-46: LGTM! Consider adding a comment for the unused parameter.

The renaming from MaxTxBytes to MaxTxSize is correct and aligns with the PR objectives. The function logic remains unchanged, which is appropriate.

Consider adding a comment explaining the purpose of the unused uint64 parameter, as it might not be immediately clear to other developers why it's there. For example:

// MaxTxSize returns the maximum transaction size.
// The uint64 parameter is unused but kept for version compatibility.
func MaxTxSize(_ uint64) int {
	return v3.MaxTxSize
}
pkg/appconsts/versioned_consts_test.go (1)

70-73: LGTM! Consider updating the version comment for consistency.

The changes correctly implement the renaming of "MaxTxBytes" to "MaxTxSize" as per the PR objectives. This improves clarity by distinguishing between mempool and application parameters.

For consistency with other test cases, consider updating the version comment in the test case name:

-			name:             "MaxTxSize v3",
+			name:             "MaxTxSize v3.0",

This aligns with the naming convention used in other test cases (e.g., "SubtreeRootThreshold v3").

app/test/prepare_proposal_test.go (1)

234-238: LGTM: New test case added for MaxTxSize limit

The new test case is a valuable addition, ensuring that both regular transactions and blob transactions are properly handled when they exceed the MaxTxSize limit. This is consistent with the changes made to the MaxTxSize parameter.

Consider adding an assertion to verify that the pruned transactions are indeed larger than the MaxTxSize limit. This would make the test more robust and self-documenting.

app/test/process_proposal_test.go (1)

Line range hint 352-362: LGTM: Test cases updated with new terminology

The test case names and descriptions have been correctly updated to use "max tx size" instead of "max tx bytes", maintaining consistency with the renamed constant. This change improves the clarity and alignment of the test cases with the updated codebase.

Consider adding a comment above these test cases to explain the significance of testing transactions larger than the configured max tx size. This could provide additional context for future developers working on this code.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between dcea313 and b88eb0b.

📒 Files selected for processing (9)
  • app/ante/max_tx_size.go (1 hunks)
  • app/ante/max_tx_size_test.go (1 hunks)
  • app/test/prepare_proposal_test.go (2 hunks)
  • app/test/process_proposal_test.go (4 hunks)
  • app/validate_txs.go (0 hunks)
  • pkg/appconsts/v3/app_consts.go (1 hunks)
  • pkg/appconsts/versioned_consts.go (1 hunks)
  • pkg/appconsts/versioned_consts_test.go (1 hunks)
  • specs/src/ante_handler_v3.md (1 hunks)
💤 Files with no reviewable changes (1)
  • app/validate_txs.go
✅ Files skipped from review due to trivial changes (1)
  • pkg/appconsts/v3/app_consts.go
🧰 Additional context used
🔇 Additional comments (12)
pkg/appconsts/versioned_consts.go (1)

45-46: Verify consistency of renaming across the codebase

The renaming from MaxTxBytes to MaxTxSize appears consistent within this file. However, it's important to ensure this change is applied consistently across the entire codebase.

Please run the following script to check for any remaining instances of MaxTxBytes that might need to be updated:

If any instances are found, please update them to maintain consistency with this change.

app/ante/max_tx_size_test.go (5)

27-28: LGTM: Consistent terminology update

The change from "max tx bytes" to "max tx size" in the test case name and the use of v3.MaxTxSize instead of v3.MaxTxBytes is consistent with the PR objectives. This update improves clarity and maintains the original test logic.


34-35: LGTM: Consistent terminology update

The change from "max tx bytes" to "max tx size" in the test case name and the use of v3.MaxTxSize instead of v3.MaxTxBytes is consistent with the PR objectives. This update maintains the original test logic while improving clarity.


41-42: LGTM: Consistent terminology update

The change from "max tx bytes" to "max tx size" in the test case name and the use of v3.MaxTxSize instead of v3.MaxTxBytes is consistent with the PR objectives. This update improves clarity while maintaining the original test logic.


49-49: LGTM: Consistent update and important backwards compatibility test

The use of v3.MaxTxSize instead of v3.MaxTxBytes is consistent with the PR objectives. This test case is particularly important as it verifies that the new size limit only applies to v3 and above, ensuring backwards compatibility with earlier versions.


Line range hint 1-79: Summary: Successful renaming and maintained test integrity

The changes in this file consistently update the terminology from "max tx bytes" to "max tx size" across all test cases. This renaming aligns with the PR objectives and improves clarity in the codebase. Importantly, the logic of the tests remains unchanged, ensuring that the functionality is still correctly tested. The update includes:

  1. Renaming test case descriptions
  2. Updating txSize values to use v3.MaxTxSize instead of v3.MaxTxBytes
  3. Maintaining the existing test logic for various scenarios (under threshold, over threshold, equal to threshold, and version compatibility)

These changes contribute to a more consistent and clear codebase while preserving the integrity of the tests.

specs/src/ante_handler_v3.md (1)

6-6: Approved: Terminology update from MaxTxBytes to MaxTxSize

The change from "MaxTxBytes" to "MaxTxSize" in the documentation is consistent with the PR objectives and improves clarity in distinguishing between mempool and application parameters.

To ensure consistency across the documentation, please run the following script:

This will help identify any instances where the old terminology might still be in use or where the new terminology might be inconsistently applied.

✅ Verification successful

Verified: Terminology update from MaxTxBytes to MaxTxSize

The terminology update from "MaxTxBytes" to "MaxTxSize" has been successfully verified across the documentation. No remaining instances of "MaxTxBytes" were found, ensuring consistency and clarity.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining instances of "MaxTxBytes" in the documentation
# and verify that "MaxTxSize" is used consistently.

echo "Checking for any remaining instances of 'MaxTxBytes':"
rg --type md "MaxTxBytes" specs/

echo "Verifying consistent usage of 'MaxTxSize':"
rg --type md "MaxTxSize" specs/

Length of output: 409

app/test/prepare_proposal_test.go (2)

163-163: LGTM: Comment updated correctly

The comment has been appropriately updated to reflect the change from "MaxTxBytes" to "MaxTxSize", which is consistent with the PR objectives.


166-166: LGTM: Comment updated correctly

The comment has been appropriately updated to reflect the change from "MaxTxBytes" to "MaxTxSize", which is consistent with the PR objectives.

app/test/process_proposal_test.go (3)

57-57: LGTM: Consistent renaming of MaxTxBytes to MaxTxSize

The change from MaxTxBytes to MaxTxSize is consistent with the PR objectives and improves clarity in distinguishing between mempool and application parameters.


60-61: LGTM: Updated comment to reflect new terminology

The comment has been appropriately updated to use "max tx size" instead of "max tx bytes", maintaining consistency with the renamed constant.


71-72: LGTM: Consistent terminology update in comment

The comment has been correctly updated to use "max tx size limit" instead of "max tx bytes limit", aligning with the renamed constant and maintaining consistency throughout the test file.

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.

3 participants