Add explanation for with examples for gas and fees config
Some checks failed
Lint / lint (18.x) (pull_request) Successful in 1m12s
Tests / cli_tests (18.x) (pull_request) Failing after 1m12s

This commit is contained in:
Prathamesh Musale 2024-08-27 16:45:13 +05:30
parent f99f222162
commit 426515a9a1
2 changed files with 91 additions and 31 deletions

120
README.md
View File

@ -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,18 +66,78 @@ services:
## Gas and Fees ## Gas and Fees
https://docs.evmos.org/users/basics/gas.html <https://docs.cosmos.network/v0.50/learn/beginner/gas-fees>
* Transactions require `gas`, set to the maximum value the transaction is allowed to consume. - `gas` is a special unit that is used to track the consumption of resources during execution of a transaction
* Typically, validators also require transaction `fees` to be provided to allow the transaction into the mempool. - 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`:
The `gas` and `fees` can be set to some default values in the config, and can be overriden for each command using the `--gas` and `--fees` arguments. ```bash
fees = gas * gasPrice
```
Example: - 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
- As such, following `gas`, `fees` and `gasPrice` combinations can be used in `laconic-registry-cli`:
- Gas set, fees set to `Xalnt`:
```bash ```bash
$ laconic registry bond create --type alnt --quantity 100000000000 --gas 200000 --fees 200000alnt # Example
``` gas: 500000
fees: 500000alnt
gasPrice:
```
- `gasPrice` config ignored
- tx rejected if given `fees` < `gas` * `min-gas-price` set by the node
- tx fails mid-execution if it runs out of given `gas`
- Fees not set, gas price set to `Xalnt`:
```bash
# Example
gas:
fees:
gasPrice: 1alnt
```
- `gas` config ignored
- uses `auto` fee calculation using gas estimation with default multiplier value from `registry-sdk`
- Fees set to a `X` (without `alnt` suffix), gas price set to `Yalnt`:
```bash
# Example
gas:
fees: 1.8
gasPrice: 1alnt
```
- `gas` config ignored
- uses `auto` fee calculation using gas estimation with `fees` as the multiplier
- Fees and gas price both not set:
```bash
# Example
gas:
fees:
gasPrice:
```
- `gas` config ignored
- Throws error:
```bash
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
```bash
# Example:
laconic registry bond create --type alnt --quantity 100000000000 --gas 200000 --fees 200000alnt
```
## Operations ## Operations
@ -263,13 +323,13 @@ $ laconic registry record get --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf
List records: List records:
```bash ```bash
$ laconic registry record list laconic registry record list
``` ```
Reserve authority: Reserve authority:
```bash ```bash
$ laconic registry authority reserve laconic laconic registry authority reserve laconic
``` ```
Check authority information: Check authority information:
@ -367,43 +427,43 @@ Reveal file: ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.j
Reveal an auction bid: Reveal an auction bid:
```bash ```bash
$ laconic registry auction bid reveal 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json laconic registry auction bid reveal 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json
``` ```
Set authority bond (after winning auction): Set authority bond (after winning auction):
```bash ```bash
$ laconic registry authority bond set laconic 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 laconic registry authority bond set laconic 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785
``` ```
Create sub-authority (same owner as parent authority): Create sub-authority (same owner as parent authority):
```bash ```bash
$ laconic registry authority reserve echo.laconic laconic registry authority reserve echo.laconic
``` ```
Create sub-authority (custom owner for sub-authority): Create sub-authority (custom owner for sub-authority):
```bash ```bash
$ laconic registry authority reserve kube.laconic --owner laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k laconic registry authority reserve kube.laconic --owner laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k
``` ```
Get all the authorities: Get all the authorities:
```bash ```bash
$ laconic registry authority list laconic registry authority list
``` ```
Get all the authorities by owner: Get all the authorities by owner:
```bash ```bash
$ laconic registry authority list --owner laconic1zayjut6pd4xy9dguut56v55hktzmeq6r777hmd laconic registry authority list --owner laconic1zayjut6pd4xy9dguut56v55hktzmeq6r777hmd
``` ```
Set name: Set name:
```bash ```bash
$ laconic registry name set lrn://laconic/watcher/erc20 bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba laconic registry name set lrn://laconic/watcher/erc20 bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba
``` ```
Lookup name information: Lookup name information:
@ -475,7 +535,7 @@ $ laconic registry name resolve lrn://laconic/watcher/erc20
Create bond: Create bond:
```bash ```bash
$ laconic registry bond create --type alnt --quantity 1000 laconic registry bond create --type alnt --quantity 1000
``` ```
List bonds: List bonds:
@ -555,41 +615,41 @@ $ laconic registry bond list --owner laconic15za32wly5exgcrt2zfr8php4ya49n5y7mas
Refill bond: Refill bond:
```bash ```bash
$ laconic registry bond refill --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type alnt --quantity 1000 laconic registry bond refill --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type alnt --quantity 1000
``` ```
Withdraw funds from bond: Withdraw funds from bond:
```bash ```bash
$ laconic registry bond withdraw --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type alnt --quantity 500 laconic registry bond withdraw --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type alnt --quantity 500
``` ```
Cancel bond: Cancel bond:
```bash ```bash
$ laconic registry bond cancel --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 laconic registry bond cancel --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785
``` ```
Associate bond (with record): Associate bond (with record):
```bash ```bash
$ laconic registry bond associate --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba --bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0 laconic registry bond associate --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba --bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0
``` ```
Disassociate bond (from record): Disassociate bond (from record):
```bash ```bash
$ laconic registry bond dissociate --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba laconic registry bond dissociate --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba
``` ```
Dissociate all records from bond: Dissociate all records from bond:
```bash ```bash
$ laconic registry bond records dissociate --bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0 laconic registry bond records dissociate --bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0
``` ```
Reassociate records (switch bond): Reassociate records (switch bond):
```bash ```bash
$ laconic registry bond records reassociate --old-bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0 --new-bond-id 3e11c61f179897e4b12e9b63de35d36f88ac146755e7a28ce0bcdd07cf3a03ae laconic registry bond records reassociate --old-bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0 --new-bond-id 3e11c61f179897e4b12e9b63de35d36f88ac146755e7a28ce0bcdd07cf3a03ae
``` ```

View File

@ -7,4 +7,4 @@ services:
chainId: laconic_9000-1 chainId: laconic_9000-1
gas: 200000 gas: 200000
fees: 200000alnt fees: 200000alnt
gasPrice: 1alnt gasPrice: