chaintope/tapyrus-signer

Get federation update settings from config file.

rantan opened this issue · 6 comments

Make a tapyrus-signerd possible to get federation update settings from config file or command arguments.
This issue aims faster release federation management than full support for federation management specification.
The fields of adding to config is here.

This is new toml config file format for federation management which I propose.

The federation section can be set only in toml file not command line argument.

The pros of this format are that we can use same format for the first federation and updated federations. And we don't need to rewrite config file after updating federation would be finished. If the on going federation has special format such as put it in signer section, it should be re-written after the updating federation would be finished.

[signer]
publickey = "02785a891f323acd6cef0fc509bb14304410595914267c50467e51c87142acbb5e"

# Remove threshold and nodevss fields from `signer` section.

# federation section can be wrote multiple times.
[[federation]]
# This is the first federation when the network gets started.
block_height = 0
threshold = 2
nodevss = [
  "02785a891f323a...",
  "02ce7edc292d7b...",
  "03831a69b8009..."
]

# From block height is 100(includes the 100 height block), signer network works on new this federation config.
# This means the 99 height block has an aggregated public key for new federation.
[[federation]]
block_height = 100
threshold = 3
nodevss = [
  "0204b76790e15...",
  "02785a891f323a...",
  "02ce7edc292d7b...",
  "03410942870d9...",
  "03831a69b8009..."
]

# ... other config ..

And the federation config is deserialized like below:

#[derive(Debug, Deserialize)]
pub struct FederationToml {
    block_height: Option<u64>,
    threshold: Option<u8>,
    nodevss: Option<Vec<String>>,
}

#[derive(Debug, Deserialize, Default)]
struct ConfigToml {
    signer: Option<SignerToml>,
    rpc: Option<RpcToml>,
    redis: Option<RedisToml>,
    general: Option<GeneralToml>,
    federation: Option<Vec<FederationToml>>,
}

This means we can get federation config as Vec type.

Each property in FederationToml must be required, not Option?

Each property in FederationToml must be required, not Option?

Yes, it's true but no problem.
Current implementation uses Option type for make it through the deserialize process, and then it checks validity of each config item.

It is better to make it an independent file because of the writing that will occur when registering it by RPC call in the future.

Agree. I will make it an independent file.

All PRs for this issue were merged. #93, #98, #99