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

Estimate gas limit by default whenever possible #487

Merged
merged 3 commits into from
Mar 4, 2025

Conversation

popenta
Copy link
Collaborator

@popenta popenta commented Feb 24, 2025

The --estimate-gas flag was removed from all commands. The gas limit is now estimated by default wherever possible (excluding smart contract transactions).

@popenta popenta self-assigned this Feb 24, 2025
@popenta popenta marked this pull request as draft February 24, 2025 13:21
Base automatically changed from refactoring-delegation-operations to feat/next March 3, 2025 14:18
@popenta popenta marked this pull request as ready for review March 3, 2025 15:50
gas_limit = 0 if args.estimate_gas else args.gas_limit
chain_id = cli_shared.get_chain_id(args.chain, args.proxy)
config = TransactionsFactoryConfig(chain_id)
delegation = DelegationOperations(config)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed

gas_limit = 0 if args.estimate_gas else args.gas_limit
chain_id = cli_shared.get_chain_id(args.chain, args.proxy)
config = TransactionsFactoryConfig(chain_id)
delegation = DelegationOperations(config)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed

@@ -54,7 +53,7 @@ def create_transaction_for_staking(
rewards_address=rewards_address,
)

if estimate_gas:
if not gas_limit:
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we can drop self.estimate_* functions, since gas estimation is performed by controllers in sdk-py.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here, the transactions are not created using a controller from sdk-py. This will be changed in a later PR. We still left the --gas-limit argument in case a user wants to specify the gas.

proxy = ProxyNetworkProvider(url=args.proxy, config=network_provider_config)
args.nonce = proxy.get_account(account.address).nonce


def get_current_nonce_for_address(address: Address, proxy_url: Union[str, None]) -> int:
Copy link
Contributor

Choose a reason for hiding this comment

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

Previously reviewed 💭



def prepare_sender(args: Any):
"""Reurns a tuple containing the sender's account and the account nonce.
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment is outdated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed

@@ -57,7 +56,6 @@ def test_create_new_delegation_contract_with_provided_gas_limit(capsys: Any):
str(alice),
"--nonce",
"7",
"--estimate-gas",
Copy link
Contributor

Choose a reason for hiding this comment

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

We should document this breaking change in the PR description (so that we don't forget about it when writing the release notes).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a short description.

@popenta popenta added the breaking change Pull request contains breaking changes label Mar 4, 2025
@popenta popenta merged commit 99a64d5 into feat/next Mar 4, 2025
10 of 12 checks passed
@popenta popenta deleted the estimate-gas-by-default branch March 4, 2025 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Pull request contains breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants