Skip to content

Commit

Permalink
fix: fix the breaking change of genesis state for testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
yutianwu committed Jan 17, 2023
1 parent 39fb95f commit b0109bc
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 37 deletions.
4 changes: 4 additions & 0 deletions types/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import (
"github.com/tendermint/tendermint/libs/log"
)

const (
ChainIdGanges = "Binance-Chain-Ganges"
)

type Context struct {
ctx context.Context
ms MultiStore
Expand Down
12 changes: 6 additions & 6 deletions x/paramHub/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,19 @@ const (
IOCExpireFeeNative = 5e3

// cross chain
CrossBindFee = 1e8
CrossUnbindFee = 1e8
CrossTransferOutFee = 2e4
CrossBindFee = 1e6
CrossUnbindFee = 1e6
CrossTransferOutFee = 1e6

CrossTransferOutRelayFee = 1e5
CrossTransferOutRelayFee = 2e6
CrossBindRelayFee = 2e6
CrossUnbindRelayFee = 2e6

//MiniToken fee
TinyIssueFee = 2e8
MiniIssueFee = 3e8
MiniIssueFee = 4e8
MiniSetUriFee = 37500
MiniListingFee = 8e8
MiniListingFee = 10e8

// Cross stake fee
CrossDistributeRewardRelayFee = 6e5 // 0.006 BNB
Expand Down
95 changes: 68 additions & 27 deletions x/paramHub/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,41 +34,82 @@ func RegisterUpgradeBeginBlocker(paramHub *ParamHub) {
paramHub.UpdateFeeParams(ctx, swapFeeParams)
})
sdk.UpgradeMgr.RegisterBeginBlocker(sdk.LaunchBscUpgrade, func(ctx sdk.Context) {
updateFeeParams := []param.FeeParam{
&param.FixedFeeParams{MsgType: "side_create_validator", Fee: CreateSideChainValidatorFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "side_edit_validator", Fee: EditSideChainValidatorFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "side_delegate", Fee: SideChainDelegateFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "side_redelegate", Fee: SideChainRedelegateFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "side_undelegate", Fee: SideChainUndelegateFee, FeeFor: sdk.FeeForProposer},
println("-=================-")
println(ctx.ChainID())
if ctx.ChainID() == sdk.ChainIdGanges {
updateFeeParams := []param.FeeParam{
&param.FixedFeeParams{MsgType: "side_create_validator", Fee: CreateSideChainValidatorFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "side_edit_validator", Fee: EditSideChainValidatorFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "side_delegate", Fee: SideChainDelegateFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "side_redelegate", Fee: SideChainRedelegateFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "side_undelegate", Fee: SideChainUndelegateFee, FeeFor: sdk.FeeForProposer},

&param.FixedFeeParams{MsgType: "bsc_submit_evidence", Fee: BscSubmitEvidenceFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "side_chain_unjail", Fee: SideChainUnjail, FeeFor: sdk.FeeForProposer},

&param.FixedFeeParams{MsgType: "side_submit_proposal", Fee: SideProposeFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "side_deposit", Fee: SideDepositFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "side_vote", Fee: SideVoteFee, FeeFor: sdk.FeeForProposer},

&param.FixedFeeParams{MsgType: "bsc_submit_evidence", Fee: BscSubmitEvidenceFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "side_chain_unjail", Fee: SideChainUnjail, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "crossBind", Fee: 1e6, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "crossUnbind", Fee: 1e6, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "crossTransferOut", Fee: 1e6, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "oracleClaim", Fee: sdk.ZeroFee, FeeFor: sdk.FeeFree},

&param.FixedFeeParams{MsgType: "side_submit_proposal", Fee: SideProposeFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "side_deposit", Fee: SideDepositFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "side_vote", Fee: SideVoteFee, FeeFor: sdk.FeeForProposer},
// Following fees are charged on BC, and received at BSC, they are still fees in a broad sense, so still
// decide to put it here, rather than in paramset.
&param.FixedFeeParams{MsgType: "crossBindRelayFee", Fee: CrossBindRelayFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "crossUnbindRelayFee", Fee: CrossUnbindRelayFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "crossTransferOutRelayFee", Fee: 2e6, FeeFor: sdk.FeeForProposer},
}
paramHub.UpdateFeeParams(ctx, updateFeeParams)
} else {
updateFeeParams := []param.FeeParam{
&param.FixedFeeParams{MsgType: "side_create_validator", Fee: CreateSideChainValidatorFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "side_edit_validator", Fee: EditSideChainValidatorFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "side_delegate", Fee: SideChainDelegateFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "side_redelegate", Fee: SideChainRedelegateFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "side_undelegate", Fee: SideChainUndelegateFee, FeeFor: sdk.FeeForProposer},

&param.FixedFeeParams{MsgType: "crossBind", Fee: CrossBindFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "crossUnbind", Fee: CrossUnbindFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "crossTransferOut", Fee: CrossTransferOutFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "oracleClaim", Fee: sdk.ZeroFee, FeeFor: sdk.FeeFree},
&param.FixedFeeParams{MsgType: "bsc_submit_evidence", Fee: BscSubmitEvidenceFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "side_chain_unjail", Fee: SideChainUnjail, FeeFor: sdk.FeeForProposer},

// Following fees are charged on BC, and received at BSC, they are still fees in a broad sense, so still
// decide to put it here, rather than in paramset.
&param.FixedFeeParams{MsgType: "crossBindRelayFee", Fee: CrossBindRelayFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "crossUnbindRelayFee", Fee: CrossUnbindRelayFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "crossTransferOutRelayFee", Fee: CrossTransferOutRelayFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "side_submit_proposal", Fee: SideProposeFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "side_deposit", Fee: SideDepositFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "side_vote", Fee: SideVoteFee, FeeFor: sdk.FeeForProposer},

&param.FixedFeeParams{MsgType: "crossBind", Fee: CrossBindFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "crossUnbind", Fee: CrossUnbindFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "crossTransferOut", Fee: CrossTransferOutFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "oracleClaim", Fee: sdk.ZeroFee, FeeFor: sdk.FeeFree},

// Following fees are charged on BC, and received at BSC, they are still fees in a broad sense, so still
// decide to put it here, rather than in paramset.
&param.FixedFeeParams{MsgType: "crossBindRelayFee", Fee: CrossBindRelayFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "crossUnbindRelayFee", Fee: CrossUnbindRelayFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "crossTransferOutRelayFee", Fee: CrossTransferOutRelayFee, FeeFor: sdk.FeeForProposer},
}
paramHub.UpdateFeeParams(ctx, updateFeeParams)
}
paramHub.UpdateFeeParams(ctx, updateFeeParams)
})
sdk.UpgradeMgr.RegisterBeginBlocker(sdk.BEP8, func(ctx sdk.Context) {
miniTokenFeeParams := []param.FeeParam{
&param.FixedFeeParams{MsgType: "tinyIssueMsg", Fee: TinyIssueFee, FeeFor: sdk.FeeForAll},
&param.FixedFeeParams{MsgType: "miniIssueMsg", Fee: MiniIssueFee, FeeFor: sdk.FeeForAll},
&param.FixedFeeParams{MsgType: "miniTokensSetURI", Fee: MiniSetUriFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "dexListMini", Fee: MiniListingFee, FeeFor: sdk.FeeForAll},
if ctx.ChainID() == sdk.ChainIdGanges {
miniTokenFeeParams := []param.FeeParam{
&param.FixedFeeParams{MsgType: "tinyIssueMsg", Fee: TinyIssueFee, FeeFor: sdk.FeeForAll},
&param.FixedFeeParams{MsgType: "miniIssueMsg", Fee: 4e8, FeeFor: sdk.FeeForAll},
&param.FixedFeeParams{MsgType: "miniTokensSetURI", Fee: MiniSetUriFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "dexListMini", Fee: 10e8, FeeFor: sdk.FeeForAll},
}
paramHub.UpdateFeeParams(ctx, miniTokenFeeParams)
} else {
miniTokenFeeParams := []param.FeeParam{
&param.FixedFeeParams{MsgType: "tinyIssueMsg", Fee: TinyIssueFee, FeeFor: sdk.FeeForAll},
&param.FixedFeeParams{MsgType: "miniIssueMsg", Fee: MiniIssueFee, FeeFor: sdk.FeeForAll},
&param.FixedFeeParams{MsgType: "miniTokensSetURI", Fee: MiniSetUriFee, FeeFor: sdk.FeeForProposer},
&param.FixedFeeParams{MsgType: "dexListMini", Fee: MiniListingFee, FeeFor: sdk.FeeForAll},
}
paramHub.UpdateFeeParams(ctx, miniTokenFeeParams)
}
paramHub.UpdateFeeParams(ctx, miniTokenFeeParams)
})
sdk.UpgradeMgr.RegisterBeginBlocker(sdk.BEP82, func(ctx sdk.Context) {
updateFeeParams := []param.FeeParam{
Expand Down
2 changes: 1 addition & 1 deletion x/stake/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package stake
import (
"fmt"

"github.com/pkg/errors"
abci "github.com/tendermint/tendermint/abci/types"
tmtypes "github.com/tendermint/tendermint/types"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/stake/types"
"github.com/pkg/errors"
)

// InitGenesis sets the pool and parameters for the provided keeper and
Expand Down
13 changes: 10 additions & 3 deletions x/stake/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package keeper
import (
"time"

"github.com/tendermint/tendermint/crypto"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/params"
"github.com/cosmos/cosmos-sdk/x/stake/types"
"github.com/tendermint/tendermint/crypto"
)

// Default parameter namespace
Expand Down Expand Up @@ -161,8 +162,14 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
k.paramstore.Set(ctx, types.KeyMaxValidators, params.MaxValidators)
k.paramstore.Set(ctx, types.KeyBondDenom, params.BondDenom)
if sdk.IsUpgrade(sdk.LaunchBscUpgrade) {
k.paramstore.Set(ctx, types.KeyMinSelfDelegation, params.MinSelfDelegation)
k.paramstore.Set(ctx, types.KeyMinDelegationChange, params.MinDelegationChange)
if ctx.ChainID() == sdk.ChainIdGanges {
k.paramstore.Set(ctx, types.KeyMaxValidators, uint16(11))
k.paramstore.Set(ctx, types.KeyMinSelfDelegation, int64(5000000000000))
k.paramstore.Set(ctx, types.KeyMinDelegationChange, params.MinDelegationChange)
} else {
k.paramstore.Set(ctx, types.KeyMinSelfDelegation, params.MinSelfDelegation)
k.paramstore.Set(ctx, types.KeyMinDelegationChange, params.MinDelegationChange)
}
}
if sdk.IsUpgrade(sdk.BEP128) {
k.paramstore.Set(ctx, types.KeyRewardDistributionBatchSize, params.RewardDistributionBatchSize)
Expand Down

0 comments on commit b0109bc

Please sign in to comment.