Skip to content

Commit

Permalink
Merge branch 'main' into rp/consistent-param-percentages
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp committed Sep 14, 2023
2 parents 856d943 + 9fa9fbf commit 0362953
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 53 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
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
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())
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
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
)
41 changes: 0 additions & 41 deletions pkg/user/tx_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
sdkclient "github.com/cosmos/cosmos-sdk/client"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
)

type TxOption func(builder sdkclient.TxBuilder) sdkclient.TxBuilder
Expand Down Expand Up @@ -80,43 +79,3 @@ func SetGasLimitAndFee(gasLimit uint64, gasPrice float64) TxOption {
return builder
}
}

// InheritTxConfig sets all of the accessible configurations from a given tx
// into a given client.TxBuilder
func InheritTxConfig(builder sdkclient.TxBuilder, tx authsigning.Tx) sdkclient.TxBuilder {
if gas := tx.GetGas(); gas != 0 {
builder.SetGasLimit(gas)
}

if feeAmmount := tx.GetFee(); !feeAmmount.AmountOf("utia").Equal(sdk.NewInt(0)) {
builder.SetFeeAmount(tx.GetFee())
}

if memo := tx.GetMemo(); memo != "" {
builder.SetMemo(tx.GetMemo())
}

if tip := tx.GetTip(); tip != nil {
builder.SetTip(tip)
}

if timeoutHeight := tx.GetTimeoutHeight(); timeoutHeight != 0 {
builder.SetTimeoutHeight(timeoutHeight)
}

signers := tx.GetSigners()
// Note: if there are multiple signers in a PFB, then this could create an
// invalid signature. This is not an issue at this time because we currently
// ignore pfbs with multiple signers
if len(signers) == 1 {
if feePayer := tx.FeeGranter(); !feePayer.Equals(signers[0]) {
builder.SetFeeGranter(tx.FeeGranter())
}
}

if feeGranter := tx.FeeGranter(); !feeGranter.Empty() {
builder.SetFeeGranter(tx.FeeGranter())
}

return builder
}
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 | 0.02 (2%) | Percentage of the inflation sent to the community pool. | True |
| distribution.CommunityTax | 0.02 (2%) | 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 | 0.05 (5%) | Percentage slashed after a validator is jailed for double-signing. | True |
| slashing.SlashFractionDowntime | 0.01 (1%) | Percentage slashed after a validator is jailed for downtime. | True |
| slashing.MinSignedPerWindow | 0.75 (75%) | 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 | 0.05 (5%) | Percentage slashed after a validator is jailed for double signing. | True |
| slashing.SlashFractionDowntime | 0.00 (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 | 0.10 (10%) | The rate at which the annual provisions decrease each year. | False |
| mint.InflationRate | 0.08 (8%) | 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 0362953

Please sign in to comment.