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

[cli] Add gas estimate feature #17322

Merged
merged 17 commits into from
Apr 30, 2024

Conversation

stefan-mysten
Copy link
Contributor

Description

This PR adds automatic gas estimation by dry running the transaction if the gas budget is not provided. That means that the gas_budget flag is now optional.

Test plan

Existing tests + new test

cd crates/sui && cargo test -- test_gas_estimation

Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • Indexer:
  • JSON-RPC:
  • GraphQL:
  • CLI: Added automatic gas estimation feature for the Sui CLI. If gas budget is not provided, the tool will dry run the transaction to get a gas budget estimate, and then it will execute the transaction. That means that for all relevant commands the --gas-budget flag is now optional. Please note that this incurs a small cost in performance due to the additional dry run call.
  • Rust SDK:

@stefan-mysten stefan-mysten requested a review from a team April 24, 2024 22:01
Copy link

vercel bot commented Apr 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-core ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 29, 2024 11:41pm
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 29, 2024 11:41pm
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Apr 29, 2024 11:41pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Apr 29, 2024 11:41pm
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Apr 29, 2024 11:41pm

Copy link
Member

@amnn amnn left a comment

Choose a reason for hiding this comment

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

Nice! Check out the comment on the actual gas estimation logic, but other than that, I think this is good to go!

crates/sui/src/client_commands.rs Outdated Show resolved Hide resolved
crates/sui/src/client_commands.rs Outdated Show resolved Hide resolved
crates/sui/src/client_ptb/ptb.rs Show resolved Hide resolved
crates/sui/src/client_commands.rs Show resolved Hide resolved
@stefan-mysten
Copy link
Contributor Author

Nice! Check out the comment on the actual gas estimation logic, but other than that, I think this is good to go!

Excellent. With this occasion, I also fixed a bug there and now the TS SDK implementation and this one match.

Copy link
Member

@amnn amnn left a comment

Choose a reason for hiding this comment

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

Looks like the output from --preview for PTB commands that do not have --gas-budget is slightly broken, but that's the only remaining comment.

crates/sui/src/client_commands.rs Outdated Show resolved Hide resolved
crates/sui/src/client_commands.rs Outdated Show resolved Hide resolved
Copy link
Member

@amnn amnn left a comment

Choose a reason for hiding this comment

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

Happy days! Thanks @stefan-mysten

@stefan-mysten stefan-mysten merged commit 7af10f5 into MystenLabs:main Apr 30, 2024
43 of 44 checks passed
@stefan-mysten stefan-mysten deleted the cli_gas_estimation branch April 30, 2024 14:57
stefan-mysten added a commit to stefan-mysten/sui that referenced this pull request May 1, 2024
## Description 

This PR adds automatic gas estimation by dry running the transaction if
the gas budget is not provided. That means that the `gas_budget` flag is
now optional.

## Test plan 

Existing tests + new test
```
cd crates/sui && cargo test -- test_gas_estimation
```

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [x] CLI: Added automatic gas estimation feature for the Sui CLI. If
gas budget is not provided, the tool will dry run the transaction to get
a gas budget estimate, and then it will execute the transaction. That
means that for all relevant commands the `--gas-budget` flag is now
optional. Please note that this incurs a small cost in performance due
to the additional dry run call.
- [ ] Rust SDK:
stefan-mysten added a commit to stefan-mysten/sui that referenced this pull request May 1, 2024
## Description 

This PR adds automatic gas estimation by dry running the transaction if
the gas budget is not provided. That means that the `gas_budget` flag is
now optional.

## Test plan 

Existing tests + new test
```
cd crates/sui && cargo test -- test_gas_estimation
```

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [x] CLI: Added automatic gas estimation feature for the Sui CLI. If
gas budget is not provided, the tool will dry run the transaction to get
a gas budget estimate, and then it will execute the transaction. That
means that for all relevant commands the `--gas-budget` flag is now
optional. Please note that this incurs a small cost in performance due
to the additional dry run call.
- [ ] Rust SDK:
stefan-mysten added a commit that referenced this pull request May 1, 2024
## Description 

Cherry picking feature into `releases/sui-v1.24.0-release` branch for
the next release next week.
This PR adds automatic gas estimation by dry running the transaction if
the gas budget is not provided. That means that the `gas_budget` flag is
now optional.

## Test plan 

Existing tests + new test
```
cd crates/sui && cargo test -- test_gas_estimation
```

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [x] CLI: Added automatic gas estimation feature for the Sui CLI. If
gas budget is not provided, the tool will dry run the transaction to get
a gas budget estimate, and then it will execute the transaction. That
means that for all relevant commands the `--gas-budget` flag is now
optional. Please note that this incurs a small cost in performance due
to the additional dry run call.
- [ ] Rust SDK:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants