In addition to --networkid 3
starting geth with --testnet
also makes sure that you use the correct genesis node for Ropsten.
You can start Ropsten also this way:
geth init ropsten_genesis.json && geth --networkid 3
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.
Best Answer
Network id and Chain id are the same thing
You can edit
NetworkId
ineth/config.go
¶ms/config.go
and get rid of this problem forever, you won't need to specifynetwork id
on the commandline anymore.Ethereum's
geth
has hardcoded the value1
in the files I told you , so this is why you have these problems.The
chain id
is now part of transaction as result of Ethereum Improvement Proposal (EIP) #155, so theinvalid sender
is shown becausechain id
is different. You can disable this using EIP155BlockNum , but you would be vulnerable to replay attack, if you use multiple networks, like a testnet for example.chain id
is not part of the block's hash, so specifying it in the genesis file is really useless. What you have to do instead, is specify chainID in the source code or using commandline parameters.