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

Revert "Gaslimit + gascap flags" #1717

Closed
wants to merge 1 commit into from

Conversation

otherview
Copy link
Contributor

Reverts #1682

Copy link

coderabbitai bot commented Dec 22, 2023

Walkthrough

The overall change reflects a comprehensive update to the gas limit configuration and handling within a blockchain-related codebase. It involves increasing gas limits, consolidating multiple gas-related settings into a single GasLimit field or flag, and revising the related logic across various modules. The update affects enclave configuration, transaction execution, batch processing, and deployment scripts, indicating a shift towards accommodating more resource-intensive operations.

Changes

File(s) Change Summary
.github/workflows/build-pr.yml Removed specific directories from the retention list.
contracts/deployment_scripts/.../001_whitelist_tokens.ts Increased gasLimit parameter within a function.
go/config/enclave_cli_flags.go, go/config/enclave_config.go, go/config/enclave_config_test.go, integration/common/constants.go Replaced multiple gas-related flags with a single L2GasLimitFlag and updated default values.
go/enclave/components/batch_executor.go, go/enclave/components/interfaces.go, go/enclave/components/rollup_compression.go, go/enclave/crosschain/message_bus_manager.go, go/enclave/nodetype/sequencer.go, go/enclave/nodetype/validator.go, integration/simulation/simulation.go, tools/hardhatdeployer/contract_deployer.go Adjusted gas limit handling in functions, struct fields, and method signatures.
go/enclave/enclave.go, go/enclave/evm/evm_facade.go Added fields to structs and modified gas estimation methods.
go/enclave/l2chain/l2_chain.go Removed gasEstimationCap field and updated struct and function logic.
integration/simulation/devnetwork/node.go, integration/simulation/network/network_utils.go Updated import statements and field initializations with new gas limit values.
integration/datagenerator/common.go Changed GasPrice field assignment in transaction data creation.

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 X ?


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>.
  • You can tag CodeRabbit on specific lines of code or entire files in the PR by tagging @coderabbitai in a comment. Examples:
  • You can tag @coderabbitai in a PR comment and ask questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions. Examples:
    • @coderabbitai render interesting statistics about this repository as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai generate unit tests for the src/utils.ts file.

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: 5

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c990832 and 510dbd0.
Files selected for processing (20)
  • .github/workflows/build-pr.yml (1 hunks)
  • contracts/deployment_scripts/testnet/layer2/001_whitelist_tokens.ts (1 hunks)
  • go/config/enclave_cli_flags.go (2 hunks)
  • go/config/enclave_config.go (2 hunks)
  • go/config/enclave_config_test.go (3 hunks)
  • go/enclave/components/batch_executor.go (6 hunks)
  • go/enclave/components/interfaces.go (1 hunks)
  • go/enclave/components/rollup_compression.go (1 hunks)
  • go/enclave/crosschain/message_bus_manager.go (2 hunks)
  • go/enclave/enclave.go (7 hunks)
  • go/enclave/evm/evm_facade.go (7 hunks)
  • go/enclave/l2chain/l2_chain.go (3 hunks)
  • go/enclave/nodetype/sequencer.go (2 hunks)
  • go/enclave/nodetype/validator.go (1 hunks)
  • integration/common/constants.go (2 hunks)
  • integration/datagenerator/common.go (1 hunks)
  • integration/simulation/devnetwork/node.go (2 hunks)
  • integration/simulation/network/network_utils.go (2 hunks)
  • integration/simulation/simulation.go (1 hunks)
  • tools/hardhatdeployer/contract_deployer.go (1 hunks)
Files skipped from review due to trivial changes (2)
  • .github/workflows/build-pr.yml
  • integration/simulation/devnetwork/node.go
Additional comments: 25
integration/datagenerator/common.go (1)
  • 52-52: The change from gethcommon.Big1 to big.NewInt(1) for the GasPrice field in the CreateL2TxData function should not affect the behavior, as both expressions evaluate to the same value. However, ensure that this change is consistent with the usage of big.Int throughout the rest of the codebase for maintainability.
integration/common/constants.go (1)
  • 87-87: The GasLimit field in the DefaultEnclaveConfig function is now set to params.MaxGasLimit / 6. Verify that this new gas limit aligns with the intended transaction throughput and system capabilities.
go/config/enclave_config_test.go (1)
  • 44-44: The renaming of GasBatchExecutionLimit to L2GasLimitFlag should be reflected across all test cases and usage within the codebase. Confirm that the new name is consistently applied and that it accurately describes the flag's functionality.
go/enclave/nodetype/validator.go (1)
  • 136-136: The addition of the gasLimit parameter to the CreateGenesisState method in the handleGenesis function should be carefully reviewed to ensure that it is being used correctly within the method and that it aligns with the intended genesis state creation logic.
go/enclave/components/interfaces.go (1)
  • 79-79: The addition of an extra *big.Int parameter to the CreateGenesisState method in the BatchExecutor interface should be reviewed to ensure that it is correctly implemented and that the method's consumers are updated to pass this new parameter.
go/config/enclave_cli_flags.go (1)
  • 57-57: The consolidation of GasBatchExecutionLimit and GasLocalExecutionCapFlag into L2GasLimitFlag should be thoroughly checked to ensure that all references to the old flags are updated and that the new flag is being used correctly throughout the codebase.
contracts/deployment_scripts/testnet/layer2/001_whitelist_tokens.ts (1)
  • 125-125: The increase of the gasLimit parameter to 1024_000_000 within the relayMessage function call is substantial. Ensure that this new limit is justified by the complexity of the operations being performed and that it does not introduce any inefficiencies or security concerns.
integration/simulation/network/network_utils.go (1)
  • 97-97: The GasLimit has been set to a very high value of 1_000_000_000_000_000_000. Confirm that this value is appropriate for the system's requirements and does not pose any risk of inefficient gas usage or other unintended consequences.
tools/hardhatdeployer/contract_deployer.go (1)
  • 94-95: The GasPrice and Gas values in the deployContractTx struct have been significantly increased to 2000000000 and 1025_000_000, respectively. Verify that these values are justified by the network conditions and the contract's complexity, and ensure they do not lead to excessive costs or other issues.
go/config/enclave_config.go (1)
  • 187-187: The initialization of GasLimit using L2GasLimitFlag appears correct. Confirm that L2GasLimitFlag is correctly defined and used consistently across the codebase.
go/enclave/evm/evm_facade.go (3)
  • 6-6: The math package has been imported. Verify that it is used within the file, otherwise, it should be removed to keep the imports clean.

  • 43-43: The ExecuteTransactions function now initializes a gas pool (gp) within initParams. Ensure that gp is correctly used within the function and that its introduction does not affect the transaction execution logic.

  • 205-210: The initParams function now returns a *gethcore.GasPool. Confirm that all calls to initParams correctly handle the new return value and that the gas pool is utilized appropriately.

go/enclave/l2chain/l2_chain.go (2)
  • 37-37: The removal of the gasEstimationCap field from the obscuroChain struct simplifies the configuration. Confirm that this field is no longer required and that its removal does not affect any functionality that previously depended on it.

  • 37-37: The Registry field in the obscuroChain struct has been moved to a separate line. This change is cosmetic and should not affect the functionality, but verify that the repositioning aligns with the codebase's struct layout conventions.

go/enclave/crosschain/message_bus_manager.go (2)
  • 89-89: The gas limit for the GenerateMessageBusDeployTx function has been increased to 5,000,000. Ensure that this increase is justified by the complexity of the contract being deployed and does not lead to unnecessarily high transaction costs.

  • 222-222: The gas limit for the CreateSyntheticTransactions function has been increased to 5,000,000. Verify that this increase is necessary for the transactions being created and that it does not result in excessive gas costs.

go/enclave/nodetype/sequencer.go (1)
  • 141-141: The addition of s.settings.BatchGasLimit as a parameter to the CreateGenesisState method should be checked to ensure that the method correctly handles the new *big.Int type for gas limit.
go/enclave/components/batch_executor.go (2)
  • 42-45: The removal of the batchGasLimit field from the batchExecutor struct should be carefully checked to ensure that it does not affect other parts of the code where it might have been used.

  • 311-314: The default value assignment for gasLimit in the CreateGenesisState method should be reviewed to ensure it aligns with the expected gas limit for genesis state creation.

go/enclave/components/rollup_compression.go (1)
  • 439-439: The initialization of a new big.Int with the value of calldataRollupHeader.GasLimit for the CreateGenesisState method call should be verified to ensure that the gasLimit is being correctly used and handled.
go/enclave/enclave.go (4)
  • 84-86: The addition of GlobalGasCap and BaseFee fields to the enclaveImpl struct is consistent with the summary provided. Ensure that these new fields are properly initialized and used throughout the codebase.

  • 187-187: The NewEnclave function now initializes batchExecutor without the config.GasBatchExecutionLimit parameter, which aligns with the summary. Verify that this change is reflected everywhere NewBatchExecutor is called.

  • 225-225: The BatchGasLimit within SequencerSettings is now set to config.GasLimit. Confirm that this new assignment is correctly handled in all relevant parts of the codebase where BatchGasLimit is used.

  • 1031-1031: The DoEstimateGas method now uses e.GlobalGasCap which is consistent with the removal of GasLocalExecutionCapFlag. Ensure that the GlobalGasCap is properly used in all gas estimation logic.

Comment on lines +278 to +279
GlobalGasCap: 5_000_000_000, // todo (#627) - make config
BaseFee: gethcommon.Big0,
Copy link

Choose a reason for hiding this comment

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

The GlobalGasCap and BaseFee fields are initialized with hardcoded values. Consider making these configurable through the config object or environment variables to avoid recompilation for changes.

Comment on lines +1158 to 1161
hi = e.GlobalGasCap
}
// Normalize the max fee per gas the call is willing to spend.
var feeCap *big.Int
Copy link

Choose a reason for hiding this comment

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

The DoEstimateGas method has a high cognitive complexity. Consider refactoring to simplify the logic and improve readability. Additionally, address the TODO comment regarding the review of gas mechanics/tokenomics.

@@ -35,7 +35,7 @@ type SequencerSettings struct {
MaxBatchSize uint64
MaxRollupSize uint64
GasPaymentAddress gethcommon.Address
BatchGasLimit uint64
BatchGasLimit *big.Int
Copy link

Choose a reason for hiding this comment

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

The BatchGasLimit field type change from uint64 to *big.Int requires careful handling of the new pointer type to avoid nil pointer dereferences. Ensure that all usages of BatchGasLimit check for nil before dereferencing.

Comment on lines +68 to +70
GasPaymentAddress gethcommon.Address
BaseFee *big.Int
GasLimit *big.Int
Copy link

Choose a reason for hiding this comment

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

The consolidation of GasBatchExecutionLimit and GasLocalExecutionCapFlag into a single GasLimit field simplifies the configuration. Ensure that all usages of the old fields are updated to use GasLimit.

@@ -227,7 +227,7 @@ func (s *Simulation) deployObscuroERC20s() {

deployContractTx := types.DynamicFeeTx{
Nonce: NextNonce(s.ctx, s.RPCHandles, owner),
Gas: 2_000_000,
Gas: 1025_000_000,
Copy link

Choose a reason for hiding this comment

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

The Gas value for deploying Obscuro ERC20 contracts has been significantly increased to 1025_000_000. This seems excessively high and could lead to very high transaction costs. Verify that this value is correct and necessary for the deployment of these contracts.

@otherview
Copy link
Contributor Author

closed in preference of #1721

@otherview otherview closed this Dec 27, 2023
@otherview otherview deleted the revert-1682-pedro/gaslimit_gascap_flags branch December 27, 2023 10:48
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.

1 participant