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

Dry run gas limit estimation #484

Merged
merged 35 commits into from
Aug 11, 2022
Merged

Dry run gas limit estimation #484

merged 35 commits into from
Aug 11, 2022

Conversation

ascjones
Copy link
Collaborator

@ascjones ascjones commented Mar 31, 2022

To determine the gas limit to supply for instantiate and call commands, first invoke via rpc to determine gas_required for estimation.

By default instantiate and call commands will do a dry run first, and if --gas is not specified will use the gas_required from the RPC result as the gas_limit for the subsequent transaction. The user can skip the dry run with --skip-dry-run, in which case the --gas parameter is required.

The user will be prompted to confirm transaction submission with the suggested gas limit. This prompt can be skipped with the --skip-confirm flag, and the transaction will be submitted without user input.

image

From #432.

/cc @athei

@ascjones ascjones marked this pull request as ready for review August 3, 2022 17:09
@ascjones ascjones requested a review from athei August 3, 2022 17:11
@athei
Copy link
Contributor

athei commented Aug 8, 2022

I tested this. Works fine so far. But there is one regression: It does no longer print the debug buffer. Also, I think the formatting of the error is harder to read now. I think the output for the automatic dry run should be the same as for the manual one before.

Before:

Result ModuleError: Contracts::ContractTrapped: ["Contract trapped during execution."]
    Gas Consumed 185457130
    Gas Required 185457130
 Storage Deposit StorageDeposit::Charge(541630000000)
   Debug Message panicked at 'lol', /Users/alexander/Downloads/flipper/lib.rs:29:13

Now:

ERROR: Pre-submission dry-run failed: 'ModuleError: Contracts::ContractTrapped: ["Contract trapped during execution."]'. Use --skip-dry-run to skip this step.

@ascjones
Copy link
Collaborator Author

ascjones commented Aug 9, 2022

Yes this is a regression. In order to avoid this type of regression I want to revive the automated end to end tests see #518.

Fixed see below 👇

image

@athei
Copy link
Contributor

athei commented Aug 10, 2022

Nice this issue is fixed. More:

  • No automatic dry run is performed for upload_code (needed to inform user about storage_deposit_limit and subsequently set it for the extrinsic)
  • Automatic dry-run for instantiate or call doesn't show storage deposit on success. I assume it doesn't set it for the extrinsic either. On error or for the manual dry-run the full information is shown.
  • I can't confirm by just pressing enter. I need to type out Y which seems to be the default choice. It is also case sensitive.

@ascjones
Copy link
Collaborator Author

ascjones commented Aug 10, 2022

* No automatic dry run is performed for `upload_code` (needed to inform user about `storage_deposit_limit` and subsequently set it for the extrinsic)

* Automatic dry-run for `instantiate` or `call` doesn't show storage deposit on success. I assume it doesn't set it for the extrinsic either. On error or for the manual dry-run the full information is shown.

My intention was to add storage deposit as a nice and easy follow up, since it wasn't part of the (original) scope.

* I can't confirm by just pressing enter. I need to type out `Y` which seems to be the default choice. It is also case sensitive.

This was by design, I have seen it in other CLIs where confirming requires pressing two keys to make Y to avoid accidental presses, as in "are you really sure?" confirmation. However happy to make it less strict if you think that is too much

@athei
Copy link
Contributor

athei commented Aug 10, 2022

Ok then let's keep the deposit as follow up.

Regarding the confirmation: The only confusing thing is that Y/n suggests that the capital option is the default. I suggest making them both lowercase or both uppercase.

@ascjones
Copy link
Collaborator Author

ascjones commented Aug 11, 2022

Regarding the confirmation: The only confusing thing is that Y/n suggests that the capital option is the default. I suggest making them both lowercase or both uppercase.

Ok I have reverted to your previous suggestion, make it case insensitive and have Y as the default option. It seems I was wrong and the convention is as you suggest: https://askubuntu.com/questions/322600/do-you-want-to-continuey-n-why-the-upper-case.

image

@ascjones ascjones merged commit 069f8a4 into master Aug 11, 2022
@ascjones ascjones deleted the aj/dry-run-gas-limit branch August 11, 2022 13:51
@ascjones ascjones mentioned this pull request Aug 15, 2022
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.

2 participants