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 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
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
54 changes: 52 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(75, 2) // 75%
params.SignedBlocksWindow = 5000
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.ZeroDec() // 0%

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

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

type ibcModule struct {
ibc.AppModuleBasic
}

// DefaultGenesis returns custom x/ibc module genesis state.
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(gs)
}

type mintModule struct {
mint.AppModuleBasic
}
Expand All @@ -117,7 +158,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 +179,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 +197,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
2 changes: 1 addition & 1 deletion app/default_overrides_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func Test_newGovModule(t *testing.T) {

want := []types.Coin{{
Denom: BondDenom,
Amount: types.NewInt(10000000),
Amount: types.NewInt(1000000000),
}}

assert.Equal(t, want, govGenesisState.DepositParams.MinDeposit)
Expand Down
5 changes: 5 additions & 0 deletions pkg/appconsts/consensus_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ import "time"
const (
TimeoutPropose = time.Second * 10
TimeoutCommit = time.Second * 11
// GoalBlockTime is the target time interval between blocks. Since the block
// interval isn't enforced at consensus, the real block interval isn't
// guaranteed to exactly match GoalBlockTime. GoalBlockTime is currently targeted
// through static timeouts (i.e. TimeoutPropose, TimeoutCommit).
GoalBlockTime = time.Second * 15
)
14 changes: 7 additions & 7 deletions specs/src/specs/params.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ are blocked by the `x/paramfilter` module.
| consensus.block.MaxBytes | 1.88MiB | Governance parameter for the maximum size of the protobuf encoded block. | True |
| consensus.block.MaxGas | -1 | Maximum gas allowed per block (-1 is infinite). | True |
| consensus.block.TimeIotaMs | 1000 | Minimum time added to the time in the header each block. | False |
| consensus.evidence.MaxAgeNumBlocks | 100000 | The maximum number of blocks before evidence is considered invalid. This value will stop CometBFT from pruning block data. | True |
| consensus.evidence.MaxAgeNumBlocks | 120960 | The maximum number of blocks before evidence is considered invalid. This value will stop CometBFT from pruning block data. | True |
| consensus.evidence.MaxAgeDuration | 1814400000000000 (21 days) | The maximum age of evidence before it is considered invalid in nanoseconds. This value should be identical to the unbonding period. | True |
| consensus.evidence.MaxBytes | 1MiB | Maximum size in bytes used by evidence in a given block. | True |
| consensus.validator.PubKeyTypes | Ed25519 | The type of public key used by validators. | False |
| consensus.Version.AppVersion | 1 | Determines protocol rules used for a given height. Incremented by the application upon an upgrade. | False |
| distribution.communitytax | 2.0% | Percentage of the inflation sent to the community pool. | True |
| distribution.CommunityTax | 2.0% | Percentage of the inflation sent to the community pool. | True |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

| distribution.WithdrawAddrEnabled | true | Enables delegators to withdraw funds to a different address. | True |
| distribution.BaseProposerReward | 0 | Reward in the mint demonination for proposing a block. | True |
| distribution.BonusProposerReward | 0 | Extra reward in the mint denomination for proposers based on the voting power included in the commit. | True |
Expand All @@ -42,17 +42,17 @@ are blocked by the `x/paramfilter` module.
| ibc.Transfer.SendEnabled | true | Enable sending tokens via IBC. | True |
| ibc.Transfer.ReceiveEnabled | true | Enable receiving tokens via IBC. | True |
| slashing.SignedBlocksWindow | 5000 | The range of blocks used to count for downtime. | True |
| slashing.MinSignedPerWindow | 5 | Minumum signatures in the block. | True |
| slashing.DowntimeJailDuration | 10 mins | Duration of time a validator must stay jailed. | True |
| slashing.SlashFractionDoubleSign | 5.0% | Percentage slashed after a validator is jailed for downtime. | True |
| slashing.SlashFractionDowntime | 1.0% | Percentage slashed after a validator is jailed for downtime. | True |
| slashing.MinSignedPerWindow | 75.0% | The percentage of SignedBlocksWindow that must be signed not to get jailed. | True |
| slashing.DowntimeJailDuration | 1 min | Duration of time a validator must stay jailed. | True |
| slashing.SlashFractionDoubleSign | 5.0% | Percentage slashed after a validator is jailed for double signing. | True |
| slashing.SlashFractionDowntime | 0.0% | Percentage slashed after a validator is jailed for downtime. | True |
| staking.UnbondingTime | 1814400 (21 days) | Duration of time for unbonding in seconds. | False |
| staking.MaxValidators | 100 | Maximum number of validators. | False |
| staking.MaxEntries | 7 | Maximum number of entries in the redelegation queue. | True |
| staking.HistoricalEntries | 10000 | Number of historical entries to persist in store. | True |
| staking.BondDenom | utia | Bondable coin denomination. | False |
| staking.MinCommissionRate | 0.05 (5%) | Minimum commission rate used by all validators. | True |
| mint.BondDenom | utia | Denomination that is inflated and sent to the distribution module account. | True |
| mint.BondDenom | utia | Denomination that is inflated and sent to the distribution module account. | False |
| mint.InflationRateChange | 10.0% | The rate at which the annual provisions decrease each year. | False |
| mint.InflationRate | 8.0% | Initial annual inflation rate used to calculate the annual provisions. | False |
| qgb.DataCommitmentWindow | 400 | Number of blocks that are included in a signed batch (DataCommitment). | True |
Loading