github.com/lino-network/lino@v0.6.11/param/param.go (about)

     1  package param
     2  
     3  import (
     4  	sdk "github.com/cosmos/cosmos-sdk/types"
     5  
     6  	"github.com/lino-network/lino/types"
     7  )
     8  
     9  // Parameter - parameter in Lino Blockchain
    10  type Parameter interface{}
    11  
    12  // GlobalAllocationParam - global allocation parameters
    13  // ContentCreatorAllocation - percentage for all content creator related allocation
    14  // DeveloperAllocation - percentage of inflation for developers
    15  // ValidatorAllocation - percentage of inflation for validators
    16  type GlobalAllocationParam struct {
    17  	GlobalGrowthRate         sdk.Dec `json:"global_growth_rate"`
    18  	ContentCreatorAllocation sdk.Dec `json:"content_creator_allocation"`
    19  	DeveloperAllocation      sdk.Dec `json:"developer_allocation"`
    20  	ValidatorAllocation      sdk.Dec `json:"validator_allocation"`
    21  }
    22  
    23  func (gp GlobalAllocationParam) IsValid() bool {
    24  	sum := sdk.NewDec(0)
    25  	sum = sum.Add(gp.ContentCreatorAllocation)
    26  	sum = sum.Add(gp.DeveloperAllocation)
    27  	sum = sum.Add(gp.ValidatorAllocation)
    28  	return sum.Equal(sdk.NewDec(1))
    29  }
    30  
    31  // VoteParam - vote parameters
    32  // MinStakeIn - minimum stake for stake in msg
    33  // VoterCoinReturnIntervalSec - when withdraw or revoke, the deposit return to voter by return event
    34  // VoterCoinReturnTimes - when withdraw or revoke, the deposit return to voter by return event
    35  // DelegatorCoinReturnIntervalSec - when withdraw or revoke, the deposit return to delegator by return event
    36  // DelegatorCoinReturnTimes - when withdraw or revoke, the deposit return to delegator by return event
    37  type VoteParam struct {
    38  	MinStakeIn                     types.Coin `json:"min_stake_in"`
    39  	VoterCoinReturnIntervalSec     int64      `json:"voter_coin_return_interval_second"`
    40  	VoterCoinReturnTimes           int64      `json:"voter_coin_return_times"`
    41  	DelegatorCoinReturnIntervalSec int64      `json:"delegator_coin_return_interval_second"`
    42  	DelegatorCoinReturnTimes       int64      `json:"delegator_coin_return_times"`
    43  }
    44  
    45  // ProposalParam - proposal parameters
    46  // ContentCensorshipDecideSec - seconds after content censorship proposal created till expired
    47  // ContentCensorshipMinDeposit - minimum deposit to propose content censorship proposal
    48  // ContentCensorshipPassRatio - upvote and downvote ratio for content censorship proposal
    49  // ContentCensorshipPassVotes - minimum voting power required to pass content censorship proposal
    50  // ChangeParamDecideSec - seconds after parameter change proposal created till expired
    51  // ChangeParamExecutionSec - seconds after parameter change proposal pass till execution
    52  // ChangeParamMinDeposit - minimum deposit to propose parameter change proposal
    53  // ChangeParamPassRatio - upvote and downvote ratio for parameter change proposal
    54  // ChangeParamPassVotes - minimum voting power required to pass parameter change proposal
    55  // ProtocolUpgradeDecideSec - seconds after protocol upgrade proposal created till expired
    56  // ProtocolUpgradeMinDeposit - minimum deposit to propose protocol upgrade proposal
    57  // ProtocolUpgradePassRatio - upvote and downvote ratio for protocol upgrade proposal
    58  // ProtocolUpgradePassVotes - minimum voting power required to pass protocol upgrade proposal
    59  type ProposalParam struct {
    60  	ContentCensorshipDecideSec  int64      `json:"content_censorship_decide_second"`
    61  	ContentCensorshipMinDeposit types.Coin `json:"content_censorship_min_deposit"`
    62  	ContentCensorshipPassRatio  sdk.Dec    `json:"content_censorship_pass_ratio"`
    63  	ContentCensorshipPassVotes  types.Coin `json:"content_censorship_pass_votes"`
    64  	ChangeParamDecideSec        int64      `json:"change_param_decide_second"`
    65  	ChangeParamExecutionSec     int64      `json:"change_param_execution_second"`
    66  	ChangeParamMinDeposit       types.Coin `json:"change_param_min_deposit"`
    67  	ChangeParamPassRatio        sdk.Dec    `json:"change_param_pass_ratio"`
    68  	ChangeParamPassVotes        types.Coin `json:"change_param_pass_votes"`
    69  	ProtocolUpgradeDecideSec    int64      `json:"protocol_upgrade_decide_second"`
    70  	ProtocolUpgradeMinDeposit   types.Coin `json:"protocol_upgrade_min_deposit"`
    71  	ProtocolUpgradePassRatio    sdk.Dec    `json:"protocol_upgrade_pass_ratio"`
    72  	ProtocolUpgradePassVotes    types.Coin `json:"protocol_upgrade_pass_votes"`
    73  }
    74  
    75  // DeveloperParam - developer parameters
    76  // DeveloperMinDeposit - minimum deposit to become a developer
    77  // DeveloperCoinReturnIntervalSec - when withdraw or revoke, coin return to developer by coin return event
    78  // DeveloperCoinReturnTimes - when withdraw or revoke, coin return to developer by coin return event
    79  type DeveloperParam struct {
    80  	DeveloperMinDeposit            types.Coin `json:"developer_min_deposit"`
    81  	DeveloperCoinReturnIntervalSec int64      `json:"developer_coin_return_interval_second"`
    82  	DeveloperCoinReturnTimes       int64      `json:"developer_coin_return_times"`
    83  }
    84  
    85  // ValidatorParam - validator parameters
    86  // ValidatorMinDeposit - minimum deposit requirement for user wanna be validator
    87  // ValidatorCoinReturnIntervalSec - when withdraw or revoke, coin return to validator by coin return event
    88  // ValidatorCoinReturnTimes - when withdraw or revoke, coin return to validator by coin return event
    89  // minus PenaltyMissCommit amount of Coin from validator deposit
    90  // PenaltyMissCommit - when missing block till AbsentCommitLimitation, minus PenaltyMissCommit amount of Coin from validator deposit
    91  // PenaltyByzantine - when validator acts as byzantine (double sign, for example),
    92  // minus PenaltyByzantine amount of Coin from validator deposit
    93  // AbsentCommitLimitation - absent block limitation till penalty
    94  // OncallSize - the size of oncall validators
    95  // StandbySize - the size of standby validators
    96  // ValidatorRevokePendingSec - how many seconds before unassign validator duty
    97  // OncallInflationWeight - oncall validator's weight when distributing inflation
    98  // StandbyInflationWeight - standby validator's weight when distributing inflation
    99  // MaxVotedValidators - the number of max validators one voter can vote
   100  // SlashLimitation - slash limitation till into jail
   101  type ValidatorParam struct {
   102  	ValidatorMinDeposit            types.Coin `json:"validator_min_deposit"`
   103  	ValidatorCoinReturnIntervalSec int64      `json:"validator_coin_return_second"`
   104  	ValidatorCoinReturnTimes       int64      `json:"validator_coin_return_times"`
   105  	PenaltyMissCommit              types.Coin `json:"penalty_miss_commit"`
   106  	PenaltyByzantine               types.Coin `json:"penalty_byzantine"`
   107  	AbsentCommitLimitation         int64      `json:"absent_commit_limitation"`
   108  	OncallSize                     int64      `json:"oncall_size"`
   109  	StandbySize                    int64      `json:"standby_size"`
   110  	ValidatorRevokePendingSec      int64      `json:"validator_revoke_pending_sec"`
   111  	OncallInflationWeight          int64      `json:"oncall_inflation_weight"`
   112  	StandbyInflationWeight         int64      `json:"standby_inflation_weight"`
   113  	MaxVotedValidators             int64      `json:"max_voted_validators"`
   114  	SlashLimitation                int64      `json:"slash_limitation"`
   115  }
   116  
   117  // CoinDayParam - coin day parameters
   118  // SecondsToRecoverCoinDay - seconds for each incoming balance coin day fully charged
   119  type CoinDayParam struct {
   120  	SecondsToRecoverCoinDay int64 `json:"seconds_to_recover_coin_day"`
   121  }
   122  
   123  // BandwidthParam - bandwidth parameters
   124  // SecondsToRecoverBandwidth - seconds for user tps capacity fully charged
   125  // CapacityUsagePerTransaction - capacity usage per transaction, dynamic changed based on traffic
   126  // GeneralMsgQuotaRatio - the ratio for reserved general messages per second
   127  // GeneralMsgEMAFactor - the multiplier for weighting the general message EMA
   128  // AppMsgQuotaRatio - the ratio for reserved app messages per second
   129  // AppMsgEMAFactor - the multiplier for weighting the app message EMA
   130  // ExpectedMaxMPS - the expected max messages per second
   131  // MsgFeeFactorA - factor A for calculating msg fee
   132  // MsgFeeFactorB - factor B for calculating msg fee
   133  // MaxMPSDecayRate - decay rate for historical max message per seconds
   134  // AppBandwidthPoolSize - the depth for app bandwidth pool
   135  // AppVacancyFactor - app vacancy factor for calculating u
   136  // AppPunishmentFactor - app punishment factor for calculating p
   137  
   138  type BandwidthParam struct {
   139  	SecondsToRecoverBandwidth   int64      `json:"seconds_to_recover_bandwidth"`
   140  	CapacityUsagePerTransaction types.Coin `json:"capacity_usage_per_transaction"`
   141  	VirtualCoin                 types.Coin `json:"virtual_coin"`
   142  	GeneralMsgQuotaRatio        sdk.Dec    `json:"general_msg_quota_ratio"`
   143  	GeneralMsgEMAFactor         sdk.Dec    `json:"general_msg_ema_factor"`
   144  	AppMsgQuotaRatio            sdk.Dec    `json:"app_msg_quota_ratio"`
   145  	AppMsgEMAFactor             sdk.Dec    `json:"app_msg_ema_factor"`
   146  	ExpectedMaxMPS              sdk.Dec    `json:"expected_max_mps"`
   147  	MsgFeeFactorA               sdk.Dec    `json:"msg_fee_factor_a"`
   148  	MsgFeeFactorB               sdk.Dec    `json:"msg_fee_factor_b"`
   149  	MaxMPSDecayRate             sdk.Dec    `json:"max_mps_decay_rate"`
   150  	AppBandwidthPoolSize        sdk.Dec    `json:"app_bandwidth_pool_size"`
   151  	AppVacancyFactor            sdk.Dec    `json:"app_vacancy_factor"`
   152  	AppPunishmentFactor         sdk.Dec    `json:"app_punishment_factor"`
   153  }
   154  
   155  // AccountParam - account parameters
   156  // MinimumBalance - minimum balance each account need to maintain
   157  // RegisterFee - register fee need to pay to developer inflation pool for each account registration
   158  // FirstDepositFullCoinDayLimit - when register account, some of coin day of register fee to newly open account will be fully charged
   159  // MaxNumFrozenMoney - the upper limit for each person's ongoing frozen money
   160  type AccountParam struct {
   161  	MinimumBalance               types.Coin `json:"minimum_balance"`
   162  	RegisterFee                  types.Coin `json:"register_fee"`
   163  	FirstDepositFullCoinDayLimit types.Coin `json:"first_deposit_full_coin_day_limit"`
   164  	MaxNumFrozenMoney            int64      `json:"max_num_frozen_money"`
   165  }
   166  
   167  // PostParam - post parameters
   168  // ReportOrUpvoteIntervalSec - report interval second
   169  // PostIntervalSec - post interval second
   170  type PostParam struct {
   171  	ReportOrUpvoteIntervalSec int64      `json:"report_or_upvote_interval_second"`
   172  	PostIntervalSec           int64      `json:"post_interval_sec"`
   173  	MaxReportReputation       types.Coin `json:"max_report_reputation"`
   174  }
   175  
   176  // ReputationParam: parameters of reputation
   177  // BestContentIndexN - hard cap of how many content can be indexed every round.
   178  // UserMaxN - maximum different donation target counted every round.
   179  type ReputationParam struct {
   180  	BestContentIndexN int `json:"best_content_index_n"`
   181  	UserMaxN          int `json:"user_max_n"`
   182  }
   183  
   184  // PriceParam - parameters of price module.
   185  type PriceParam struct {
   186  	TestnetMode     bool       `json:"testnet_mode"`
   187  	UpdateEverySec  int64      `json:"update_every"`
   188  	FeedEverySec    int64      `json:"feed_every"`
   189  	HistoryMaxLen   int        `json:"history_max_len"`
   190  	PenaltyMissFeed types.Coin `json:"penalty_miss_feed"`
   191  }