0

At first thought that running a private network with Ethereum is going to be easy. Just download the source, modify your difficulty function and you are done. But after getting deeper into the source base I am seeing many if conditions that modify the functionality depending on the block number. And there are a lot of block numbers that affect the branch of execution:

MainnetChainConfig = &ChainConfig{
    ChainId:         big.NewInt(1),
    HomesteadBlock:  big.NewInt(1150000),
    DAOForkBlock:    big.NewInt(1920000),
    DAOForkSupport:  true,
    EIP150Block:     big.NewInt(2463000),
    EIP150Hash:  common.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"),
    EIP155Block:     big.NewInt(2675000),
    EIP158Block:     big.NewInt(2675000),
    MetropolisBlock: big.NewInt(math.MaxInt64), // Don't enable yet

    Ethash: new(EthashConfig),
}

for example, this if is a Use Case only for Metropolis release:

func AccumulateRewards(config *params.ChainConfig, state *state.StateDB, header *types.Header, uncles []*types.Header) {
    // Select the correct block reward based on chain progression
    blockReward := frontierBlockReward
    if config.IsMetropolis(header.Number) {
        blockReward = metropolisBlockReward
    }

So.... the question is, to all of those who have set up a private network already, what has to be done to obtain a generic version of today's latest code of Ethereum but without all those old fixes. Because, I guess, when you start running your own private network from block 0 you will reach the day when some hardcoded block number will be created and the rules will apply. For example, the DAO hack happened at block 1920000, will your own private Ethereum based network also try to repeat the same fixes as the original Ethereum network had to ???

This is kind of quesiton I want to as, how to configure the installation so you can use the latest source code but without patches for things happened in the past.

1

Most parameters are configurable in your genesis file, so you can run a private network without modifying the source code.

For example this is my genesis file:

{
  "config": {
    "chainId": 1234,
    "homesteadBlock": 0,
    "eip155Block": 0,
    "eip158Block": 0
  },
  "gasLimit": "0x400000",
  "difficulty": "0x1000",
  "alloc": {
  }
}

You can refer to this questions for more details about each parameter meaning:

  • ok, but what about DAOForkBlock and DAOForkSupport ? Also MethropolisBlock can be set to zero too ? Will it run without bugs? – Nulik Oct 9 '17 at 12:53
  • All new parameters are inside the 'config' block params/config.go. – Ismael Oct 9 '17 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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