Skip to content

Commit

Permalink
feat: set syncFee to 0.05bnb after FirstSunsetFork
Browse files Browse the repository at this point in the history
  • Loading branch information
j75689 committed Dec 22, 2023
1 parent 2b34b1a commit 40b0074
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion x/paramHub/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ package keeper

import (
"fmt"
"math/big"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/tendermint/tendermint/libs/log"

"github.com/cosmos/cosmos-sdk/bsc/rlp"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -13,7 +17,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/params"
"github.com/cosmos/cosmos-sdk/x/sidechain"
sTypes "github.com/cosmos/cosmos-sdk/x/sidechain/types"
"github.com/tendermint/tendermint/libs/log"
)

var (
Expand Down Expand Up @@ -130,6 +133,28 @@ func (keeper *Keeper) EndBreatheBlock(ctx sdk.Context) {
return
}

func (keeper *Keeper) SetSyncFeeAfterFirstSunsetFork(ctx sdk.Context) {
log := keeper.Logger(ctx)
if sdk.IsUpgrade(sdk.FirstSunsetFork) && keeper.ScKeeper != nil {
log.Info("Set sync fee to 0.05 BNB after first sunset hardfork")
sideChainIds, storePrefixes := keeper.ScKeeper.GetAllSideChainPrefixes(ctx)
cscChanges := make([]types.CSCParamChange, 0, 1)
fee := new(big.Int).Mul(big.NewInt(5), big.NewInt(1e10))
fee = new(big.Int).Div(fee, big.NewInt(100))
cscChanges = append(cscChanges, types.CSCParamChange{
Key: "syncFee",
Value: "0.05",
Target: "0x0000000000000000000000000000000000001008",
ValueBytes: fee.FillBytes(make([]byte, 32)),
TargetBytes: common.HexToAddress("0x0000000000000000000000000000000000001008").Bytes(),
})
for idx := range storePrefixes {
sideChainCtx := ctx.WithSideChainKeyPrefix(storePrefixes[idx])
keeper.notifyOnUpdate(sideChainCtx, types.CSCParamChanges{Changes: cscChanges, ChainID: sideChainIds[idx]})
}
}
}

func (keeper *Keeper) EndBlock(ctx sdk.Context) {
log := keeper.Logger(ctx)
log.Info("Sync params proposals.")
Expand Down

0 comments on commit 40b0074

Please sign in to comment.