Skip to content

Commit

Permalink
chore: update more default parameters (#2417)
Browse files Browse the repository at this point in the history
## Overview

minor update to the defaults to match #2416. ofc, these are not
consensus breaking as they're just changes to the defaults. This saves
us from having to manually change this for mainnet or mocha

## Checklist

- [x] New and updated code has appropriate documentation
- [x] New and updated code has new and/or updated testing
- [x] Required CI checks are passing
- [x] Visual proof for any user facing features like CLI or
documentation updates
- [ ] Linked issues closed with keywords

---------

Co-authored-by: Rootul P <[email protected]>
(cherry picked from commit 9fa9fbf)

# Conflicts:
#	app/default_overrides.go
  • Loading branch information
evan-forbes authored and mergify[bot] committed Sep 14, 2023
1 parent 9ef2d6d commit d73dc65
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 12 deletions.
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
97 changes: 95 additions & 2 deletions app/default_overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,17 @@ 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"
<<<<<<< HEAD

Check failure on line 26 in app/default_overrides.go

View workflow job for this annotation

GitHub Actions / test / test

missing import path

Check failure on line 26 in app/default_overrides.go

View workflow job for this annotation

GitHub Actions / test / test-coverage

missing import path

Check failure on line 26 in app/default_overrides.go

View workflow job for this annotation

GitHub Actions / test / test-race

missing import path
=======
ibctypes "github.com/cosmos/ibc-go/v6/modules/core/types"
tmcfg "github.com/tendermint/tendermint/config"
>>>>>>> 9fa9fbf (chore: update more default parameters (#2417))
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
coretypes "github.com/tendermint/tendermint/types"
)
Expand Down Expand Up @@ -71,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
}
Expand All @@ -88,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
}
Expand All @@ -113,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 @@ -134,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 @@ -151,3 +196,51 @@ func DefaultBlockParams() tmproto.BlockParams {
TimeIotaMs: 1, // 1ms
}
}
<<<<<<< HEAD
=======

// 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
// TODO: make TimeoutBroadcastTx configurable per https://github.com/celestiaorg/celestia-app/issues/1034
cfg.RPC.TimeoutBroadcastTxCommit = 50 * time.Second
cfg.RPC.MaxBodyBytes = int64(8388608) // 8 MiB
cfg.Mempool.TTLNumBlocks = 10
// Given that there is a stateful transaction size check in CheckTx,
// We set a loose upper bound on what we expect the transaction to
// be based on the upper bound size of the entire block for the given
// version. This acts as a first line of DoS protection
upperBoundBytes := appconsts.DefaultSquareSizeUpperBound * appconsts.DefaultSquareSizeUpperBound * appconsts.ContinuationSparseShareContentSize
cfg.Mempool.MaxTxBytes = upperBoundBytes

cfg.Mempool.Version = "v1" // prioritized mempool
cfg.Consensus.TimeoutPropose = appconsts.TimeoutPropose
cfg.Consensus.TimeoutCommit = appconsts.TimeoutCommit
cfg.Consensus.SkipTimeoutCommit = false
cfg.TxIndex.Indexer = "null"
return cfg
}

func DefaultAppConfig() *serverconfig.Config {
cfg := serverconfig.DefaultConfig()
cfg.API.Enable = true

// the default snapshot interval was determined by picking a large enough
// value as to not dramatically increase resource requirements while also
// being greater than zero so that there are more nodes that will serve
// snapshots to nodes that state sync
cfg.StateSync.SnapshotInterval = 1500
cfg.StateSync.SnapshotKeepRecent = 2
cfg.MinGasPrices = fmt.Sprintf("%v%s", appconsts.DefaultMinGasPrice, BondDenom)
return cfg
}
>>>>>>> 9fa9fbf (chore: update more default parameters (#2417))
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 |
| 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 |

0 comments on commit d73dc65

Please sign in to comment.