Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set initial peers and genesis code alongside network id #243

Open
steinerkelvin opened this issue Nov 22, 2022 · 5 comments
Open

Set initial peers and genesis code alongside network id #243

steinerkelvin opened this issue Nov 22, 2022 · 5 comments
Assignees

Comments

@steinerkelvin
Copy link
Contributor

  • 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 = [
  ...
]
@dan-da
Copy link

dan-da commented Nov 22, 2022

I think I could take this one.

@dan-da
Copy link

dan-da commented Nov 22, 2022

@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.

@steinerkelvin
Copy link
Contributor Author

Yeap, it's kindelia_core/genesis.kdl.

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

@dan-da
Copy link

dan-da commented Nov 22, 2022

[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.

@steinerkelvin
Copy link
Contributor Author

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.

dan-da added a commit to dan-da/Kindelia that referenced this issue Nov 24, 2022
Addresses kindelia#243

Support for loading a different genesis block for each network.

The genesis block is loaded from a file whose path is the pattern:
~/.kindelia/genesis/<network-id>.kdl

Changes:

 core:
  * add util::genesis_path() with associated error enum
  * add util::genesis_code() with associated error enum
  * modify hvm::test_statements*() to accept network_id and load genesis
    block from file instead of compiled string
  * modify node::new() to to accept network_id and load genesis block
    from file instead of compiled string

 cli:
  * add network_id to test command, required by hvm::test_statements()
dan-da added a commit to dan-da/Kindelia that referenced this issue Nov 24, 2022
Addresses kindelia#243

Support for loading a different genesis block for each network.

The genesis block is loaded from a file whose path is the pattern:
~/.kindelia/genesis/<network-id>.kdl

Changes:

 core:
  * add util::genesis_path() with associated error enum
  * add util::genesis_code() with associated error enum
  * modify hvm::test_statements*() to accept network_id and load genesis
    block from file instead of compiled string
  * modify node::new() to to accept network_id and load genesis block
    from file instead of compiled string

 cli:
  * add network_id to test command, required by hvm::test_statements()
  * fix parsing of hex values for --network_id
  * add clap_num dep for parsing hex values
dan-da added a commit to dan-da/Kindelia that referenced this issue Nov 28, 2022
Addresses kindelia#243

Support for loading a different genesis block for each network.

The genesis block is loaded from a file whose path is the pattern:
~/.kindelia/genesis/<network-id>.kdl

Changes:

 core:
  * add util::genesis_path() with associated error enum
  * add util::genesis_code() with associated error enum
  * modify hvm::test_statements*() to accept network_id and load genesis
    block from file instead of compiled string
  * modify node::new() to to accept network_id and load genesis block
    from file instead of compiled string

 cli:
  * add network_id to test command, required by hvm::test_statements()
  * fix parsing of hex values for --network_id
  * add clap_num dep for parsing hex values
dan-da added a commit to dan-da/Kindelia that referenced this issue Nov 28, 2022
Addresses kindelia#243

Support for loading a different genesis block for each network.

The genesis block is loaded from a file whose path is the pattern:
~/.kindelia/genesis/<network-id>.kdl

Changes:

 core:
  * add util::genesis_path() with associated error enum
  * add util::genesis_code() with associated error enum
  * modify hvm::test_statements*() to accept network_id and load genesis
    block from file instead of compiled string
  * modify node::new() to to accept network_id and load genesis block
    from file instead of compiled string

 cli:
  * add network_id to test command, required by hvm::test_statements()
  * fix parsing of hex values for --network_id
  * add clap_num dep for parsing hex values
dan-da added a commit to dan-da/Kindelia that referenced this issue Dec 4, 2022
Addresses kindelia#243

Support for loading a different genesis block for each network.

The genesis block is loaded from a file whose path is the pattern:
~/.kindelia/genesis/<network-id>.kdl

Changes:

 core:
  * add util::genesis_path() with associated error enum
  * add util::genesis_code() with associated error enum
  * modify hvm::test_statements*() to accept network_id and load genesis
    block from file instead of compiled string
  * modify node::new() to to accept network_id and load genesis block
    from file instead of compiled string

 cli:
  * add network_id to test command, required by hvm::test_statements()
  * fix parsing of hex values for --network_id
  * add clap_num dep for parsing hex values
dan-da added a commit to dan-da/Kindelia that referenced this issue Dec 7, 2022
Addresses kindelia#243

Support for loading a different genesis block for each network.

The genesis block is loaded from a file whose path is the pattern:
~/.kindelia/genesis/<network-id>.kdl

Changes:

 core:
  * add util::genesis_path() with associated error enum
  * add util::genesis_code() with associated error enum
  * modify hvm::test_statements*() to accept network_id and load genesis
    block from file instead of compiled string
  * modify node::new() to to accept network_id and load genesis block
    from file instead of compiled string

 cli:
  * add network_id to test command, required by hvm::test_statements()
  * fix parsing of hex values for --network_id
  * add clap_num dep for parsing hex values
dan-da added a commit to dan-da/Kindelia that referenced this issue Dec 7, 2022
Addresses kindelia#243

Support for loading a different genesis block for each network.

The genesis block is loaded from a file whose path is the pattern:
~/.kindelia/genesis/<network-id>.kdl

Changes:

 core:
  * add util::genesis_path() with associated error enum
  * add util::genesis_code() with associated error enum
  * modify hvm::test_statements*() to accept network_id and load genesis
    block from file instead of compiled string
  * modify node::new() to to accept network_id and load genesis block
    from file instead of compiled string

 cli:
  * add network_id to test command, required by hvm::test_statements()
  * fix parsing of hex values for --network_id
  * add clap_num dep for parsing hex values
dan-da added a commit to dan-da/Kindelia that referenced this issue Dec 13, 2022
Addresses kindelia#243

Support for loading a different genesis block for each network.

The genesis block is loaded from a file whose path is the pattern:
~/.kindelia/genesis/<network-id>.kdl

Changes:

 core:
  * add util::genesis_path() with associated error enum
  * add util::genesis_code() with associated error enum
  * modify hvm::test_statements*() to accept network_id and load genesis
    block from file instead of compiled string
  * modify node::new() to to accept network_id and load genesis block
    from file instead of compiled string

 cli:
  * add network_id to test command, required by hvm::test_statements()
  * fix parsing of hex values for --network_id
  * add clap_num dep for parsing hex values
dan-da added a commit to dan-da/Kindelia that referenced this issue Dec 18, 2022
Addresses kindelia#243

Support for loading a different genesis block for each network.

The genesis block is loaded from a file whose path is the pattern:
~/.kindelia/genesis/<network-id>.kdl

Changes:

 core:
  * add util::genesis_path() with associated error enum
  * add util::genesis_code() with associated error enum
  * modify hvm::test_statements*() to accept network_id and load genesis
    block from file instead of compiled string
  * modify node::new() to to accept network_id and load genesis block
    from file instead of compiled string

 cli:
  * add network_id to test command, required by hvm::test_statements()
  * fix parsing of hex values for --network_id
  * add clap_num dep for parsing hex values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants