diff --git a/app/app.go b/app/app.go index 9a7d5243b4..de40c4dac1 100644 --- a/app/app.go +++ b/app/app.go @@ -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{}, diff --git a/app/default_overrides.go b/app/default_overrides.go index c7867bca98..0468ba94ce 100644 --- a/app/default_overrides.go +++ b/app/default_overrides.go @@ -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" @@ -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 + params.SlashFractionDoubleSign = sdk.NewDecWithPrec(5, 2) // 5% + params.SlashFractionDowntime = sdk.ZeroDec() // 0% + + return cdc.MustMarshalJSON(&slashingtypes.GenesisState{ + Params: params, + }) +} + type crisisModule struct { crisis.AppModuleBasic } @@ -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()) + return cdc.MustMarshalJSON(gs) +} + type mintModule struct { mint.AppModuleBasic } @@ -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) } @@ -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, @@ -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 + 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 diff --git a/app/default_overrides_test.go b/app/default_overrides_test.go index 3dc8b81eb9..b4c97fcb83 100644 --- a/app/default_overrides_test.go +++ b/app/default_overrides_test.go @@ -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) diff --git a/pkg/appconsts/consensus_consts.go b/pkg/appconsts/consensus_consts.go index fd2d2297ee..c26e4078eb 100644 --- a/pkg/appconsts/consensus_consts.go +++ b/pkg/appconsts/consensus_consts.go @@ -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 ) diff --git a/specs/src/specs/params.md b/specs/src/specs/params.md index c7a0af3a49..3c347462f2 100644 --- a/specs/src/specs/params.md +++ b/specs/src/specs/params.md @@ -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 | | 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 | @@ -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 |