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

chore: update more default parameters #2417

Merged
merged 15 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
4 changes: 2 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ var (
newGovModule(),
params.AppModuleBasic{},
crisisModule{},
slashing.AppModuleBasic{},
slashingModule{},
authzmodule.AppModuleBasic{},
feegrantmodule.AppModuleBasic{},
ibc.AppModuleBasic{},
ibcModule{},
evidence.AppModuleBasic{},
transfer.AppModuleBasic{},
vesting.AppModuleBasic{},
Expand Down
56 changes: 54 additions & 2 deletions app/default_overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ import (
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
"github.com/cosmos/cosmos-sdk/x/slashing"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
ibc "github.com/cosmos/ibc-go/v6/modules/core"
ibcclientclient "github.com/cosmos/ibc-go/v6/modules/core/02-client/client"
ibctypes "github.com/cosmos/ibc-go/v6/modules/core/types"
tmcfg "github.com/tendermint/tendermint/config"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
coretypes "github.com/tendermint/tendermint/types"
Expand Down Expand Up @@ -75,12 +79,33 @@ func (stakingModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
params := stakingtypes.DefaultParams()
params.UnbondingTime = appconsts.DefaultUnbondingTime
params.BondDenom = BondDenom
params.MinCommissionRate = sdk.NewDecWithPrec(5, 2) // 5%

return cdc.MustMarshalJSON(&stakingtypes.GenesisState{
Params: params,
})
}

// stakingModule wraps the x/staking module in order to overwrite specific
// ModuleManager APIs.
type slashingModule struct {
slashing.AppModuleBasic
}

// DefaultGenesis returns custom x/staking module genesis state.
func (slashingModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
params := slashingtypes.DefaultParams()
params.MinSignedPerWindow = sdk.NewDecWithPrec(5, 2) // 5%
evan-forbes marked this conversation as resolved.
Show resolved Hide resolved
params.SignedBlocksWindow = 15000
evan-forbes marked this conversation as resolved.
Show resolved Hide resolved
params.DowntimeJailDuration = time.Minute * 1
evan-forbes marked this conversation as resolved.
Show resolved Hide resolved
params.SlashFractionDoubleSign = sdk.NewDecWithPrec(5, 2) // 5%
params.SlashFractionDowntime = sdk.NewDecWithPrec(1, 2) // 1%

return cdc.MustMarshalJSON(&slashingtypes.GenesisState{
Params: params,
})
}

type crisisModule struct {
crisis.AppModuleBasic
}
Expand All @@ -92,6 +117,24 @@ func (crisisModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
})
}

type ibcModule struct {
ibc.AppModuleBasic
}

// DefaultGenesis returns custom x/crisis module genesis state.
evan-forbes marked this conversation as resolved.
Show resolved Hide resolved
func (ibcModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
// per ibc documentation, this value should be 3-5 times the expected block
// time. The expected block time is 15 seconds, therefore this value is 75
// seconds.
maxBlockTime := appconsts.GoalBlockTime * 5
gs := ibctypes.DefaultGenesisState()
gs.ClientGenesis.Params.AllowedClients = []string{"06-solomachine", "07-tendermint"}
gs.ConnectionGenesis.Params.MaxExpectedTimePerBlock = uint64(maxBlockTime.Nanoseconds())
evan-forbes marked this conversation as resolved.
Show resolved Hide resolved
return cdc.MustMarshalJSON(&ibctypes.GenesisState{
ClientGenesis: ibctypes.DefaultGenesisState().ClientGenesis,
})
}

type mintModule struct {
mint.AppModuleBasic
}
Expand All @@ -117,7 +160,7 @@ type govModule struct {
// DefaultGenesis returns custom x/gov module genesis state.
func (govModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
genState := govtypes.DefaultGenesisState()
genState.DepositParams.MinDeposit = sdk.NewCoins(sdk.NewCoin(BondDenom, sdk.NewInt(10000000)))
genState.DepositParams.MinDeposit = sdk.NewCoins(sdk.NewCoin(BondDenom, sdk.NewInt(1_000_000_000))) // 1000 TIA

return cdc.MustMarshalJSON(genState)
}
Expand All @@ -138,7 +181,7 @@ func getLegacyProposalHandlers() (result []govclient.ProposalHandler) {
func DefaultConsensusParams() *tmproto.ConsensusParams {
return &tmproto.ConsensusParams{
Block: DefaultBlockParams(),
Evidence: coretypes.DefaultEvidenceParams(),
Evidence: DefaultEvidenceParams(),
Validator: coretypes.DefaultValidatorParams(),
Version: tmproto.VersionParams{
AppVersion: appconsts.LatestVersion,
Expand All @@ -156,6 +199,15 @@ func DefaultBlockParams() tmproto.BlockParams {
}
}

// DefaultEvidenceParams returns a default EvidenceParams with a MaxAge
// determined using a goal block time.
func DefaultEvidenceParams() tmproto.EvidenceParams {
evdParams := coretypes.DefaultEvidenceParams()
evdParams.MaxAgeDuration = appconsts.DefaultUnbondingTime
evdParams.MaxAgeNumBlocks = int64(appconsts.DefaultUnbondingTime.Seconds())/int64(appconsts.GoalBlockTime.Seconds()) + 1
evan-forbes marked this conversation as resolved.
Show resolved Hide resolved
return evdParams
}

func DefaultConsensusConfig() *tmcfg.Config {
cfg := tmcfg.DefaultConfig()
// Set broadcast timeout to be 50 seconds in order to avoid timeouts for long block times
Expand Down
1 change: 1 addition & 0 deletions pkg/appconsts/consensus_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ import "time"
const (
TimeoutPropose = time.Second * 10
TimeoutCommit = time.Second * 11
GoalBlockTime = time.Second * 15
evan-forbes marked this conversation as resolved.
Show resolved Hide resolved
)
Loading