|
| 1 | +package app |
| 2 | + |
| 3 | +import sdk "github.com/cosmos/cosmos-sdk/types" |
| 4 | + |
| 5 | +var Forks = []Fork{ |
| 6 | + ForkV1Mainnnet, |
| 7 | + ForkV1Dryrun, |
| 8 | +} |
| 9 | + |
| 10 | +// Fork defines a struct containing the requisite fields for a non-software upgrade proposal |
| 11 | +// Hard Fork at a given height to implement. |
| 12 | +// There is one time code that can be added for the start of the Fork, in `BeginForkLogic`. |
| 13 | +// Any other change in the code should be height-gated, if the goal is to have old and new binaries |
| 14 | +// to be compatible prior to the upgrade height. |
| 15 | +// |
| 16 | +// Adapted from osmosis: https://github.com/osmosis-labs/osmosis/blob/057192c2c0949fde5673a5f314bf41816f808fd9/app/upgrades/types.go#L40 |
| 17 | +type Fork struct { |
| 18 | + // Upgrade version name, for the upgrade handler, e.g. `v7` |
| 19 | + UpgradeName string |
| 20 | + // height the upgrade occurs at |
| 21 | + UpgradeHeight int64 |
| 22 | + // chain-id the upgrade occurs at |
| 23 | + UpgradeChainId string |
| 24 | + |
| 25 | + // Function that runs some custom state transition code at the beginning of a fork. |
| 26 | + BeginForkLogic func(ctx sdk.Context, app *App) |
| 27 | +} |
| 28 | + |
| 29 | +// BeginBlockForks is intended to be ran in a chain upgrade. |
| 30 | +func BeginBlockForks(ctx sdk.Context, app *App) { |
| 31 | + for _, fork := range Forks { |
| 32 | + if ctx.BlockHeight() == fork.UpgradeHeight && ctx.ChainID() == fork.UpgradeChainId { |
| 33 | + fork.BeginForkLogic(ctx, app) |
| 34 | + return |
| 35 | + } |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +func ForkV1Logic(ctx sdk.Context, app *App) { |
| 40 | + params := app.FeeMarketKeeper.GetParams(ctx) |
| 41 | + params.BaseFeeChangeDenominator = 300 |
| 42 | + params.ElasticityMultiplier = 4 |
| 43 | + params.BaseFee = sdk.NewInt(10000000000000) |
| 44 | + params.MinGasPrice = sdk.NewDecWithPrec(10000, 9) |
| 45 | + app.FeeMarketKeeper.SetParams(ctx, params) |
| 46 | +} |
| 47 | + |
| 48 | +var ( |
| 49 | + ForkV1Mainnnet = Fork{ |
| 50 | + UpgradeName: "v1.0.x-base-fee", |
| 51 | + UpgradeHeight: 11608760, |
| 52 | + UpgradeChainId: "cronosmainnet_25-1", |
| 53 | + BeginForkLogic: ForkV1Logic, |
| 54 | + } |
| 55 | + ForkV1Dryrun = Fork{ |
| 56 | + UpgradeName: "v1.0.x-base-fee", |
| 57 | + UpgradeHeight: 5214180, |
| 58 | + UpgradeChainId: "tempcronosmainnet_28-1", |
| 59 | + BeginForkLogic: ForkV1Logic, |
| 60 | + } |
| 61 | +) |
0 commit comments