add docs for gas consumption (#9118)

Co-authored-by: technicallyty <48813565+tytech3@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
technicallyty 2021-04-15 02:09:01 -07:00 committed by GitHub
parent ef69863f46
commit bc4c3be15c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 2 deletions

View File

@ -35,3 +35,6 @@ Cosmos-SDK `x/authz` module comes with following authorization types
+++ https://github.com/cosmos/cosmos-sdk/blob/c95de9c4177442dee4c69d96917efc955b5d19d9/x/authz/types/generic_authorization.go#L20-L28
- `method_name` holds ServiceMsg type.
## Gas
In order to prevent DoS attacks, granting `StakeAuthorizaiton`s with `x/authz` incur gas. `StakeAuthorizaiton` allows you to authorize another account to delegate, undelegate, or redelegate to validators. The authorizer can define a list of validators they will allow and/or deny delegations to. The SDK will iterate over these lists and charge 10 gas for each validator in both of the lists.

View File

@ -16,6 +16,7 @@ granting arbitrary privileges from one account (the granter) to another account
1. **[Concept](01_concepts.md)**
- [Authorization](01_concepts.md#Authorization)
- [Built-in Authorizations](01_concepts.md#Built-in-Authorization)
- [Gas](01_concepts.md#gas)
2. **[State](02_state.md)**
3. **[Messages](03_messages.md)**
- [Msg/GrantAuthorization](03_messages.md#MsgGrantAuthorization)

View File

@ -3,7 +3,6 @@ order: 1
-->
# Concepts
## FeeAllowanceGrant
`FeeAllowanceGrant` is stored in the KVStore to record a grant with full context. Every grant will contain `granter`, `grantee` and what kind of `allowance` is granted. `granter` is an account address who is giving permission to `grantee` (the beneficiary account address) to pay for some or all of `grantee`'s transaction fees. `allowance` defines what kind of fee allowance (`BasicFeeAllowance` or `PeriodicFeeAllowance`, see below) is granted to `grantee`. `allowance` accepts an interface which implements `FeeAllowanceI`, encoded as `Any` type. There can be only one existing fee grant allowed for a `grantee` and `granter`, self grants are not allowed.
@ -68,3 +67,8 @@ Example cmd:
## DeductGrantedFeeDecorator
`feegrant` module also adds a `DeductGrantedFeeDecorator` ante handler. Whenever a transaction is being executed with `granter` field set, then this ante handler will check whether `payer` and `granter` have proper fee allowance grant in state. If it exists the fees will be deducted from the `granter`'s account address. If the `granter` field isn't set then this ante handler works as normal fee deductor.
## Gas
In order to prevent DoS attacks, using a filtered `x/feegrant` incurs gas. The SDK must assure that the `grantee`'s transactions all conform to the filter set by the `granter`. The SDK does this by iterating over the allowed messages in the filter and charging 10 gas per filtered message. The SDK will then iterate over the messages being sent by the `grantee` to ensure the messages adhere to the filter, also charging 10 gas per message. The SDK will stop iterating and fail the transaction if it finds a message that does not conform to the filter.
**WARNING**: The gas is charged against the granted allowance. Ensure your messages conform to the filter, if any, before sending transactions using your allowance.

View File

@ -20,12 +20,13 @@ This module allows accounts to grant fee allowances and to use fees from their a
- [PeriodicFeeAllowance](01_concepts.md#periodicfeeallowance)
- [FeeAccount flag](01_concepts.md#feeaccount-flag)
- [DeductGrantedFeeDecorator](01_concepts.md#deductgrantedfeedecorator)
- [Gas](01_concepts.md#gas)
2. **[State](02_state.md)**
- [FeeAllowance](02_state.md#feeallowance)
3. **[Messages](03_messages.md)**
- [Msg/GrantFeeAllowance](03_messages.md#msggrantfeeallowance)
- [Msg/RevokeFeeAllowance](03_messages.md#msgrevokefeeallowance)
3. **[Events](04_events.md)**
4. **[Events](04_events.md)**
- [MsgGrantFeeAllowance](04_events.md#msggrantfeeallowance)
- [MsgrevokeFeeAllowance](04_events.md#msgrevokefeeallowance)
- [Exec fee allowance](04_events.md#exec-fee-allowance)