cli icon indicating copy to clipboard operation
cli copied to clipboard

`network`: add genesis verification for special allocations

Open lumtis opened this issue 3 years ago • 0 comments

Depends on https://github.com/tendermint/spn/issues/790

Is your feature request related to a problem? Please describe.

Mainnets can have special allocations: shares of the campaign allocated for a specific purposes other than redeemed vouchers When a special allocation is defined for a mainnet, the client must verify the initial genesis of the chain is valid regarding the special allocation. The chain genesis shouldn't be generated if the initial genesis is invalid

There are two types of special allocations:

  • GenesisDistribution
  • ClaimableAirdrop

The query SpecialAllocationsBalance from campaign from spn allows to get the final tokens allocated for each special allocations

The client must perform the following verifications in the initial genesis of the chain:

If genesis distribution defined:

  • bank.supply must be equal to GenesisDistribution

If genesis distribution is not defined:

  • bank.balances must be empty

If claimable airdrop defined:

  • claim.airdropSupply must be equal to ClaimableAirdrop

If one of the checks above doesn't pass, the initial genesis of the chain is invalid and the chain can't be launched from it

Describe the solution you'd like

The routine initGenesis in networkchain/init.go generates the initial genesis of the chain. I suggest having this check in this routine when the chain is a mainnet. If the special allocations is invalid initGenesis returns an error. We should pass the information that the chain is a mainnet and the special allocations into the Chain object.

After GenesisDistribution verification is completed. bank.supply should be removed from the genesis. The initial genesis is valid, other accounts will be added during genesis generation, therefore the final genesis will not be valid if we keep bank.supply

lumtis avatar May 11 '22 11:05 lumtis