class BeaconChainController extends Service implements TimeTickChannel {

  @VisibleForTesting
  Bytes getP2pPrivateKeyBytes(KeyValueStore<String, Bytes> keyValueStore) {
    final Bytes privateKey;
    final String p2pPrivateKeyFile = config.getP2pPrivateKeyFile();
    if (p2pPrivateKeyFile != null) {
      try {
        privateKey = Bytes.fromHexString(Files.readString(Paths.get(p2pPrivateKeyFile)));
      } catch (IOException e) {
        throw new RuntimeException("p2p private key file not found - " + p2pPrivateKeyFile);
      }
    } else {
      final Optional<Bytes> generatedKeyBytes = keyValueStore.get(GENERATED_NODE_KEY_KEY);
      if (generatedKeyBytes.isEmpty()) {
        final PrivKey privKey = KeyKt.generateKeyPair(KEY_TYPE.SECP256K1).component1();
        privateKey = Bytes.wrap(KeyKt.marshalPrivateKey(privKey));
        keyValueStore.put(GENERATED_NODE_KEY_KEY, privateKey);
        STATUS_LOG.usingGeneratedP2pPrivateKey(GENERATED_NODE_KEY_KEY, true);
      } else {
        privateKey = generatedKeyBytes.get();
        STATUS_LOG.usingGeneratedP2pPrivateKey(GENERATED_NODE_KEY_KEY, false);
      }
    }

    return privateKey;
  }

  public  BeaconChainController(
      final ServiceConfig serviceConfig, final BeaconChainConfiguration beaconConfig);

}