0

I am having a hugely difficult time understanding the genesis.json file.

Assumption: it seems to me that it serves to both initialize the first block, and also set configuration parameters for the rest of the chain. True or false?

Questions:

  1. Is the first block on the Ethereum mainnet blockchain always the same regardless of what else is in the genesis.json file? How specifically does the genesis.json file affect it?
  2. If a new EIP is accepted, then the genesis.json file might change. Specifically, how would this make the first block look different? Would it?
  3. Why are things like nonce, mixHash, and coinbase options to put in the genesis.json file? What purpose do they serve if the first block can't be mined?
  4. Why do I need a genesis.json file if I end up "syncing" with peers and downloading their entire blockchain anyway? Am I actually creating the first block myself through genesis.json, and then syncing the rest with my peers?
  5. On the Ethereum mainnet, the genesis block allocates ether to certain accounts. Is there a corresponding genesis.json file that has those accounts in the alloc {} section? Or was that first block somehow created without this file?
1
  • it seems to me that it serves to both initialize the first block, and also set configuration parameters for the rest of the chain. True or false?

True.

  • Is the first block on the Ethereum mainnet blockchain always the same regardless of what else is in the genesis.json file? How specifically does the genesis.json file affect it?

Your question is tricky. To be a peer of the main net, you need the exact same genesis file as everyone on the network. If not, then you won't be a peer.

  • If a new EIP is accepted, then the genesis.json file might change. Specifically, how would this make the first block look different? Would it?

I don't think so, you started with a specific genesis file, you end with it, or you completely change the chain

  • Why are things like "nonce", "mixHash", and "coinbase" options to put in the genesis.json file? What purpose do they serve if the first block can't be mined?

Check this

  • Why do I need a genesis.json file if I end up "syncing" with peers and downloading their entire blockchain anyway? Am I actually creating the first block myself through genesis.json, and then syncing the rest with my peers?

Because to state if you are allowed to synchronize, we need a way to know if you want to synchronize with this specific chain. The genesis file is like the ID of the chain. Lets say I have 2 private chains, each one with the same chainID but with a different config in the genesis file: Some of my node will connect to chain A and others to chain B, depending on which genesis I gave them. If you try to sync with a peer that has a different genesis file, it will be rejected.

You don't actually "create" the first block. The genesis file is just an ID and a describtion of the chain BEFORE block 0.

  • On the Ethereum mainnet, the genesis block allocates ether to certain accounts. Is there a corresponding genesis.json file that has those accounts in the alloc {} section? Or was that first block somehow created without this file?

I think you have a misunderstanding between block and genesis file. As said above, the genesis file is a description of the chain BEFORE the first block. If the genesis file has some allocated addresses, the state of the chain will have this addresses wit ha specific balance, starting from block 0.


Here is an example of the first block of a private chain, with pre allocated addresses, is you can see, it is just a normal block without any transaction. The only specific thing is the parentHash. As it does not exists but comes from the genesis file.

{
  difficulty: 1024,
  extraData: "0x",
  gasLimit: 134217728,
  gasUsed: 0,
  hash: "0xd3f87ee4cf1e44bc4024a519d91b08efdf187fa05f3a7a39efd1e4f73c29426a",
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  miner: "0x0000000000000000000000000000000000000000",
  mixHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
  nonce: "0x0000000000000042",
  number: 0,
  parentHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
  receiptsRoot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
  sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
  size: 507,
  stateRoot: "0x041288fa59918e8775cddb418d92c1ef125438a1d9f2e4d481fae84ab85fcd22",
  timestamp: 0,
  totalDifficulty: 1024,
  transactions: [],
  transactionsRoot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
  uncles: []
}
  • Two major points: 1) "Why are things like "nonce", "mixHash", and "coinbase" options to put in the genesis.json file?" --> The link you provided just defined those terms. The mixhash definition is "...proves that a sufficient amount of computation has been carried out on this block:" What block? 2) Again, you make a distinction between the first block and the genesis file. But, the genesis file defines which accounts start with ether. And therefore, it defines the transaction that occur in the first block. Correct? – AlwaysQuestioning Jan 28 '18 at 13:55
  • What block: From my understanding -> The block before block 0 The genesis file does not only tell which account has what balance, it's a description of the chain and the state before block 0. There won't be any transaction in block 0. I'll give you an example in the answer of block 0 of my private chain with pre allocated addresses. – Florian Castelain Jan 29 '18 at 1:25

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.