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

Problem: v0.50.x is outdated #392

Merged
merged 39 commits into from
Jun 4, 2024
Merged
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
87ad797
build(deps): Bump github.com/cosmos/gogoproto from 1.4.11 to 1.4.12 (…
dependabot[bot] Mar 21, 2024
a0faab3
feat(x/gov): emit proposer address in submit proposal event (backport…
mergify[bot] Mar 24, 2024
9c53142
feat(x/gov): emit depositor in `proposal_deposit` event (backport #19…
mergify[bot] Mar 25, 2024
d78edac
reuse fromAddrString (minor cleanup) (#19881)
yihuang Mar 27, 2024
8641cd2
feat(client): replace `event-query-tx-for` with `wait-tx` (backport #…
mergify[bot] Mar 27, 2024
7b35e36
feat(server): add custom start handler (backport #19854) (#19884)
mergify[bot] Mar 28, 2024
405471b
build(deps): Bump cosmossdk.io/store from 1.0.2 to 1.1.0 (#19810)
dependabot[bot] Mar 28, 2024
f63e5fd
docs(x/mint): Fix inconsistency in mint docs (backport #19915) (#19925)
mergify[bot] Apr 3, 2024
4b71767
build(deps): Bump github.com/cosmos/iavl from 1.1.1 to 1.1.2 (#19985)
dependabot[bot] Apr 10, 2024
525b720
fix(client/v2): add encoder for `cosmos.base.v1beta1.DecCoin` (backpo…
mergify[bot] Apr 10, 2024
f76c659
fix(mempool): use no-op mempool as default (backport #19970) (#20008)
mergify[bot] Apr 11, 2024
974a24c
feat: Conditionally emit metrics based on enablement (backport #19903…
mergify[bot] Apr 12, 2024
452632f
fix(x/bank): align query with multi denoms for send-enabled (backport…
mergify[bot] Apr 12, 2024
521ebe5
fix: Implement gogoproto customtype to secp256r1 keys (backport #2002…
mergify[bot] Apr 13, 2024
741b01c
fix(client/v2): respect output format from client ctx (backport #2003…
mergify[bot] Apr 15, 2024
d6a0fa1
build(deps): Bump cosmossdk.io/x/tx from 0.13.1 to 0.13.2 (#20042)
dependabot[bot] Apr 15, 2024
dafcc78
feat(x/bank): support depinject for send restrictions (backport #2001…
mergify[bot] Apr 15, 2024
9941498
fix(baseapp): don't share global gas meter in tx execution (backport …
mergify[bot] Apr 16, 2024
49c3ae6
fix: secp256r1 json missing quotes (backport #20060) (#20069)
mergify[bot] Apr 17, 2024
a2abf1a
build(deps): Bump github.com/cosmos/cosmos-proto from 1.0.0-beta.4 to…
dependabot[bot] Apr 19, 2024
2a32f42
feat(client/v2): implement version filtering using annotation (backpo…
mergify[bot] Apr 19, 2024
4bd0e02
chore: prepare v0.50.6 (#19998)
julienrbrt Apr 21, 2024
0a682f7
fix: use timestamp for sim log file name (backport #20108) (#20111)
mergify[bot] Apr 21, 2024
fcb9d84
fix(x/authz,x/feegrant): check blocked address (#20102)
julienrbrt Apr 21, 2024
c4d9a49
chore: update v0.50.6 release notes (#20124)
julienrbrt Apr 22, 2024
a42a85a
build(deps): bump sdk in modules (#20126)
julienrbrt Apr 22, 2024
3437fd5
docs(gas/fees): Update block gas documentation (backport #20128) (#20…
mergify[bot] Apr 22, 2024
7828a00
fix(baseapp): avoid header height overwrite block height (backport #2…
mergify[bot] Apr 22, 2024
ad8c205
docs: fix broken link (backport #20133) (#20138)
mergify[bot] Apr 22, 2024
bb9f451
build(deps): bump modules in simapp (#20137)
julienrbrt Apr 22, 2024
d4896c2
build(deps): Bump cosmossdk.io/x/tx from 0.13.2 to 0.13.3 (#20152)
dependabot[bot] Apr 23, 2024
016389c
docs: add authz reference info in the circuit antehandler (backport #…
mergify[bot] Apr 23, 2024
66ac784
fix(testsuite/sims): set all signatures (backport #20151) (#20185)
mergify[bot] Apr 25, 2024
f74c0e9
build(deps): Bump github.com/cometbft/cometbft from 0.38.6 to 0.38.7 …
dependabot[bot] Apr 29, 2024
a65c2f7
fix(server): bootstrap-state command can't parse latest genesis forma…
mergify[bot] Apr 29, 2024
8ffc807
fix: remove txs from mempool when antehandler fails in recheck (backp…
mergify[bot] May 2, 2024
c42a5e1
Merge remote-tracking branch 'origin/release/v0.50.x' into release/v0…
mmsqe May 3, 2024
d745b17
fix resolve
mmsqe May 3, 2024
0bd0905
align dependencies
mmsqe Jun 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs(gas/fees): Update block gas documentation (backport cosmos#20128) (
cosmos#20131)

Co-authored-by: samricotta <[email protected]>
mergify[bot] and samricotta authored Apr 22, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 3437fd5006a3290b0fabbaae39036b0dc9747945
20 changes: 12 additions & 8 deletions docs/docs/learn/beginner/04-gas-fees.md
Original file line number Diff line number Diff line change
@@ -56,21 +56,25 @@ Gas consumption can be done manually, generally by the module developer in the [

### Block Gas Meter

`ctx.BlockGasMeter()` is the gas meter used to track gas consumption per block and make sure it does not go above a certain limit. A new instance of the `BlockGasMeter` is created each time [`FinalizeBlock`](../advanced/00-baseapp.md#finalizeblock) is called. The `BlockGasMeter` is finite, and the limit of gas per block is defined in the application's consensus parameters. By default, Cosmos SDK applications use the default consensus parameters provided by CometBFT:
`ctx.BlockGasMeter()` is the gas meter used to track gas consumption per block and make sure it does not go above a certain limit.

```go reference
https://github.com/cometbft/cometbft/blob/v0.37.0/types/params.go#L66-L105
During the genesis phase, gas consumption is unlimited to accommodate initialisation transactions.

```go
app.finalizeBlockState.SetContext(app.finalizeBlockState.Context().WithBlockGasMeter(storetypes.NewInfiniteGasMeter()))
```

When a new [transaction](../advanced/01-transactions.md) is being processed via `FinalizeBlock`, the current value of `BlockGasMeter` is checked to see if it is above the limit. If it is, the transaction fails and returned to the consensus engine as a failed transaction. This can happen even with the first transaction in a block, as `FinalizeBlock` itself can consume gas. If not, the transaction is processed normally. At the end of `FinalizeBlock`, the gas tracked by `ctx.BlockGasMeter()` is increased by the amount consumed to process the transaction:
Following the genesis block, the block gas meter is set to a finite value by the SDK. This transition is facilitated by the consensus engine (e.g., CometBFT) calling the `RequestFinalizeBlock` function, which in turn triggers the SDK's `FinalizeBlock` method. Within `FinalizeBlock`, `internalFinalizeBlock` is executed, performing necessary state updates and function executions. The block gas meter, initialised each with a finite limit, is then incorporated into the context for transaction execution, ensuring gas consumption does not exceed the block's gas limit and is reset at the end of each block.

Modules within the Cosmos SDK can consume block gas at any point during their execution by utilising the `ctx`. This gas consumption primarily occurs during state read/write operations and transaction processing. The block gas meter, accessible via `ctx.BlockGasMeter()`, monitors the total gas usage within a block, enforcing the gas limit to prevent excessive computation. This ensures that gas limits are adhered to on a per-block basis, starting from the first block post-genesis.

```go
ctx.BlockGasMeter().ConsumeGas(
ctx.GasMeter().GasConsumedToLimit(),
"block gas meter",
)
gasMeter := app.getBlockGasMeter(app.finalizeBlockState.Context())
app.finalizeBlockState.SetContext(app.finalizeBlockState.Context().WithBlockGasMeter(gasMeter))
```

This above shows the general mechanism for setting the block gas meter with a finite limit based on the block's consensus parameters.

## AnteHandler

The `AnteHandler` is run for every transaction during `CheckTx` and `FinalizeBlock`, before a Protobuf `Msg` service method for each `sdk.Msg` in the transaction.