Consensys / quorum-examples

Examples for Quorum
Apache License 2.0
321 stars 348 forks source link

How the istanbul genesis extradata generated. #153

Closed pccr10001 closed 5 years ago

pccr10001 commented 5 years ago

Hello.

I am looking for how the genesis of istanbul extradata generated.

I tried istanbul-tools to generate extradata field, but its structure is different from istanbul-genesis.json provided in this repo.

extradata from repo.

$ bin/istanbul extra decode --extradata 0x0000000000000000000000000000000000000000000000000000000000000000f897f893946571d97f340c8495b661a823f2c2145ca47d63c2948157d4437104e3b8df4451a85f7b2438ef6699ff94b131288f355bc27090e542ae0be213c20350b76794b912de287f9b047b4228436e94b5b78e3ee1617194d8dba507e85f116b1f7e231ca8525fc9008a696694e36cbeb565b061217930767886474e3cde903ac594f512a992f3fb749857d758ffda1330e590fa915e80c0

vanity:  0x0000000000000000000000000000000000000000000000000000000000000000
validator:  0x6571D97f340c8495B661a823F2C2145cA47D63c2
validator:  0x8157D4437104e3B8dF4451a85F7B2438ef6699FF
validator:  0xb131288F355BC27090E542aE0be213c20350B767
validator:  0xb912De287F9b047B4228436E94B5b78E3Ee16171
validator:  0xd8Dba507e85F116b1f7e231cA8525fC9008A6966
validator:  0xe36cbeB565B061217930767886474e3cDe903AC5
validator:  0xF512a992F3fb749857d758fFDa1330e590fa915E

My config

$ cat istanbul.toml
vanity = "0x00"
validators = [
  "0x68a9b697d1727c2e19e4b4ea2f7efb10456b0b54",
  "0x5fb9446a93d270d58b1af2904d5786ac73968511",
  "0x992147f326bf27a903234276442689b43b432d74",
  "0x90b4111937655f3d0fd0d1ad2030135ed6c1151e"
]

$ istanbul extra encode --config istanbul.toml
Encoded Istanbul extra-data: 0x0000000000000000000000000000000000000000000000000000000000000000f89af8549468a9b697d1727c2e19e4b4ea2f7efb10456b0b54945fb9446a93d270d58b1af2904d5786ac7396851194992147f326bf27a903234276442689b43b432d749490b4111937655f3d0fd0d1ad2030135ed6c1151eb8410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0

$ istanbul extra decode --extradata 0x0000000000000000000000000000000000000000000000000000000000000000f89af8549468a9b697d1727c2e19e4b4ea2f7efb10456b0b54945fb9446a93d270d58b1af2904d5786ac7396851194992147f326bf27a903234276442689b43b432d749490b4111937655f3d0fd0d1ad2030135ed6c1151eb8410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0
vanity:  0x0000000000000000000000000000000000000000000000000000000000000000
validator:  0x68A9B697d1727C2e19e4b4ea2F7efB10456b0B54
validator:  0x5FB9446A93D270d58b1af2904d5786Ac73968511
validator:  0x992147f326bf27a903234276442689B43B432D74
validator:  0x90b4111937655F3d0Fd0d1AD2030135ED6C1151E
seal: 0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
$ cat genesis.json
{
  "alloc": {
    "9b2949aad118ca3a0512cc6481fad8ebfd8a89a7": {
      "balance": "1000000000000000000000000000"
    },
    "24b1d8e2a938a1d7817d3a42bd25368185e831aa": {
      "balance": "1000000000000000000000000000"
    },
    "68a9b697d1727c2e19e4b4ea2f7efb10456b0b54": {
      "balance": "1000000000000000000000000000"
    },
    "5fb9446a93d270d58b1af2904d5786ac73968511": {
      "balance": "1000000000000000000000000000"
    },
    "992147f326bf27a903234276442689b43b432d74": {
      "balance": "1000000000000000000000000000"
    },
    "90b4111937655f3d0fd0d1ad2030135ed6c1151e": {
      "balance": "1000000000000000000000000000"
    }
  },
  "coinbase": "0x0000000000000000000000000000000000000000",
  "config": {
      "chainId": 2017,
      "byzantiumBlock": 3,
      "constantinopleBlock": 3,
      "homesteadBlock": 1,
      "eip150Block": 2,
      "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "eip155Block": 3,
      "eip158Block": 3,
     "istanbul": {
        "epoch": 30000,
        "policy": 0
    },
      "isQuorum": true
  },
  "difficulty": "0x1",
  "gasLimit": "0x2FEFD800",
  "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000f89af8549468a9b697d1727c2e19e4b4ea2f7efb10456b0b54945fb9446a93d270d58b1af2904d5786ac7396851194992147f326bf27a903234276442689b43b432d749490b4111937655f3d0fd0d1ad2030135ed6c1151eb8410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0",
  "mixHash": "0x63746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365",
  "nonce": "0x0",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp": "0x5c346632"
}

It case unauthorized address in geth logs

INFO [01-08|08:58:38.561] Unlocked account                         address=0x90b4111937655F3d0Fd0d1AD2030135ED6C1151E
INFO [01-08|08:58:38.561] Transaction pool price threshold updated price=18000000000
INFO [01-08|08:58:38.561] Starting mining operation
INFO [01-08|08:58:38.561] Commit new mining work                   number=1 txs=0 uncles=0 elapsed=64.504µs
WARN [01-08|08:58:38.561] Block sealing failed                     err=unauthorized
ERROR[01-08|08:58:48.567] Failed to decode message from payload    address=0xfA75f782A607698FF4F7d280156DaB6CD2BE8081 err="unauthorized address"
...

My System Info: Ubuntu 18.04.1 Geth: Version: 1.8.12-stable Git Commit: 8f678278aab02529cc56d934606e5b275b94f6cf Quorum Version: 2.2.0

Thank you.

fixanoid commented 5 years ago

hi @pccr10001 how are you? IBFT setup is a bit finicky and requires a bit more -- some steps get obscured when running the istanbul-tools and get missed when setting up. Best to read this doc: https://github.com/jpmorganchase/quorum/wiki/From-Scratch#quorum-with-istanbul-bft-consensus first.

In your issue above, the unauthorized address is likely due to the nodes not having the right nodekey -- its the nodekey that gets used to generate the ethereum validator addresses and it requires you to run the tools correctly like so: istanbul setup --num 1 --nodes --quorum --save --verbose

Let me know if you run into any other issues.