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!: version gas scheduler variables #3735

Merged
merged 23 commits into from
Sep 20, 2024

Conversation

ninabarbakadze
Copy link
Member

@ninabarbakadze ninabarbakadze commented Jul 25, 2024

Copy link

github-actions bot commented Jul 25, 2024

PR Preview Action v1.4.8
🚀 Deployed preview to https://celestiaorg.github.io/celestia-app/pr-preview/pr-3735/
on branch gh-pages at 2024-09-17 18:29 UTC

@ninabarbakadze ninabarbakadze force-pushed the nina/version-gas-scheduler-variables branch from 83ebe01 to 612c3de Compare August 1, 2024 14:13
@ninabarbakadze ninabarbakadze changed the title refactor!: version gas scheduler variables refactor: version gas scheduler variables Aug 1, 2024
@ninabarbakadze ninabarbakadze marked this pull request as ready for review August 2, 2024 05:02
@ninabarbakadze ninabarbakadze requested a review from a team as a code owner August 2, 2024 05:02
@ninabarbakadze ninabarbakadze requested review from cmwaters and rach-id and removed request for a team August 2, 2024 05:02
Copy link
Contributor

coderabbitai bot commented Aug 2, 2024

Walkthrough

Walkthrough

The updates introduce a versioned gas scheduling system for the Celestia application, enabling gas costs associated with transactions to remain constant across different application versions. This includes restructuring gas consumption calculations, creating new constants for transaction size costs, and enhancing testing frameworks. Overall, these modifications aim to improve transaction processing efficiency and predictability for clients submitting transactions.

Changes

Files Change Summary
app/ante/ante.go, app/ante/tx_size.go Modified instantiation references for NewConsumeGasForTxSizeDecorator; implemented a new mechanism for gas consumption based on transaction size.
app/ante/tx_size_test.go Introduced tests for ConsumeGasForTxSizeDecorator, validating gas consumption across various transaction scenarios.
pkg/appconsts/initial_consts.go Removed DefaultGasPerBlobByte; added DefaultNetworkMinGasPrice for transaction gas pricing in version 3.
x/blob/keeper/keeper.go Updated PayForBlobs logic for version-aware gas calculations.
x/blob/types/payforblob.go Changed dependency for DefaultEstimateGas function, now using appconsts for transaction size cost.
x/blob/README.md Updated documentation to clarify that GasPerBlobByte is now a versioned parameter.
app/test/std_sdk_test.go Adjusted import paths and assertions to reflect changes in gas pricing constants.
x/blob/keeper/keeper_test.go Enhanced tests to support versioning, ensuring gas calculations work correctly across different application versions.

Assessment against linked issues

Objective Addressed Explanation
Version gas scheduler variables (CIP Development)
Implement versioned gas cost changes (CIP Implementation)
Ensure gas costs remain constant across versions
Simplify gas estimation for client transactions Further refinements needed to fully achieve this.
Allow gas costs to change only with hard forks Implementation seems on track, but clarity on governance processes is needed.

Possibly related PRs

  • feat: add multi-account support #3433: This PR introduces multi-account support, which is relevant as it may interact with the changes in the NewConsumeGasForTxSizeDecorator function and how transactions are handled with different accounts.
  • docs: update specs for v2 #3661: This PR updates the specifications for version 2 of the Celestia app, which includes changes to the NewAnteHandler function to ensure gas prices meet the network's minimum requirements, directly relating to the modifications made in the main PR.

Suggested labels

WS: V2 ✌️

Suggested reviewers

  • No specific reviewers suggested.

Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f6f08c6 and 4832d1b.

Files selected for processing (3)
  • app/ante/tx_size.go (1 hunks)
  • app/ante/tx_size_test.go (1 hunks)
  • x/blob/types/payforblob.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • app/ante/tx_size_test.go
  • x/blob/types/payforblob.go
Additional context used
Gitleaks
app/ante/tx_size.go

90-91: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

Additional comments not posted (6)
app/ante/tx_size.go (6)

29-34: Inline the placeholder public key initialization.

The past review comment suggesting to inline this code instead of using an init function is valid. Consider moving this logic closer to where it is used in the AnteHandle method for better readability.


50-52: LGTM!

The struct definition is correct and the ante.AccountKeeper field is used appropriately in the AnteHandle method.


60-115: LGTM!

The AnteHandle method correctly consumes gas based on the transaction size and handles simulated transactions appropriately. The past review comment clarifies the usage of the simulate flag for gas estimation.

Tools
Gitleaks

90-91: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


118-138: LGTM!

The isIncompleteSignature function correctly checks if a SignatureData is fully filled in, handling both SingleSignatureData and MultiSignatureData types.


142-151: LGTM!

The consumeGasForTxSize function correctly consumes gas based on the transaction size, using the appropriate parameters depending on the app version. The versioning logic ensures backward compatibility.


90-91: Dismiss the static analysis hint.

The flagged lines do not contain an actual API key. The simSecp256k1Pubkey is a predefined placeholder public key used for simulating gas costs and does not pose a security risk.

Tools
Gitleaks

90-91: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


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 generate interesting stats about this repository and render them as a table.
    -- @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, codebase verification and nitpick comments (2)
x/blob/keeper/params_test.go (1)

12-12: Inconsistency Found:

The CreateKeeper function in keeper_test.go is called with different version values (v2.Version and v3.Version) instead of appconsts.LatestVersion. To ensure consistency across the codebase, consider updating these calls to use appconsts.LatestVersion.

  • File: x/blob/keeper/keeper_test.go
  • Lines:
    versions := []uint64{v2.Version, v3.Version}
    for _, version := range versions {
        t.Run("AppVersion_"+fmt.Sprint(version), func(t *testing.T) {
            k, _, ctx := CreateKeeper(t, version)
Analysis chain

LGTM! Ensure the function usage is consistent.

The test changes align with the PR objectives and ensure the keeper is initialized with the latest version. Verify that all calls to CreateKeeper include the new argument.


Let's verify the definition and usage of the version variable in keeper_test.go to ensure it aligns with appconsts.LatestVersion.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `CreateKeeper` include the new argument `appconsts.LatestVersion`.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'CreateKeeper'

Length of output: 3183


Script:

#!/bin/bash
# Search for the definition and usage of the `version` variable in `keeper_test.go`
rg --type go -A 5 -B 5 'version' x/blob/keeper/keeper_test.go

Length of output: 1913

pkg/appconsts/initial_consts.go (1)

Update references to DefaultGasPerBlobByte to use versioned parameters.

The references to DefaultGasPerBlobByte in the following files still use the old constant from appconsts. Please update them to use the versioned constant from pkg/appconsts/versioned_consts.go:

  • x/blob/types/payforblob.go
  • x/blob/types/params.go

This will ensure consistency with the move to versioned parameters.

Analysis chain

Line range hint 6-6:
Removal of DefaultGasPerBlobByte is consistent with versioning changes.

The removal of DefaultGasPerBlobByte aligns with the move to versioned parameters. Ensure that all references to this constant are updated accordingly.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all references to `DefaultGasPerBlobByte` are updated.

# Test: Search for occurrences of `DefaultGasPerBlobByte`. Expect: No occurrences found.
rg --type go 'DefaultGasPerBlobByte'

Length of output: 446


Script:

#!/bin/bash
# Extract relevant lines from the files where `DefaultGasPerBlobByte` is found.

# Extract lines from x/blob/types/payforblob.go
echo "File: x/blob/types/payforblob.go"
rg --type go --context 5 'DefaultGasPerBlobByte' x/blob/types/payforblob.go

# Extract lines from x/blob/types/params.go
echo "File: x/blob/types/params.go"
rg --type go --context 5 'DefaultGasPerBlobByte' x/blob/types/params.go

# Extract lines from pkg/appconsts/versioned_consts.go
echo "File: pkg/appconsts/versioned_consts.go"
rg --type go --context 5 'DefaultGasPerBlobByte' pkg/appconsts/versioned_consts.go

Length of output: 1935

app/ante/tx_size.go Outdated Show resolved Hide resolved
app/ante/tx_size_test.go Outdated Show resolved Hide resolved
)

func setup() (*app.App, sdk.Context, client.Context, sdk.AnteHandler, error) {
app, _, _ := testutil.NewTestAppWithGenesisSet(app.DefaultConsensusParams())
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: If we're using DefaultConsensusParams that will mean we're using app version 3 right? Has this been updated yet?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it hasn't been updated yet but I left it as DefaultConsensusParams because we're planning to do so.

x/blob/ante/ante.go Outdated Show resolved Hide resolved
x/blob/keeper/gas_test.go Outdated Show resolved Hide resolved
x/blob/keeper/keeper.go Outdated Show resolved Hide resolved
Comment on lines -16 to -23
// DefaultGasPerBlobByte is the default gas cost deducted per byte of blob
// included in a PayForBlobs txn
DefaultGasPerBlobByte = 8

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: this is breaking so we should prob add ! to the PR title.

[no change needed] If we want to prep for the v3 release, we could also write a changelog entry on how consumers of this package need to modify their code if they used DefaultGasPerBlobByte. We could write these entires in a new markdown file in a new directory like changelog/v3.md

Copy link
Collaborator

Choose a reason for hiding this comment

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

https://github.com/celestiaorg/celestia-app/blob/main/docs/release-notes/pending-release.md now exists so we should add a line that states this constant was removed and what library consumers should use instead.

pkg/appconsts/v3/app_consts.go Outdated Show resolved Hide resolved
pkg/appconsts/versioned_consts.go Show resolved Hide resolved
@ninabarbakadze ninabarbakadze changed the title refactor: version gas scheduler variables refactor!: version gas scheduler variables Aug 6, 2024
@celestia-bot celestia-bot requested review from a team and staheri14 and removed request for a team August 6, 2024 10:24
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, codebase verification and nitpick comments (1)
pkg/appconsts/v2/app_consts.go (1)

Extensive usage of NetworkMinGasPrice found in multiple files.

The NetworkMinGasPrice constant is used extensively across the codebase, including in the following files:

  • x/paramfilter/test/gov_params_test.go
  • x/minfee/params.go
  • x/minfee/grpc_query_test.go
  • x/minfee/query.pb.gw.go
  • x/minfee/query.pb.go
  • x/minfee/module.go
  • x/minfee/genesis.pb.go
  • x/minfee/grpc_query.go
  • x/minfee/genesis.go
  • pkg/user/tx_client.go
  • test/tokenfilter/setup.go
  • pkg/appconsts/initial_consts.go
  • app/test/upgrade_test.go
  • app/test/testnode_test.go
  • app/ante/min_fee_test.go
  • app/ante/fee_checker.go

Please review and refactor the dependent code to ensure that removing NetworkMinGasPrice does not break any functionality related to transaction fee validation and querying the network minimum gas price.

Analysis chain

Line range hint 1-7:
Verify the impact of removing NetworkMinGasPrice.

The constant NetworkMinGasPrice has been removed. Ensure that this removal does not break any functionality related to transaction fee validation.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of removing `NetworkMinGasPrice`.

# Test: Search for the usage of `NetworkMinGasPrice`. Expect: No occurrences of the removed constant.
rg --type go 'NetworkMinGasPrice'

Length of output: 13925

app/ante/tx_size.go Outdated Show resolved Hide resolved
app/ante/tx_size.go Outdated Show resolved Hide resolved
pkg/appconsts/initial_consts.go Show resolved Hide resolved
Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

Overall LGTM. We'll also need to add a params v3 page to the specs and mark the params: blob.GasPerBlobByte and auth.TxSizeCostPerByte as non governance modifiable on that page.

Ref: https://github.com/celestiaorg/celestia-app/blob/main/specs/src/specs/parameters_v2.md

app/ante/tx_size.go Show resolved Hide resolved
app/ante/tx_size_test.go Outdated Show resolved Hide resolved
app/ante/tx_size_test.go Outdated Show resolved Hide resolved
pkg/appconsts/initial_consts.go Outdated Show resolved Hide resolved
pkg/appconsts/initial_consts.go Outdated Show resolved Hide resolved
x/blob/README.md Outdated Show resolved Hide resolved
x/blob/keeper/keeper.go Outdated Show resolved Hide resolved
@celestia-bot celestia-bot requested a review from a team August 7, 2024 08:47
@ninabarbakadze ninabarbakadze marked this pull request as ready for review September 17, 2024 18:32
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 (1)
specs/src/parameters_v3.md (1)

1-8: Excellent introduction! Minor language improvement suggested.

The introduction provides a clear and concise overview of the document's purpose and scope. It effectively sets the right expectations by mentioning the governance changeability and hard fork requirements for certain parameters upfront.

To improve readability, consider adding a comma before 'or' in line 7:

-hardcoded in the application or they are blocked by the `x/paramfilter` module.
+hardcoded in the application, or they are blocked by the `x/paramfilter` module.
Tools
LanguageTool

[uncategorized] ~7-~7: Use a comma before ‘or’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...ng manually hardcoded in the application or they are blocked by the x/paramfilter...

(COMMA_COMPOUND_SENTENCE)

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 21ec979 and 0f3282a.

Files selected for processing (11)
  • app/ante/tx_size_test.go (1 hunks)
  • app/test/std_sdk_test.go (1 hunks)
  • app/test/upgrade_test.go (1 hunks)
  • pkg/appconsts/initial_consts.go (1 hunks)
  • pkg/appconsts/versioned_consts.go (1 hunks)
  • specs/src/parameters_v3.md (1 hunks)
  • x/blob/README.md (1 hunks)
  • x/blob/ante/ante_test.go (2 hunks)
  • x/blob/keeper/gas_test.go (3 hunks)
  • x/blob/keeper/keeper_test.go (4 hunks)
  • x/blob/types/payforblob.go (1 hunks)
Additional context used
LanguageTool
specs/src/parameters_v3.md

[uncategorized] ~7-~7: Use a comma before ‘or’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...ng manually hardcoded in the application or they are blocked by the x/paramfilter...

(COMMA_COMPOUND_SENTENCE)

Additional comments not posted (31)
pkg/appconsts/versioned_consts.go (6)

19-21: LGTM!

The function has been updated to return the constant value from the v3 package, which aligns with the PR objective of transitioning to versioned parameters.


24-26: LGTM!

The function has been updated to return the constant value from the v3 package, which aligns with the PR objective of transitioning to versioned parameters.


28-30: LGTM!

The new function TxSizeCostPerByte has been added to return the constant value from the v3 package, which aligns with the PR objective of transitioning to versioned parameters.


32-34: LGTM!

The new function GasPerBlobByte has been added to return the constant value from the v3 package, which aligns with the PR objective of transitioning to versioned parameters.


39-39: LGTM!

The new variable DefaultTxSizeCostPerByte has been added and is assigned the value returned by TxSizeCostPerByte(LatestVersion), which aligns with the PR objective of transitioning to versioned parameters.

The past review comment is no longer applicable as the LatestVersion is now set to v3.Version and the constants are defined for v3.


40-40: LGTM!

The new variable DefaultGasPerBlobByte has been added and is assigned the value returned by GasPerBlobByte(LatestVersion), which aligns with the PR objective of transitioning to versioned parameters.

The past review comment is no longer applicable as the LatestVersion is now set to v3.Version and the constants are defined for v3.

pkg/appconsts/initial_consts.go (2)

29-29: Breaking change: Removal of DefaultGasPerBlobByte.

The removal of DefaultGasPerBlobByte is a breaking change as it affects the public API of the package. Please consider the following suggestions:

  1. Add a ! to the PR title to indicate that this is a breaking change.
  2. Write a changelog entry in a new file changelog/v3.md on how consumers of this package need to modify their code if they used DefaultGasPerBlobByte.

30-33: LGTM!

The introduction of DefaultNetworkMinGasPrice is a useful addition. The constant is well-documented with comments explaining its purpose and version applicability.

x/blob/keeper/gas_test.go (8)

6-6: LGTM!

The import statement is necessary and correctly added.


27-27: LGTM!

The gas consumption calculation is correctly updated to use the versioned appconsts.GasPerBlobByte constant.


32-32: LGTM!

The gas consumption calculation is correctly updated to use the versioned appconsts.GasPerBlobByte constant.


37-37: LGTM!

The gas consumption calculation is correctly updated to use the versioned appconsts.GasPerBlobByte constant.


42-42: LGTM!

The gas consumption calculation is correctly updated to use the versioned appconsts.GasPerBlobByte constant.


47-47: LGTM!

The gas consumption calculation is correctly updated to use the versioned appconsts.GasPerBlobByte constant.


53-53: LGTM!

The CreateKeeper function call is correctly updated to include the appconsts.LatestVersion constant.


66-66: LGTM!

The CreateKeeper function call is correctly updated to include the appconsts.LatestVersion constant.

x/blob/ante/ante_test.go (3)

8-8: LGTM!

The import statement for appconsts is necessary for the updated test setup.


14-15: LGTM!

The import statements for Tendermint protocol types are necessary for the updated test setup.


94-99: Great improvement to the test setup!

The updated test context, which includes the latest application version in the header, ensures that the test environment more closely resembles the actual application environment. This change improves the fidelity of the test and may help catch issues related to versioning that might have been missed with the previous setup.

x/blob/keeper/keeper_test.go (2)

30-30: LGTM!

The CreateKeeper function is now called with appconsts.LatestVersion, ensuring that the tests run with the latest application version set in the context. This change aligns with the updated function signature.


Line range hint 75-90: Excellent work on improving the test setup!

The updated CreateKeeper function signature, which now accepts a version parameter, allows for dynamically setting the application version in the context header. This change enhances the flexibility of the test setup, enabling the keeper to operate with different application versions as needed.

Additionally, setting the keeper's parameters to a known, non-default value using SetParams(ctx, types.DefaultParams()) ensures a consistent starting point for the tests, improving their robustness.

These modifications demonstrate a strong commitment to writing maintainable and reliable test code.

Also applies to: 104-104

app/ante/tx_size_test.go (3)

28-44: LGTM!

The setup function correctly initializes a test environment, including a test app, context, and client context with the necessary configurations. The code is well-structured and follows best practices.


46-137: Excellent test coverage!

The TestConsumeGasForTxSize function provides comprehensive test coverage for the ConsumeGasForTxSizeDecorator. It covers different transaction versions and signature types, correctly calculates the expected gas consumption, and verifies the actual gas consumed matches the expected value. The test also validates that the simulation mode does not underestimate the gas consumption.

The test cases are well-structured, and the assertions are thorough, ensuring the decorator behaves as expected in various scenarios.


139-184: Well-implemented helper function!

The createTestTx function is a well-implemented helper function that creates a test transaction given the necessary inputs. It follows a two-round process to gather signer information and sign the transaction correctly.

The function properly sets the signatures on the transaction builder and returns the final transaction. The code is clean, readable, and follows best practices.

x/blob/types/payforblob.go (1)

167-167: Constant change aligns with versioned gas parameters objective.

The modification to source the default transaction size cost per byte from appconsts.DefaultTxSizeCostPerByte instead of auth.DefaultTxSizeCostPerByte aligns with the pull request's objective of transitioning gas scheduler variables to versioned parameters.

Verify that appconsts.DefaultTxSizeCostPerByte is defined with the intended value, as this constant will now be used for default gas estimation of pay-for-blob transactions. Changing this value would impact the gas costs.

Verification successful

Verification of DefaultTxSizeCostPerByte implementation and usage

The constant DefaultTxSizeCostPerByte is correctly implemented and used as intended:

  • It's defined in the appconsts package, aligning with the PR objective.
  • The value is set to 10 in v3/app_consts.go.
  • It's used consistently across the codebase, including in the ante handler for v3 and above.

While the TxSizeCostPerByte function allows for version-dependent values, it currently always returns the v3 value. This design allows for future versioning if needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify appconsts.DefaultTxSizeCostPerByte has the intended value.

# Test: Search for the constant definition. Expect: Defined with the correct value.
rg --type go $'DefaultTxSizeCostPerByte'

Length of output: 264


Script:

#!/bin/bash
# Description: Examine TxSizeCostPerByte function, LatestVersion, and usage of TxSizeCostPerByte

# Check TxSizeCostPerByte function implementation
echo "TxSizeCostPerByte function implementation:"
rg --type go -A 10 "func TxSizeCostPerByte"

# Check LatestVersion definition
echo -e "\nLatestVersion definition:"
rg --type go "LatestVersion.*="

# Check for other usage of TxSizeCostPerByte
echo -e "\nOther usage of TxSizeCostPerByte:"
rg --type go "TxSizeCostPerByte" | grep -v "func TxSizeCostPerByte" | grep -v "DefaultTxSizeCostPerByte"

Length of output: 3551

x/blob/README.md (1)

52-52: Looks good! The existing comment has been addressed.

The added clarification provides useful context about the GasPerBlobByte parameter, distinguishing its behavior in different versions. This information will help developers understand how the parameter can be modified based on the application version they are working with.

app/test/upgrade_test.go (1)

148-149: LGTM! The test coverage for the upgrade process is comprehensive.

The changes in this test function ensure that the upgrade process from v1 to v2 is thoroughly tested for multiple modules. Querying module params before and after the upgrade helps verify the expected changes.

Note: The initialization of NetworkMinGasPriceDec now uses appconsts.DefaultNetworkMinGasPrice instead of v2.NetworkMinGasPrice. This change suggests a modification in the source of the gas price configuration, which may impact how the application handles network gas pricing during upgrades.

app/test/std_sdk_test.go (1)

352-352: LGTM!

The update to the assertion aligns with the removal of the versioned package import. Using the default value from appconsts simplifies the test case and reduces the dependency on versioned constants.

specs/src/parameters_v3.md (3)

9-15: Great job with the global parameters table!

The table provides a clear and structured format for presenting the global parameters. The "Changeable via Governance" column is particularly helpful for users to quickly identify which parameters are immutable. The concise explanations in the "Summary" column effectively convey the purpose of each parameter.


16-69: Comprehensive and well-structured module parameters table!

The module parameters table is extensive and covers a wide range of functionalities. The consistent structure, including the "Changeable via Governance" column, makes it easy to navigate and understand each parameter. The default values and summaries provide valuable context for users and developers alike.


70-72: Informative note about the mint module parameters!

The note provides important information about the mint module parameters, clearly stating that they are not governance modifiable due to being hardcoded constants. Referencing the x/mint README.md file is a helpful addition for users who want to learn more about the reasoning behind this decision.

rootulp
rootulp previously approved these changes Sep 17, 2024
app/ante/tx_size.go Show resolved Hide resolved
Comment on lines +67 to +70
{v2.Version, "SingleSignatureData v2", signing.SignatureV2{PubKey: priv1.PubKey()}},
{v2.Version, "MultiSignatureData v2", signing.SignatureV2{PubKey: priv1.PubKey(), Data: multisig.NewMultisig(2)}},
{appconsts.LatestVersion, fmt.Sprintf("SingleSignatureData v%d", appconsts.LatestVersion), signing.SignatureV2{PubKey: priv1.PubKey()}},
{appconsts.LatestVersion, fmt.Sprintf("MultiSignatureData v%d", appconsts.LatestVersion), signing.SignatureV2{PubKey: priv1.PubKey(), Data: multisig.NewMultisig(2)}},
Copy link
Collaborator

Choose a reason for hiding this comment

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

These test cases don't contain an expected amount of gas to be consumed. IMO this test would be more likely to catch bugs if it verified that the amount of gas consumed by v2 differed from v3. Since the params for v2 and v3 are the same, one way to do that would be to change the value of the param for v2 and/or v3 and verify that the gas consumed was based on that.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

app/test/upgrade_test.go Outdated Show resolved Hide resolved
Comment on lines -16 to -23
// DefaultGasPerBlobByte is the default gas cost deducted per byte of blob
// included in a PayForBlobs txn
DefaultGasPerBlobByte = 8

Copy link
Collaborator

Choose a reason for hiding this comment

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

https://github.com/celestiaorg/celestia-app/blob/main/docs/release-notes/pending-release.md now exists so we should add a line that states this constant was removed and what library consumers should use instead.

Comment on lines -7 to -9
// NetworkMinGasPrice is used by x/minfee to prevent transactions from being
// included in a block if they specify a gas price lower than this.
NetworkMinGasPrice float64 = 0.000001 // utia
Copy link
Collaborator

Choose a reason for hiding this comment

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

pkg/appconsts/versioned_consts.go Show resolved Hide resolved
x/blob/keeper/keeper_test.go Outdated Show resolved Hide resolved
x/blob/types/payforblob.go Outdated Show resolved Hide resolved
@ninabarbakadze
Copy link
Member Author

DefaultGasPerBlobByte is still accessible through appconsts.DefaultGasPerBlobByte so I don't think library consumers would need to change anything

@rootulp
Copy link
Collaborator

rootulp commented Sep 18, 2024

DefaultGasPerBlobByte is still accessible through appconsts.DefaultGasPerBlobByte so I don't think library consumers would need to change anything

Oh good point, nvm disregard my comment about adding it to release notes. Does that mean the only breaking change in this PR is the removal of NetworkMinGasPrice? Should we add that to pending-release notes?

Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

Since this PR is marked breaking, I think we should at the very least add notes to pending-release.md about what was API breaking.

If we wanted to go above and beyond, we could add a line describing what this refactor does to pending-release.md so that we can use it in the release notes.

@ninabarbakadze
Copy link
Member Author

Since this PR is marked breaking, I think we should at the very least add notes to pending-release.md about what was API breaking.

If we wanted to go above and beyond, we could add a line describing what this refactor does to pending-release.md so that we can use it in the release notes.

I want to merge this but will do in a follow up

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.

Great work!

Comment on lines +48 to +54
// GasPerBlobByte is a versioned param from version 3 onwards.
var gasToConsume uint64
if ctx.BlockHeader().Version.App <= v2.Version {
gasToConsume = types.GasToConsume(msg.BlobSizes, k.GasPerBlobByte(ctx))
} else {
gasToConsume = types.GasToConsume(msg.BlobSizes, appconsts.GasPerBlobByte(ctx.BlockHeader().Version.App))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@ninabarbakadze ninabarbakadze merged commit 857d107 into main Sep 20, 2024
32 of 33 checks passed
@ninabarbakadze ninabarbakadze deleted the nina/version-gas-scheduler-variables branch September 20, 2024 14:06
@rootulp rootulp mentioned this pull request Sep 20, 2024
2 tasks
@coderabbitai coderabbitai bot mentioned this pull request Oct 9, 2024
rootulp added a commit that referenced this pull request Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants