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

feat: eip target gas from consensus params #7270

Merged
merged 12 commits into from
Jan 9, 2024
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Features

* [#6993](https://github.com/osmosis-labs/osmosis/pull/6993) feat(math): add mutative api for BigDec.BigInt()
* [#7270](https://github.com/osmosis-labs/osmosis/pull/7270) feat: eip target gas from consensus params

### Misc Improvements

Expand All @@ -64,7 +65,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Bug Fixes

* [#7245](https://github.com/osmosis-labs/osmosis/pull/7245) fix: correcting json tag value for `SwapAmountOutSplitRouteWrapper.OutDenom`
* [#7233](https://github.com/osmosis-labs/osmosis/pull/7233) fix: config overwrite ignores app.toml values
* [#7233](https://github.com/osmosis-labs/osmosis/pull/7233) fix: config overwrite ignores app.toml values
* [#7243](https://github.com/osmosis-labs/osmosis/pull/7243) fix: chore: update gov metadata length from 256 to 10200
* [#7246](https://github.com/osmosis-labs/osmosis/pull/7246) fix: config overwrite fails with exit code 1 if wrong permissions
* [#7267](https://github.com/osmosis-labs/osmosis/pull/7267) fix: support CL pools in tx fee module
Expand Down
1 change: 1 addition & 0 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
appKeepers.PoolManagerKeeper,
appKeepers.ProtoRevKeeper,
appKeepers.DistrKeeper,
appKeepers.ConsensusParamsKeeper,
dataDir,
)
appKeepers.TxFeesKeeper = &txFeesKeeper
Expand Down
9 changes: 6 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,15 @@ replace (
// https://github.com/osmosis-labs/wasmd/releases/tag/v0.45.0-osmo
github.com/CosmWasm/wasmd => github.com/osmosis-labs/wasmd v0.45.0-osmo

// fork of cometbft which allows for better app hash logging
github.com/cometbft/cometbft => github.com/osmosis-labs/cometbft v0.0.0-20240103055822-28da358e3146

// v1.0.0-beta.3 is incompatible, so we use v1.0.0-beta.2
github.com/cosmos/cosmos-proto => github.com/cosmos/cosmos-proto v1.0.0-beta.2

// Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk/tree/osmo/v0.47.5, current branch: osmo/v0.47.5. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/cc29414c72c73d567e0c75b4a0800961a26d7af4
// https://github.com/osmosis-labs/cosmos-sdk/releases/tag/v0.47.5-osmo-4
github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.47.6-0.20240103225327-6652b67a6ae8
// Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk/tree/osmo/v0.47.5, current branch: osmo/v0.47.5. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/65d7acfdc2a94cc49837bb9abec462f129029540
// https://github.com/osmosis-labs/cosmos-sdk/releases/tag/v0.47.5-v21-osmo-6
github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.47.5-v21-osmo-6
github.com/cosmos/gogoproto => github.com/cosmos/gogoproto v1.4.10
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1

Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -738,8 +738,6 @@ github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZ
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
github.com/coinbase/rosetta-sdk-go/types v1.0.0 h1:jpVIwLcPoOeCR6o1tU+Xv7r5bMONNbHU7MuEHboiFuA=
github.com/coinbase/rosetta-sdk-go/types v1.0.0/go.mod h1:eq7W2TMRH22GTW0N0beDnN931DW0/WOI1R2sdHNHG4c=
github.com/cometbft/cometbft v0.37.2 h1:XB0yyHGT0lwmJlFmM4+rsRnczPlHoAKFX6K8Zgc2/Jc=
github.com/cometbft/cometbft v0.37.2/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs=
github.com/cometbft/cometbft-db v0.8.0 h1:vUMDaH3ApkX8m0KZvOFFy9b5DZHBAjsnEuo9AKVZpjo=
github.com/cometbft/cometbft-db v0.8.0/go.mod h1:6ASCP4pfhmrCBpfk01/9E1SI29nD3HfVHrY4PG8x5c0=
github.com/confio/ics23/go v0.9.1 h1:3MV46eeWwO3xCauKyAtuAdJYMyPnnchW4iLr2bTw6/U=
Expand Down Expand Up @@ -1453,8 +1451,10 @@ github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnh
github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA=
github.com/ory/dockertest/v3 v3.10.0 h1:4K3z2VMe8Woe++invjaTB7VRyQXQy5UY+loujO4aNE4=
github.com/ory/dockertest/v3 v3.10.0/go.mod h1:nr57ZbRWMqfsdGdFNLHz5jjNdDb7VVFnzAeW1n5N1Lg=
github.com/osmosis-labs/cosmos-sdk v0.47.6-0.20240103225327-6652b67a6ae8 h1:rKsGBYTfP0XMsEddGJhBkVtQZeeGMwjZ47U69Y5G4ic=
github.com/osmosis-labs/cosmos-sdk v0.47.6-0.20240103225327-6652b67a6ae8/go.mod h1:EHwCeN9IXonsjKcjpS12MqeStdZvIdxt3VYXhus3G3c=
github.com/osmosis-labs/cometbft v0.0.0-20240103055822-28da358e3146 h1:Qkshh58fZCRoHSzbyW8NJf1wBhf9bg1MPFZEuyuI9lE=
github.com/osmosis-labs/cometbft v0.0.0-20240103055822-28da358e3146/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs=
github.com/osmosis-labs/cosmos-sdk v0.47.5-v21-osmo-6 h1:80nco4oGzcrS5XGdg6UoAKn961Ra9UpE+W9YvBJ2h2E=
github.com/osmosis-labs/cosmos-sdk v0.47.5-v21-osmo-6/go.mod h1:4BNXIoS9XecywMSdPr/DIwCgH2/Qjyr2+qhrHu8YSEo=
github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3 h1:YlmchqTmlwdWSmrRmXKR+PcU96ntOd8u10vTaTZdcNY=
github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3/go.mod h1:lV6KnqXYD/ayTe7310MHtM3I2q8Z6bBfMAi+bhwPYtI=
github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20240108180923-ddfef98789fd h1:99/1YpOf9+hMH2u1AGUGTNlzcpdduUm6kgZER6/yoyY=
Expand Down
6 changes: 3 additions & 3 deletions osmomath/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ replace (
// v1.0.0-beta.3 is incompatible, so we use v1.0.0-beta.2
github.com/cosmos/cosmos-proto => github.com/cosmos/cosmos-proto v1.0.0-beta.2

// Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk/tree/osmo/v0.47.5, current branch: osmo/v0.47.5. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/cc29414c72c73d567e0c75b4a0800961a26d7af4
// https://github.com/osmosis-labs/cosmos-sdk/releases/tag/v0.47.5-osmo-4
github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.47.6-0.20240103225327-6652b67a6ae8
// Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk/tree/osmo/v0.47.5, current branch: osmo/v0.47.5. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/65d7acfdc2a94cc49837bb9abec462f129029540
// https://github.com/osmosis-labs/cosmos-sdk/releases/tag/v0.47.5-v21-osmo-6
github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.47.5-v21-osmo-6
github.com/cosmos/gogoproto => github.com/cosmos/gogoproto v1.4.10
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1

Expand Down
9 changes: 6 additions & 3 deletions osmoutils/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ replace (
// v1.0.0-beta.3 is incompatible, so we use v1.0.0-beta.2
github.com/cosmos/cosmos-proto => github.com/cosmos/cosmos-proto v1.0.0-beta.2

// Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk/tree/osmo/v0.47.5, current branch: osmo/v0.47.5. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/cc29414c72c73d567e0c75b4a0800961a26d7af4
// https://github.com/osmosis-labs/cosmos-sdk/releases/tag/v0.47.5-osmo-4
github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.47.6-0.20240103225327-6652b67a6ae8
// Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk/tree/osmo/v0.47.5, current branch: osmo/v0.47.5. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/65d7acfdc2a94cc49837bb9abec462f129029540
// https://github.com/osmosis-labs/cosmos-sdk/releases/tag/v0.47.5-v21-osmo-6
github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.47.5-v21-osmo-6
github.com/cosmos/gogoproto => github.com/cosmos/gogoproto v1.4.10
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1

Expand All @@ -177,6 +177,9 @@ replace (
// newer versions of exp treat sorting differently, which is incompatible with the current version of cosmos-sdk
golang.org/x/exp => golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb

// fork of cometbft which allows for better app hash logging
github.com/cometbft/cometbft => github.com/osmosis-labs/cometbft v0.0.0-20240103055822-28da358e3146

// Local replaces commented for development
// github.com/osmosis-labs/osmosis/osmomath => ../osmomath
// github.com/osmosis-labs/osmosis/v21 => ./../
Expand Down
9 changes: 6 additions & 3 deletions x/epochs/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,18 @@ replace (
// v1.0.0-beta.3 is incompatible, so we use v1.0.0-beta.2
github.com/cosmos/cosmos-proto => github.com/cosmos/cosmos-proto v1.0.0-beta.2

// Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk/tree/osmo/v0.47.5, current branch: osmo/v0.47.5. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/cc29414c72c73d567e0c75b4a0800961a26d7af4
// https://github.com/osmosis-labs/cosmos-sdk/releases/tag/v0.47.5-osmo-4
github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.47.6-0.20240103225327-6652b67a6ae8
// Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk/tree/osmo/v0.47.5, current branch: osmo/v0.47.5. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/65d7acfdc2a94cc49837bb9abec462f129029540
// https://github.com/osmosis-labs/cosmos-sdk/releases/tag/v0.47.5-v21-osmo-6
github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.47.5-v21-osmo-6
github.com/cosmos/gogoproto => github.com/cosmos/gogoproto v1.4.10
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1

// newer versions of exp treat sorting differently, which is incompatible with the current version of cosmos-sdk
golang.org/x/exp => golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb

// fork of cometbft which allows for better app hash logging
github.com/cometbft/cometbft => github.com/osmosis-labs/cometbft v0.0.0-20240103055822-28da358e3146

// Local replaces commented for development
// github.com/osmosis-labs/osmosis/osmoutils => ../../osmoutils
)
12 changes: 6 additions & 6 deletions x/ibc-hooks/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,6 @@ replace (
// adds expedited proposal support and 1000MB cache default
// https://github.com/osmosis-labs/wasmd/releases/tag/v0.45.0-osmo
github.com/CosmWasm/wasmd => github.com/osmosis-labs/wasmd v0.45.0-osmo
// Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk/tree/osmo/v0.47.5, current branch: osmo/v0.47.5. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/cc29414c72c73d567e0c75b4a0800961a26d7af4
// https://github.com/osmosis-labs/cosmos-sdk/releases/tag/v0.47.5-osmo-4
github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.47.6-0.20240103225327-6652b67a6ae8

github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1

Expand All @@ -206,15 +203,18 @@ replace (

// v1.0.0-beta.3 is incompatible, so we use v1.0.0-beta.2
github.com/cosmos/cosmos-proto => github.com/cosmos/cosmos-proto v1.0.0-beta.2
// Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk/tree/osmo/v0.47.5, current branch: osmo/v0.47.5. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/cc29414c72c73d567e0c75b4a0800961a26d7af4
// https://github.com/osmosis-labs/cosmos-sdk/releases/tag/v0.47.5-osmo-4
github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.47.6-0.20240103225327-6652b67a6ae8
// Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk/tree/osmo/v0.47.5, current branch: osmo/v0.47.5. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/65d7acfdc2a94cc49837bb9abec462f129029540
// https://github.com/osmosis-labs/cosmos-sdk/releases/tag/v0.47.5-v21-osmo-6
github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.47.5-v21-osmo-6
github.com/cosmos/gogoproto => github.com/cosmos/gogoproto v1.4.10
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1

// newer versions of exp treat sorting differently, which is incompatible with the current version of cosmos-sdk
golang.org/x/exp => golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb

// fork of cometbft which allows for better app hash logging
github.com/cometbft/cometbft => github.com/osmosis-labs/cometbft v0.0.0-20240103055822-28da358e3146

// Local replaces commented for development
// github.com/osmosis-labs/osmosis/osmoutils => ../../osmoutils
// github.com/osmosis-labs/osmosis/v19 => ./../
Expand Down
15 changes: 15 additions & 0 deletions x/txfees/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/osmosis-labs/osmosis/v21/x/txfees/types"

storetypes "github.com/cosmos/cosmos-sdk/store/types"

tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
)

type Keeper struct {
Expand All @@ -21,6 +23,7 @@ type Keeper struct {
poolManager types.PoolManager
protorevKeeper types.ProtorevKeeper
distributionKeeper types.DistributionKeeper
consensusKeeper types.ConsensusKeeper
dataDir string
}

Expand All @@ -33,6 +36,7 @@ func NewKeeper(
poolManager types.PoolManager,
protorevKeeper types.ProtorevKeeper,
distributionKeeper types.DistributionKeeper,
consensusKeeper types.ConsensusKeeper,
dataDir string,
) Keeper {
return Keeper{
Expand All @@ -42,6 +46,7 @@ func NewKeeper(
poolManager: poolManager,
protorevKeeper: protorevKeeper,
distributionKeeper: distributionKeeper,
consensusKeeper: consensusKeeper,
dataDir: dataDir,
}
}
Expand All @@ -54,3 +59,13 @@ func (k Keeper) GetFeeTokensStore(ctx sdk.Context) sdk.KVStore {
store := ctx.KVStore(k.storeKey)
return prefix.NewStore(store, types.FeeTokensStorePrefix)
}

// GetParamsNoUnmarshal returns the current consensus parameters from the consensus params store as raw bytes.
func (k Keeper) GetParamsNoUnmarshal(ctx sdk.Context) []byte {
return k.consensusKeeper.GetParamsNoUnmarshal(ctx)
}

// UnmarshalParamBytes unmarshals the consensus params bytes to the consensus params type.
func (k Keeper) UnmarshalParamBytes(ctx sdk.Context, bz []byte) (*tmproto.ConsensusParams, error) {
return k.consensusKeeper.UnmarshalParamBytes(ctx, bz)
}
5 changes: 3 additions & 2 deletions x/txfees/keeper/mempool-1559/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ var (

// Max increase per block is a factor of 1.06, max decrease is 9/10
// If recovering at ~30M gas per block, decrease is .94
MaxBlockChangeRate = sdk.NewDec(1).Quo(sdk.NewDec(10))
TargetGas = int64(75_000_000)
MaxBlockChangeRate = sdk.NewDec(1).Quo(sdk.NewDec(10))
TargetGas = int64(187_500_000)
TargetBlockSpacePercent = sdk.MustNewDecFromStr("0.625")
// In face of continuous spam, will take ~19 blocks from base fee > spam cost, to mempool eviction
// ceil(log_{1.06}(RecheckFeeConstant))
// So potentially 1.8 minutes of impaired UX from 1559 nodes on top of time to get to base fee > spam.
Expand Down
60 changes: 58 additions & 2 deletions x/txfees/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ only specify their tx fee parameters for a single "base" asset.
package txfees

import (
"bytes"
"context"
"encoding/json"
"fmt"
Expand All @@ -31,8 +32,9 @@ import (
)

var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
cachedConsParamBytes []byte
)

const ModuleName = types.ModuleName
Expand Down Expand Up @@ -151,6 +153,10 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
// BeginBlock executes all ABCI BeginBlock logic respective to the txfees module.
func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {
mempool1559.BeginBlockCode(ctx)

// Check if the block gas limit has changed.
// If it has, update the target gas for eip1559.
am.CheckAndSetTargetGas(ctx)
}

// EndBlock executes all ABCI EndBlock logic respective to the txfees module. It
Expand All @@ -162,3 +168,53 @@ func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Val

// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 1 }

// On start, we unmarshal the consensus params once and cache them.
// Then, on every block, we check if the current consensus param bytes have changed in comparison to the cached value.
// If they have, we unmarshal the current consensus params, update the target gas, and cache the value.
// This is done to improve performance by not having to fetch and unmarshal the consensus params on every block.
func (am AppModule) CheckAndSetTargetGas(ctx sdk.Context) {
// Check if the block gas limit has changed.
// If it has, update the target gas for eip1559.
consParamsBytes := am.keeper.GetParamsNoUnmarshal(ctx)

// If cachedConsParamBytes is nil, set equal to consParamsBytes and set the target gas.
if cachedConsParamBytes == nil {
cachedConsParamBytes = consParamsBytes
newConsensusParams, err := am.keeper.UnmarshalParamBytes(ctx, consParamsBytes)
if err != nil {
panic(err)
}

// Check if newConsensusParams.Block is nil to prevent panic
if newConsensusParams.Block == nil || newConsensusParams.Block.MaxGas == 0 {
return
}

if newConsensusParams.Block.MaxGas == -1 {
return
}

newBlockMaxGas := mempool1559.TargetBlockSpacePercent.Mul(sdk.NewDec(newConsensusParams.Block.MaxGas)).TruncateInt().Int64()
mempool1559.TargetGas = newBlockMaxGas
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't right, it should be max gas times .625

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done here d148048

return
}

// If the consensus params have changed, unmarshal and update the target gas.
if !bytes.Equal(consParamsBytes, cachedConsParamBytes) {
newConsensusParams, err := am.keeper.UnmarshalParamBytes(ctx, consParamsBytes)
if err != nil {
panic(err)
}

if newConsensusParams.Block.MaxGas == -1 {
return
}

// Sure, its possible that the thing that changes in consensus params was something other than the block gas limit,
// but just double setting it here is fine instead of doing more logic to see what actually changed.
newBlockMaxGas := mempool1559.TargetBlockSpacePercent.Mul(sdk.NewDec(newConsensusParams.Block.MaxGas)).TruncateInt().Int64()
mempool1559.TargetGas = newBlockMaxGas
cachedConsParamBytes = consParamsBytes
}
}
Loading