Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[META] Genesis Management #1203

Closed
zivkovicmilos opened this issue Oct 7, 2023 · 1 comment · Fixed by #1252
Closed

[META] Genesis Management #1203

zivkovicmilos opened this issue Oct 7, 2023 · 1 comment · Fixed by #1252
Assignees
Labels
🌱 feature New update to Gno

Comments

@zivkovicmilos
Copy link
Member

zivkovicmilos commented Oct 7, 2023

Description

This task proposes the introduction of a top-level genesis tool that is capable of executing operations related to a chain's genesis.json, as outlined in #1189 (library requirements).

It is worth noting that gno currently has a structure for the genesis document, but does not have the tools to fully utilize it:

//------------------------------------------------------------
// core types for a genesis definition
// NOTE: any changes to the genesis definition should
// be reflected in the documentation:
// docs/tendermint-core/using-tendermint.md
// GenesisValidator is an initial validator.
type GenesisValidator struct {
Address Address `json:"address"`
PubKey crypto.PubKey `json:"pub_key"`
Power int64 `json:"power"`
Name string `json:"name"`
}
// GenesisDoc defines the initial conditions for a tendermint blockchain, in particular its validator set.
type GenesisDoc struct {
GenesisTime time.Time `json:"genesis_time"`
ChainID string `json:"chain_id"`
ConsensusParams abci.ConsensusParams `json:"consensus_params,omitempty"`
Validators []GenesisValidator `json:"validators,omitempty"`
AppHash []byte `json:"app_hash"`
AppState interface{} `json:"app_state,omitempty"`
}

Below, you can find the proposal for the entire suite of subcommands relating to genesis manipulation and creation.

---
title: Genesis command structure
---
flowchart TD
    A(genesis) --> B(generate)
    A --> C(verify)
    A --> D(validator)
    A --> E(balances)
    A --> F(txs)

    D --> D1(add)
    D --> D2(remove)

    E --> E1(add)
    E --> E2(remove)


    F --> F1(add)
    F --> F2(remove)
Loading

generate

The generate subcommand should generate a genesis.json file on disk.

Flags

  • --output-path - the output path for the genesis.json. If there is a genesis.json already there, the command fails
  • --genesis-time - unix time for the genesis block
  • --chain-id - the ID of the chain
  • --block-max-tx-bytes - the max size of the block transaction
  • --block-max-data-bytes - the max size of the block data
  • --block-max-gas - the max gas limit for the block
  • --block-time-iota - the block time iota (in ms)

validator

The validator subcommand should manage validators in the genesis.json.

Flags

  • --genesis-path - the path to the genesis.json

validator add

The validator add subcommand should add a new validator to the genesis.json. The command should fail if the validator already exists in the genesis.json.

Flags

  • --address - the string address of the validator
  • --pub-key - the hex representation of the validator's public key
  • --name - the name of the validator (must be unique)
  • --power - the voting power of the validator

validator remove

The validator remove subcommand should remove a validator from the genesis.json. The command should fail if the validator does not exist in the genesis.json.

Flags

  • --address - the string address of the validator

verify

The verify subcommand validates the genesis.json, according to different section rules:

  • validates the genesis time is valid
  • validates the chain ID is valid
  • validates the consensus params for the block are valid
  • validates the validator set is valid (and not empty!)
  • validates the transactions are valid (format is good)
  • validates the balances are valid (format is good)

Flags

  • --genesis-path - the path to the genesis.json

balances

The balances subcommand manages the genesis.json balances information.

Flags

  • --genesis-path - the path to the genesis.json

balances add

The balances add subcommand adds in the balance information from a specified source (see flags) to the genesis.json.

Flags (EITHER-OR)

  • --balance-sheet - the path to the balance file containing addresses in the format <address>=<amount>ugnot
  • --single - the direct balance addition in the format <address>=<amount>ugnot
  • --parse-export - the path to the tx-archive export containing a list of transactions. The command should parse the exported transactions and calculate balances of initialized accounts

balances remove

The balances remove subcommand removes the balance information of a specific account from the genesis.json.

Flags

  • --address - the address of the account whose balance information should be removed from genesis.json

txs

The txs subcommand manages the initial transaction data in the genesis.json.

Flags

  • --genesis-path - the path to the genesis.json

txs add

The txs add subcommand imports the transactions from a tx-archive backup to the genesis.json. Existing transactions are skipped.

Flags

  • --parse-export - the path to the tx-archive export containing a list of transactions.

txs remove

The txs remove subcommand removes the transaction from the genesis.json. If the transaction doesn't exist, the command fails

Flags

  • --hash - the transaction hash (hex format)

PR against branch: feat/genesis

@moul
Copy link
Member

moul commented Oct 9, 2023

Looks great! I recommend reading #1105, even if we don't merge everything. I believe this collection of libraries and tools should be placed in gnosdk/pkg/genesis.

@moul moul moved this to 🚀 Needed for Launch in 🚀 The Launch [DEPRECATED] Oct 9, 2023
@zivkovicmilos zivkovicmilos self-assigned this Oct 18, 2023
moul pushed a commit that referenced this issue Oct 28, 2023
## Description

This PR introduces the genesis.json command suite, as outlined in #1203.

Closes #1203 and #1189

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>
gfanton pushed a commit to gfanton/gno that referenced this issue Nov 9, 2023
## Description

This PR introduces the genesis.json command suite, as outlined in gnolang#1203.

Closes gnolang#1203 and gnolang#1189

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>
moul pushed a commit to moul/gno that referenced this issue Nov 14, 2023
## Description

This PR introduces the genesis.json command suite, as outlined in gnolang#1203.

Closes gnolang#1203 and gnolang#1189

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌱 feature New update to Gno
Projects
Status: 🚀 Needed for Launch
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants