Add a config option and arg to set gas price for auto
fees calculation
#81
74
README.md
74
README.md
@ -4,7 +4,7 @@ CLI utility written in TS, used to interact with laconicd. Depends on [registry-
|
|||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
- Add `.npmrc` file in desired project to resolve package
|
* Add `.npmrc` file in desired project to resolve package
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@cerc-io:registry=https://git.vdb.to/api/packages/cerc-io/npm/
|
@cerc-io:registry=https://git.vdb.to/api/packages/cerc-io/npm/
|
||||||
@ -12,13 +12,13 @@ CLI utility written in TS, used to interact with laconicd. Depends on [registry-
|
|||||||
|
|
||||||
This will set the registry for `cerc-io` scoped packages in the project
|
This will set the registry for `cerc-io` scoped packages in the project
|
||||||
|
|
||||||
- Install the CLI using package manager
|
* Install the CLI using package manager
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn add @cerc-io/laconic-registry-cli
|
yarn add @cerc-io/laconic-registry-cli
|
||||||
```
|
```
|
||||||
|
|
||||||
- For installing CLI globally add `.npmrc` file above in home directory and run
|
* For installing CLI globally add `.npmrc` file above in home directory and run
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn global add @cerc-io/laconic-registry-cli
|
yarn global add @cerc-io/laconic-registry-cli
|
||||||
@ -26,13 +26,13 @@ CLI utility written in TS, used to interact with laconicd. Depends on [registry-
|
|||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
- Run `yarn` to install all dependencies.
|
* Run `yarn` to install all dependencies.
|
||||||
|
|
||||||
- Run `yarn build`.
|
* Run `yarn build`.
|
||||||
|
|
||||||
- Create a `config.yml` file from [config.example.yml](./config.example.yml) file.
|
* Create a `config.yml` file from [config.example.yml](./config.example.yml) file.
|
||||||
|
|
||||||
- Add CLI cmd to path
|
* Add CLI cmd to path
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export PATH="$PWD/bin:$PATH"
|
export PATH="$PWD/bin:$PATH"
|
||||||
@ -42,7 +42,7 @@ CLI utility written in TS, used to interact with laconicd. Depends on [registry-
|
|||||||
|
|
||||||
Run the chain:
|
Run the chain:
|
||||||
|
|
||||||
- In laconicd repo run:
|
* In laconicd repo run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
TEST_AUCTION_ENABLED=true ./scripts/init.sh clean
|
TEST_AUCTION_ENABLED=true ./scripts/init.sh clean
|
||||||
@ -66,24 +66,24 @@ services:
|
|||||||
|
|
||||||
## Gas and Fees
|
## Gas and Fees
|
||||||
|
|
||||||
- Gas and fees in `cosmos-sdk`:
|
* Gas and fees in `cosmos-sdk`:
|
||||||
- <https://docs.cosmos.network/v0.50/learn/beginner/gas-fees>
|
* <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
|
* `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
|
* 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`:
|
* `fees` have to be paid by sender to allow the transaction into the mempool and is calculated using `gasPrice`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
fees = gas * gasPrice
|
fees = gas * gasPrice
|
||||||
```
|
```
|
||||||
|
|
||||||
- Typically, validators / full nodes set `min-gas-prices` to only allow txs providing minimum amount of fees
|
* 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:
|
* 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`)
|
* 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)
|
* 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)
|
||||||
|
|
||||||
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`:
|
* As such, following `gas`, `fees` and `gasPrice` combinations can be used in `laconic-registry-cli`:
|
||||||
- Gas set, fees set to `Xalnt`:
|
* Gas set, fees set to `Xalnt`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Example
|
# Example
|
||||||
@ -92,10 +92,10 @@ services:
|
|||||||
gasPrice:
|
gasPrice:
|
||||||
```
|
```
|
||||||
|
|
||||||
- `gasPrice` config ignored
|
* `gasPrice` config ignored
|
||||||
- tx rejected if given `fees` < `gas` * `min-gas-price` set by the node
|
* tx rejected if given `fees` < `gas` * `min-gas-price` set by the node
|
||||||
- tx fails mid-execution if it runs out of given `gas`
|
* tx fails mid-execution if it runs out of given `gas`
|
||||||
- Fees not set, gas price set to `Xalnt`:
|
* Fees not set, gas price set to `Xalnt`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Example
|
# Example
|
||||||
@ -104,11 +104,11 @@ services:
|
|||||||
gasPrice: 1alnt
|
gasPrice: 1alnt
|
||||||
```
|
```
|
||||||
|
|
||||||
- `gas` config ignored
|
* `gas` config ignored
|
||||||
- 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`
|
* 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 rejected if given `gasPrice` < `min-gas-price` set by the node
|
||||||
- tx fails mid-execution if it runs out of calculated gas
|
* tx fails mid-execution if it runs out of calculated gas
|
||||||
- Fees set to a `X` (without `alnt` suffix), gas price set to `Yalnt`:
|
* Fees set to a `X` (without `alnt` suffix), gas price set to `Yalnt`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Example
|
# Example
|
||||||
@ -117,11 +117,11 @@ services:
|
|||||||
gasPrice: 1alnt
|
gasPrice: 1alnt
|
||||||
```
|
```
|
||||||
|
|
||||||
- `gas` config ignored
|
* `gas` config ignored
|
||||||
- uses `auto` fee calculation using gas estimation with `fees` as the multiplier
|
* uses `auto` fee calculation using gas estimation with `fees` as the multiplier
|
||||||
- tx rejected if given `gasPrice` < `min-gas-price` set by the node
|
* 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`)
|
* 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:
|
* Fees and gas price both not set:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Example
|
# Example
|
||||||
@ -130,15 +130,15 @@ services:
|
|||||||
gasPrice:
|
gasPrice:
|
||||||
```
|
```
|
||||||
|
|
||||||
- `gas` config ignored
|
* `gas` config ignored
|
||||||
- uses `auto` fee calculation using gas estimation
|
* uses `auto` fee calculation using gas estimation
|
||||||
- throws error:
|
* throws error:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
Gas price must be set in the client options when auto gas is used.
|
Gas price must be set in the client options when auto gas is used.
|
||||||
```
|
```
|
||||||
|
|
||||||
- The `gas`, `fees` and `gasPrice` can be set to some default values in the config as shown above, and can be overriden for each command using the `--gas`, `--fees` and `--gasPrice` arguments:
|
* The `gas`, `fees` and `gasPrice` can be set to some default values in the config as shown above, and can be overriden for each command using the `--gas`, `--fees` and `--gasPrice` arguments:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Example:
|
# Example:
|
||||||
|
Loading…
Reference in New Issue
Block a user