Files
nym/contracts/mixnet/src/constants.rs
T
Jędrzej Stuczyński d8c84cc4d6 feat: key rotation (#5777)
* wip

* wip: wrap node's sphinx key with a manager

* wip: choosing correct key for packet processing

* further propagation of key rotation information

* attaching key rotation information to reply surbs

* added basic key rotation information to mixnet contract

* wip: introducing cached queries for key rotation info from nym api

* unified nym-api contract cache refreshing

* finish packet decoding

* multi api client + retrieving rotation id

* rotating sphinx key files

* logic for migrating config file

* wip: putting new sphinx keys to self described endpoints

* processing loop of KeyRotationController

* fixed sphinx key loading

* rotating bloomfilters

* wired up KeyRotationController

* flushing bloomfilters to disk and loading

* most of nym-node changes

* post rebase fixes

* fixes due to backwards compatible hostkeys

* split http state.rs file

* dont use deprecated fields

* fixed backwards compatible deserialisation of host information

* split up node describe cache

* added a dedicated CacheRefresher listener to perform full refresh outside the set interval

* controlling announced sphinx keys within nym-api

* retrieving rotation id when pulling topology

* split nym-nodes http handlers

* v2 nym-api endpoints to retrieve nodes with additional metadata information

* bug fixes...

* additional bugfixes and guards against stuck epoch

* testnet manager: set first nym-api as the rewarder

* fixed host information deserialisation

* fixed panic during first key rotation

* post rebase fixes

* clippy

* more guards against stuck epochs

* added helper method to reset node's sphinx key

* instantiate mixnet contract with custom key rotation validity

* additional bugfixes and debugging nym-api deadlock

* passing shutdown to nym apis client

* remove dead test

* post rebasing fixes

* missing MixnetQueryClient variants

* remove usage of deprecated methods in sdk example

* fix: incorrect method signature

* post rebasing fixes

* attempt to retrieve key rotation id before doing any config migration work

* ignore tests relying on networking behaviour

* allow networking failures in certain tests
2025-06-03 11:22:51 +01:00

112 lines
4.6 KiB
Rust

// Copyright 2022-2023 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
use cosmwasm_std::{Coin, Uint128};
use mixnet_contract_common::{
NodeCostParams, DEFAULT_INTERVAL_OPERATING_COST_AMOUNT, DEFAULT_PROFIT_MARGIN_PERCENT,
};
use nym_contracts_common::Percent;
/// Constant specifying minimum of coin amount required to bond a node
pub const INITIAL_PLEDGE_AMOUNT: Uint128 = Uint128::new(100_000_000);
pub fn default_node_costs<S: Into<String>>(rewarding_denom: S) -> NodeCostParams {
// safety: our hardcoded PM value is a valid percent
#[allow(clippy::unwrap_used)]
NodeCostParams {
profit_margin_percent: Percent::from_percentage_value(DEFAULT_PROFIT_MARGIN_PERCENT)
.unwrap(),
interval_operating_cost: Coin::new(DEFAULT_INTERVAL_OPERATING_COST_AMOUNT, rewarding_denom),
}
}
// retrieval limits
// TODO: those would need to be empirically verified whether they're not way too small or way too high
pub const GATEWAY_BOND_DEFAULT_RETRIEVAL_LIMIT: u32 = 50;
pub const GATEWAY_BOND_MAX_RETRIEVAL_LIMIT: u32 = 100;
pub const MIXNODE_BOND_DEFAULT_RETRIEVAL_LIMIT: u32 = 50;
pub const MIXNODE_BOND_MAX_RETRIEVAL_LIMIT: u32 = 100;
pub const NYM_NODE_BOND_DEFAULT_RETRIEVAL_LIMIT: u32 = 50;
pub const NYM_NODE_BOND_MAX_RETRIEVAL_LIMIT: u32 = 100;
pub const MIXNODE_DETAILS_DEFAULT_RETRIEVAL_LIMIT: u32 = 50;
pub const MIXNODE_DETAILS_MAX_RETRIEVAL_LIMIT: u32 = 75;
pub const NYM_NODE_DETAILS_DEFAULT_RETRIEVAL_LIMIT: u32 = 50;
pub const NYM_NODE_DETAILS_MAX_RETRIEVAL_LIMIT: u32 = 75;
pub const UNBONDED_MIXNODES_DEFAULT_RETRIEVAL_LIMIT: u32 = 100;
pub const UNBONDED_MIXNODES_MAX_RETRIEVAL_LIMIT: u32 = 200;
pub const UNBONDED_NYM_NODES_DEFAULT_RETRIEVAL_LIMIT: u32 = 100;
pub const UNBONDED_NYM_NODES_MAX_RETRIEVAL_LIMIT: u32 = 200;
pub const DELEGATION_PAGE_DEFAULT_RETRIEVAL_LIMIT: u32 = 100;
pub const DELEGATION_PAGE_MAX_RETRIEVAL_LIMIT: u32 = 500;
pub const EPOCH_EVENTS_DEFAULT_RETRIEVAL_LIMIT: u32 = 50;
pub const EPOCH_EVENTS_MAX_RETRIEVAL_LIMIT: u32 = 100;
pub const INTERVAL_EVENTS_DEFAULT_RETRIEVAL_LIMIT: u32 = 50;
pub const INTERVAL_EVENTS_MAX_RETRIEVAL_LIMIT: u32 = 100;
// storage keys
pub const DELEGATION_PK_NAMESPACE: &str = "dl";
pub const DELEGATION_OWNER_IDX_NAMESPACE: &str = "dlo";
pub const DELEGATION_MIXNODE_IDX_NAMESPACE: &str = "dlm";
pub const GATEWAYS_PK_NAMESPACE: &str = "gt";
pub const GATEWAYS_OWNER_IDX_NAMESPACE: &str = "gto";
pub const CURRENT_EPOCH_STATUS_KEY: &str = "ces";
pub const CURRENT_INTERVAL_KEY: &str = "ci";
pub const EPOCH_EVENT_ID_COUNTER_KEY: &str = "eic";
pub const INTERVAL_EVENT_ID_COUNTER_KEY: &str = "iic";
pub const PENDING_EPOCH_EVENTS_NAMESPACE: &str = "pee";
pub const PENDING_INTERVAL_EVENTS_NAMESPACE: &str = "pie";
pub const LAST_EPOCH_EVENT_ID_KEY: &str = "lee";
pub const LAST_INTERVAL_EVENT_ID_KEY: &str = "lie";
pub const ADMIN_STORAGE_KEY: &str = "admin";
pub const CONTRACT_STATE_KEY: &str = "state";
pub const VERSION_HISTORY_ID_COUNTER_KEY: &str = "vhid";
pub const VERSION_HISTORY_NAMESPACE: &str = "vh";
pub const NYMNODE_ROLES_ASSIGNMENT_NAMESPACE: &str = "roles";
pub const NYMNODE_REWARDED_SET_METADATA_NAMESPACE: &str = "roles_metadata";
pub const NYMNODE_ACTIVE_ROLE_ASSIGNMENT_KEY: &str = "active_roles";
pub const KEY_ROTATION_STATE_KEY: &str = "key_rot_state";
pub const NODE_ID_COUNTER_KEY: &str = "nic";
pub const PENDING_MIXNODE_CHANGES_NAMESPACE: &str = "pmc";
pub const MIXNODES_PK_NAMESPACE: &str = "mnn";
pub const MIXNODES_OWNER_IDX_NAMESPACE: &str = "mno";
pub const MIXNODES_IDENTITY_IDX_NAMESPACE: &str = "mni";
pub const MIXNODES_SPHINX_IDX_NAMESPACE: &str = "mns";
pub const PENDING_NYMNODE_CHANGES_NAMESPACE: &str = "pnc";
pub const NYMNODE_PK_NAMESPACE: &str = "nn";
pub const NYMNODE_OWNER_IDX_NAMESPACE: &str = "nno";
pub const NYMNODE_IDENTITY_IDX_NAMESPACE: &str = "nni";
pub const UNBONDED_MIXNODES_PK_NAMESPACE: &str = "ubm";
pub const UNBONDED_MIXNODES_OWNER_IDX_NAMESPACE: &str = "umo";
pub const UNBONDED_MIXNODES_IDENTITY_IDX_NAMESPACE: &str = "umi";
pub const UNBONDED_NYMNODE_PK_NAMESPACE: &str = "ubnn";
pub const UNBONDED_NYMNODE_OWNER_IDX_NAMESPACE: &str = "ubno";
pub const UNBONDED_NYMNODE_IDENTITY_IDX_NAMESPACE: &str = "ubni";
pub const CUMULATIVE_EPOCH_WORK_KEY: &str = "cumulative_epoch_work";
pub const REWARDING_PARAMS_KEY: &str = "rparams";
pub const PENDING_REWARD_POOL_KEY: &str = "prp";
pub const MIXNODES_REWARDING_PK_NAMESPACE: &str = "mnr";
pub const NYMNODE_REWARDING_PK_NAMESPACE: &str = MIXNODES_REWARDING_PK_NAMESPACE;
pub const SIGNING_NONCES_NAMESPACE: &str = "sn";
// temporary storage keys created for the transition period:
pub const LEGACY_GATEWAY_ID_NAMESPACE: &str = "lgidr";