Hidden hardcoded Duniter variables

I’m creating this thread to list hidden hardcoded Duniter variables that should be exposed in a cleaner way (for example in pallet_config) so that we have easier control over Duniter parameters tuning.

Most of the constants are common in pallets_config.rs:

https://git.duniter.org/nodes/rust/duniter-v2s/-/blob/master/runtime/common/src/pallets_config.rs

Some are specific to gdev, gtest, or g1. Example:

https://git.duniter.org/nodes/rust/duniter-v2s/-/blob/master/runtime/g1/src/parameters.rs

1 Like
const TOKEN_DECIMALS: usize = 2;
const EXISTENTIAL_DEPOSIT: u64 = 200;

both hardcoded in chainspec, should be somewhere else

idty_name.len() >= 3
        && idty_name.len() <= 64

The bounds of identity length should be in pallet_config and not hardcoded. Without this, the wallets will not be able to get the values programmatically.

Duniter uses some environment variables. I do not consider it good practice as it is less explicit than a proper configuration file when not properly documented.

if let Ok(genesis_timestamp) = std::env::var("DUNITER_GENESIS_TIMESTAMP") {
    genesis_timestamp
        .parse()
        .map_err(|_| "DUNITER_GENESIS_TIMESTAMP must be a number".to_owned())?

Maybe the genesis timestamp could be directly in the genesis json. @poka do you know the genesis timestamp you used for ĞDev5 ? Or it can be provided by a system call like now().

[edit] actually it was the other option if genesis timestamp was not provided

use std::time::SystemTime;
SystemTime::now()
    .duration_since(SystemTime::UNIX_EPOCH)
    .expect("SystemTime before UNIX EPOCH!")
    .as_secs()
1 Like

No, I don’t know.
Please don’t remind me nightmares…

[…]

1 Like

It seems that the genesis timestamp isn’t used anywhere else than for computing membership expiration in number of blocks. So you could not have found it. The first timestamp is the one of the first block set_timestamp event.

I know, but…

When you provide a runtime name you should know that its beginning determines the runtime type:

impl IdentifyRuntimeType for Box<dyn sc_chain_spec::ChainSpec> {
    fn runtime_type(&self) -> RuntimeType {
        if self.id().starts_with("g1") {
            RuntimeType::G1
        } else if self.id().starts_with("gdem") {
            RuntimeType::GTest
        } else if self.id().starts_with("dev") || self.id().starts_with("gdev") {
            RuntimeType::GDev
        } else if self.id().starts_with("gt") {
            RuntimeType::GTest
        } else {
            panic!("unknown runtime")
        }
    }
}

Who did know about “gdem” or so?

1 Like

IIRC we have 2 options:

  1. place them in storage, so they can be mutated by governance
    But it makes any access slower.
  2. place them in runtime constants, so they can be mutated by runtime upgrade

I can’t find the issues. It could be a D-easy issue I think?

1 Like

The answer might be in Liste des paramètres (protocolaires) de Duniter-v2s