Cosmos - genesis json文件

创世文件Genesis.json

在比特币网络中存在着创世区块,而在cosmos中genesis.json承担着创世区块的角色,节点是从block1开始出块的,而block1引用的就是genesis.json。

在genesis.json中包含着genesis account和genesis tx,以及各模块的状态和参数设置,下面我们看下genesis文件中包含的信息。

Init genesis.json

当前cosmos已经将cosmos-sdk和gaia两个项目分开,本文档构建的gaia项目是commitd4e4a4f

gaiad init [moniker] [flags]会生成初始的genesis.json,如下所示:

{
  "moniker": "node0",
  "chain_id": "test-chain-frA80C",
  "node_id": "4f32da46aa41b7c786082c7a5c4712f9900e2b47",
  "gentxs_dir": "",
  "app_message": {
    "mint": {
      "minter": {
        "inflation": "0.130000000000000000",
        "annual_provisions": "0.000000000000000000"
      },
      "params": {
        "mint_denom": "stake",
        "inflation_rate_change": "0.130000000000000000",
        "inflation_max": "0.200000000000000000",
        "inflation_min": "0.070000000000000000",
          "goal_bonded": "0.670000000000000000",
        "blocks_per_year": "6311520"
      }
    },
    "params": null,
    "auth": {
      "collected_fees": [],
      "params": {
        "max_memo_characters": "256",
        "tx_sig_limit": "7",
        "tx_size_cost_per_byte": "10",
        "sig_verify_cost_ed25519": "590",
        "sig_verify_cost_secp256k1": "1000"
      }
    },
    "bank": {
      "send_enabled": true
    },
    "distr": {
      "fee_pool": {
        "community_pool": []
      },
      "community_tax": "0.020000000000000000",
      "base_proposer_reward": "0.010000000000000000",
      "bonus_proposer_reward": "0.040000000000000000",
      "withdraw_addr_enabled": true,
      "delegator_withdraw_infos": [],
      "previous_proposer": "",
      "outstanding_rewards": [],
      "validator_accumulated_commissions": [],
      "validator_historical_rewards": [],
      "validator_current_rewards": [],
      "delegator_starting_infos": [],
      "validator_slash_events": []
    },
    "crisis": {
      "constant_fee": {
        "denom": "stake",
        "amount": "1000"
      }
    },
    "gov": {
      "starting_proposal_id": "1",
      "deposits": null,
      "votes": null,
      "proposals": null,
      "deposit_params": {
        "min_deposit": [
          {
            "denom": "stake",
            "amount": "10000000"
          }
        ],
        "max_deposit_period": "172800000000000"
      },
      "voting_params": {
        "voting_period": "172800000000000"
      },
      "tally_params": {
        "quorum": "0.334000000000000000",
        "threshold": "0.500000000000000000",
        "veto": "0.334000000000000000"
      }
    },
    "genutil": {
      "gentxs": null
    },
    "staking": {
      "pool": {
        "not_bonded_tokens": "0",
        "bonded_tokens": "0"
      },
      "params": {
        "unbonding_time": "259200000000000",
        "max_validators": 100,
        "max_entries": 7,
        "bond_denom": "stake"
      },
      "last_total_power": "0",
      "last_validator_powers": null,
      "validators": null,
      "delegations": null,
      "unbonding_delegations": null,
      "redelegations": null,
      "exported": false
    },
    "accounts": [],
    "slashing": {
      "params": {
        "max_evidence_age": "120000000000",
        "signed_blocks_window": "100",
        "min_signed_per_window": "0.500000000000000000",
        "downtime_jail_duration": "600000000000",
        "slash_fraction_double_sign": "0.050000000000000000",
        "slash_fraction_downtime": "0.010000000000000000"
      },
      "signing_infos": {},
      "missed_blocks": {}
    }
  }
}
  • monikergaiad init的参数,将本地节点命名为"node0"
  • chain_id:链的唯一标识符,比如cosmos主网的chain_id是cosmoshub-1cosmoshub-2;如果gaiad init时没有指定,会随机分配一个chain_id “test-chain-frA80C”
  • node_id:节点的标识符
  • app_message:包含了如下所有模块的信息

Mint

cosmos的经济模型是通胀的,mint模块管理token供应的通胀逻辑

  • minter
    • inflation:token供应量的年化通胀百分比,"0.130000000000000000"表示当前每年的通货膨胀率目标为13%;inflation每周会重新计算一次
    • annual_provisions:年度准备金的金额,初始genesis.json中为0;annual_provisions会逐块计算
  • params
    • mint_denom:增发token的denom,此处是"sake"用于test chain,在cosmoshub即为"uatom"
    • inflation_rate_change:每年通胀的最大浮动范围,"0.130000000000000000"即最大浮动13%
    • inflation_max:通胀的最高值,"0.200000000000000000"即最高为20%
    • inflation_min:通胀的最低值,"0.070000000000000000"即最低为7%
    • goal_bonded:staking数量占总供应量的百分比目标,如果staking token 的实际百分比低于此目标,则通胀率会增加,直至达到inflation_max;如果staking token 的实际百分比高于此目标,则通胀率会下降,直至达到inflation_min。"0.670000000000000000"意味着如果staking数量占token总量的比例大于67%,则通胀率会一直下降,最低下降到7%,反之则会一直上升,最高上升到20%
    • blocks_per_year: 每年的出块量估算

Auth

  • collected_fees:收集到的交易费
  • params
    • max_memo_characters:memo的限制为256个字符
    • tx_sig_limit:交易的sig限制为7
    • tx_size_cost_per_byte:交易每字节需要花费的交易费为10
    • sig_verify_cost_ed25519:ed25519验签需要花费的交易费为590
    • sig_verify_cost_secp256k1:secp256k1验签需要花费的交易费为1000

Bank

  • send_enabled:当前为true,表示token可进行转账。在cosmoshub-1阶段时,还未开启atom转账,send_enabled即为false。

Distr

distr模块管理区块总收益(交易费+区块奖励)对validators和delegators的分发

  • fee_pool
    • community_pool:社区储备,用于社区激励,通过提案分配奖励
  • community_tax:community_pool税率,"0.020000000000000000"即为从每个区块总收益中抽取2%的token放入社区储备中
  • base_proposer_reward:proposer从有效区块中获得的基础奖励,"0.010000000000000000"即proposer将获得区块总收益的1%。
  • bonus_proposer_reward:proposer从有效区块中按照打包precommits的比例获得的bonus奖励,"0.040000000000000000"意味着如果proposer打包了所有的precommits,将会获得区块总收益的4%。
  • withdraw_addr_enabled:委托人是否可以设置其他地址提取奖励
  • delegator_withdraw_infos:委托人收益地址列表
  • previous_proposer: 上一个块的proposer
  • outstanding_rewards: validator未提取的总奖励(需要支付给delegator的佣金+属于自己的奖励)
  • validator_accumulated_commission: validator需要支付给delegator的佣金
  • validator_historical_rewards:validator的历史奖励情况
  • validators_current_rewards:validator当前的属于自己的奖励
  • delegator_starting_infos:记录delegator的starting_info
  • validator_slash_events: validator被惩罚的记录

Crisis

  • constant_fee:执行crisis检查需要的fee

Gov

gov模块处理和治理相关的交易

  • starting_proposal_id:定义第n个proposal的ID,每个proposal都由唯一ID标识
  • deposits:每个proposal的保证金列表
  • votes:每个proposal的投票列表
  • proposals:所有的proposal
  • deposit_params
    • min_deposit:使proposal进入投票期的最小抵押数量
    • max_deposit_period:等待抵押期的最大时长,"172800000000000"单位为纳秒
  • voting_params
    • voting_period:投票期时长, "172800000000000"单位为纳秒
  • tally_params
    • quorum:proposal生效所需的投票数占总抵押数的最小百分比
    • threshold:proposal生效所需 YES 票占总投票的最小百分比
    • veto:proposal生效所需NO_WITH_VETO票占总投票的最大百分比

Staking

  • pool
    • not_bonded_tokens:not bonded token的数量
    • bonded_tokens:bonded token的数量
  • params
    • unbonding_time:unbonding延迟时间,“259200000000000"意味着token需要经过"259200000000000”(单位为纳秒)时间后才完全unbonding
    • max_validators:最大validator节点数量为100
    • max_entries:每对delegator和validator之间可进行的最大unbonding delegations 和redelegations次数为7
    • bond_denom:staking token的denom
  • last_total_power:总的voting power值
  • last_validator_powers:最新状态下的每一个validator的voting power
  • validators:最新状态下的validator列表
  • delegations:最新状态下的delegation列表
  • unbonding_delegations:最新状态下的unbonding delegation列表
  • redelegations:最新状态下的redelegation列表
  • exported:genesis是否是从之前的状态导出的

Slashing

slashing模块对validator双签/可用性差的不当行为进行处罚

  • params
    • max_evidence_age:证据的最长有效期,"120000000000"单位为纳秒
    • signed_blocks_window:用于验证validator是否在线的时间窗口,为100个block
    • min_signed_per_window:一个在线validator在一个时间窗口中需要提交precommits的最小百分比,"0.500000000000000000"意味着如果validator在signed_blocks_window(100个block)中提交的precommits小于50%(50个),则被认为可用性差
    • downtime_jail_duration:validator因可用性差而被关监狱的时长。“600000000000"意味着如果validator因可用性差被关监狱,需要经过"600000000000”(时间为纳秒)时间后,才能发起Unjail把自己从监狱中释放出来
    • slash_fraction_double_sign:validator双签时,slash的罚金占总委托数量的百分比
    • slash_fraction_downtime: validator可用性差时,slash的罚金占总委托数量的百分比
  • signing_infosslashing 模块所需的Validator Signing的信息
  • missed_blocksslashing 模块所需的关于Missed Block的信息

本文由 CoinEx Chain团队 zhichao 写作,转载无需授权