Skip to content

Integrate gas limit estimator#537

Merged
popenta merged 3 commits intomainfrom
integrate-gas-estimator
Jul 30, 2025
Merged

Integrate gas limit estimator#537
popenta merged 3 commits intomainfrom
integrate-gas-estimator

Conversation

@popenta
Copy link
Copy Markdown
Collaborator

@popenta popenta commented Jul 29, 2025

No description provided.

@popenta popenta self-assigned this Jul 29, 2025
@andreibancioiu andreibancioiu requested a review from Copilot July 29, 2025 12:20
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR integrates a gas limit estimator feature into the MultiversX SDK CLI, upgrading the SDK dependency from v1.6.2 to v2.0.0. The main changes enable automatic gas limit estimation for transactions when no explicit gas limit is provided.

Key changes include:

  • Added gas limit estimator integration across all transaction controllers
  • Updated parameter types from int to Union[int, None] for gas limits
  • Added gas limit multiplier configuration and CLI argument support
  • Updated SDK method calls to use newer API patterns

Reviewed Changes

Copilot reviewed 22 out of 23 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pyproject.toml Updated CLI version to 11.1.0 and SDK dependency to 2.0.0
multiversx_sdk_cli/validators.py Added GasLimitEstimator support to ValidatorsController
multiversx_sdk_cli/transactions.py Integrated gas estimator into TransactionsController
multiversx_sdk_cli/tests/test_*.py Updated tests for gas estimation and method name changes
multiversx_sdk_cli//cli_.py Added gas estimator initialization across CLI modules
multiversx_sdk_cli/config.py Added gas_limit_multiplier configuration option
multiversx_sdk_cli/cli_shared.py Added gas estimator initialization helper function
Comments suppressed due to low confidence (1)

def test_contract_verification_create_request_signature():
account = Account.new_from_pem(file_path=testdata_folder / "walletKey.pem")
contract_address = Address.from_bech32("erd1qqqqqqqqqqqqqpgqeyj9g344pqguukajpcfqz9p0rfqgyg4l396qespdck")
contract_address = Address.new_from_bech32("erd1qqqqqqqqqqqqqpgqeyj9g344pqguukajpcfqz9p0rfqgyg4l396qespdck")
Copy link

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

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

The method name change from Address.from_bech32 to Address.new_from_bech32 is inconsistent with the pattern used elsewhere in the codebase. Consider using a consistent naming pattern across all similar changes.

Suggested change
contract_address = Address.new_from_bech32("erd1qqqqqqqqqqqqqpgqeyj9g344pqguukajpcfqz9p0rfqgyg4l396qespdck")
contract_address = Address.from_bech32("erd1qqqqqqqqqqqqqpgqeyj9g344pqguukajpcfqz9p0rfqgyg4l396qespdck")

Copilot uses AI. Check for mistakes.

delegation_config["owner"] = owner.address.bech32()
dns_config["owner"] = owner.address.bech32()
delegation_config["owner"] = owner.address.to_bech32()
Copy link

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

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

The method name change from bech32() to to_bech32() should be consistent with the pattern used elsewhere. Verify this aligns with the new SDK API conventions.

Copilot uses AI. Check for mistakes.
"signature": self.signature.hex(),
"payload": {
"contract": self.contract.bech32(),
"contract": self.contract.to_bech32(),
Copy link

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

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

Similar to other files, ensure the method name change from bech32() to to_bech32() is consistent with the new SDK API.

Copilot uses AI. Check for mistakes.
Comment on lines +802 to +804
def initialize_gas_limit_estimator(args: Any) -> Union[GasLimitEstimator, None]:
# if proxy is not provided, we can't use GasLimitEstimator
if hasattr(args, "proxy") and not args.proxy:
Copy link

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

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

The function returns None when proxy is not provided, but the return type annotation indicates Union[GasLimitEstimator, None]. Consider adding a check to ensure this behavior is intentional and properly handled by callers.

Suggested change
def initialize_gas_limit_estimator(args: Any) -> Union[GasLimitEstimator, None]:
# if proxy is not provided, we can't use GasLimitEstimator
if hasattr(args, "proxy") and not args.proxy:
def initialize_gas_limit_estimator(args: Any) -> Union[GasLimitEstimator, None]:
"""
Initializes and returns a GasLimitEstimator object.
Returns:
GasLimitEstimator: If a valid proxy is provided.
None: If the proxy is not provided or is falsy.
Note:
If `None` is returned, callers must handle this case appropriately.
"""
# if proxy is not provided, we can't use GasLimitEstimator
if hasattr(args, "proxy") and not args.proxy:
logger.warning("Proxy is not provided. GasLimitEstimator cannot be initialized.")

Copilot uses AI. Check for mistakes.
validate_chain_id_args(args)


def _initialize_multisig_wrapper(args: Any) -> MultisigWrapper:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can be _create_multisig_wrapper.

chain_id = proxy.get_network_config().chain_id
multisig = MultisigController(chain_id, proxy, abi)

multisig = _initialize_multisig_controller(args)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also here, maybe _create... instead of _initialize....

"--gas-limit-multiplier",
required=False,
type=float,
help="if `--gas-limit` is not provided, the estimated value will be multiplied by this multiplier (e.g 1.1)",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can be ... is not explicitly provided ... (nitpicking).

args.proxy = env.proxy_url


def initialize_gas_limit_estimator(args: Any) -> Union[GasLimitEstimator, None]:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

_create....

@popenta popenta merged commit 12d9483 into main Jul 30, 2025
13 checks passed
@popenta popenta deleted the integrate-gas-estimator branch July 30, 2025 07:34
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.

4 participants