From e3a09418255b6f00d5f4f59756e2fe79b81ff0f6 Mon Sep 17 00:00:00 2001 From: j75689 Date: Fri, 22 Dec 2023 14:55:51 +0800 Subject: [PATCH] feat: set syncFee to 0.05bnb after FirstSunsetFork --- x/paramHub/keeper/keeper.go | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/x/paramHub/keeper/keeper.go b/x/paramHub/keeper/keeper.go index b01d2db10..f0b15571d 100644 --- a/x/paramHub/keeper/keeper.go +++ b/x/paramHub/keeper/keeper.go @@ -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" @@ -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 ( @@ -130,6 +133,30 @@ func (keeper *Keeper) EndBreatheBlock(ctx sdk.Context) { return } +func (keeper *Keeper) SetSyncFeeAfterFirstSunsetFork(ctx sdk.Context) error { + 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]}) + } + } + + return nil +} + func (keeper *Keeper) EndBlock(ctx sdk.Context) { log := keeper.Logger(ctx) log.Info("Sync params proposals.")