Skip to main content

nym_mixnet_contract_common/
msg.rs

1// Copyright 2021-2024 - Nym Technologies SA <contact@nymtech.net>
2// SPDX-License-Identifier: Apache-2.0
3
4use crate::delegation::{self, OwnerProxySubKey};
5use crate::error::MixnetContractError;
6use crate::gateway::{Gateway, GatewayConfigUpdate};
7use crate::helpers::IntoBaseDecimal;
8use crate::mixnode::{MixNode, MixNodeConfigUpdate, NodeCostParams};
9use crate::nym_node::{NodeConfigUpdate, Role};
10use crate::pending_events::{EpochEventId, IntervalEventId};
11use crate::reward_params::{
12    ActiveSetUpdate, IntervalRewardParams, IntervalRewardingParamsUpdate, NodeRewardingParameters,
13    Performance, RewardedSetParams, RewardingParams, WorkFactor,
14};
15use crate::types::NodeId;
16use crate::{
17    ContractStateParamsUpdate, NymNode, OutdatedVersionWeights, RoleAssignment,
18    VersionScoreFormulaParams,
19};
20use crate::{OperatingCostRange, ProfitMarginRange};
21use cosmwasm_schema::cw_serde;
22use cosmwasm_std::{Coin, Decimal};
23use nym_contracts_common::{IdentityKey, Percent, signing::MessageSignature};
24use std::time::Duration;
25
26#[cfg(feature = "schema")]
27use crate::{
28    config_score::{CurrentNymNodeVersionResponse, NymNodeVersionHistoryResponse},
29    delegation::{
30        NodeDelegationResponse, PagedAllDelegationsResponse, PagedDelegatorDelegationsResponse,
31        PagedNodeDelegationsResponse,
32    },
33    gateway::{
34        GatewayBondResponse, GatewayOwnershipResponse, PagedGatewayResponse,
35        PreassignedGatewayIdsResponse,
36    },
37    interval::{CurrentIntervalResponse, EpochStatus},
38    key_rotation::{KeyRotationIdResponse, KeyRotationState},
39    mixnode::{
40        MixOwnershipResponse, MixStakeSaturationResponse, MixnodeDetailsByIdentityResponse,
41        MixnodeDetailsResponse, MixnodeRewardingDetailsResponse, PagedMixnodeBondsResponse,
42        PagedMixnodesDetailsResponse, PagedUnbondedMixnodesResponse, UnbondedMixnodeResponse,
43    },
44    nym_node::{
45        EpochAssignmentResponse, NodeDetailsByIdentityResponse, NodeDetailsResponse,
46        NodeOwnershipResponse, NodeRewardingDetailsResponse, PagedNymNodeBondsResponse,
47        PagedNymNodeDetailsResponse, PagedUnbondedNymNodesResponse, RolesMetadataResponse,
48        StakeSaturationResponse, UnbondedNodeResponse,
49    },
50    pending_events::{
51        NumberOfPendingEventsResponse, PendingEpochEventResponse, PendingEpochEventsResponse,
52        PendingIntervalEventResponse, PendingIntervalEventsResponse,
53    },
54    rewarding::{EstimatedCurrentEpochRewardResponse, PendingRewardResponse},
55    types::{ContractState, ContractStateParams},
56};
57#[cfg(feature = "schema")]
58use cosmwasm_schema::QueryResponses;
59#[cfg(feature = "schema")]
60use nym_contracts_common::{ContractBuildInformation, signing::Nonce};
61
62#[cw_serde]
63pub struct InstantiateMsg {
64    pub rewarding_validator_address: String,
65    pub vesting_contract_address: String,
66    pub node_families_contract_address: String,
67
68    pub rewarding_denom: String,
69    pub epochs_in_interval: u32,
70    pub epoch_duration: Duration,
71    pub initial_rewarding_params: InitialRewardingParams,
72
73    pub current_nym_node_version: String,
74
75    #[serde(default)]
76    pub version_score_weights: OutdatedVersionWeights,
77
78    #[serde(default)]
79    pub version_score_params: VersionScoreFormulaParams,
80
81    #[serde(default)]
82    pub profit_margin: ProfitMarginRange,
83
84    #[serde(default)]
85    pub interval_operating_cost: OperatingCostRange,
86
87    #[serde(default)]
88    pub key_validity_in_epochs: Option<u32>,
89}
90
91impl InstantiateMsg {
92    // needs to give us enough time to pre-announce key for following epoch
93    // and have an overlap with the preceding epoch
94    pub const MIN_KEY_ROTATION_VALIDITY: u32 = 3;
95    pub fn key_validity_in_epochs(&self) -> u32 {
96        self.key_validity_in_epochs.unwrap_or(24)
97    }
98}
99
100#[cw_serde]
101pub struct InitialRewardingParams {
102    pub initial_reward_pool: Decimal,
103    pub initial_staking_supply: Decimal,
104
105    pub staking_supply_scale_factor: Percent,
106    pub sybil_resistance: Percent,
107    pub active_set_work_factor: Decimal,
108    pub interval_pool_emission: Percent,
109
110    pub rewarded_set_params: RewardedSetParams,
111}
112
113impl InitialRewardingParams {
114    pub fn into_rewarding_params(
115        self,
116        epochs_in_interval: u32,
117    ) -> Result<RewardingParams, MixnetContractError> {
118        let epoch_reward_budget = self.initial_reward_pool
119            / epochs_in_interval.into_base_decimal()?
120            * self.interval_pool_emission;
121        let stake_saturation_point = self.initial_staking_supply
122            / self
123                .rewarded_set_params
124                .rewarded_set_size()
125                .into_base_decimal()?;
126
127        Ok(RewardingParams {
128            interval: IntervalRewardParams {
129                reward_pool: self.initial_reward_pool,
130                staking_supply: self.initial_staking_supply,
131                staking_supply_scale_factor: self.staking_supply_scale_factor,
132                epoch_reward_budget,
133                stake_saturation_point,
134                sybil_resistance: self.sybil_resistance,
135                active_set_work_factor: self.active_set_work_factor,
136                interval_pool_emission: self.interval_pool_emission,
137            },
138            rewarded_set: self.rewarded_set_params,
139        })
140    }
141}
142
143#[cw_serde]
144pub enum ExecuteMsg {
145    /// Change the admin
146    UpdateAdmin {
147        admin: String,
148    },
149
150    // state/sys-params-related
151    UpdateRewardingValidatorAddress {
152        address: String,
153    },
154    UpdateContractStateParams {
155        update: ContractStateParamsUpdate,
156    },
157    UpdateCurrentNymNodeSemver {
158        current_version: String,
159    },
160    UpdateActiveSetDistribution {
161        update: ActiveSetUpdate,
162        force_immediately: bool,
163    },
164    UpdateRewardingParams {
165        updated_params: IntervalRewardingParamsUpdate,
166        force_immediately: bool,
167    },
168    UpdateIntervalConfig {
169        epochs_in_interval: u32,
170        epoch_duration_secs: u64,
171        force_immediately: bool,
172    },
173
174    BeginEpochTransition {},
175    ReconcileEpochEvents {
176        limit: Option<u32>,
177    },
178    AssignRoles {
179        assignment: RoleAssignment,
180    },
181
182    // mixnode-related:
183    BondMixnode {
184        mix_node: MixNode,
185        cost_params: NodeCostParams,
186        owner_signature: MessageSignature,
187    },
188    BondMixnodeOnBehalf {
189        mix_node: MixNode,
190        cost_params: NodeCostParams,
191        owner_signature: MessageSignature,
192        owner: String,
193    },
194    PledgeMore {},
195    PledgeMoreOnBehalf {
196        owner: String,
197    },
198    DecreasePledge {
199        decrease_by: Coin,
200    },
201    DecreasePledgeOnBehalf {
202        owner: String,
203        decrease_by: Coin,
204    },
205    UnbondMixnode {},
206    UnbondMixnodeOnBehalf {
207        owner: String,
208    },
209    #[serde(
210        alias = "UpdateMixnodeCostParams",
211        alias = "update_mixnode_cost_params"
212    )]
213    UpdateCostParams {
214        new_costs: NodeCostParams,
215    },
216    UpdateMixnodeCostParamsOnBehalf {
217        new_costs: NodeCostParams,
218        owner: String,
219    },
220    UpdateMixnodeConfig {
221        new_config: MixNodeConfigUpdate,
222    },
223    UpdateMixnodeConfigOnBehalf {
224        new_config: MixNodeConfigUpdate,
225        owner: String,
226    },
227    MigrateMixnode {},
228
229    // gateway-related:
230    BondGateway {
231        gateway: Gateway,
232        owner_signature: MessageSignature,
233    },
234    BondGatewayOnBehalf {
235        gateway: Gateway,
236        owner: String,
237        owner_signature: MessageSignature,
238    },
239    UnbondGateway {},
240    UnbondGatewayOnBehalf {
241        owner: String,
242    },
243    UpdateGatewayConfig {
244        new_config: GatewayConfigUpdate,
245    },
246    UpdateGatewayConfigOnBehalf {
247        new_config: GatewayConfigUpdate,
248        owner: String,
249    },
250    MigrateGateway {
251        cost_params: Option<NodeCostParams>,
252    },
253
254    // nym-node related:
255    BondNymNode {
256        node: NymNode,
257        cost_params: NodeCostParams,
258        owner_signature: MessageSignature,
259    },
260    UnbondNymNode {},
261    UpdateNodeConfig {
262        update: NodeConfigUpdate,
263    },
264
265    // delegation-related:
266    #[serde(alias = "DelegateToMixnode", alias = "delegate_to_mixnode")]
267    Delegate {
268        #[serde(alias = "mix_id")]
269        node_id: NodeId,
270    },
271    DelegateToMixnodeOnBehalf {
272        mix_id: NodeId,
273        delegate: String,
274    },
275    #[serde(alias = "UndelegateFromMixnode", alias = "undelegate_from_mixnode")]
276    Undelegate {
277        #[serde(alias = "mix_id")]
278        node_id: NodeId,
279    },
280    UndelegateFromMixnodeOnBehalf {
281        mix_id: NodeId,
282        delegate: String,
283    },
284
285    // reward-related
286    RewardNode {
287        #[serde(alias = "mix_id")]
288        node_id: NodeId,
289        params: NodeRewardingParameters,
290    },
291    WithdrawOperatorReward {},
292    WithdrawOperatorRewardOnBehalf {
293        owner: String,
294    },
295    WithdrawDelegatorReward {
296        #[serde(alias = "mix_id")]
297        node_id: NodeId,
298    },
299    WithdrawDelegatorRewardOnBehalf {
300        mix_id: NodeId,
301        owner: String,
302    },
303
304    // vesting migration:
305    MigrateVestedMixNode {},
306    MigrateVestedDelegation {
307        mix_id: NodeId,
308    },
309    /// Admin-only: forcibly migrate the vested mixnode owned by `owner`.
310    /// Used to drain the last vested entries so the mixnet contract can drop its dependency on the vesting contract.
311    AdminMigrateVestedMixNode {
312        owner: String,
313    },
314    /// Admin-only: forcibly migrate the vested delegation `(mix_id, owner)`.
315    /// Used to drain the last vested entries so the mixnet contract can drop its dependency on the vesting contract.
316    AdminMigrateVestedDelegation {
317        mix_id: NodeId,
318        owner: String,
319    },
320    /// Admin-only: batch variant of [`ExecuteMsg::AdminMigrateVestedDelegation`].
321    /// Reverts the entire batch on the first error, so callers should treat it as all-or-nothing.
322    AdminBatchMigrateVestedDelegations {
323        entries: Vec<VestedDelegationMigrationEntry>,
324    },
325
326    // testing-only
327    #[cfg(feature = "contract-testing")]
328    TestingResolveAllPendingEvents {
329        limit: Option<u32>,
330    },
331}
332
333impl ExecuteMsg {
334    pub fn default_memo(&self) -> String {
335        match self {
336            ExecuteMsg::UpdateAdmin { admin } => format!("updating contract admin to {admin}"),
337            ExecuteMsg::UpdateRewardingValidatorAddress { address } => {
338                format!("updating rewarding validator to {address}")
339            }
340            ExecuteMsg::UpdateContractStateParams { .. } => {
341                "updating mixnet state parameters".into()
342            }
343            ExecuteMsg::UpdateCurrentNymNodeSemver { current_version } => {
344                format!("updating current nym-node semver to {current_version}")
345            }
346            ExecuteMsg::UpdateActiveSetDistribution {
347                force_immediately, ..
348            } => format!("updating active set distribution. forced: {force_immediately}"),
349            ExecuteMsg::UpdateRewardingParams {
350                force_immediately, ..
351            } => format!("updating mixnet rewarding parameters. forced: {force_immediately}"),
352            ExecuteMsg::UpdateIntervalConfig {
353                force_immediately, ..
354            } => format!("updating mixnet interval configuration. forced: {force_immediately}"),
355            ExecuteMsg::BeginEpochTransition {} => "beginning epoch transition".into(),
356            ExecuteMsg::ReconcileEpochEvents { .. } => "reconciling epoch events".into(),
357            ExecuteMsg::BondMixnode { mix_node, .. } => {
358                format!("bonding mixnode {}", mix_node.identity_key)
359            }
360            ExecuteMsg::BondMixnodeOnBehalf { mix_node, .. } => {
361                format!("bonding mixnode {} on behalf", mix_node.identity_key)
362            }
363            ExecuteMsg::PledgeMore {} => "pledging additional tokens".into(),
364            ExecuteMsg::PledgeMoreOnBehalf { .. } => "pledging additional tokens on behalf".into(),
365            ExecuteMsg::DecreasePledge { .. } => "decreasing mixnode pledge".into(),
366            ExecuteMsg::DecreasePledgeOnBehalf { .. } => {
367                "decreasing mixnode pledge on behalf".into()
368            }
369            ExecuteMsg::UnbondMixnode { .. } => "unbonding mixnode".into(),
370            ExecuteMsg::UnbondMixnodeOnBehalf { .. } => "unbonding mixnode on behalf".into(),
371            ExecuteMsg::UpdateCostParams { .. } => "updating mixnode cost parameters".into(),
372            ExecuteMsg::UpdateMixnodeCostParamsOnBehalf { .. } => {
373                "updating mixnode cost parameters on behalf".into()
374            }
375            ExecuteMsg::UpdateMixnodeConfig { .. } => "updating mixnode configuration".into(),
376            ExecuteMsg::UpdateMixnodeConfigOnBehalf { .. } => {
377                "updating mixnode configuration on behalf".into()
378            }
379            ExecuteMsg::BondGateway { gateway, .. } => {
380                format!("bonding gateway {}", gateway.identity_key)
381            }
382            ExecuteMsg::BondGatewayOnBehalf { gateway, .. } => {
383                format!("bonding gateway {} on behalf", gateway.identity_key)
384            }
385            ExecuteMsg::UnbondGateway { .. } => "unbonding gateway".into(),
386            ExecuteMsg::UnbondGatewayOnBehalf { .. } => "unbonding gateway on behalf".into(),
387            ExecuteMsg::UpdateGatewayConfig { .. } => "updating gateway configuration".into(),
388            ExecuteMsg::UpdateGatewayConfigOnBehalf { .. } => {
389                "updating gateway configuration on behalf".into()
390            }
391            ExecuteMsg::Delegate { node_id: mix_id } => format!("delegating to mixnode {mix_id}"),
392            ExecuteMsg::DelegateToMixnodeOnBehalf { mix_id, .. } => {
393                format!("delegating to mixnode {mix_id} on behalf")
394            }
395            ExecuteMsg::Undelegate { node_id: mix_id } => {
396                format!("removing delegation from mixnode {mix_id}")
397            }
398            ExecuteMsg::UndelegateFromMixnodeOnBehalf { mix_id, .. } => {
399                format!("removing delegation from mixnode {mix_id} on behalf")
400            }
401            ExecuteMsg::RewardNode { node_id, .. } => format!("rewarding node {node_id}"),
402            ExecuteMsg::WithdrawOperatorReward { .. } => "withdrawing operator reward".into(),
403            ExecuteMsg::WithdrawOperatorRewardOnBehalf { .. } => {
404                "withdrawing operator reward on behalf".into()
405            }
406            ExecuteMsg::WithdrawDelegatorReward { node_id: mix_id } => {
407                format!("withdrawing delegator reward from mixnode {mix_id}")
408            }
409            ExecuteMsg::WithdrawDelegatorRewardOnBehalf { mix_id, .. } => {
410                format!("withdrawing delegator reward from mixnode {mix_id} on behalf")
411            }
412            ExecuteMsg::MigrateVestedMixNode { .. } => "migrate vested mixnode".into(),
413            ExecuteMsg::MigrateVestedDelegation { .. } => "migrate vested delegation".to_string(),
414            ExecuteMsg::AdminMigrateVestedMixNode { owner } => {
415                format!("admin migrating vested mixnode of {owner}")
416            }
417            ExecuteMsg::AdminMigrateVestedDelegation { mix_id, owner } => {
418                format!("admin migrating vested delegation of {owner} on mixnode {mix_id}")
419            }
420            ExecuteMsg::AdminBatchMigrateVestedDelegations { entries } => {
421                format!("admin batch migrating {} vested delegations", entries.len())
422            }
423            ExecuteMsg::AssignRoles { .. } => "assigning epoch roles".into(),
424            ExecuteMsg::MigrateMixnode { .. } => "migrating legacy mixnode".into(),
425            ExecuteMsg::MigrateGateway { .. } => "migrating legacy gateway".into(),
426            ExecuteMsg::BondNymNode { .. } => "bonding nym-node".into(),
427            ExecuteMsg::UnbondNymNode { .. } => "unbonding nym-node".into(),
428            ExecuteMsg::UpdateNodeConfig { .. } => "updating node config".into(),
429
430            #[cfg(feature = "contract-testing")]
431            ExecuteMsg::TestingResolveAllPendingEvents { .. } => {
432                "resolving all pending events".into()
433            }
434        }
435    }
436}
437
438#[cw_serde]
439#[cfg_attr(feature = "schema", derive(QueryResponses))]
440pub enum QueryMsg {
441    #[cfg_attr(feature = "schema", returns(cw_controllers::AdminResponse))]
442    Admin {},
443
444    // state/sys-params-related
445    /// Gets build information of this contract, such as the commit hash used for the build or rustc version.
446    #[cfg_attr(feature = "schema", returns(ContractBuildInformation))]
447    GetContractVersion {},
448
449    /// Gets the stored contract version information that's required by the CW2 spec interface for migrations.
450    #[serde(rename = "get_cw2_contract_version")]
451    #[cfg_attr(feature = "schema", returns(cw2::ContractVersion))]
452    GetCW2ContractVersion {},
453
454    /// Gets the address of the validator that's allowed to send rewarding transactions and transition the epoch.
455    #[cfg_attr(feature = "schema", returns(String))]
456    GetRewardingValidatorAddress {},
457
458    /// Gets the contract parameters that could be adjusted in a transaction by the contract admin.
459    #[cfg_attr(feature = "schema", returns(ContractStateParams))]
460    GetStateParams {},
461
462    /// Gets the current state of the contract.
463    #[cfg_attr(feature = "schema", returns(ContractState))]
464    GetState {},
465
466    /// Get the current expected version of a Nym Node.
467    #[cfg_attr(feature = "schema", returns(CurrentNymNodeVersionResponse))]
468    GetCurrentNymNodeVersion {},
469
470    /// Get the version history of Nym Node.
471    #[cfg_attr(feature = "schema", returns(NymNodeVersionHistoryResponse))]
472    GetNymNodeVersionHistory {
473        /// Controls the maximum number of entries returned by the query. Note that too large values will be overwritten by a saner default.
474        limit: Option<u32>,
475
476        /// Pagination control for the values returned by the query. Note that the provided value itself will **not** be used for the response.
477        start_after: Option<u32>,
478    },
479
480    /// Gets the current parameters used for reward calculation.
481    #[cfg_attr(feature = "schema", returns(RewardingParams))]
482    GetRewardingParams {},
483
484    /// Gets the status of the current rewarding epoch.
485    #[cfg_attr(feature = "schema", returns(EpochStatus))]
486    GetEpochStatus {},
487
488    /// Get the details of the current rewarding interval.
489    #[cfg_attr(feature = "schema", returns(CurrentIntervalResponse))]
490    GetCurrentIntervalDetails {},
491
492    // mixnode-related:
493    /// Gets the basic list of all currently bonded mixnodes.
494    #[cfg_attr(feature = "schema", returns(PagedMixnodeBondsResponse))]
495    GetMixNodeBonds {
496        /// Controls the maximum number of entries returned by the query. Note that too large values will be overwritten by a saner default.
497        limit: Option<u32>,
498
499        /// Pagination control for the values returned by the query. Note that the provided value itself will **not** be used for the response.
500        start_after: Option<NodeId>,
501    },
502
503    /// Gets the detailed list of all currently bonded mixnodes.
504    #[cfg_attr(feature = "schema", returns(PagedMixnodesDetailsResponse))]
505    GetMixNodesDetailed {
506        /// Controls the maximum number of entries returned by the query. Note that too large values will be overwritten by a saner default.
507        limit: Option<u32>,
508
509        /// Pagination control for the values returned by the query. Note that the provided value itself will **not** be used for the response.
510        start_after: Option<NodeId>,
511    },
512
513    /// Gets the basic list of all unbonded mixnodes.
514    #[cfg_attr(feature = "schema", returns(PagedUnbondedMixnodesResponse))]
515    GetUnbondedMixNodes {
516        /// Controls the maximum number of entries returned by the query. Note that too large values will be overwritten by a saner default.
517        limit: Option<u32>,
518
519        /// Pagination control for the values returned by the query. Note that the provided value itself will **not** be used for the response.
520        start_after: Option<NodeId>,
521    },
522
523    /// Gets the basic list of all unbonded mixnodes that belonged to a particular owner.
524    #[cfg_attr(feature = "schema", returns(PagedUnbondedMixnodesResponse))]
525    GetUnbondedMixNodesByOwner {
526        /// The address of the owner of the mixnodes used for the query.
527        owner: String,
528
529        /// Controls the maximum number of entries returned by the query. Note that too large values will be overwritten by a saner default.
530        limit: Option<u32>,
531
532        /// Pagination control for the values returned by the query. Note that the provided value itself will **not** be used for the response.
533        start_after: Option<NodeId>,
534    },
535
536    /// Gets the basic list of all unbonded mixnodes that used the particular identity key.
537    #[cfg_attr(feature = "schema", returns(PagedUnbondedMixnodesResponse))]
538    GetUnbondedMixNodesByIdentityKey {
539        /// The identity key (base58-encoded ed25519 public key) of the mixnode used for the query.
540        identity_key: String,
541
542        /// Controls the maximum number of entries returned by the query. Note that too large values will be overwritten by a saner default.
543        limit: Option<u32>,
544
545        /// Pagination control for the values returned by the query. Note that the provided value itself will **not** be used for the response.
546        start_after: Option<NodeId>,
547    },
548
549    /// Gets the detailed mixnode information belonging to the particular owner.
550    #[cfg_attr(feature = "schema", returns(MixOwnershipResponse))]
551    GetOwnedMixnode {
552        /// Address of the mixnode owner to use for the query.
553        address: String,
554    },
555
556    /// Gets the detailed mixnode information of a node with the provided id.
557    #[cfg_attr(feature = "schema", returns(MixnodeDetailsResponse))]
558    GetMixnodeDetails {
559        /// Id of the node to query.
560        mix_id: NodeId,
561    },
562
563    /// Gets the rewarding information of a mixnode with the provided id.
564    #[cfg_attr(feature = "schema", returns(MixnodeRewardingDetailsResponse))]
565    GetMixnodeRewardingDetails {
566        /// Id of the node to query.
567        mix_id: NodeId,
568    },
569
570    /// Gets the stake saturation of a mixnode with the provided id.
571    #[cfg_attr(feature = "schema", returns(MixStakeSaturationResponse))]
572    GetStakeSaturation {
573        /// Id of the node to query.
574        mix_id: NodeId,
575    },
576
577    /// Gets the basic information of an unbonded mixnode with the provided id.
578    #[cfg_attr(feature = "schema", returns(UnbondedMixnodeResponse))]
579    GetUnbondedMixNodeInformation {
580        /// Id of the node to query.
581        mix_id: NodeId,
582    },
583
584    /// Gets the detailed mixnode information of a node given its current identity key.
585    #[cfg_attr(feature = "schema", returns(MixnodeDetailsByIdentityResponse))]
586    GetBondedMixnodeDetailsByIdentity {
587        /// The identity key (base58-encoded ed25519 public key) of the mixnode used for the query.
588        mix_identity: IdentityKey,
589    },
590
591    // gateway-related:
592    /// Gets the basic list of all currently bonded gateways.
593    #[cfg_attr(feature = "schema", returns(PagedGatewayResponse))]
594    GetGateways {
595        /// Pagination control for the values returned by the query. Note that the provided value itself will **not** be used for the response.
596        start_after: Option<IdentityKey>,
597
598        /// Controls the maximum number of entries returned by the query. Note that too large values will be overwritten by a saner default.
599        limit: Option<u32>,
600    },
601
602    /// Gets the gateway details of a node given its identity key.
603    #[cfg_attr(feature = "schema", returns(GatewayBondResponse))]
604    GetGatewayBond {
605        /// The identity key (base58-encoded ed25519 public key) of the gateway used for the query.
606        identity: IdentityKey,
607    },
608
609    /// Gets the detailed gateway information belonging to the particular owner.
610    #[cfg_attr(feature = "schema", returns(GatewayOwnershipResponse))]
611    GetOwnedGateway {
612        /// Address of the gateway owner to use for the query.
613        address: String,
614    },
615
616    /// Get the `NodeId`s of all the legacy gateways that they will get assigned once migrated into NymNodes
617    #[cfg_attr(feature = "schema", returns(PreassignedGatewayIdsResponse))]
618    GetPreassignedGatewayIds {
619        /// Pagination control for the values returned by the query. Note that the provided value itself will **not** be used for the response.
620        start_after: Option<IdentityKey>,
621
622        /// Controls the maximum number of entries returned by the query. Note that too large values will be overwritten by a saner default.
623        limit: Option<u32>,
624    },
625
626    // nym-node-related:
627    /// Gets the basic list of all currently bonded nymnodes.
628    #[cfg_attr(feature = "schema", returns(PagedNymNodeBondsResponse))]
629    GetNymNodeBondsPaged {
630        /// Controls the maximum number of entries returned by the query. Note that too large values will be overwritten by a saner default.
631        limit: Option<u32>,
632
633        /// Pagination control for the values returned by the query. Note that the provided value itself will **not** be used for the response.
634        start_after: Option<NodeId>,
635    },
636
637    /// Gets the detailed list of all currently bonded nymnodes.
638    #[cfg_attr(feature = "schema", returns(PagedNymNodeDetailsResponse))]
639    GetNymNodesDetailedPaged {
640        /// Controls the maximum number of entries returned by the query. Note that too large values will be overwritten by a saner default.
641        limit: Option<u32>,
642
643        /// Pagination control for the values returned by the query. Note that the provided value itself will **not** be used for the response.
644        start_after: Option<NodeId>,
645    },
646
647    /// Gets the basic information of an unbonded nym-node with the provided id.
648    #[cfg_attr(feature = "schema", returns(UnbondedNodeResponse))]
649    GetUnbondedNymNode {
650        /// Id of the node to query.
651        node_id: NodeId,
652    },
653
654    /// Gets the basic list of all unbonded nymnodes.
655    #[cfg_attr(feature = "schema", returns(PagedUnbondedNymNodesResponse))]
656    GetUnbondedNymNodesPaged {
657        /// Controls the maximum number of entries returned by the query. Note that too large values will be overwritten by a saner default.
658        limit: Option<u32>,
659
660        /// Pagination control for the values returned by the query. Note that the provided value itself will **not** be used for the response.
661        start_after: Option<NodeId>,
662    },
663
664    /// Gets the basic list of all unbonded nymnodes that belonged to a particular owner.
665    #[cfg_attr(feature = "schema", returns(PagedUnbondedNymNodesResponse))]
666    GetUnbondedNymNodesByOwnerPaged {
667        /// The address of the owner of the nym-node used for the query
668        owner: String,
669
670        /// Controls the maximum number of entries returned by the query. Note that too large values will be overwritten by a saner default.
671        limit: Option<u32>,
672
673        /// Pagination control for the values returned by the query. Note that the provided value itself will **not** be used for the response.
674        start_after: Option<NodeId>,
675    },
676
677    /// Gets the basic list of all unbonded nymnodes that used the particular identity key.
678    #[cfg_attr(feature = "schema", returns(PagedUnbondedNymNodesResponse))]
679    GetUnbondedNymNodesByIdentityKeyPaged {
680        /// The identity key (base58-encoded ed25519 public key) of the node used for the query.
681        identity_key: IdentityKey,
682
683        /// Controls the maximum number of entries returned by the query. Note that too large values will be overwritten by a saner default.
684        limit: Option<u32>,
685
686        /// Pagination control for the values returned by the query. Note that the provided value itself will **not** be used for the response.
687        start_after: Option<NodeId>,
688    },
689
690    /// Gets the detailed nymnode information belonging to the particular owner.
691    #[cfg_attr(feature = "schema", returns(NodeOwnershipResponse))]
692    GetOwnedNymNode {
693        /// Address of the node owner to use for the query.
694        address: String,
695    },
696
697    /// Gets the detailed nymnode information of a node with the provided id.
698    #[cfg_attr(feature = "schema", returns(NodeDetailsResponse))]
699    GetNymNodeDetails {
700        /// Id of the node to query.
701        node_id: NodeId,
702    },
703
704    /// Gets the detailed nym-node information given its current identity key.
705    #[cfg_attr(feature = "schema", returns(NodeDetailsByIdentityResponse))]
706    GetNymNodeDetailsByIdentityKey {
707        /// The identity key (base58-encoded ed25519 public key) of the nym-node used for the query.
708        node_identity: IdentityKey,
709    },
710
711    /// Gets the rewarding information of a nym-node with the provided id.
712    #[cfg_attr(feature = "schema", returns(NodeRewardingDetailsResponse))]
713    GetNodeRewardingDetails {
714        /// Id of the node to query.
715        node_id: NodeId,
716    },
717
718    /// Gets the stake saturation of a nym-node with the provided id.
719    #[cfg_attr(feature = "schema", returns(StakeSaturationResponse))]
720    GetNodeStakeSaturation {
721        /// Id of the node to query.
722        node_id: NodeId,
723    },
724
725    #[cfg_attr(feature = "schema", returns(EpochAssignmentResponse))]
726    GetRoleAssignment { role: Role },
727
728    #[cfg_attr(feature = "schema", returns(RolesMetadataResponse))]
729    GetRewardedSetMetadata {},
730
731    // delegation-related:
732    /// Gets all delegations associated with particular node
733    #[cfg_attr(feature = "schema", returns(PagedNodeDelegationsResponse))]
734    #[serde(alias = "GetMixnodeDelegations", alias = "get_mixnode_delegations")]
735    GetNodeDelegations {
736        /// Id of the node to query.
737        #[serde(alias = "mix_id")]
738        node_id: NodeId,
739
740        /// Pagination control for the values returned by the query. Note that the provided value itself will **not** be used for the response.
741        start_after: Option<OwnerProxySubKey>,
742
743        /// Controls the maximum number of entries returned by the query. Note that too large values will be overwritten by a saner default.
744        limit: Option<u32>,
745    },
746
747    /// Gets all delegations associated with particular delegator
748    #[cfg_attr(feature = "schema", returns(PagedDelegatorDelegationsResponse))]
749    GetDelegatorDelegations {
750        // since `delegator` is user-provided input, we can't use `Addr` as we
751        // can't guarantee it's validated.
752        /// The address of the owner of the delegations.
753        delegator: String,
754
755        /// Pagination control for the values returned by the query. Note that the provided value itself will **not** be used for the response.
756        start_after: Option<(NodeId, OwnerProxySubKey)>,
757
758        /// Controls the maximum number of entries returned by the query. Note that too large values will be overwritten by a saner default.
759        limit: Option<u32>,
760    },
761
762    /// Gets delegation information associated with particular mixnode - delegator pair
763    #[cfg_attr(feature = "schema", returns(NodeDelegationResponse))]
764    GetDelegationDetails {
765        /// Id of the node to query.
766        #[serde(alias = "mix_id")]
767        node_id: NodeId,
768
769        /// The address of the owner of the delegation.
770        delegator: String,
771
772        /// Entity who made the delegation on behalf of the owner.
773        /// If present, it's most likely the address of the vesting contract.
774        proxy: Option<String>,
775    },
776
777    /// Gets all delegations in the system
778    #[cfg_attr(feature = "schema", returns(PagedAllDelegationsResponse))]
779    GetAllDelegations {
780        /// Pagination control for the values returned by the query. Note that the provided value itself will **not** be used for the response.
781        start_after: Option<delegation::StorageKey>,
782
783        /// Controls the maximum number of entries returned by the query. Note that too large values will be overwritten by a saner default.
784        limit: Option<u32>,
785    },
786
787    // rewards related
788    /// Gets the reward amount accrued by the node operator that has not yet been claimed.
789    #[cfg_attr(feature = "schema", returns(PendingRewardResponse))]
790    GetPendingOperatorReward {
791        /// Address of the operator to use for the query.
792        address: String,
793    },
794
795    /// Gets the reward amount accrued by the particular mixnode that has not yet been claimed.
796    #[cfg_attr(feature = "schema", returns(PendingRewardResponse))]
797    #[serde(
798        alias = "GetPendingMixNodeOperatorReward",
799        alias = "get_pending_mix_node_operator_reward"
800    )]
801    GetPendingNodeOperatorReward {
802        /// Id of the node to query.
803        #[serde(alias = "mix_id")]
804        node_id: NodeId,
805    },
806
807    /// Gets the reward amount accrued by the particular delegator that has not yet been claimed.
808    #[cfg_attr(feature = "schema", returns(PendingRewardResponse))]
809    GetPendingDelegatorReward {
810        /// Address of the delegator to use for the query.
811        address: String,
812
813        /// Id of the node to query.
814        #[serde(alias = "mix_id")]
815        node_id: NodeId,
816
817        /// Entity who made the delegation on behalf of the owner.
818        /// If present, it's most likely the address of the vesting contract.
819        proxy: Option<String>,
820    },
821
822    /// Given the provided node performance, attempt to estimate the operator reward for the current epoch.
823    #[cfg_attr(feature = "schema", returns(EstimatedCurrentEpochRewardResponse))]
824    GetEstimatedCurrentEpochOperatorReward {
825        /// Id of the node to query.
826        #[serde(alias = "mix_id")]
827        node_id: NodeId,
828
829        /// The estimated performance for the current epoch of the given node.
830        estimated_performance: Performance,
831
832        /// The estimated work for the current epoch of the given node.
833        estimated_work: Option<WorkFactor>,
834    },
835
836    /// Given the provided node performance, attempt to estimate the delegator reward for the current epoch.
837    #[cfg_attr(feature = "schema", returns(EstimatedCurrentEpochRewardResponse))]
838    GetEstimatedCurrentEpochDelegatorReward {
839        /// Address of the delegator to use for the query.
840        address: String,
841
842        /// Id of the node to query.
843        #[serde(alias = "mix_id")]
844        node_id: NodeId,
845
846        /// The estimated performance for the current epoch of the given node.
847        estimated_performance: Performance,
848
849        /// The estimated work for the current epoch of the given node.
850        estimated_work: Option<WorkFactor>,
851    },
852
853    // interval-related
854    /// Gets the list of all currently pending epoch events that will be resolved once the current epoch finishes.
855    #[cfg_attr(feature = "schema", returns(PendingEpochEventsResponse))]
856    GetPendingEpochEvents {
857        /// Controls the maximum number of entries returned by the query. Note that too large values will be overwritten by a saner default.
858        limit: Option<u32>,
859
860        /// Pagination control for the values returned by the query. Note that the provided value itself will **not** be used for the response.
861        start_after: Option<u32>,
862    },
863
864    /// Gets the list of all currently pending interval events that will be resolved once the current interval finishes.
865    #[cfg_attr(feature = "schema", returns(PendingIntervalEventsResponse))]
866    GetPendingIntervalEvents {
867        /// Controls the maximum number of entries returned by the query. Note that too large values will be overwritten by a saner default.
868        limit: Option<u32>,
869
870        /// Pagination control for the values returned by the query. Note that the provided value itself will **not** be used for the response.
871        start_after: Option<u32>,
872    },
873
874    /// Gets detailed information about a pending epoch event given its id.
875    #[cfg_attr(feature = "schema", returns(PendingEpochEventResponse))]
876    GetPendingEpochEvent {
877        /// The unique id associated with the event.
878        event_id: EpochEventId,
879    },
880
881    /// Gets detailed information about a pending interval event given its id.
882    #[cfg_attr(feature = "schema", returns(PendingIntervalEventResponse))]
883    GetPendingIntervalEvent {
884        /// The unique id associated with the event.
885        event_id: IntervalEventId,
886    },
887
888    /// Gets the information about the number of currently pending epoch and interval events.
889    #[cfg_attr(feature = "schema", returns(NumberOfPendingEventsResponse))]
890    GetNumberOfPendingEvents {},
891
892    // signing-related
893    /// Gets the signing nonce associated with the particular cosmos address.
894    #[cfg_attr(feature = "schema", returns(Nonce))]
895    GetSigningNonce {
896        /// Cosmos address used for the query of the signing nonce.
897        address: String,
898    },
899
900    // sphinx key rotation-related
901    #[cfg_attr(feature = "schema", returns(KeyRotationState))]
902    /// Gets the current state config of the key rotation (i.e. starting epoch id and validity duration)
903    GetKeyRotationState {},
904
905    /// Gets the current key rotation id
906    #[cfg_attr(feature = "schema", returns(KeyRotationIdResponse))]
907    GetKeyRotationId {},
908}
909
910#[cw_serde]
911pub struct VestedDelegationMigrationEntry {
912    pub mix_id: NodeId,
913    pub owner: String,
914}
915
916#[cw_serde]
917pub struct MigrateMsg {
918    pub unsafe_skip_state_updates: Option<bool>,
919    pub vesting_contract_address: Option<String>,
920    pub node_families_contract_address: String,
921}