celestiaorg / celestia-app

Celestia consensus node
https://celestiaorg.github.io/celestia-app/
Apache License 2.0
345 stars 292 forks source link

refactor: version constants for msg limits #3982

Closed rootulp closed 1 month ago

rootulp commented 1 month ago

Closes https://github.com/celestiaorg/celestia-app/issues/3973

coderabbitai[bot] commented 1 month ago
📝 Walkthrough ## Walkthrough The changes in this pull request focus on implementing version-aware transaction limits for both PFB (Pay For Blob) and non-PFB transactions. This involves removing static constants and replacing them with dynamic retrieval methods based on the application version. The updates affect various files, including test cases that validate the new version-dependent transaction limits, ensuring that the application can adapt to future changes in transaction constraints. ## Changes | File(s) | Change Summary | |-------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------| | `app/test/prepare_proposal_test.go` | Updated transaction cap constants to be version-dependent; modified test cases accordingly. | | `app/validate_txs.go` | Updated `filterStdTxs` and `filterBlobTxs` functions to retrieve transaction capacity based on version. | | `pkg/appconsts/global_consts.go` | Removed static constants `NonPFBTransactionCap` and `PFBTransactionCap`. | | `pkg/appconsts/v2/app_consts.go`, `pkg/appconsts/v3/app_consts.go` | Added version-specific constants for transaction caps (200 for NonPFB, 600 for PFB). | | `pkg/appconsts/versioned_consts.go`, `pkg/appconsts/versioned_consts_test.go` | Introduced functions for retrieving version-specific constants and updated tests for validation. | ## Assessment against linked issues | Objective | Addressed | Explanation | |-----------------------------------------------------|-----------|--------------------------------------------| | Version the parameters used to limit tx types (#3973) | ✅ | | ## Possibly related PRs - **#3909**: Updates to `prepare_proposal_test.go` related to transaction size limits, connecting to the handling of transaction limits in the main PR. - **#3942**: Introduces new test functions in `prepare_proposal_test.go` to validate transaction limits, aligning with the main PR's focus. - **#3967**: Refactors handling of transaction size limits, relevant to changes regarding transaction limits and version-aware constants. ## Suggested labels `optimization`, `WS: Maintenance 🔧`, `external` ## Suggested reviewers - liamsi - evan-forbes - cmwaters - 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 - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
🪧 Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): > ‼️ **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](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
cmwaters commented 1 month ago

These values are just in prepare proposal. They are not part of consensus and thus don't need to be versioned. We can change them at will from minor release to minor release

rootulp commented 1 month ago

These values are just in prepare proposal. They are not part of consensus and thus don't need to be versioned. We can change them at will from minor release to minor release

is a good point. I think we should close this PR and https://github.com/celestiaorg/celestia-app/issues/3973 as won't do.

evan-forbes commented 1 month ago

These values are just in prepare proposal. They are not part of consensus and thus don't need to be versioned. We can change them at will from minor release to minor release

this is what I thought as well, but I think someone pointed out that this would just save us the scenario where we can't increase them until some consensus breaking change. In that case, we don't have to have the consensus breaking change first, then cut a release that has the increased values.

therefore I'm good with this now

evan-forbes commented 1 month ago

we can also version them later if that is the case, so I'm also good with keeping this closed until then

rootulp commented 1 month ago

but I think someone pointed out that this would just save us the scenario where we can't increase them until some consensus breaking change.

Why can't we change them until some consensus breaking change? It's confusing because the constants are located in a file named global_consts.go but they don't actually need to remain constant for the lifetime of the network like the other constants in that file:

https://github.com/rootulp/celestia-app/blob/17b3a727e698c298658f329362ab77d5fb045684/pkg/appconsts/global_consts.go#L14

They can change whenever. In retrospect, it might have been clearer to define these constants where they're used in validate_txs.go.

rach-id commented 1 month ago

We could argue that versioning can be beneficial in scenarios like one version is running 2mb blocks, with these limitations softly enforced by validators not changing the code, and the next version has some outstanding optimisations that won't be activated until a breaking upgrade is done that allows for higher limitations and 8mb blocks for example. In this case we would want to enforce a soft control on the blocks being produced until the upgrade height, and versioning would be beneficial.

But I guess that it's fine to leave it for future us to worry about it and implement it if needed. We can always version anything in the code 😄

In retrospect, it might have been clearer to define these constants where they're used in validate_txs.go

I think the confusion arises from these constants being recommended but not mandatory, being only softly enforced. The reason why I think they belong in app consts is to avoid having limitations scattered around the repo that devs will need to source dive to find them (similar to what sometimes happens in LibP2P where some consts are set in weird places, and you have no idea why the code is behaving in a certain way until you deep dive). Having the consts in the same place helps with this.

We might think of adding a new file that contains non consensus breaking consts and put them all in there, to make the distinction between consensus breaking vs non-breaking. But I guess we don't need to worry much about this as this code will change in the near future with blocks increasing in size, and we might not even need to enforce such limitations.

TL;DR: I see no harm in merging this PR or leaving it for our future selves to worry about 😄

rootulp commented 1 month ago

We might think of adding a new file that contains non consensus breaking consts and put them all in there, to make the distinction between consensus breaking vs non-breaking.

I agree, this could help