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

feat: clamp to consensus max gas #51

Closed
wants to merge 16 commits into from
Closed

Conversation

aljo242
Copy link
Collaborator

@aljo242 aljo242 commented Dec 28, 2023

Closes BLO-590

Adds the consensusparams keeper to the fee posthandler. Whenever consensus.MaxGas < feeMarket.MaxGas the consensus value is used. This effectively clamps our max gas to this value whenever we exceed it, but still allows the values to differ if consensus.MaxGas > feeMarket.MaxGas.

Also removes the crisis module from the app. This module isnt needed for testing and contains vulnerabilities

Summary by CodeRabbit

  • New Features

    • Implemented new consensus parameter handling in fee market logic.
    • Enhanced fee deduction decorator to utilize updated consensus parameters.
  • Bug Fixes

    • Fixed fee market state update logic to correctly use block utilization parameters.
  • Refactor

    • Removed crisis module dependencies across tests and application configurations.
    • Introduced new ConsensusKeeper for managing consensus parameters.
  • Tests

    • Updated test suites and mocks to align with new consensus parameter usage.
    • Added error handling and boundary case simulations for consensus parameters.
  • Documentation

    • Updated comments to clarify units of measurement for block utilization.
  • Chores

    • Cleaned up imports and unused references pertaining to the crisis module.

Copy link

coderabbitai bot commented Dec 28, 2023

Walkthrough

The changes involve a significant reconfiguration of the application's module structure and functionality to align with EIP-1559. This includes removing the crisis module, introducing a ConsensusParamsKeeper, and adjusting various components to utilize the new max block gas parameters. The modifications aim to enhance gas efficiency and fee estimation in accordance with EIP-1559 standards.

Changes

File Pattern Change Summary
tests/app/* Removal of crisis module and associated components, addition of ConsensusParamsKeeper, and adjustments to initialization and handler options.
tests/app/config.go Removal of references to crisistypes and crisismodulev1 modules, and adjustments to module initialization.
testutils/keeper/keeper.go Addition of ConsensusKeeper and ConsensusParams declarations, and modifications to initialize and set consensus parameters.
x/feemarket/* Various adjustments to accommodate new max block gas parameters, addition of ConsensusKeeper interfaces and mocks, and updates to tests.

Assessment against linked issues

Objective Addressed Explanation
Update consensus parameters to incorporate the max block gas from EIP-1559 (BLO-590)
Ensure that the reset aligns with the specifications outlined in EIP-1559 (BLO-590)
Test the updated consensus parameters to verify their compatibility with the EIP-1559 standard (BLO-590) It is unclear if tests specifically validate compatibility with EIP-1559 without seeing the test outcomes.
Document the changes made to the consensus parameters (BLO-590) Documentation and instructions are not part of the code changes.
Communicate the impact of the reset on existing functionality (BLO-590) Communication of impact is not part of the code changes.

Related issues

  • BLO-590: This issue is directly addressed by the PR, as it involves updating consensus parameters in line with EIP-1559 standards.

Poem

In the world of code where gas is king,
A rabbit hopped in, made the blocks sing.
With EIP's wisdom and a keen mind,
It tweaked the gas, left old limits behind. 🐇💨📈

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 with CodeRabbit Bot (@coderabbitai)

  • You can directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • You can tag CodeRabbit on specific lines of code or entire files in the PR by tagging @coderabbitai in a comment. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • You can tag @coderabbitai in a PR comment and ask questions about the PR and the codebase. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid.
    • @coderabbitai read the files in the src/scheduler package and generate README in the markdown format.

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.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@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.

Review Status

Actionable comments generated: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 30c4d13 and 13bc7bc.
Files ignored due to filter (1)
  • x/feemarket/types/params.pb.go
Files selected for processing (21)
  • proto/feemarket/feemarket/v1/params.proto (1 hunks)
  • tests/app/app.go (6 hunks)
  • tests/app/config.go (6 hunks)
  • tests/app/export.go (1 hunks)
  • tests/app/feemarketd/cmd/root.go (3 hunks)
  • tests/app/post.go (2 hunks)
  • testutils/keeper/keeper.go (6 hunks)
  • x/feemarket/ante/suite/suite.go (5 hunks)
  • x/feemarket/fuzz/aimd_eip1559_test.go (2 hunks)
  • x/feemarket/fuzz/eip1559_test.go (2 hunks)
  • x/feemarket/keeper/feemarket_test.go (8 hunks)
  • x/feemarket/keeper/msg_server_test.go (1 hunks)
  • x/feemarket/post/expected_keeper.go (2 hunks)
  • x/feemarket/post/fee.go (2 hunks)
  • x/feemarket/post/fee_test.go (4 hunks)
  • x/feemarket/post/feegrant_test.go (1 hunks)
  • x/feemarket/post/mocks/mock_consensus_keeper.go (1 hunks)
  • x/feemarket/post/mocks/mock_feemarket_keeper.go (2 hunks)
  • x/feemarket/types/state.go (1 hunks)
  • x/feemarket/types/state_fuzz_test.go (2 hunks)
  • x/feemarket/types/state_test.go (6 hunks)
Files skipped from review due to trivial changes (1)
  • tests/app/export.go
Additional comments: 46
x/feemarket/post/mocks/mock_consensus_keeper.go (1)
  • 13-57: The mock implementation for ConsensusKeeper and its constructor NewConsensusKeeper are correctly set up to simulate interface behavior and assert expectations post-test.
tests/app/post.go (1)
  • 31-47: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [11-44]

The addition of the ConsensusParamsKeeper field to the PostHandlerOptions struct and the corresponding validation and usage in the NewPostHandler function are correctly implemented.

x/feemarket/keeper/msg_server_test.go (1)
  • 50-51: The state.Update function is called with params.MaxBlockUtilization for both parameters. Verify if this is intended, as it may be a logic error if the function expects different values for current and maximum block utilization.
x/feemarket/types/state_fuzz_test.go (2)
  • 36-36: The state.Update function is called with params.MaxBlockUtilization for both parameters in the FuzzDefaultFeeMarket function. Verify if this is intended, as it may be a logic error if the function expects different values for current and maximum block utilization.

  • 85-85: The state.Update function is called with params.MaxBlockUtilization for both parameters in the FuzzAIMDFeeMarket function. Verify if this is intended, as it may be a logic error if the function expects different values for current and maximum block utilization.

x/feemarket/post/expected_keeper.go (1)
  • 47-56: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [4-56]

The new import tmproto and the ConsensusKeeper interface with its Get method are correctly defined and follow Go's interface naming and method signature conventions.

proto/feemarket/feemarket/v1/params.proto (1)
  • 69-73: The updated comments for TargetBlockUtilization and MaxBlockUtilization in the params.proto file provide clarity by specifying that these values are measured in units of gas, aligning with EIP-1559 specifications.
x/feemarket/fuzz/eip1559_test.go (2)
  • 27-27: The state.Update function is called with params.MaxBlockUtilization for both parameters in the TestLearningRate function. Verify if this is intended, as it may be a logic error if the function expects different values for current and maximum block utilization.

  • 53-53: The state.Update function is called with params.MaxBlockUtilization for both parameters in the TestBaseFee function. Verify if this is intended, as it may be a logic error if the function expects different values for current and maximum block utilization.

x/feemarket/post/mocks/mock_feemarket_keeper.go (2)
  • 44-66: The mock functions GetParams and SetParams for the FeeMarketKeeper are correctly set up to simulate the behavior of getting and setting fee market parameters.

  • 92-103: The mock function SetParams for the FeeMarketKeeper is correctly set up to simulate the behavior of setting fee market parameters.

testutils/keeper/keeper.go (4)
  • 7-8: The addition of consensustypes import is necessary for the new ConsensusKeeper field in the TestKeepers struct.

  • 15-15: The addition of consensuskeeper import is necessary for the new ConsensusKeeper field in the TestKeepers struct.

  • 28-28: The new ConsensusKeeper field has been added to the TestKeepers struct. Ensure that all references to TestKeepers throughout the codebase are updated to handle this new field.

  • 60-60: The Consensus function is introduced to initialize the consensus parameters module. Ensure that this function is used wherever consensus parameters need to be initialized in tests.

x/feemarket/fuzz/aimd_eip1559_test.go (2)
  • 38-38: The state.Update function call has been modified to pass params.MaxBlockUtilization instead of params. Ensure that the Update function's signature has been updated accordingly and that this change is consistent across all test cases.
Verification successful

The verification of the state.Update function call in aimd_eip1559_test.go has been successful:

  • The state.Update function signature has been confirmed to accept two uint64 arguments, which is consistent with the change to pass params.MaxBlockUtilization.
  • The usage of state.Update across various test files has been checked, and it consistently uses params.MaxBlockUtilization as the second argument.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for the state.Update function signature to confirm the change.
rg --type go "func \(.*State\) Update"
# Search for all occurrences of state.Update to ensure consistency.
rg --type go "state.Update"

Length of output: 7169

* 83-83: The `state.Update` function call has been modified to pass `params.MaxBlockUtilization` instead of `params`. Ensure that the `Update` function's signature has been updated accordingly and that this change is consistent across all test cases.
Verification successful

The verification process has confirmed that:

  • The state.Update function's signature has been updated to accept two uint64 arguments.
  • The change to pass params.MaxBlockUtilization instead of params is consistent across all test cases where state.Update is called.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for the state.Update function signature to confirm the change.
rg --type go "func \(.*State\) Update"
# Search for all occurrences of state.Update to ensure consistency.
rg --type go "state.Update"

Length of output: 7169

x/feemarket/types/state.go (1)
  • 28-30: The Update method now takes an additional maxGas parameter. Ensure that all calls to this method are updated to pass the correct maxGas value and that the method's logic correctly handles the new parameter.
Verification successful

The verification of the state.Update method calls across the codebase shows that the second parameter being passed is consistent with the intended maxGas value as per the PR objectives and the AI-generated summary. The calls in both test and non-test files are using params.MaxBlockUtilization or other appropriate uint64 values as the maxGas parameter.

  • The Update method's calls have been correctly updated to pass the maxGas value, and the method's logic is consistent with the new parameters.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for all calls to the State.Update method to ensure they pass the correct maxGas value.
rg --type go "state.Update"

Length of output: 6862

x/feemarket/post/fee.go (3)
  • 23-27: The FeeMarketDeductDecorator struct has been updated to include a consensusParamsKeeper field. Ensure that all instances of this struct are updated to provide the new field.
Verification successful

The shell script output shows that the FeeMarketDeductDecorator struct is being correctly instantiated with the new consensusParamsKeeper field in the files feegrant_test.go, suite.go, and post.go. The constructor function NewFeeMarketDeductDecorator is also updated to accept the ConsensusKeeper as a parameter, which is consistent with the changes described.

Based on the provided output, it appears that the integration of the consensusParamsKeeper field into the FeeMarketDeductDecorator struct and its related functions has been handled correctly in the instances found.

  • The FeeMarketDeductDecorator struct has been correctly updated to include the consensusParamsKeeper field, and all instances of this struct are updated to provide the new field.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for all instances of FeeMarketDeductDecorator to ensure they provide the new consensusParamsKeeper field.
rg --type go "FeeMarketDeductDecorator"

Length of output: 1095

* 30-36: The `NewFeeMarketDeductDecorator` function has been updated to accept a `ConsensusKeeper` as a parameter. Ensure that all calls to this function are updated to pass the new parameter.
Verification successful

The verification process has confirmed that all calls to NewFeeMarketDeductDecorator across the codebase have been updated to include the new ConsensusKeeper parameter as required.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for all calls to NewFeeMarketDeductDecorator to ensure they pass the new ConsensusKeeper parameter.
rg --type go "NewFeeMarketDeductDecorator"

Length of output: 541



Script:

#!/bin/bash
# Check the parameters passed to NewFeeMarketDeductDecorator in the specified files
cat x/feemarket/ante/suite/suite.go
cat tests/app/post.go

Length of output: 9360

* 104-119: The `PostHandle` method now retrieves `consensusParams` and uses it to update `maxGas` before updating the state. Ensure that the retrieval and usage of `consensusParams` are correct and that error handling is adequate.
x/feemarket/post/feegrant_test.go (1)
  • 132-132: The addition of s.ConsensusKeeper as an argument to FeeMarketDeductDecorator aligns with the PR's objective to integrate max block gas limits from EIP-1559 into the consensus parameters. Ensure that the ConsensusKeeper is properly initialized and used within the FeeMarketDeductDecorator.
x/feemarket/ante/suite/suite.go (3)
  • 38-44: The addition of ConsensusKeeper and MockConsensusParamsKeeper to the TestSuite struct is necessary for the integration of consensus parameters into the test suite. Ensure that these keepers are properly initialized and used in the test setup.

  • 81-84: The initialization of ConsensusKeeper and MockConsensusParamsKeeper in the SetupTestSuite function is consistent with the PR's objectives. Verify that the initialization logic is correct and that the keepers are being used as intended in the tests.

  • 97-102: The conditional assignment of consensusKeeper in the SetupHandlers function based on the mock parameter is a good practice for test modularity. Confirm that the mock behavior is consistent with the expected test scenarios.

tests/app/feemarketd/cmd/root.go (2)
  • 33-33: The introduction of flagCrisisDummy as a placeholder for the crisis module flag is a security measure to avoid importing the crisis module. Confirm that this change does not affect the functionality where the crisis module's flags are used.

  • 181-182: The modification of the addModuleInitFlags function to include the flagCrisisDummy is consistent with the removal of the crisis module. Ensure that this dummy flag is handled appropriately in the application's flag parsing logic.

tests/app/config.go (2)
  • 9-14: The removal of crisis-related modules and the addition of consensus-related modules in the imports section should be verified to ensure that it aligns with the intended changes and does not introduce any unintended side effects.

  • 57-62: The change in the genesisModuleOrder array reflects the removal of the crisis module and the addition of the consensus module. Ensure that this new order maintains the correct initialization sequence and does not disrupt any dependencies between modules.

x/feemarket/post/fee_test.go (3)
  • 149-166: The new test case "error getting consensus params - should fail" has been added to simulate an error when retrieving consensus parameters. Verify that the error handling is implemented correctly and that the test case accurately reflects a realistic error scenario.

  • 169-187: The test case "using consensus params for invalid gas limit (exceeds max gas)" is designed to test the behavior when the gas limit exceeds the max gas set in consensus parameters. Ensure that the test case is set up correctly and that the expected error is the appropriate one for this scenario.

  • 190-208: The test case "using consensus params for max gas override - valid)" tests a scenario where the gas limit is within the max gas set in consensus parameters. Confirm that the test case is correctly testing a valid transaction and that the expected outcome is success without errors.

tests/app/app.go (5)
  • 34-39: The removal of the crisis module should be verified to ensure that no references to it remain elsewhere in the codebase that could lead to compilation errors or runtime panics.
Verification successful
  • The references to the crisis module found in tests/app/feemarketd/cmd/root.go are for a dummy flag and do not indicate active use of the crisis module. This suggests that the removal of the crisis module from app.go is consistent and should not cause issues related to these references.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for any remaining references to the crisis module.
rg --type go 'crisis'

Length of output: 306

* 94-99: The removal of the crisis module from `ModuleBasics` should be verified to ensure that it does not affect the application's functionality, especially in terms of invariants checking which is typically a role of the crisis module.
  • 129-134: The removal of the CrisisKeeper field from the TestApp struct should be verified to ensure that there are no orphaned references or logic that depend on the crisis keeper.
Verification successful

The search for CrisisKeeper in the Go files of the codebase did not yield any results, indicating that there are no orphaned references or logic remaining after its removal from the TestApp struct.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for any orphaned references or logic that depend on the CrisisKeeper.
rg --type go 'CrisisKeeper'

Length of output: 27

* 206-211: The changes in the dependency injection setup should be verified to ensure that the removal of the crisis module's keeper is handled correctly and does not cause any issues with the application's initialization.
Verification successful

To verify the changes in the dependency injection setup, a broader search for the initialization function of the TestApp is needed. Let's try searching for just TestApp within Go files to locate the relevant initialization code.


To ensure that the removal of the crisis module's keeper is correctly reflected in the initialization of TestApp, the contents of the tests/app/app.go file need to be examined, particularly the constructor or initialization function.


The review of the tests/app/app.go file confirms that the CrisisKeeper has been removed from the TestApp struct and its constructor function New. Additionally, the ConsensusParamsKeeper is present, which is in line with the PR's objectives to integrate the max block gas limits from EIP-1559 into the consensus parameters. No issues related to the removal of the crisis module's keeper are evident from the provided context.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for any issues with the application's initialization due to the removal of the crisis module's keeper.
rg --type go 'NewTestApp'

Length of output: 25



Script:

#!/bin/bash
# Broaden the search to find the initialization function for TestApp
rg --type go 'TestApp'

Length of output: 1441



Script:

#!/bin/bash
# View the contents of the tests/app/app.go file to examine the initialization function
cat tests/app/app.go

Length of output: 13394

* 270-274: The addition of `ConsensusParamsKeeper` to `PostHandlerOptions` should be verified to ensure that it is correctly implemented and that the rest of the application is updated to use this new field where necessary.
x/feemarket/keeper/feemarket_test.go (2)
  • 77-77: The change in the state.Update function call to use params.MaxBlockUtilization instead of params should be verified to ensure that the new argument is correct and that the logic of the tests still holds.
Verification successful

The verification of the state.Update function call in x/feemarket/keeper/feemarket_test.go confirms that the change to pass params.MaxBlockUtilization as the second argument is correct, as the Update function is defined to accept two uint64 arguments.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for the definition of the Update function to ensure the new argument is correct.
rg --type go 'func \(.*State\) Update'

Length of output: 306

* 101-101: Ensure that the changes to the `state.Update` function calls across various test cases are correct and reflect the intended logic for updating the fee market based on block utilization parameters.

Also applies to: 124-124, 151-151, 177-177, 201-201, 228-228, 255-255

x/feemarket/types/state_test.go (7)
  • 20-22: The change to pass params.MaxBlockUtilization instead of params to state.Update is consistent with the PR's objective to align with EIP-1559's max block gas limits. Ensure that the Update function's signature has been modified to accept a single uint64 value for max block utilization, and that this change is reflected across all test cases.

  • 29-35: The test case "can add several txs to window" has been updated to use params.MaxBlockUtilization. This change should be verified to ensure that the Update function is being called with the correct parameters and that the test logic reflects the intended behavior.

  • 42-43: The test case "errors when it exceeds max block utilization" correctly tests the boundary condition where the block utilization exceeds the maximum allowed. This is a good test for ensuring that the Update function enforces the max block gas limit as per EIP-1559.

  • 50-62: The test case "can update with several blocks in default eip-1559" has been updated to use params.MaxBlockUtilization. It's important to verify that the state's window is updated correctly and that the test reflects the expected behavior after the update.

  • 69-89: The test case "can update with several blocks in default aimd eip-1559" has been updated to use params.MaxBlockUtilization. This change should be verified to ensure that the Update function is being called with the correct parameters and that the test logic reflects the intended behavior for the AIMD (Additive Increase/Multiplicative Decrease) model.

  • 97-118: The test case "correctly wraps around with aimd eip-1559" has been updated to use params.MaxBlockUtilization. This change should be verified to ensure that the state's window wraps around correctly and that the test reflects the expected behavior after the update.

  • 406-408: The test case "recovers from overflow with large max block utilization ratio" has been updated to use params.MaxBlockUtilization. This is a critical test to ensure that the system can handle extreme values without causing an overflow, which is important for maintaining system stability.

testutils/keeper/keeper.go Outdated Show resolved Hide resolved
testutils/keeper/keeper.go Show resolved Hide resolved
testutils/keeper/keeper.go Show resolved Hide resolved
tests/app/app.go Show resolved Hide resolved
tests/app/post.go Outdated Show resolved Hide resolved
x/feemarket/post/fee.go Outdated Show resolved Hide resolved
@aljo242 aljo242 requested a review from nivasan1 January 2, 2024 16:42
Copy link

@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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 13bc7bc and a3707da.
Files selected for processing (5)
  • tests/app/app.go (5 hunks)
  • x/feemarket/ante/suite/suite.go (4 hunks)
  • x/feemarket/post/fee.go (1 hunks)
  • x/feemarket/post/fee_test.go (2 hunks)
  • x/feemarket/types/state.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • tests/app/app.go
Additional comments: 7
x/feemarket/types/state.go (1)
  • 28-34: The Update method correctly checks if the block utilization exceeds the maximum allowed gas and returns an error if this condition is met. This change aligns with the PR objectives to integrate max block gas limits from EIP-1559 into the consensus parameters.
x/feemarket/post/fee.go (1)
  • 102-117: The logic to adjust maxGas based on the lesser of consensusMaxGas and params.MaxBlockUtilization is sound and correctly implemented. The error handling is also improved by wrapping the error from state.Update with sdkerrors.ErrTxTooLarge, providing more context in case of failure.
x/feemarket/ante/suite/suite.go (2)
  • 76-84: The SetupTestSuite function has been correctly updated to set the consensus parameters in the context, which is necessary for testing with the new consensus parameters introduced by the PR.

  • 210-218: The RunTestCase function now resets the consensus parameters after each test case, ensuring that each test starts with a clean state. This is a good practice for test isolation and reliability.

x/feemarket/post/fee_test.go (3)
  • 7-9: The addition of new imports for tmproto and testkeeper is noted. Ensure that these packages are used in the test cases and that they are necessary for the changes related to EIP-1559.

  • 150-176: The test case "using consensus params for invalid gas limit (exceeds max gas)" correctly sets up a scenario where the gas limit exceeds the max gas set in the consensus parameters. This should indeed result in an ErrTxTooLarge error. Ensure that the MaxGas value used in the test reflects realistic scenarios based on EIP-1559 specifications.

Verification successful

The output from the executed script provides several instances where MaxGas is referenced in the codebase. Here's a breakdown of the findings:

  • In x/feemarket/post/fee.go, MaxGas is retrieved from the consensus parameters and compared with params.MaxBlockUtilization. If MaxGas from the consensus parameters is less than params.MaxBlockUtilization and is not negative, it is used as the maxGas for the block.
  • The test case in x/feemarket/post/fee_test.go sets MaxGas to 10, which is intended to test the scenario where the transaction gas limit exceeds the maximum gas allowed by the block parameters.
  • Another test case in x/feemarket/post/fee_test.go sets MaxGas to gasLimit - 1 to test the max gas override functionality.
  • In testutils/keeper/keeper.go, a default MaxGas value of 1,000,000 is set in the ConsensusParams.
  • In x/feemarket/ante/suite/suite.go, MaxGas is set to 1,000,000,000 in the consensus parameters for the test suite context.

The MaxGas value of 10 in the test case is likely chosen to be deliberately low to ensure that the test triggers the ErrTxTooLarge error when the transaction gas limit exceeds this value. This is a valid test case to confirm that the system correctly handles transactions that exceed the block gas limit.

Given the context, the test case seems to be correctly designed to test the behavior when the gas limit exceeds the max gas set in the consensus parameters, aligning with the objectives of the PR to integrate max block gas limits from EIP-1559 into the consensus parameters and to test their impact on block processing and transaction inclusion.

Based on the information provided, the review comment appears to be correct, and the test case is appropriately testing the intended behavior.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the MaxGas value aligns with realistic EIP-1559 scenarios.
rg --type go 'MaxGas' --context 5

Length of output: 4135

* 178-195: The test case "using consensus params for max gas override - valid" appears to be testing the scenario where the gas limit is just below the max gas, which should pass. This is a valid test case to ensure that transactions close to the gas limit are handled correctly. However, it's important to verify that the `gasLimit - 1` is a deliberate choice and aligns with the intended testing strategy.
Verification successful

The search for the expression gasLimit - 1 in Go files only returned the instance within the test case "using consensus params for max gas override - valid)" in the x/feemarket/post/fee_test.go file. This indicates that the choice of gasLimit - 1 is specific to this test case and is not a pattern used elsewhere in the codebase.

Given this context, it seems that the gasLimit - 1 is indeed a deliberate choice for this particular test case, likely intended to test the behavior of the system when the gas used is just below the maximum gas limit allowed. This would be a valid scenario to test to ensure that transactions are processed correctly when they are close to the gas limit.

  • The use of gasLimit - 1 is specific to this test case.
  • It is a deliberate choice to test the system's behavior with a gas amount just below the max gas limit.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the gasLimit - 1 is a deliberate choice for testing.
rg --type go 'gasLimit - 1' --context 5

Length of output: 933

Copy link
Contributor

@Eric-Warehime Eric-Warehime left a comment

Choose a reason for hiding this comment

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

LGTM

@aljo242
Copy link
Collaborator Author

aljo242 commented May 15, 2024

Closing as this is outdated and breaking

@aljo242 aljo242 closed this May 15, 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
Development

Successfully merging this pull request may close these issues.

3 participants