Skip to content

Commit 8885265

Browse files
author
yihuang
authored
Problem: need hardfork to adjust feemarket parameters (#1259)
Update CHANGELOG.md Signed-off-by: yihuang <[email protected]> parameters add dry-run upgrade dry-run upgrade height
1 parent 20c170f commit 8885265

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## UNRELEASED
4+
5+
- [#1259](https://github.com/crypto-org-chain/cronos/pull/1259) Use a hard-fork style upgrade to adjust feemarket parameters.
6+
37
*Nov 20, 2023*
48

59
## v1.0.13

app/app.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,8 @@ func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.R
854854
panic("halt application")
855855
}
856856

857+
BeginBlockForks(ctx, app)
858+
857859
return app.mm.BeginBlock(ctx, req)
858860
}
859861

app/forks.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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

Comments
 (0)