Genesis File
This document explains how the genesis file of the AIOZ Network mainnet is structured. It also explains how you can build a genesis file for your own aioz
testnet.
Note that you can generate a default genesis file for your own testnet by running the following command:
aiozd init <moniker> --chain-id <chain-id>
The genesis file is stored in ~/.aioz/config/genesis.toml
.
What is a Genesis File
A genesis file is a JSON file which defines the initial state of your blockchain. It can be seen as height 0
of your blockchain. The first block, at height 1
, will reference the genesis file as its parent.
The state defined in the genesis file contains all the necessary information, like initial token allocation, genesis time, default parameters, and more. Let us break down these information.
Genesis Time and Chain_id
The genesis_time
is defined at the top of the genesis file. It is a UTC
timestamps which specifies when the blockchain is due to start. At this time, genesis validators are supposed to come online and start participating in the consensus process. The blockchain starts when more than 2/3rd of the genesis validators (weighted by voting power) are online.
"genesis_time": "2021-03-13T17:00:00.000000000Z",
The chain_id
is a unique identifier for your chain. It helps differentiate between different chains using the same version of the software.
"chain_id": "aioz-2",
Consensus Parameters
Next, the genesis file defines consensus parameters. Consensus parameters regroup all the parameters that are related to the consensus layer, which is Tendermint
in the case of aioz
. Let us look at these parameters:
block
max_bytes
: Maximum number of bytes per block.max_gas
: Gas limit per block. Each transaction included in the block will consume some gas. The total gas used by transactions included in a block cannot exceed this limit.
evidence
max_age
: An evidence is a proof that a validator signed two different blocks at the same height (and round). This is an explicitly malicious behaviour that is punished at the state-machine level. Themax_age
defines the maximum number of blocks after which an evidence is not valid anymore.
validator
pub_key_types
: The types of pubkey (ed25519
,secp256k1
,ethsecp256k1
, ...) that are accepted for validators. Currently onlyed25519
is accepted.
"consensus_params": {
"block_size": {
"max_bytes": "150000",
"max_gas": "1500000"
},
"evidence": {
"max_age": "1000000"
},
"validator": {
"pub_key_types": [
"ed25519"
]
}
},
Application State
The application state defines the initial state of the state-machine.
Genesis Accounts
In this section, initial allocation of tokens is defined. It is possible to add accounts manually by directly editing the genesis file, but it is also possible to use the following command:
// Example: aiozd add-genesis-account 0x414F55f716A3dD8b08327590E9C04356A5E72a3F 10000000000000000000attoaioz
aiozd add-genesis-account <account-address> <amount><denom>
This command creates an item in the accounts
list, under the app_state
section.
"accounts": [
{
"address": "0x414F55f716A3dD8b08327590E9C04356A5E72a3F",
"coins": [
{
"denom": "attoaioz",
"amount": "10000000000000000000"
}
],
"sequence_number": "0",
"account_number": "0",
"original_vesting": [
{
"denom": "attoaioz",
"amount": "26306000000"
}
],
"delegated_free": null,
"delegated_vesting": null,
"start_time": "0",
"end_time": "10000"
}
]
Let us break down the parameters:
sequence_number
: This number is used to count the number of transactions sent by this account. It is incremented each time a transaction is included in a block, and used to prevent replay attacks. Initial value is0
.account_number
: Unique identifier for the account. It is generated the first time a transaction including this account is included in a block.original_vesting
: Vesting is natively supported byaioz
. You can define an amount of token owned by the account that needs to be vested for a period of time before they can be transferred. Vested tokens can be delegated. Default value isnull
.delegated_free
: Amount of delegated tokens that can be transferred after they've been vested. Most of the time, will benull
in genesis.delegated_vesting
: Amount of delegated tokens that are still vesting. Most of the time, will benull
in genesis.start_time
: Block at which the vesting period starts.0
most of the time in genesis.end_time
: Block at which the vesting period ends.0
if no vesting for this account.
Bank
The bank
module handles tokens. The only parameter that needs to be defined in this section is wether transfers
are enabled at genesis or not.
"bank": {
"send_enabled": false
}
Staking
The staking
module handles the bulk of the Proof-of-Stake logic of the state-machine. This section should look like the following:
"staking": {
"params": {
"unbonding_time": "1814400s",
"max_validators": 21,
"max_entries": 7,
"historical_entries": 10000,
"bond_denom": "attoaioz",
"accept_all_validators": true
},
"last_total_power": "0",
"last_validator_powers": [],
"validators": [],
"delegations": [],
"unbonding_delegations": [],
"redelegations": [],
"exported": false
}
Let us break down the parameters:
params
unbonding_time
: Time in nanosecond it takes for tokens to complete unbonding.max_validators
: Maximum number of active validators.max_entries
: Maximum unbonding delegations and redelegations between a particular pair of delegator / validator.bond_denom
: Denomination of the staking token.accept_all_validators
: Allow to create validator with governance mechanism.
last_total_power
: Total amount of voting power. Generally0
in genesis (except if genesis was generated using a previous state).last_validator_powers
: Power of each validator toin last known state. Generally[]
in genesis (except if genesis was generated using a previous state).validators
: List of last known validators. Generally[]
in genesis (except if genesis was generated using a previous state).delegations
: List of last known delegation. Generally[]
in genesis (except if genesis was generated using a previous state).unbonding_delegations
: List of last known unbonding delegations. Generally[]
in genesis (except if genesis was generated using a previous state).redelegations
: List of last known redelegations. Generally[]
in genesis (except if genesis was generated using a previous state).exported
: Wether this genesis was generated using the export of a previous state.
Mint
The mint
module governs the logic of inflating the supply of token. The mint
section in the genesis file looks like the follwing:
"mint": {
"params": {
"mint_denom": "attoaioz",
"blocks_per_year": "6311520",
"start_height": "6311520",
"inflation": "0.000000013654032124"
}
}
Let us break down the parameters:
params
mint_denom
: Denom of the staking token that is inflated.blocks_per_year
: Estimation of the amount of blocks per year. Used to compute the annual inflation and annual provisions.start_height
: Block height that starts mintinginflation
: Per block percentage of increase in the total supply of staking token. A0.000000013654032124
value means the target is9%
annual inflation.
Distribution
The distribution
module handles the logic of distribution block provisions and fees to validators and delegators. The distribution
section in the genesis file looks like the follwing:
"distribution": {
"params": {
"community_tax": "0.020000000000000000",
"base_proposer_reward": "0.010000000000000000",
"bonus_proposer_reward": "0.040000000000000000",
"withdraw_addr_enabled": true
},
"fee_pool": {
"community_pool": []
},
"delegator_withdraw_infos": [],
"previous_proposer": "",
"outstanding_rewards": [],
"validator_accumulated_commissions": [],
"validator_historical_rewards": [],
"validator_current_rewards": [],
"delegator_starting_infos": [],
"validator_slash_events": []
}
Let us break down the parameters:
params
community_tax
: The tax percentage on fees and block rewards that goes to the community pool.base_proposer_reward
: Base bonus on transaction fees collected in a valid block that goes to the proposer of block. If value is0.010000000000000000
, 1% of the fees go to the proposer.bonus_proposer_reward
: Max bonus on transaction fees collected in a valid block that goes to the proposer of block. The bonus depends on the number ofprecommits
the proposer includes. If the proposer includes 2/3rdprecommits
weighted by voting power (minimum for the block to be valid), they get a bonus ofbase_proposer_reward
. This bonus increases linearly up tobonus_proposer_reward
if the proposer includes 100% ofprecommits
.withdraw_addr_enabled
: Iftrue
, delegators can set a different address to withdraw their rewards. Set tofalse
if you want to disable transfers at genesis, as it can be used as a way to get around the restriction.
fee_pool
community_pool
: The community pool is a pool of tokens that can be used to pay for bounties. It is allocated via governance proposals. Generally[]
in genesis.
delegator_withdraw_infos
: List of delegators withdraw address. Generally[]
if genesis was not exported from previous state.previous_proposer
: Proposer of the previous block. Set to""
if genesis was not exported from previous state.outstanding_rewards
: Outstanding (un-withdrawn) rewards. Set to[]
if genesis was not exported from previous state.validator_accumulated_commission
: Outstanding (un-withdrawn) commission of validators. Set to[]
if genesis was not exported from previous state.validator_historical_rewards
: Set of information related to the historical rewards of validators and used by thedistribution
module for various computation. Set to[]
if genesis was not exported from previous state.validators_current_rewards
: Set of information related to the current rewards of validators and used by thedistribution
module for various computation. Set to[]
if genesis was not exported from previous state.delegator_starting_infos
: Tracks the previous validator period, the delegation's amount of staking token, and the creation height (to check later on if any slashes have occurred). Set to[]
if genesis was not exported from previous state.validator_slash_events
: Set of information related to the past slashing of validators. Set to[]
if genesis was not exported from previous state.
Governance
The gov
module handles all governance-related transactions. The initial state of the gov
section looks like the following:
"gov": {
"starting_proposal_id": "1",
"deposits": [],
"votes": [],
"proposals": [],
"deposit_params": {
"min_deposit": [
{
"denom": "attoaioz",
"amount": "1000000000000000000000"
}
],
"max_deposit_period": "172800s"
},
"voting_params": {
"voting_period": "300s"
},
"tally_params": {
"quorum": "0.334000000000000000",
"threshold": "0.500000000000000000",
"veto_threshold": "0.334000000000000000"
}
}
Let us break down the parameters:
starting_proposal_id
: This parameter defines the ID of the first proposal. Each proposal is identified by a unique ID.deposits
: List of deposits for each proposal ID. Set to[]
if genesis was not exported from previous state.votes
: List of votes for each proposal ID. Set to[]
if genesis was not exported from previous state.proposals
: List of proposals for each proposal ID: Set to[]
if genesis was not exported from previous state.deposit_params
min_deposit
: The minimum deposit required for the proposal to enterVoting Period
. If multiple denoms are provided, theOR
operator applies.max_deposit_period
: The maximum period (in nanoseconds) after which it is not possible to deposit on the proposal anymore.
voting_params
voting_period
: Length of the voting period in nanoseconds.
tally_params
quorum
: Minimum percentage of bonded staking tokens that needs to vote for the result to be valid.threshold
: Minimum percentage of votes that need to beYES
for the result to be valid.veto_threshold
: Maximum percentageNO_WITH_VETO
votes for the result to be valid.
Slashing
The slashing
module handles the logic to slash delegators if their validator misbehave. The slashing
section in genesis looks as follows:
"slashing": {
"params": {
"signed_blocks_window": "100",
"min_signed_per_window": "0.500000000000000000",
"downtime_jail_duration": "600s",
"slash_fraction_double_sign": "0.050000000000000000",
"slash_fraction_downtime": "0.010000000000000000"
},
"signing_infos": [],
"missed_blocks": []
}
Let us break down the parameters:
params
signed_blocks_window
: Moving window of blocks to figure out offline validators.min_signed_per_window
: Minimum percentage ofprecommits
that must be present in theblock window
for the validator to be considered online.downtime_jail_duration
: Duration in nanoseconds for which a validator is jailed after they get slashed for downtime.slash_fraction_double_sign
: Percentage of delegators bonded stake slashed when their validator double signs.slash_fraction_downtime
: Percentage of delegators bonded stake slashed when their validator is down.
signing_infos
: Various infos per validator needed by theslashing
module. Set to{}
if genesis was not exported from previous state.missed_blocks
: Various infos related to missed blocks needed by theslashing
module. Set to{}
if genesis was not exported from previous state.
Genesis Transactions
By default, the genesis file do not contain any gentxs
. A gentx
is a transaction that bonds staking token present in the genesis file under accounts
to a validator, essentially creating a validator at genesis. The chain will start as soon as more than 2/3rds of the validators (weighted by voting power) that are the recipient of a valid gentx
come online after genesis_time
.
A gentx
can be added manually to the genesis file, or via the following command:
aiozd collect-gentxs
This command will add all the gentxs
stored in ~/.aioz/config/gentx
to the genesis file. In order to create a genesis transaction, click here.