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

add MercuryHeight #163

Merged
merged 2 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,9 @@ func (app *OKBChainApp) InitUpgrade(ctx sdk.Context) {
app.ParamsKeeper.ClaimReadyForUpgrade(tmtypes.MILESTONE_EARTH, func(info paramstypes.UpgradeInfo) {
tmtypes.InitMilestoneEarthHeight(int64(info.EffectiveHeight))
})
app.ParamsKeeper.ClaimReadyForUpgrade(tmtypes.MILESTONE_MERCURY, func(info paramstypes.UpgradeInfo) {
tmtypes.InitMilestoneMercuryHeight(int64(info.EffectiveHeight))
})
if err := app.ParamsKeeper.ApplyEffectiveUpgrade(ctx); err != nil {
tmos.Exit(fmt.Sprintf("failed apply effective upgrade height info: %s", err))
}
Expand Down
2 changes: 1 addition & 1 deletion app/refund/refund.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func gasRefund(ik innertx.InnerTxKeeper, ak accountKeeperInterface, sk types.Sup
return nil, nil
}

if tmtypes.HigherThanEarth(ctx.BlockHeight()) {
if tmtypes.HigherThanMercury(ctx.BlockHeight()) {
if ctx.GetOutOfGas() {
ctx.GasMeter().SetGas(ctx.GasMeter().Limit())
currentGasMeter.SetGas(gasLimit)
Expand Down
2 changes: 1 addition & 1 deletion libs/cosmos-sdk/baseapp/baseapp_runtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (app *BaseApp) runtxWithInfo(info *runTxInfo, mode runTxMode, txBytes []byt
tx.GetType() == sdk.EvmTxType {
handler.handleDeferRefund(info)
} else {
if tmtypes.HigherThanEarth(info.ctx.BlockHeight()) {
if tmtypes.HigherThanMercury(info.ctx.BlockHeight()) {
info.ctx.GasMeter().SetGas(info.ctx.GasMeter().Limit())
}
}
Expand Down
38 changes: 34 additions & 4 deletions libs/tendermint/types/milestone.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import (
// 4. ibc

var (
milestoneEarthHeight int64
milestoneVenus4Height int64
milestoneEarthHeight int64
milestoneVenus4Height int64
milestoneMercuryHeight int64

// note: it stores the earlies height of the node,and it is used by cli
nodePruneHeight int64
Expand All @@ -22,8 +23,9 @@ const (
MainNet = system.Chain + "-196"
TestNet = system.TestnetPrefix + "-195"

MILESTONE_EARTH = "earth"
MILESTONE_Venus4 = "venus4"
MILESTONE_EARTH = "earth"
MILESTONE_Venus4 = "venus4"
MILESTONE_MERCURY = "mercury"
)

func SetupMainNetEnvironment(pruneH int64) {
Expand Down Expand Up @@ -109,3 +111,31 @@ func GetVenus4Height() int64 {

// =========== Venus4 ===============
// ==================================

// ==================================
// =========== Mercury ===============
func UnittestOnlySetMilestoneMercuryHeight(h int64) {
milestoneEarthHeight = h
}

func SetMilestoneMercuryHeight(h int64) {
milestoneMercuryHeight = h
}

func HigherThanMercury(h int64) bool {
if milestoneMercuryHeight == 0 {
return false
}
return h >= milestoneMercuryHeight
}

func GetMercuryHeight() int64 {
return milestoneMercuryHeight
}

func InitMilestoneMercuryHeight(h int64) {
milestoneMercuryHeight = h
}

// =========== Mercury ===============
// ==================================