As I tried to search from Google, there are some genesis.json example files to customize the parameter of genesis block in Ethereum private blockchain.

In the file, there is a part called "config"

"config": {
    "chainId": 1,
    "homesteadBlock": 0,
    "eip155Block": 0,
    "eip158Block": 0
}

What is the meaning or specification for those parameter in "config"? May I setup part of parameter(s) only if necessary?

up vote 21 down vote accepted

This is the chain configuration field, defined in config.go:

// ChainConfig is the core config which determines the blockchain settings.
//
// ChainConfig is stored in the database on a per block basis. This means
// that any network, identified by its genesis block, can have its own
// set of configuration options.

The available fields and their descriptions are shown below:

type ChainConfig struct {
    ChainId *big.Int `json:"chainId"` // Chain id identifies the current chain and is used for replay protection

    HomesteadBlock *big.Int `json:"homesteadBlock,omitempty"` // Homestead switch block (nil = no fork, 0 = already homestead)
    DAOForkBlock   *big.Int `json:"daoForkBlock,omitempty"`   // TheDAO hard-fork switch block (nil = no fork)
    DAOForkSupport bool     `json:"daoForkSupport,omitempty"` // Whether the nodes supports or opposes the DAO hard-fork

    // EIP150 implements the Gas price changes (https://github.com/ethereum/EIPs/issues/150)
    EIP150Block *big.Int    `json:"eip150Block,omitempty"` // EIP150 HF block (nil = no fork)
    EIP150Hash  common.Hash `json:"eip150Hash,omitempty"`  // EIP150 HF hash (fast sync aid)

    EIP155Block *big.Int `json:"eip155Block,omitempty"` // EIP155 HF block
    EIP158Block *big.Int `json:"eip158Block,omitempty"` // EIP158 HF block

    // Various consensus engines
    Ethash *EthashConfig `json:"ethash,omitempty"`
    Clique *CliqueConfig `json:"clique,omitempty"`
}

The config for the main chain is as follows (again in config.go):

MainnetChainConfig = &ChainConfig{
    ChainId:        MainNetChainID,
    HomesteadBlock: MainNetHomesteadBlock,
    DAOForkBlock:   MainNetDAOForkBlock,
    DAOForkSupport: true,
    EIP150Block:    MainNetHomesteadGasRepriceBlock,
    EIP150Hash:     MainNetHomesteadGasRepriceHash,
    EIP155Block:    MainNetSpuriousDragon,
    EIP158Block:    MainNetSpuriousDragon,
    Ethash:         new(EthashConfig),

With the actual values being defined in util.go.


So in answer to your questions...

"config": { "chainId": 1, "homesteadBlock": 0, "eip155Block": 0, "eip158Block": 0 }

What is the meaning or specification for those parameter in "config"?

  • Chain id - identifies the current chain and is used for replay protection. You should set it to a unique value for your private chain.
  • homesteadBlock - your chain won't be undergoing the switch to Homestead, so leave this as 0.
  • eip155Block - your chain won't be hard-forking for these changes, so leave as 0.
  • eip158Block - your chain won't be hard-forking for these changes, so leave as 0.

May I setup part of parameter(s) only if necessary?

Yes. Any of the values that set a block or hash number can be ignored for a private chain - they're only really relevant to the public main chain.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.