Kindelia icon indicating copy to clipboard operation
Kindelia copied to clipboard

Set initial peers and genesis code alongside network id

Open steinerkelvin opened this issue 3 years ago • 5 comments

  • Which peers you want to connect to depends on which network id / protocol version you are using
  • Also, the genesis code, which defines the hash of the genesis code, reverberate on the entire chain

It's interesting to be able to associate both with the network id in the node configuration.

[node.network]
network_id = "0xCAFE0004"

[node.networks.0xCAFE0004]
genesis_code = '~/.kindelia/genesis/cafe0004.kdl'
initial_peers = [
  "64.227.110.69",
  "188.166.3.140",
]

[node.networks.0xCAFE0005]
genesis_code = '~/.kindelia/genesis/cafe0005.kdl'
initial_peers = [
  ...
]

steinerkelvin avatar Nov 22 '22 14:11 steinerkelvin

I think I could take this one.

dan-da avatar Nov 22 '22 16:11 dan-da

@steinerkelvin can you provide an example of what might go in ~/.kindelia/genesis/cafe0004.kdl? and cafe0005.kdl?

is it different than kindelia_core/genesis.kdl?

btw, initial_peers is already defined per-network as of #235. See default.toml.

dan-da avatar Nov 22 '22 17:11 dan-da

Yeap, it's kindelia_core/genesis.kdl.

~/.kindelia/genesis/0xCAFE00XX.kdl would store an specific version of kindelia_core/genesis.kdl.

steinerkelvin avatar Nov 22 '22 18:11 steinerkelvin

[node.networks.0xCAFE0004]
genesis_code = '~/.kindelia/genesis/cafe0004.kdl'

It occurs to me that the path of the genesis block file could be deterministic (automagic) based on network ID.

Eg for [node.networks.0xCAFE0004] the node would automatically look for the matching file ~/.kindelia/genesis/0xCAFE0004.kdl and print an error with the path if not found. So it is not necessary to specify genesis_code (line 2 above goes away) and that's one less thing to possibly get wrong in the config.

Of course it sacrifices flexibility in terms of naming and path. So that's the tradeoff.

Counter-argument is that the deterministic approach is more regular and predictable. Less chance for users to screw up and use the wrong genesis block for a given network.

thoughts?

I will start with the deterministic approach because it is a bit faster to impl and after make it configurable if that is the consensus.

dan-da avatar Nov 22 '22 22:11 dan-da

I think is fine to do it deterministically. Less bloat and it could be added in the future as an optional field if it feels necessary.

steinerkelvin avatar Nov 23 '22 20:11 steinerkelvin