GithubHelp home page GithubHelp logo

consensys / quorum-genesis-tool Goto Github PK

View Code? Open in Web Editor NEW
19.0 6.0 17.0 1.47 MB

The quorum genesis tool creates genesis configs, configuration files, and keys for Hyperledger Besu, GoQuorum and Tessera.

License: Apache License 2.0

TypeScript 91.64% JavaScript 8.36%

quorum-genesis-tool's Introduction

Quorum Genesis Tool

Table of Contents

  1. Prerequisites
  2. Usage
  3. Troubleshooting

Prerequisites

Usage

NOTE: Where possible, based on the consensus algortithm selected, the Quorum Genesis Tool will create keys and genesis files for both HLF Besu and GoQuorum and you can pick the one you'd like to use. At present only QBFT has cross client compatibility.

Generation of Keys

Create the artifacts with:

npx quorum-genesis-tool

   ___
  / _ \  _   _   ___   _ __  _   _  _ __ ___
 | | | || | | | / _ \ | '__|| | | || '_'  _  \
 | |_| || |_| || (_) || |   | |_| || | | | | |
  \__\_\ \__,_| \___/ |_|    \__,_||_| |_| |_|

      / ___|  ___  _ __    ___  ___ (_) ___
     | |  _  / _ \| '_ \  / _ \/ __|| |/ __|
     | |_| ||  __/| | | ||  __/\__ \| |\__ \
      \____| \___||_| |_|_\___||___/|_||___/
              _____              _
             |_   _|___    ___  | |
               | | / _ \  / _ \ | |
               | || (_) || (_) || |
               |_| \___/  \___/ |_|



Welcome to the Quorum Genesis Tool. This tool can be used
to rapidly generate genesis, account keys, and configs for Besu and GoQuorum.

To get started, be sure that you have read Besu and GoQuorum documentation regarding
genesis config options, then answer the following questions.

Which consensus algorithm will you use? Default: QBFT
        1. IBFT1
        2. IBFT2
        3. QBFT
        4. Clique
        5. RAFT

Set your chainID value: (integer) Default: 1337

Set your blockperiodseconds value: (integer) Default: 5

(GoQ only) Set your emptyblockperiodseconds value: (integer) Default: 60

Set your requestTimeoutSeconds value: (integer) Default: 10

Set your epoch length value: (integer) Default: 30000

Set your difficulty: (integer) Default: 1

Set your gas limit value: (string) Default: 0xFFFF

Set your coinbase address for rewards: (string) Default: 0x0000000000000000000000000000000000000000

Set your max code size value: (integer) Default: 64

Set your transaction size limit value: (integer) Default: 64

Choose number of validator node keys to generate: (integer) Default: 4

Choose number of member node keys to generate: (integer) Default: 1

Choose number of bootnode node keys to generate: (integer) Default: 2

Set your account password: (empty for none)

This prompts you to pick a consensus algorithm variant, and specifics for your genesis file. By default, artifact files are stored at ./output/<TIMESTAMP>, where TIMESTAMP is the time in a user friendly string:

Alternatively, you can use cli options and skip the prompt above like so:

npx quorum-genesis-tool --help

Options:
  --help                   Show help                                   [boolean]
  --version                Show version number                         [boolean]
  --consensus              Consensus algorithm to use
        [string] [required] [choices: "ibft", "ibft2", "qbft", "clique", "raft"]
                                                               [default: "qbft"]
  --chainID                ChainID for blockchain
                                             [number] [required] [default: 1337]
  --blockperiod            Number of seconds per block
                                                [number] [required] [default: 5]
  --requestTimeout         Minimum request timeout for each round
                                                          [number] [default: 10]
  --emptyBlockPeriod       Reduce number (seconds) of blocks produced when there
                           are no transactions            [number] [default: 60]
  --epochLength            Number of blocks after which votes reset
                                            [number] [required] [default: 30000]
  --difficulty             Difficulty of network[number] [required] [default: 1]
  --gasLimit               Block gas limit
                                         [string] [required] [default: "0xFFFF"]
  --coinbase               Address to pay mining rewards to
                [string] [default: "0x0000000000000000000000000000000000000000"]
  --maxCodeSize            Maximum contract size (kb)     [number] [default: 64]
  --txnSizeLimit           Maximum transaction size (kb)  [number] [default: 64]
  --validators             Number of validator node keys to generate
                                                [number] [required] [default: 4]
  --members                Number of member node keys to generate
                                                [number] [required] [default: 1]
  --bootnodes              Number of bootnode node keys to generate
                                                [number] [required] [default: 2]
  --accountPassword        Password for keys              [string] [default: ""]
  --outputPath             Output path relative to current directory
                                                  [string] [default: "./output"]
  --tesseraEnabled         Whether to generate tessera keys
                                                      [boolean] [default: false]
  --tesseraPassword        Set password to encrypt generated keys
                                                          [string] [default: ""]
  --quickstartDevAccounts  Include quorum-dev-quickstart test accounts
                                           [boolean] [required] [default: false]
  --alloc                   Defines accounts with balances
                                                        [string] [default: "{}"]

To generate keys for QBFT (default) with 4 validators, 2 bootnodes and 2 members:

npx quorum-genesis-tool --consensus QBFT

To generate config for HLF Besu using QBFT

npx quorum-genesis-tool --consensus qbft --chainID 400 --blockperiod 5 --requestTimeout 10 --epochLength 30000 --difficulty 1 --gasLimit '0xFFFFFF' --coinbase '0x0000000000000000000000000000000000000000' --validators 4 --members 1 --bootnodes 0

To generate config for GoQuorum using IBFT

npx quorum-genesis-tool --consensus ibft --chainID 400 --blockperiod 5 --requestTimeout 10 --epochLength 30000 --difficulty 1 --gasLimit '0xFFFFFF' --coinbase '0x0000000000000000000000000000000000000000' --validators 4 --members 1 --bootnodes 0

Eth Accounts and Tessera Passwords

Eth Accounts

For each node (bootnode/validator/member) an account is generated (files in their respective directories start with account*) to perform transactions and prefilled with a large balance. If you would like to remove or edit certain accounts from the genesis before the network has been spun up, you can find the genesis for Besu and goQuorum under each of their respective directories (besu/genesis.json or goQuorum/genesis.json).

If the flag quickstartDevAccounts is set to true, it will include the quorum-dev-quickstart test accounts. It is important to remove these accounts when going into production!

If the flag is not specified, then it will default to false with the assumption that the genesis is to be used in production. You should specify the flag only if you would like the accounts in testing/dev.

Tessera Passwords and Configuration

If you opt to provide a tesseraPassword to encrypt the tessera private keys, you will need to pass a passwordFile field with the password in a file. You will also need to update the privateKeyPath and publicKeyPath to the paths where you store your keys. See more here.

Using the keys and genesis files on instances

Once generated, the output should resemble the file structure below.

  ├── validator0
  │   └──  nodekey                      # the node private key
  │   └──  nodekey.pub                  # the node's public key which is used in the enode
  │   └──  address                      # the node's address which is used to vote the validator in/out
  │   └──  accountAddress               # GoQuorum only - the accountAddress
  │   └──  accountKeystore              # GoQuorum only - the account's v3 keystore
  │   └──  accountPassword              # GoQuorum only - the account's password (you would have supplied this)
  │   └──  accountPrivateKey            # GoQuorum only - the account's private key
  │               └── ...
  ├── validatorN
  │   └──  nodekey                      # the node private key
  │   └──  nodekey.pub                  # the node's public key which is used in the enode
  │   └──  ...
  |
  ├── bootnodeN
  │   └──  nodekey                      # the node private key
  │   └──  nodekey.pub                  # the node's public key which is used in the enode
  │   └──  ...
  |
  ├── memberN
  │   └──  nodekey                      # the node private key
  │   └──  nodekey.pub                  # the node's public key which is used in the enode
  │   └──  ...
  |
  └── besu
  │   └──  static-nodes.json            # a list of static nodes to make peering faster
  │   └──  genesis.json                 # this genesis file for any HLF Besu nodes
  │   └──  permissioned-nodes.json      # local permissions for any HLF Besu node
  │
  └── goQuorum
  │   └──  static-nodes.json            # a list of static nodes to make peering faster
  │   └──  genesis.json                 # this genesis file for any GoQuorum nodes
  │   └──  permissioned-nodes.json      # local permissions for any GoQuorum node
  │   └──  disallowed-nodes.json        # disallowed nodes for any GoQuorum node ie this new nodes will not connect to any nodes on this list
  │
  └── userData.json                     # this answers provided in a single map
  └── README.md                         # this file

Please remember to do the following:

  1. Update the in both the permissions file and the static nodes files. Please note the selected ports are default and you may need to check firewall rules if using alternate ports
  2. As above, update the permissions.json files
  3. Update in every Besu nodes' config.toml

quorum-genesis-tool's People

Contributors

abhinavmsra avatar dependabot[bot] avatar ezzahhh avatar iloomans avatar joshuafernandes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

quorum-genesis-tool's Issues

some questions default values do not work as expected

Choose number of member node keys to generate: (integer) Default: 2 default seems to be set at 1.

Include quorum-dev-quickstart test accounts: [y/N] default 'N' doesn't work, shows an error:

Sorry, but I didn't understand your answer. Please select Y or N,
or just hit enter if you want the default.

Steps to reproduce: npx quorum-genesis-tool and just press Enter to use default configs.

genesis tool should allow users to skip the timestamp suffix behavior in output dir

Currently when you run the genesis tool, it allows you to override the output path with user input, but it nests the output inside a subfolder which is named with an arbitrary timestamp (see this line of code)

This seems by design, but it would be great if there was another boolean flag that users could set to bypass this behavior such as --noOutputTimestamp

By setting this flag, users could tell the genesis tool to skip that nested timestamp folder logic and instead output the files directly into the folder the user has already specified

The reason for this change is that the current default behavior makes it hard to consume the output automatically by a script, because that script would need to parse the STDOUT spew to find the subdir time stamp name

Enhancement: specify milestone, add pre funded accounts or contracts

Hi!

Is it possible to add more options to QGT ?

I'm asking the question because the quorum kubernetes repo is using QGT to generate the genesis file, validators keys, etc... (https://github.com/ConsenSys/quorum-kubernetes/blob/master/helm/charts/besu-genesis/templates/genesis-job-init.yaml#L110), and I'm using this repo to deploy a private Besu network

But I'm lacking some options, like the ability to specify a milestone, or to add pre funded accounts / contracts.

I think that it can be a good idea to have more granularity with the CLI

R1 curve

  • add secp256r1 to the besu genesis if picked
  • check if goquorum supports r1 or only k1 - if it only does k1 should we make the curve a hidden parameter?

requesttimeoutseconds is not written in the GoQuorum genesis file.

When I run the following command, the requesttimeoutseconds is not written in the GoQuorum genesis file.
npx quorum-genesis-tool --consensus qbft --chainID 400 --blockperiod 5 --requestTimeout 10 --validators 4 --members 1 --bootnodes 0
Only Besu genesis file is written requesttimeoutseconds.
Please make sure that requesttimeoutseconds is also written to the GoQuorum genesis file.

Can we use this tool for production?

Choose number of validator node keys to generate: (integer) Default: 4

This tool generates validator node keys instead of accepting node keys from inputs. Is this a safe procedure for production?
I wonder if each of the four validators should generate their own keys.

Fix goquorum genesis.json

As per docs:

istanbul | Network uses IBFT or QBFT. This option is being deprecated and will be removed in a future release. Use ibft or qbft instead.

But generated goquorum genesis still contains istanbul section, plus it's missing blockperiodseconds altogether.

Was able to track it to:

https://github.com/ConsenSys/quorum-genesis-tool/blob/25d88c3f89eab0243529c170df989ccc15f8a8aa/src/lib/genesisGenerate.ts#L161

    case Consensus.ibft: {
      goquorum.config.istanbul = {
        policy: 0,
        epoch: quorumConfig.epochLength,
        ceil2Nby3Block: 0,
      };
      break;
    }
    case Consensus.qbft: {
      goquorum.config.istanbul = {
        policy: 0,
        epoch: quorumConfig.epochLength,
        ceil2Nby3Block: 0,
        testQBFTBlock: 0,
      };

while besu section is fine:
https://github.com/ConsenSys/quorum-genesis-tool/blob/25d88c3f89eab0243529c170df989ccc15f8a8aa/src/lib/genesisGenerate.ts#L98

    case Consensus.ibft2: {
      besu.config.ibft2 = {
        blockperiodseconds: quorumConfig.blockperiod,
        epochlength: quorumConfig.epochLength,
        requesttimeoutseconds: quorumConfig.requestTimeout,
      };
      break;
    }
    case Consensus.qbft: {
      besu.config.qbft = {
        blockperiodseconds: quorumConfig.blockperiod,
        epochlength: quorumConfig.epochLength,
        requesttimeoutseconds: quorumConfig.requestTimeout,
      };

P.S. Also would be nice to have a new goquorum feature emptyBlockPeriodSeconds added to questionary/cli args and to generated qbft config.

Bug while running npx quorum-genesis-tool, no such file or directory[build/templates/README.md]

Seems while publishing build/templates golder is not coied. I copy templates folder manual from source, It is working.

Details:

  • Command: npx quorum-genesis-tool --consensus qbft --chainID 1337 --blockperiod 5 --requestTimeout 10 --epochLength 30000 --difficulty 1 --gasLimit '0xFFFFFF' --coinbase '0x0000000000000000000000000000000000000000' --validators 5 --members 0 --bootnodes 0 --outputPath 'artifacts'
  • NodeJS Details:
{
  'codefi-orchestrate-quick-start': '4.0.0',
  npm: '8.15.0',
  node: '16.17.0',
  v8: '9.4.146.26-node.22',
  uv: '1.43.0',
  zlib: '1.2.11',
  brotli: '1.0.9',
  ares: '1.18.1',
  modules: '93',
  nghttp2: '1.47.0',
  napi: '8',
  llhttp: '6.0.7',
  openssl: '1.1.1q+quic',
  cldr: '41.0',
  icu: '71.1',
  tz: '2022a',
  unicode: '14.0',
  ngtcp2: '0.1.0-DEV',
  nghttp3: '0.1.0-DEV'
}
  • Error: ENOENT: no such file or directory, open '~/.npm-global/lib/node_modules/quorum-genesis-tool/build/templates/README.md'

feat: add `contractSizeLimit` config to besu genesis file

Description

Even when the option maxCodeSize is provided the field config.contractSizeLimit is not created for besu genesis. I think it would be just a matter of adding the code below to the createBesuGenesis function on the file src/lib/genesisGenerate.ts

  besu.config.contractSizeLimit = quorumConfig.maxCodeSize;

According to the docs, this is a field I should set for running besu on K8s: https://besu.hyperledger.org/private-networks/how-to/configure/free-gas#2-set-the-contract-size

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.