protolambda / eth2-testnet-genesis

Create a genesis state for an Eth2 testnet
MIT License
46 stars 26 forks source link

Teku compatible validator keys #12

Closed screwyprof closed 1 year ago

screwyprof commented 1 year ago

Hi guys, thanks for your awesome work!

Is it possible to make an option to output the validator keys so that they are compatible with Eth Staking Deposit Cli. It would be really helpful to use this tool to run a private testnet using Geth as an EL and Teku as a CL and as a VC.

Teku uses Eth Staking Deposit Cli-compatible validator key stores, which can be provided in a few different ways. The other benefit is that if this format is supported it could be used by some external block signers such as web3signer which uses the same format.

protolambda commented 1 year ago

Teku is already supported and has been running fine with the inputs from this tool. I think @parithosh may be able to give you some pointers how to configure the flags for it.

screwyprof commented 1 year ago

@protolambda Thanks for a quick reply. That would be great.

In the meantime, I'm getting an error from Teku using genesis.ssz:

Failed to load initial state from /home/teku/genesis.ssz : First variable element offset doesn't match the end of fixed part

The state is generated using the following command:

eth2-testnet-genesis merge --config=minimal --eth1-config=./execution/genesis.json --mnemonics=./consensus/mnemonics.yml --state-output=./consensus/genesis.ssz --tranches-dir=./consensus/tranches

I've also tried the following with the same result:

eth2-testnet-genesis merge --config=minimal --preset-phase0=minimal --preset-altair=minimal --preset-bellatrix=minimal --eth1-config=./execution/genesis.json --mnemonics=./consensus/mnemonics.yml --state-output=./consensus/genesis.ssz --tranches-dir=./consensus/tranches

Could you please tell me what could be wrong?

The genesis.json looks as follows:

 {
  "config":{
    "ChainName":"gophernet",
    "chainId":2022,
    "homesteadBlock":0,
    "daoForkSupport":true,
    "eip150Block":0,
    "eip150Hash":"0x0000000000000000000000000000000000000000000000000000000000000000",
    "eip155Block":0,
    "eip158Block":0,
    "byzantiumBlock":0,
    "constantinopleBlock":0,
    "petersburgBlock":0,
    "istanbulBlock":0,
    "muirGlacierBlock":0,
    "berlinBlock":0,
    "londonBlock":0,
    "terminalBlockHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
    "arrowGlacierBlock":0,
    "grayGlacierBlock":0,
    "ethash":{
      "fixeddifficulty":2
    },
    "terminalTotalDifficulty":50
  },
  "nonce":"0x42",
  "timestamp":"0x0",
  "extraData":"0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
  "gasLimit":"0x1fffffffffffff",
  "difficulty":"0x1",
  "mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
  "coinbase":"0x0000000000000000000000000000000000000000",
  "alloc":{
    "0x4242424242424242424242424242424242424242":{
      "balance":"0",
      "code":"0x.......omitted for clarity"
    },
    "0x123463a4B065722E99115D6c222f267d9cABb524":{
      "balance":"20000000000000000000000"
    },
    "0x5678E9E827B3be0E3d4b910126a64a697a148267":{
      "balance":"20000000000000000000000"
    }
  }
}

I tried to use the python script to inspect genesis.ssz, but I got an error:

❯ python3 compute_genesis_details.py
Traceback (most recent call last):
  File "/Users/happygopher/.virtualenvs/tmp-ae6769532be623b0/compute_genesis_details.py", line 7, in <module>
    genesis_state = BeaconState.deserialize(f, os.stat('genesis.ssz').st_size)
  File "/opt/homebrew/lib/python3.10/site-packages/remerkleable/complex.py", line 843, in deserialize
    field_values[fkey] = ftyp.deserialize(stream, fsize)
  File "/opt/homebrew/lib/python3.10/site-packages/remerkleable/complex.py", line 121, in deserialize
    raise Exception(f"first offset is too big: {first_offset}, scope: {scope}")
Exception: first offset is too big: 4273011005, scope: 64
parithosh commented 1 year ago

@screwyprof We haven't tested minimal merge states, so that might be the issue here.

The tested method is: eth2-testnet-genesis merge --config=config.yaml --mnemonics=mnemonics.yaml --eth1-config=genesis.json (meaning a mainnet preset is used)

The flags needed in teku are:

  --network="config.yaml"
  --initial-state="genesis.ssz"

The compute_genesis_details.py expects a phase0 genesis.ssz, it should probably be updated to support more. But in the meantime, I find using zcli is a lot more convenient. You can parse the genesis.ssz with: zcli pretty bellatrix BeaconState genesis.ssz > parsedBeaconState.json.

screwyprof commented 1 year ago

@parithosh Thanks for your answer. I’ll give it a try.

parithosh commented 1 year ago

I'll close the issue now and we can open a new one if there is a new problem