- Published on
What is the extraData in Besus IBFT Genesis File
- Authors
- Name
- Yair Mark
- @yairmark
If you follow Besu's tutorial on setting up an IBFT network you will end up with a genesis.json
that looks like the below (with some changes based on what your machine-generated for the different pks):
{
"config": {
"chainId": 2018,
"constantinoplefixblock": 0,
"ibft2": {
"blockperiodseconds": 2,
"epochlength": 30000,
"requesttimeoutseconds": 10
}
},
"nonce": "0x0",
"timestamp": "0x58ee40ba",
"gasLimit": "0x47b760",
"difficulty": "0x1",
"mixHash": "0x63746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"fe3b557e8fb62b89f4916b721be55ceb828dbd73": {
"privateKey": "8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "0xad78ebc5ac6200000"
},
"627306090abaB3A6e1400e9345bC60c78a8BEf57": {
"privateKey": "c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "90000000000000000000000"
},
"f17f52151EbEF6C7334FAD080c5704D77216b732": {
"privateKey": "ae6ae8e5ccbfb04590405997ee2d52d2b330726137b875053c36d94e974d162f",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "90000000000000000000000"
}
},
"extraData": "0xf87ea00000000000000000000000000000000000000000000000000000000000000000f854948539c5c368dda69bc541299a5293836ca9e3a36194b97ccc82acb5d04c557e6363e283e2f0a44c0f8b942e7427a308b7e04f53cbceec3d2a9ff6955b7b4594b7108387430622ffebe9c9777bbe5c7d647f9dea808400000000c0"
}
The extraData section stumped me initially as I was not sure what exactly besu uses this for.
After searching through their quickstart repo I came across the ibft start script which clarified what extraData is.
It is the RLP encoded array of your network's bootnodes addresses. So, for example, say my bootnode has the address: 0xf17f52151EbEF6C7334FAD080c5704D77216b732
then if this was the only bootnode my network had I would encode it as follows:
> echo "[\"0xf17f52151EbEF6C7334FAD080c5704D77216b732\"]" | besu rlp encode
Which outputs:
0xf83ea00000000000000000000000000000000000000000000000000000000000000000d594f17f52151ebef6c7334fad080c5704d77216b732808400000000c0
extraData would then be this output value. I.e:
...
"extraData" : "0xf83ea00000000000000000000000000000000000000000000000000000000000000000d594f17f52151ebef6c7334fad080c5704d77216b732808400000000c0"
...