Add a config option and arg to set gas price for auto fees calculation #81

Merged
nabarun merged 9 commits from deep-stack/laconic-registry-cli:pm-support-auto-gas into main 2024-09-06 09:44:48 +00:00
2 changed files with 21 additions and 17 deletions
Showing only changes of commit 7e44af4026 - Show all commits

View File

@ -66,21 +66,22 @@ services:
## Gas and Fees
<https://docs.cosmos.network/v0.50/learn/beginner/gas-fees>
- Gas and fees in `cosmos-sdk`:
- <https://docs.cosmos.network/v0.50/learn/beginner/gas-fees>
- `gas` is a special unit that is used to track the consumption of resources during execution of a transaction
- The maximum value a tx is allowed to consume can be capped by setting `gas` in the config
- `fees` have to be paid by sender to allow the transaction into the mempool and is calculated using `gasPrice`:
- `gas` is a special unit that is used to track the consumption of resources during execution of a transaction
- The maximum value a tx is allowed to consume can be capped by setting `gas` in the config
- `fees` have to be paid by sender to allow the transaction into the mempool and is calculated using `gasPrice`:
```bash
fees = gas * gasPrice
```
```bash
fees = gas * gasPrice
```
- Typically, validators / full nodes set `min-gas-prices` to only allow txs providing minimum amount of fees
- Using `cosmjs`, there are two ways max fees amount can be given for a tx:
- Either by specifying `fees` and `gas` (in which case `fees` should be >= `gas` * `min-gas-price`)
- Or by specifying a `gasPrice` (in which case `gasPrice` should be >= `min-gas-price` set by the node and fees is `auto` calculated by simulating the tx)
- Typically, validators / full nodes set `min-gas-prices` to only allow txs providing minimum amount of fees
- There are two ways max fees amount can be given for a tx:
- Either by specifying `fees` and `gas` in the config (in which case fees should be >= gas * min-gas-price)
- Or by specifying a `gasPrice` (in which case gasPrice should be > min-gas-price and fees is calculated by simulating the tx)
- When using the `auto` fees calculation, the gas estimation by tx simulation is typically multiplied by a multiplier
When using the `auto` fees calculation, the gas estimation by tx simulation is typically multiplied by a multiplier
- As such, following `gas`, `fees` and `gasPrice` combinations can be used in `laconic-registry-cli`:
- Gas set, fees set to `Xalnt`:
@ -104,8 +105,9 @@ services:
```
- `gas` config ignored
- uses `auto` fee calculation using gas estimation with default multiplier value from `registry-sdk`
- tx fails mid-execution if it runs out of given gas
- uses `auto` fee calculation using gas estimation with [default multiplier](https://git.vdb.to/cerc-io/registry-sdk/src/branch/main/src/constants.ts) value from `registry-sdk`
- tx rejected if given `gasPrice` < `min-gas-price` set by the node
- tx fails mid-execution if it runs out of calculated gas
- Fees set to a `X` (without `alnt` suffix), gas price set to `Yalnt`:
```bash
@ -117,7 +119,8 @@ services:
- `gas` config ignored
- uses `auto` fee calculation using gas estimation with `fees` as the multiplier
- tx fails mid-execution if it runs out of given gas, can be retried with a higher gas estimation multiplier (`fees`)
- tx rejected if given `gasPrice` < `min-gas-price` set by the node
- tx fails mid-execution if it runs out of calculated gas, can be retried with a higher gas estimation multiplier (`fees`)
- Fees and gas price both not set:
```bash
@ -128,7 +131,8 @@ services:
```
- `gas` config ignored
- Throws error:
- uses `auto` fee calculation using gas estimation
- throws error:
```bash
Gas price must be set in the client options when auto gas is used.

View File

@ -27,7 +27,7 @@ export const handler = async (argv: Arguments) => {
const { owner } = argv;
if (owner) {
const [bondsByOwnerResult] = await registry.queryBondsByOwner([String(owner)]);
const [bondsByOwnerResult] = await registry.queryBondsByOwners([String(owner)]);
result = bondsByOwnerResult.bonds;
} else {
result = await registry.queryBonds();