Renamed the type alias NodeId to MixId and fixed some usages (#1682)
* Renamed the type alias NodeId to MixId and fixed some usages * fix(wallet): bonding context * fix(wallet): remove ip field (type error) Co-authored-by: pierre <dommerc.pierre@gmail.com>
This commit is contained in:
committed by
GitHub
parent
6a3ac6b9be
commit
c3bea668d5
@@ -3,7 +3,7 @@
|
||||
|
||||
use crate::{validator_api, ValidatorClientError};
|
||||
use mixnet_contract_common::mixnode::MixNodeDetails;
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
use mixnet_contract_common::{GatewayBond, IdentityKeyRef};
|
||||
use url::Url;
|
||||
use validator_api_requests::coconut::{
|
||||
@@ -206,7 +206,7 @@ impl<C> Client<C> {
|
||||
// basically handles paging for us
|
||||
pub async fn get_all_nymd_rewarded_set_mixnodes(
|
||||
&self,
|
||||
) -> Result<Vec<(NodeId, RewardedSetNodeStatus)>, ValidatorClientError>
|
||||
) -> Result<Vec<(MixId, RewardedSetNodeStatus)>, ValidatorClientError>
|
||||
where
|
||||
C: CosmWasmClient + Sync + Send,
|
||||
{
|
||||
@@ -280,7 +280,7 @@ impl<C> Client<C> {
|
||||
|
||||
pub async fn get_all_nymd_unbonded_mixnodes(
|
||||
&self,
|
||||
) -> Result<Vec<(NodeId, UnbondedMixnode)>, ValidatorClientError>
|
||||
) -> Result<Vec<(MixId, UnbondedMixnode)>, ValidatorClientError>
|
||||
where
|
||||
C: CosmWasmClient + Sync + Send,
|
||||
{
|
||||
@@ -306,7 +306,7 @@ impl<C> Client<C> {
|
||||
pub async fn get_all_nymd_unbonded_mixnodes_by_owner(
|
||||
&self,
|
||||
owner: &cosmrs::AccountId,
|
||||
) -> Result<Vec<(NodeId, UnbondedMixnode)>, ValidatorClientError>
|
||||
) -> Result<Vec<(MixId, UnbondedMixnode)>, ValidatorClientError>
|
||||
where
|
||||
C: CosmWasmClient + Sync + Send,
|
||||
{
|
||||
@@ -332,7 +332,7 @@ impl<C> Client<C> {
|
||||
pub async fn get_all_nymd_unbonded_mixnodes_by_identity(
|
||||
&self,
|
||||
identity_key: String,
|
||||
) -> Result<Vec<(NodeId, UnbondedMixnode)>, ValidatorClientError>
|
||||
) -> Result<Vec<(MixId, UnbondedMixnode)>, ValidatorClientError>
|
||||
where
|
||||
C: CosmWasmClient + Sync + Send,
|
||||
{
|
||||
@@ -384,7 +384,7 @@ impl<C> Client<C> {
|
||||
|
||||
pub async fn get_all_nymd_single_mixnode_delegations(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<Vec<Delegation>, ValidatorClientError>
|
||||
where
|
||||
C: CosmWasmClient + Sync + Send,
|
||||
@@ -632,7 +632,7 @@ impl ApiClient {
|
||||
|
||||
pub async fn get_mixnode_core_status_count(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
since: Option<i64>,
|
||||
) -> Result<MixnodeCoreStatusResponse, ValidatorClientError> {
|
||||
Ok(self
|
||||
@@ -643,14 +643,14 @@ impl ApiClient {
|
||||
|
||||
pub async fn get_mixnode_status(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<MixnodeStatusResponse, ValidatorClientError> {
|
||||
Ok(self.validator_api.get_mixnode_status(mix_id).await?)
|
||||
}
|
||||
|
||||
pub async fn get_mixnode_reward_estimation(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<RewardEstimationResponse, ValidatorClientError> {
|
||||
Ok(self
|
||||
.validator_api
|
||||
@@ -660,7 +660,7 @@ impl ApiClient {
|
||||
|
||||
pub async fn get_mixnode_stake_saturation(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<StakeSaturationResponse, ValidatorClientError> {
|
||||
Ok(self
|
||||
.validator_api
|
||||
|
||||
@@ -44,7 +44,7 @@ pub use cosmrs::Coin as CosmosCoin;
|
||||
pub use cosmrs::{bip32, AccountId, Decimal, Denom};
|
||||
pub use cosmwasm_std::Coin as CosmWasmCoin;
|
||||
pub use fee::{gas_price::GasPrice, GasAdjustable, GasAdjustment};
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
pub use signing_client::Client as SigningNymdClient;
|
||||
pub use traits::{VestingQueryClient, VestingSigningClient};
|
||||
|
||||
@@ -725,7 +725,7 @@ impl<C> NymdClient<C> {
|
||||
#[execute("vesting")]
|
||||
fn _vesting_withdraw_delegator_reward(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
fee: Option<Fee>,
|
||||
) -> (VestingExecuteMsg, Option<Fee>)
|
||||
where
|
||||
|
||||
@@ -18,10 +18,11 @@ use mixnet_contract_common::rewarding::{
|
||||
use mixnet_contract_common::{
|
||||
delegation, ContractBuildInformation, ContractState, ContractStateParams,
|
||||
CurrentIntervalResponse, EpochEventId, GatewayBondResponse, GatewayOwnershipResponse,
|
||||
IdentityKey, IntervalEventId, LayerDistribution, MixOwnershipResponse, MixnodeDetailsResponse,
|
||||
NodeId, PagedAllDelegationsResponse, PagedDelegatorDelegationsResponse, PagedGatewayResponse,
|
||||
PagedMixNodeDelegationsResponse, PagedMixnodeBondsResponse, PagedRewardedSetResponse,
|
||||
PendingEpochEventsResponse, PendingIntervalEventsResponse, QueryMsg as MixnetQueryMsg,
|
||||
IdentityKey, IntervalEventId, LayerDistribution, MixId, MixOwnershipResponse,
|
||||
MixnodeDetailsResponse, PagedAllDelegationsResponse, PagedDelegatorDelegationsResponse,
|
||||
PagedGatewayResponse, PagedMixNodeDelegationsResponse, PagedMixnodeBondsResponse,
|
||||
PagedRewardedSetResponse, PendingEpochEventsResponse, PendingIntervalEventsResponse,
|
||||
QueryMsg as MixnetQueryMsg,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
|
||||
@@ -65,7 +66,7 @@ pub trait MixnetQueryClient {
|
||||
|
||||
async fn get_rewarded_set_paged(
|
||||
&self,
|
||||
start_after: Option<NodeId>,
|
||||
start_after: Option<MixId>,
|
||||
limit: Option<u32>,
|
||||
) -> Result<PagedRewardedSetResponse, NymdError> {
|
||||
self.query_mixnet_contract(MixnetQueryMsg::GetRewardedSet { limit, start_after })
|
||||
@@ -77,7 +78,7 @@ pub trait MixnetQueryClient {
|
||||
async fn get_mixnode_bonds_paged(
|
||||
&self,
|
||||
limit: Option<u32>,
|
||||
start_after: Option<NodeId>,
|
||||
start_after: Option<MixId>,
|
||||
) -> Result<PagedMixnodeBondsResponse, NymdError> {
|
||||
self.query_mixnet_contract(MixnetQueryMsg::GetMixNodeBonds { limit, start_after })
|
||||
.await
|
||||
@@ -86,7 +87,7 @@ pub trait MixnetQueryClient {
|
||||
async fn get_mixnodes_detailed_paged(
|
||||
&self,
|
||||
limit: Option<u32>,
|
||||
start_after: Option<NodeId>,
|
||||
start_after: Option<MixId>,
|
||||
) -> Result<PagedMixnodesDetailsResponse, NymdError> {
|
||||
self.query_mixnet_contract(MixnetQueryMsg::GetMixNodesDetailed { limit, start_after })
|
||||
.await
|
||||
@@ -95,7 +96,7 @@ pub trait MixnetQueryClient {
|
||||
async fn get_unbonded_paged(
|
||||
&self,
|
||||
limit: Option<u32>,
|
||||
start_after: Option<NodeId>,
|
||||
start_after: Option<MixId>,
|
||||
) -> Result<PagedUnbondedMixnodesResponse, NymdError> {
|
||||
self.query_mixnet_contract(MixnetQueryMsg::GetUnbondedMixNodes { limit, start_after })
|
||||
.await
|
||||
@@ -105,7 +106,7 @@ pub trait MixnetQueryClient {
|
||||
&self,
|
||||
owner: &AccountId,
|
||||
limit: Option<u32>,
|
||||
start_after: Option<NodeId>,
|
||||
start_after: Option<MixId>,
|
||||
) -> Result<PagedUnbondedMixnodesResponse, NymdError> {
|
||||
self.query_mixnet_contract(MixnetQueryMsg::GetUnbondedMixNodesByOwner {
|
||||
owner: owner.to_string(),
|
||||
@@ -119,7 +120,7 @@ pub trait MixnetQueryClient {
|
||||
&self,
|
||||
identity_key: String,
|
||||
limit: Option<u32>,
|
||||
start_after: Option<NodeId>,
|
||||
start_after: Option<MixId>,
|
||||
) -> Result<PagedUnbondedMixnodesResponse, NymdError> {
|
||||
self.query_mixnet_contract(MixnetQueryMsg::GetUnbondedMixNodesByIdentityKey {
|
||||
identity_key,
|
||||
@@ -141,7 +142,7 @@ pub trait MixnetQueryClient {
|
||||
|
||||
async fn get_mixnode_details(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<MixnodeDetailsResponse, NymdError> {
|
||||
self.query_mixnet_contract(MixnetQueryMsg::GetMixnodeDetails { mix_id })
|
||||
.await
|
||||
@@ -149,7 +150,7 @@ pub trait MixnetQueryClient {
|
||||
|
||||
async fn get_mixnode_rewarding_details(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<MixnodeRewardingDetailsResponse, NymdError> {
|
||||
self.query_mixnet_contract(MixnetQueryMsg::GetMixnodeRewardingDetails { mix_id })
|
||||
.await
|
||||
@@ -157,7 +158,7 @@ pub trait MixnetQueryClient {
|
||||
|
||||
async fn get_mixnode_stake_saturation(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<StakeSaturationResponse, NymdError> {
|
||||
self.query_mixnet_contract(MixnetQueryMsg::GetStakeSaturation { mix_id })
|
||||
.await
|
||||
@@ -165,7 +166,7 @@ pub trait MixnetQueryClient {
|
||||
|
||||
async fn get_unbonded_mixnode_information(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<UnbondedMixnodeResponse, NymdError> {
|
||||
self.query_mixnet_contract(MixnetQueryMsg::GetUnbondedMixNodeInformation { mix_id })
|
||||
.await
|
||||
@@ -212,7 +213,7 @@ pub trait MixnetQueryClient {
|
||||
/// Gets list of all delegations towards particular mixnode on particular page.
|
||||
async fn get_mixnode_delegations_paged(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
start_after: Option<String>,
|
||||
limit: Option<u32>,
|
||||
) -> Result<PagedMixNodeDelegationsResponse, NymdError> {
|
||||
@@ -228,7 +229,7 @@ pub trait MixnetQueryClient {
|
||||
async fn get_delegator_delegations_paged(
|
||||
&self,
|
||||
delegator: String,
|
||||
start_after: Option<(NodeId, OwnerProxySubKey)>,
|
||||
start_after: Option<(MixId, OwnerProxySubKey)>,
|
||||
limit: Option<u32>,
|
||||
) -> Result<PagedDelegatorDelegationsResponse, NymdError> {
|
||||
self.query_mixnet_contract(MixnetQueryMsg::GetDelegatorDelegations {
|
||||
@@ -242,7 +243,7 @@ pub trait MixnetQueryClient {
|
||||
/// Checks value of delegation of given client towards particular mixnode.
|
||||
async fn get_delegation_details(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
delegator: &AccountId,
|
||||
proxy: Option<String>,
|
||||
) -> Result<MixNodeDelegationResponse, NymdError> {
|
||||
@@ -277,7 +278,7 @@ pub trait MixnetQueryClient {
|
||||
|
||||
async fn get_pending_mixnode_operator_reward(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<PendingRewardResponse, NymdError> {
|
||||
self.query_mixnet_contract(MixnetQueryMsg::GetPendingMixNodeOperatorReward { mix_id })
|
||||
.await
|
||||
@@ -286,7 +287,7 @@ pub trait MixnetQueryClient {
|
||||
async fn get_pending_delegator_reward(
|
||||
&self,
|
||||
delegator: &AccountId,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
proxy: Option<String>,
|
||||
) -> Result<PendingRewardResponse, NymdError> {
|
||||
self.query_mixnet_contract(MixnetQueryMsg::GetPendingDelegatorReward {
|
||||
@@ -300,7 +301,7 @@ pub trait MixnetQueryClient {
|
||||
// given the provided performance, estimate the reward at the end of the current epoch
|
||||
async fn get_estimated_current_epoch_operator_reward(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
estimated_performance: Performance,
|
||||
) -> Result<EstimatedCurrentEpochRewardResponse, NymdError> {
|
||||
self.query_mixnet_contract(MixnetQueryMsg::GetEstimatedCurrentEpochOperatorReward {
|
||||
@@ -314,7 +315,7 @@ pub trait MixnetQueryClient {
|
||||
async fn get_estimated_current_epoch_delegator_reward(
|
||||
&self,
|
||||
delegator: &AccountId,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
proxy: Option<String>,
|
||||
estimated_performance: Performance,
|
||||
) -> Result<EstimatedCurrentEpochRewardResponse, NymdError> {
|
||||
|
||||
@@ -11,7 +11,7 @@ use cosmrs::AccountId;
|
||||
use mixnet_contract_common::mixnode::{MixNodeConfigUpdate, MixNodeCostParams};
|
||||
use mixnet_contract_common::reward_params::{IntervalRewardingParamsUpdate, Performance};
|
||||
use mixnet_contract_common::{
|
||||
ContractStateParams, ExecuteMsg as MixnetExecuteMsg, Gateway, MixNode, NodeId,
|
||||
ContractStateParams, ExecuteMsg as MixnetExecuteMsg, Gateway, MixId, MixNode,
|
||||
};
|
||||
|
||||
#[async_trait]
|
||||
@@ -108,7 +108,7 @@ pub trait MixnetSigningClient {
|
||||
|
||||
async fn advance_current_epoch(
|
||||
&self,
|
||||
new_rewarded_set: Vec<NodeId>,
|
||||
new_rewarded_set: Vec<MixId>,
|
||||
expected_active_set_size: u32,
|
||||
fee: Option<Fee>,
|
||||
) -> Result<ExecuteResult, NymdError> {
|
||||
@@ -324,7 +324,7 @@ pub trait MixnetSigningClient {
|
||||
|
||||
async fn delegate_to_mixnode(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
amount: Coin,
|
||||
fee: Option<Fee>,
|
||||
) -> Result<ExecuteResult, NymdError> {
|
||||
@@ -339,7 +339,7 @@ pub trait MixnetSigningClient {
|
||||
async fn delegate_to_mixnode_on_behalf(
|
||||
&self,
|
||||
delegate: AccountId,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
amount: Coin,
|
||||
fee: Option<Fee>,
|
||||
) -> Result<ExecuteResult, NymdError> {
|
||||
@@ -356,7 +356,7 @@ pub trait MixnetSigningClient {
|
||||
|
||||
async fn undelegate_from_mixnode(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
fee: Option<Fee>,
|
||||
) -> Result<ExecuteResult, NymdError> {
|
||||
self.execute_mixnet_contract(
|
||||
@@ -370,7 +370,7 @@ pub trait MixnetSigningClient {
|
||||
async fn undelegate_to_mixnode_on_behalf(
|
||||
&self,
|
||||
delegate: AccountId,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
fee: Option<Fee>,
|
||||
) -> Result<ExecuteResult, NymdError> {
|
||||
self.execute_mixnet_contract(
|
||||
@@ -388,7 +388,7 @@ pub trait MixnetSigningClient {
|
||||
|
||||
async fn reward_mixnode(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
performance: Performance,
|
||||
fee: Option<Fee>,
|
||||
) -> Result<ExecuteResult, NymdError> {
|
||||
@@ -425,7 +425,7 @@ pub trait MixnetSigningClient {
|
||||
|
||||
async fn withdraw_delegator_reward(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
fee: Option<Fee>,
|
||||
) -> Result<ExecuteResult, NymdError> {
|
||||
self.execute_mixnet_contract(
|
||||
@@ -439,7 +439,7 @@ pub trait MixnetSigningClient {
|
||||
async fn withdraw_delegator_reward_on_behalf(
|
||||
&self,
|
||||
owner: AccountId,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
fee: Option<Fee>,
|
||||
) -> Result<ExecuteResult, NymdError> {
|
||||
self.execute_mixnet_contract(
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::nymd::error::NymdError;
|
||||
use crate::nymd::NymdClient;
|
||||
use async_trait::async_trait;
|
||||
use cosmwasm_std::{Coin as CosmWasmCoin, Timestamp};
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
use vesting_contract::vesting::Account;
|
||||
use vesting_contract_common::{
|
||||
messages::QueryMsg as VestingQueryMsg, AllDelegationsResponse, DelegationTimesResponse,
|
||||
@@ -76,12 +76,12 @@ pub trait VestingQueryClient {
|
||||
async fn get_delegation_timestamps(
|
||||
&self,
|
||||
address: &str,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<DelegationTimesResponse, NymdError>;
|
||||
|
||||
async fn get_all_vesting_delegations_paged(
|
||||
&self,
|
||||
start_after: Option<(u32, NodeId, u64)>,
|
||||
start_after: Option<(u32, MixId, u64)>,
|
||||
limit: Option<u32>,
|
||||
) -> Result<AllDelegationsResponse, NymdError>;
|
||||
|
||||
@@ -269,7 +269,7 @@ impl<C: CosmWasmClient + Sync + Send> VestingQueryClient for NymdClient<C> {
|
||||
async fn get_delegation_timestamps(
|
||||
&self,
|
||||
address: &str,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<DelegationTimesResponse, NymdError> {
|
||||
let request = VestingQueryMsg::GetDelegationTimes {
|
||||
address: address.to_string(),
|
||||
@@ -282,7 +282,7 @@ impl<C: CosmWasmClient + Sync + Send> VestingQueryClient for NymdClient<C> {
|
||||
|
||||
async fn get_all_vesting_delegations_paged(
|
||||
&self,
|
||||
start_after: Option<(u32, NodeId, u64)>,
|
||||
start_after: Option<(u32, MixId, u64)>,
|
||||
limit: Option<u32>,
|
||||
) -> Result<AllDelegationsResponse, NymdError> {
|
||||
let request = VestingQueryMsg::GetAllDelegations { start_after, limit };
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::nymd::error::NymdError;
|
||||
use crate::nymd::{Coin, Fee, NymdClient};
|
||||
use async_trait::async_trait;
|
||||
use mixnet_contract_common::mixnode::{MixNodeConfigUpdate, MixNodeCostParams};
|
||||
use mixnet_contract_common::{Gateway, MixNode, NodeId};
|
||||
use mixnet_contract_common::{Gateway, MixId, MixNode};
|
||||
use vesting_contract_common::messages::{ExecuteMsg as VestingExecuteMsg, VestingSpecification};
|
||||
|
||||
#[async_trait]
|
||||
@@ -81,21 +81,21 @@ pub trait VestingSigningClient {
|
||||
async fn vesting_track_undelegation(
|
||||
&self,
|
||||
address: &str,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
amount: Coin,
|
||||
fee: Option<Fee>,
|
||||
) -> Result<ExecuteResult, NymdError>;
|
||||
|
||||
async fn vesting_delegate_to_mixnode(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
amount: Coin,
|
||||
fee: Option<Fee>,
|
||||
) -> Result<ExecuteResult, NymdError>;
|
||||
|
||||
async fn vesting_undelegate_from_mixnode(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
fee: Option<Fee>,
|
||||
) -> Result<ExecuteResult, NymdError>;
|
||||
|
||||
@@ -330,7 +330,7 @@ impl<C: SigningCosmWasmClient + Sync + Send> VestingSigningClient for NymdClient
|
||||
async fn vesting_track_undelegation(
|
||||
&self,
|
||||
address: &str,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
amount: Coin,
|
||||
fee: Option<Fee>,
|
||||
) -> Result<ExecuteResult, NymdError> {
|
||||
@@ -348,7 +348,7 @@ impl<C: SigningCosmWasmClient + Sync + Send> VestingSigningClient for NymdClient
|
||||
|
||||
async fn vesting_delegate_to_mixnode(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
amount: Coin,
|
||||
fee: Option<Fee>,
|
||||
) -> Result<ExecuteResult, NymdError> {
|
||||
@@ -365,7 +365,7 @@ impl<C: SigningCosmWasmClient + Sync + Send> VestingSigningClient for NymdClient
|
||||
|
||||
async fn vesting_undelegate_from_mixnode(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
fee: Option<Fee>,
|
||||
) -> Result<ExecuteResult, NymdError> {
|
||||
self.execute_vesting_contract(
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
use crate::validator_api::error::ValidatorAPIError;
|
||||
use crate::validator_api::routes::{CORE_STATUS_COUNT, SINCE_ARG};
|
||||
use mixnet_contract_common::mixnode::MixNodeDetails;
|
||||
use mixnet_contract_common::{GatewayBond, IdentityKeyRef, NodeId};
|
||||
use mixnet_contract_common::{GatewayBond, IdentityKeyRef, MixId};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
use validator_api_requests::coconut::{
|
||||
@@ -183,7 +183,7 @@ impl Client {
|
||||
|
||||
pub async fn get_mixnode_core_status_count(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
since: Option<i64>,
|
||||
) -> Result<MixnodeCoreStatusResponse, ValidatorAPIError> {
|
||||
if let Some(since) = since {
|
||||
@@ -215,7 +215,7 @@ impl Client {
|
||||
|
||||
pub async fn get_mixnode_status(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<MixnodeStatusResponse, ValidatorAPIError> {
|
||||
self.query_validator_api(
|
||||
&[
|
||||
@@ -232,7 +232,7 @@ impl Client {
|
||||
|
||||
pub async fn get_mixnode_reward_estimation(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<RewardEstimationResponse, ValidatorAPIError> {
|
||||
self.query_validator_api(
|
||||
&[
|
||||
@@ -249,7 +249,7 @@ impl Client {
|
||||
|
||||
pub async fn get_mixnode_stake_saturation(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<StakeSaturationResponse, ValidatorAPIError> {
|
||||
self.query_validator_api(
|
||||
&[
|
||||
@@ -266,7 +266,7 @@ impl Client {
|
||||
|
||||
pub async fn get_mixnode_inclusion_probability(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<InclusionProbabilityResponse, ValidatorAPIError> {
|
||||
self.query_validator_api(
|
||||
&[
|
||||
@@ -283,7 +283,7 @@ impl Client {
|
||||
|
||||
pub async fn get_mixnode_avg_uptime(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<UptimeResponse, ValidatorAPIError> {
|
||||
self.query_validator_api(
|
||||
&[
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
use crate::context::SigningClient;
|
||||
use clap::Parser;
|
||||
use log::info;
|
||||
use mixnet_contract_common::{Coin, NodeId};
|
||||
use mixnet_contract_common::{Coin, MixId};
|
||||
use validator_client::nymd::traits::{MixnetQueryClient, MixnetSigningClient};
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
#[clap(long)]
|
||||
pub mix_id: Option<NodeId>,
|
||||
pub mix_id: Option<MixId>,
|
||||
|
||||
#[clap(long)]
|
||||
pub identity_key: Option<String>,
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
use crate::context::SigningClient;
|
||||
use clap::Parser;
|
||||
use log::info;
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
use validator_client::nymd::traits::{MixnetQueryClient, MixnetSigningClient};
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
#[clap(long)]
|
||||
pub mix_id: Option<NodeId>,
|
||||
pub mix_id: Option<MixId>,
|
||||
|
||||
#[clap(long)]
|
||||
pub identity_key: Option<String>,
|
||||
|
||||
+2
-2
@@ -4,13 +4,13 @@
|
||||
use crate::context::SigningClient;
|
||||
use clap::Parser;
|
||||
use log::info;
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
use validator_client::nymd::traits::{MixnetQueryClient, MixnetSigningClient};
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
#[clap(long)]
|
||||
pub mix_id: Option<NodeId>,
|
||||
pub mix_id: Option<MixId>,
|
||||
|
||||
#[clap(long)]
|
||||
pub identity_key: Option<String>,
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
use crate::context::SigningClient;
|
||||
use clap::Parser;
|
||||
use log::info;
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
use validator_client::nymd::traits::{MixnetQueryClient, MixnetSigningClient};
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
#[clap(long)]
|
||||
pub mix_id: Option<NodeId>,
|
||||
pub mix_id: Option<MixId>,
|
||||
|
||||
#[clap(long)]
|
||||
pub identity_key: Option<String>,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
use clap::Parser;
|
||||
use log::info;
|
||||
|
||||
use mixnet_contract_common::{Coin, NodeId};
|
||||
use mixnet_contract_common::{Coin, MixId};
|
||||
use validator_client::nymd::traits::MixnetQueryClient;
|
||||
use validator_client::nymd::VestingSigningClient;
|
||||
|
||||
@@ -13,7 +13,7 @@ use crate::context::SigningClient;
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
#[clap(long)]
|
||||
pub mix_id: Option<NodeId>,
|
||||
pub mix_id: Option<MixId>,
|
||||
|
||||
#[clap(long)]
|
||||
pub identity_key: Option<String>,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use clap::Parser;
|
||||
use log::info;
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
use validator_client::nymd::traits::MixnetQueryClient;
|
||||
use validator_client::nymd::VestingSigningClient;
|
||||
|
||||
@@ -12,7 +12,7 @@ use crate::context::SigningClient;
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
#[clap(long)]
|
||||
pub mix_id: Option<NodeId>,
|
||||
pub mix_id: Option<MixId>,
|
||||
|
||||
#[clap(long)]
|
||||
pub identity_key: Option<String>,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// due to code generated by JsonSchema
|
||||
#![allow(clippy::field_reassign_with_default)]
|
||||
|
||||
use crate::{Addr, NodeId};
|
||||
use crate::{Addr, MixId};
|
||||
use cosmwasm_std::{Coin, Decimal};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize};
|
||||
// just use a string representation of those so that we wouldn't need to bother with decoding bytes
|
||||
// and trying to figure out whether they're valid, etc
|
||||
pub type OwnerProxySubKey = String;
|
||||
pub type StorageKey = (NodeId, OwnerProxySubKey);
|
||||
pub type StorageKey = (MixId, OwnerProxySubKey);
|
||||
|
||||
pub fn generate_owner_storage_subkey(address: &Addr, proxy: Option<&Addr>) -> String {
|
||||
if let Some(proxy) = &proxy {
|
||||
@@ -35,7 +35,7 @@ pub struct Delegation {
|
||||
|
||||
/// Id of the MixNode that this delegation was performed against.
|
||||
#[serde(alias = "node_id")]
|
||||
pub mix_id: NodeId,
|
||||
pub mix_id: MixId,
|
||||
|
||||
// Note to UI/UX devs: there's absolutely no point in displaying this value to the users,
|
||||
// it would serve them no purpose. It's only used for calculating rewards
|
||||
@@ -56,7 +56,7 @@ pub struct Delegation {
|
||||
impl Delegation {
|
||||
pub fn new(
|
||||
owner: Addr,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
cumulative_reward_ratio: Decimal,
|
||||
amount: Coin,
|
||||
height: u64,
|
||||
@@ -73,7 +73,7 @@ impl Delegation {
|
||||
}
|
||||
|
||||
pub fn generate_storage_key(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
owner_address: &Addr,
|
||||
proxy: Option<&Addr>,
|
||||
) -> StorageKey {
|
||||
@@ -83,7 +83,7 @@ impl Delegation {
|
||||
// this function might seem a bit redundant, but I'd rather explicitly keep it around in case
|
||||
// some types change in the future
|
||||
pub fn generate_storage_key_with_subkey(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
owner_proxy_subkey: OwnerProxySubKey,
|
||||
) -> StorageKey {
|
||||
(mix_id, owner_proxy_subkey)
|
||||
@@ -122,13 +122,13 @@ impl PagedMixNodeDelegationsResponse {
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
||||
pub struct PagedDelegatorDelegationsResponse {
|
||||
pub delegations: Vec<Delegation>,
|
||||
pub start_next_after: Option<(NodeId, OwnerProxySubKey)>,
|
||||
pub start_next_after: Option<(MixId, OwnerProxySubKey)>,
|
||||
}
|
||||
|
||||
impl PagedDelegatorDelegationsResponse {
|
||||
pub fn new(
|
||||
delegations: Vec<Delegation>,
|
||||
start_next_after: Option<(NodeId, OwnerProxySubKey)>,
|
||||
start_next_after: Option<(MixId, OwnerProxySubKey)>,
|
||||
) -> Self {
|
||||
PagedDelegatorDelegationsResponse {
|
||||
delegations,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::NodeId;
|
||||
use crate::MixId;
|
||||
use cosmwasm_std::{Addr, Coin, Decimal};
|
||||
use thiserror::Error;
|
||||
|
||||
@@ -32,7 +32,7 @@ pub enum MixnetContractError {
|
||||
InsufficientDelegation { received: Coin, minimum: Coin },
|
||||
|
||||
#[error("Mixnode ({mix_id}) does not exist")]
|
||||
MixNodeBondNotFound { mix_id: NodeId },
|
||||
MixNodeBondNotFound { mix_id: MixId },
|
||||
|
||||
#[error("{owner} does not seem to own any mixnodes")]
|
||||
NoAssociatedMixNodeBond { owner: Addr },
|
||||
@@ -85,21 +85,21 @@ pub enum MixnetContractError {
|
||||
|
||||
#[error("Mixnode {mix_id} has already been rewarded during the current rewarding epoch ({absolute_epoch_id})")]
|
||||
MixnodeAlreadyRewarded {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
absolute_epoch_id: u32,
|
||||
},
|
||||
|
||||
#[error("Mixnode {mix_id} hasn't been selected to the rewarding set in this epoch ({absolute_epoch_id})")]
|
||||
MixnodeNotInRewardedSet {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
absolute_epoch_id: u32,
|
||||
},
|
||||
|
||||
#[error("Mixnode {mix_id} is currently in the process of unbonding")]
|
||||
MixnodeIsUnbonding { mix_id: NodeId },
|
||||
MixnodeIsUnbonding { mix_id: MixId },
|
||||
|
||||
#[error("Mixnode {mix_id} has already unbonded")]
|
||||
MixnodeHasUnbonded { mix_id: NodeId },
|
||||
MixnodeHasUnbonded { mix_id: MixId },
|
||||
|
||||
#[error("The contract has ended up in a state that was deemed impossible: {comment}")]
|
||||
InconsistentState { comment: String },
|
||||
@@ -108,7 +108,7 @@ pub enum MixnetContractError {
|
||||
"Could not find any delegation information associated with mixnode {mix_id} for {address} (proxy: {proxy:?})"
|
||||
)]
|
||||
NoMixnodeDelegationFound {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
address: String,
|
||||
proxy: Option<String>,
|
||||
},
|
||||
@@ -135,5 +135,5 @@ pub enum MixnetContractError {
|
||||
UnexpectedRewardedSetSize { received: u32, expected: u32 },
|
||||
|
||||
#[error("Mixnode {mix_id} appears multiple times in the provided rewarded set update!")]
|
||||
DuplicateRewardedSetNode { mix_id: NodeId },
|
||||
DuplicateRewardedSetNode { mix_id: MixId },
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
use crate::mixnode::{MixNodeConfigUpdate, MixNodeCostParams};
|
||||
use crate::reward_params::{IntervalRewardParams, IntervalRewardingParamsUpdate};
|
||||
use crate::rewarding::RewardDistribution;
|
||||
use crate::{ContractStateParams, IdentityKeyRef, Interval, Layer, NodeId};
|
||||
use crate::{ContractStateParams, IdentityKeyRef, Interval, Layer, MixId};
|
||||
pub use contracts_common::events::*;
|
||||
use cosmwasm_std::{Addr, Coin, Decimal, Event};
|
||||
|
||||
@@ -159,7 +159,7 @@ pub fn new_delegation_event(
|
||||
delegator: &Addr,
|
||||
proxy: &Option<Addr>,
|
||||
amount: &Coin,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Event {
|
||||
Event::new(MixnetEventType::Delegation)
|
||||
.add_attribute(DELEGATOR_KEY, delegator)
|
||||
@@ -171,7 +171,7 @@ pub fn new_delegation_event(
|
||||
pub fn new_delegation_on_unbonded_node_event(
|
||||
delegator: &Addr,
|
||||
proxy: &Option<Addr>,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Event {
|
||||
Event::new(MixnetEventType::Delegation)
|
||||
.add_attribute(DELEGATOR_KEY, delegator)
|
||||
@@ -183,7 +183,7 @@ pub fn new_pending_delegation_event(
|
||||
delegator: &Addr,
|
||||
proxy: &Option<Addr>,
|
||||
amount: &Coin,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Event {
|
||||
Event::new(MixnetEventType::PendingDelegation)
|
||||
.add_attribute(DELEGATOR_KEY, delegator)
|
||||
@@ -196,7 +196,7 @@ pub fn new_withdraw_operator_reward_event(
|
||||
owner: &Addr,
|
||||
proxy: &Option<Addr>,
|
||||
amount: Coin,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Event {
|
||||
Event::new(MixnetEventType::WithdrawOperatorReward)
|
||||
.add_attribute(OWNER_KEY, owner.as_str())
|
||||
@@ -209,7 +209,7 @@ pub fn new_withdraw_delegator_reward_event(
|
||||
delegator: &Addr,
|
||||
proxy: &Option<Addr>,
|
||||
amount: Coin,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Event {
|
||||
Event::new(MixnetEventType::WithdrawDelegatorReward)
|
||||
.add_attribute(DELEGATOR_KEY, delegator)
|
||||
@@ -265,7 +265,7 @@ pub fn new_pending_rewarding_params_update_event(
|
||||
)
|
||||
}
|
||||
|
||||
pub fn new_undelegation_event(delegator: &Addr, proxy: &Option<Addr>, mix_id: NodeId) -> Event {
|
||||
pub fn new_undelegation_event(delegator: &Addr, proxy: &Option<Addr>, mix_id: MixId) -> Event {
|
||||
Event::new(MixnetEventType::Undelegation)
|
||||
.add_attribute(DELEGATOR_KEY, delegator)
|
||||
.add_optional_attribute(PROXY_KEY, proxy.as_ref())
|
||||
@@ -275,7 +275,7 @@ pub fn new_undelegation_event(delegator: &Addr, proxy: &Option<Addr>, mix_id: No
|
||||
pub fn new_pending_undelegation_event(
|
||||
delegator: &Addr,
|
||||
proxy: &Option<Addr>,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Event {
|
||||
Event::new(MixnetEventType::PendingUndelegation)
|
||||
.add_attribute(DELEGATOR_KEY, delegator)
|
||||
@@ -314,7 +314,7 @@ pub fn new_mixnode_bonding_event(
|
||||
proxy: &Option<Addr>,
|
||||
amount: &Coin,
|
||||
identity: IdentityKeyRef<'_>,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
assigned_layer: Layer,
|
||||
) -> Event {
|
||||
// coin implements Display trait and we use that implementation here
|
||||
@@ -327,7 +327,7 @@ pub fn new_mixnode_bonding_event(
|
||||
.add_attribute(AMOUNT_KEY, amount.to_string())
|
||||
}
|
||||
|
||||
pub fn new_mixnode_unbonding_event(mix_id: NodeId) -> Event {
|
||||
pub fn new_mixnode_unbonding_event(mix_id: MixId) -> Event {
|
||||
Event::new(MixnetEventType::MixnodeUnbonding).add_attribute(MIX_ID_KEY, mix_id.to_string())
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ pub fn new_pending_mixnode_unbonding_event(
|
||||
owner: &Addr,
|
||||
proxy: &Option<Addr>,
|
||||
identity: IdentityKeyRef<'_>,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Event {
|
||||
Event::new(MixnetEventType::PendingMixnodeUnbonding)
|
||||
.add_attribute(MIX_ID_KEY, mix_id.to_string())
|
||||
@@ -345,7 +345,7 @@ pub fn new_pending_mixnode_unbonding_event(
|
||||
}
|
||||
|
||||
pub fn new_mixnode_config_update_event(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
owner: &Addr,
|
||||
proxy: &Option<Addr>,
|
||||
update: &MixNodeConfigUpdate,
|
||||
@@ -358,7 +358,7 @@ pub fn new_mixnode_config_update_event(
|
||||
}
|
||||
|
||||
pub fn new_mixnode_pending_cost_params_update_event(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
owner: &Addr,
|
||||
proxy: &Option<Addr>,
|
||||
new_costs: &MixNodeCostParams,
|
||||
@@ -370,10 +370,7 @@ pub fn new_mixnode_pending_cost_params_update_event(
|
||||
.add_attribute(UPDATED_MIXNODE_COST_PARAMS_KEY, new_costs.to_inline_json())
|
||||
}
|
||||
|
||||
pub fn new_mixnode_cost_params_update_event(
|
||||
mix_id: NodeId,
|
||||
new_costs: &MixNodeCostParams,
|
||||
) -> Event {
|
||||
pub fn new_mixnode_cost_params_update_event(mix_id: MixId, new_costs: &MixNodeCostParams) -> Event {
|
||||
Event::new(MixnetEventType::MixnodeCostParamsUpdate)
|
||||
.add_attribute(MIX_ID_KEY, mix_id.to_string())
|
||||
.add_attribute(UPDATED_MIXNODE_COST_PARAMS_KEY, new_costs.to_inline_json())
|
||||
@@ -431,7 +428,7 @@ pub fn new_settings_update_event(
|
||||
event
|
||||
}
|
||||
|
||||
pub fn new_not_found_mix_operator_rewarding_event(interval: Interval, mix_id: NodeId) -> Event {
|
||||
pub fn new_not_found_mix_operator_rewarding_event(interval: Interval, mix_id: MixId) -> Event {
|
||||
Event::new(MixnetEventType::MixnodeRewarding)
|
||||
.add_attribute(
|
||||
INTERVAL_KEY,
|
||||
@@ -441,7 +438,7 @@ pub fn new_not_found_mix_operator_rewarding_event(interval: Interval, mix_id: No
|
||||
.add_attribute(NO_REWARD_REASON_KEY, BOND_NOT_FOUND_VALUE)
|
||||
}
|
||||
|
||||
pub fn new_zero_uptime_mix_operator_rewarding_event(interval: Interval, mix_id: NodeId) -> Event {
|
||||
pub fn new_zero_uptime_mix_operator_rewarding_event(interval: Interval, mix_id: MixId) -> Event {
|
||||
Event::new(MixnetEventType::MixnodeRewarding)
|
||||
.add_attribute(
|
||||
INTERVAL_KEY,
|
||||
@@ -453,7 +450,7 @@ pub fn new_zero_uptime_mix_operator_rewarding_event(interval: Interval, mix_id:
|
||||
|
||||
pub fn new_mix_rewarding_event(
|
||||
interval: Interval,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
reward_distribution: RewardDistribution,
|
||||
prior_delegates: Decimal,
|
||||
prior_unit_delegation: Decimal,
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::error::MixnetContractError;
|
||||
use crate::reward_params::{NodeRewardParams, RewardingParams};
|
||||
use crate::rewarding::helpers::truncate_reward;
|
||||
use crate::rewarding::RewardDistribution;
|
||||
use crate::{Delegation, EpochId, IdentityKey, NodeId, Percent, SphinxKey};
|
||||
use crate::{Delegation, EpochId, IdentityKey, MixId, Percent, SphinxKey};
|
||||
use cosmwasm_std::{Addr, Coin, Decimal, Uint128};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -47,8 +47,8 @@ impl MixNodeDetails {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mix_id(&self) -> NodeId {
|
||||
self.bond_information.id
|
||||
pub fn mix_id(&self) -> MixId {
|
||||
self.bond_information.mix_id
|
||||
}
|
||||
|
||||
pub fn is_unbonding(&self) -> bool {
|
||||
@@ -428,7 +428,8 @@ impl MixNodeRewarding {
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
||||
pub struct MixNodeBond {
|
||||
/// Unique id assigned to the bonded mixnode.
|
||||
pub id: NodeId,
|
||||
#[serde(alias = "id")]
|
||||
pub mix_id: MixId,
|
||||
|
||||
/// Address of the owner of this mixnode.
|
||||
pub owner: Addr,
|
||||
@@ -456,7 +457,7 @@ pub struct MixNodeBond {
|
||||
|
||||
impl MixNodeBond {
|
||||
pub fn new(
|
||||
id: NodeId,
|
||||
mix_id: MixId,
|
||||
owner: Addr,
|
||||
original_pledge: Coin,
|
||||
layer: Layer,
|
||||
@@ -465,7 +466,7 @@ impl MixNodeBond {
|
||||
bonding_height: u64,
|
||||
) -> Self {
|
||||
MixNodeBond {
|
||||
id,
|
||||
mix_id,
|
||||
owner,
|
||||
original_pledge,
|
||||
layer,
|
||||
@@ -608,11 +609,11 @@ impl MixNodeConfigUpdate {
|
||||
pub struct PagedMixnodeBondsResponse {
|
||||
pub nodes: Vec<MixNodeBond>,
|
||||
pub per_page: usize,
|
||||
pub start_next_after: Option<NodeId>,
|
||||
pub start_next_after: Option<MixId>,
|
||||
}
|
||||
|
||||
impl PagedMixnodeBondsResponse {
|
||||
pub fn new(nodes: Vec<MixNodeBond>, per_page: usize, start_next_after: Option<NodeId>) -> Self {
|
||||
pub fn new(nodes: Vec<MixNodeBond>, per_page: usize, start_next_after: Option<MixId>) -> Self {
|
||||
PagedMixnodeBondsResponse {
|
||||
nodes,
|
||||
per_page,
|
||||
@@ -625,14 +626,14 @@ impl PagedMixnodeBondsResponse {
|
||||
pub struct PagedMixnodesDetailsResponse {
|
||||
pub nodes: Vec<MixNodeDetails>,
|
||||
pub per_page: usize,
|
||||
pub start_next_after: Option<NodeId>,
|
||||
pub start_next_after: Option<MixId>,
|
||||
}
|
||||
|
||||
impl PagedMixnodesDetailsResponse {
|
||||
pub fn new(
|
||||
nodes: Vec<MixNodeDetails>,
|
||||
per_page: usize,
|
||||
start_next_after: Option<NodeId>,
|
||||
start_next_after: Option<MixId>,
|
||||
) -> Self {
|
||||
PagedMixnodesDetailsResponse {
|
||||
nodes,
|
||||
@@ -644,16 +645,16 @@ impl PagedMixnodesDetailsResponse {
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, JsonSchema)]
|
||||
pub struct PagedUnbondedMixnodesResponse {
|
||||
pub nodes: Vec<(NodeId, UnbondedMixnode)>,
|
||||
pub nodes: Vec<(MixId, UnbondedMixnode)>,
|
||||
pub per_page: usize,
|
||||
pub start_next_after: Option<NodeId>,
|
||||
pub start_next_after: Option<MixId>,
|
||||
}
|
||||
|
||||
impl PagedUnbondedMixnodesResponse {
|
||||
pub fn new(
|
||||
nodes: Vec<(NodeId, UnbondedMixnode)>,
|
||||
nodes: Vec<(MixId, UnbondedMixnode)>,
|
||||
per_page: usize,
|
||||
start_next_after: Option<NodeId>,
|
||||
start_next_after: Option<MixId>,
|
||||
) -> Self {
|
||||
PagedUnbondedMixnodesResponse {
|
||||
nodes,
|
||||
@@ -671,25 +672,25 @@ pub struct MixOwnershipResponse {
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
||||
pub struct MixnodeDetailsResponse {
|
||||
pub mix_id: NodeId,
|
||||
pub mix_id: MixId,
|
||||
pub mixnode_details: Option<MixNodeDetails>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
||||
pub struct MixnodeRewardingDetailsResponse {
|
||||
pub mix_id: NodeId,
|
||||
pub mix_id: MixId,
|
||||
pub rewarding_details: Option<MixNodeRewarding>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, JsonSchema)]
|
||||
pub struct UnbondedMixnodeResponse {
|
||||
pub mix_id: NodeId,
|
||||
pub mix_id: MixId,
|
||||
pub unbonded_info: Option<UnbondedMixnode>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Eq, Serialize, JsonSchema)]
|
||||
pub struct StakeSaturationResponse {
|
||||
pub mix_id: NodeId,
|
||||
pub mix_id: MixId,
|
||||
pub current_saturation: Option<Decimal>,
|
||||
pub uncapped_saturation: Option<Decimal>,
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::mixnode::{MixNodeConfigUpdate, MixNodeCostParams};
|
||||
use crate::reward_params::{
|
||||
IntervalRewardParams, IntervalRewardingParamsUpdate, Performance, RewardingParams,
|
||||
};
|
||||
use crate::{delegation, ContractStateParams, NodeId, Percent};
|
||||
use crate::{delegation, ContractStateParams, MixId, Percent};
|
||||
use crate::{Gateway, IdentityKey, MixNode};
|
||||
use cosmwasm_std::Decimal;
|
||||
use schemars::JsonSchema;
|
||||
@@ -87,7 +87,7 @@ pub enum ExecuteMsg {
|
||||
force_immediately: bool,
|
||||
},
|
||||
AdvanceCurrentEpoch {
|
||||
new_rewarded_set: Vec<NodeId>,
|
||||
new_rewarded_set: Vec<MixId>,
|
||||
expected_active_set_size: u32,
|
||||
},
|
||||
ReconcileEpochEvents {
|
||||
@@ -142,23 +142,23 @@ pub enum ExecuteMsg {
|
||||
|
||||
// delegation-related:
|
||||
DelegateToMixnode {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
},
|
||||
DelegateToMixnodeOnBehalf {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
delegate: String,
|
||||
},
|
||||
UndelegateFromMixnode {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
},
|
||||
UndelegateFromMixnodeOnBehalf {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
delegate: String,
|
||||
},
|
||||
|
||||
// reward-related
|
||||
RewardMixnode {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
performance: Performance,
|
||||
},
|
||||
WithdrawOperatorReward {},
|
||||
@@ -166,10 +166,10 @@ pub enum ExecuteMsg {
|
||||
owner: String,
|
||||
},
|
||||
WithdrawDelegatorReward {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
},
|
||||
WithdrawDelegatorRewardOnBehalf {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
owner: String,
|
||||
},
|
||||
|
||||
@@ -282,46 +282,46 @@ pub enum QueryMsg {
|
||||
GetCurrentIntervalDetails {},
|
||||
GetRewardedSet {
|
||||
limit: Option<u32>,
|
||||
start_after: Option<NodeId>,
|
||||
start_after: Option<MixId>,
|
||||
},
|
||||
|
||||
// mixnode-related:
|
||||
GetMixNodeBonds {
|
||||
limit: Option<u32>,
|
||||
start_after: Option<NodeId>,
|
||||
start_after: Option<MixId>,
|
||||
},
|
||||
GetMixNodesDetailed {
|
||||
limit: Option<u32>,
|
||||
start_after: Option<NodeId>,
|
||||
start_after: Option<MixId>,
|
||||
},
|
||||
GetUnbondedMixNodes {
|
||||
limit: Option<u32>,
|
||||
start_after: Option<NodeId>,
|
||||
start_after: Option<MixId>,
|
||||
},
|
||||
GetUnbondedMixNodesByOwner {
|
||||
owner: String,
|
||||
limit: Option<u32>,
|
||||
start_after: Option<NodeId>,
|
||||
start_after: Option<MixId>,
|
||||
},
|
||||
GetUnbondedMixNodesByIdentityKey {
|
||||
identity_key: String,
|
||||
limit: Option<u32>,
|
||||
start_after: Option<NodeId>,
|
||||
start_after: Option<MixId>,
|
||||
},
|
||||
GetOwnedMixnode {
|
||||
address: String,
|
||||
},
|
||||
GetMixnodeDetails {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
},
|
||||
GetMixnodeRewardingDetails {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
},
|
||||
GetStakeSaturation {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
},
|
||||
GetUnbondedMixNodeInformation {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
},
|
||||
GetBondedMixnodeDetailsByIdentity {
|
||||
mix_identity: IdentityKey,
|
||||
@@ -343,7 +343,7 @@ pub enum QueryMsg {
|
||||
// delegation-related:
|
||||
// gets all [paged] delegations associated with particular mixnode
|
||||
GetMixnodeDelegations {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
// since `start_after` is user-provided input, we can't use `Addr` as we
|
||||
// can't guarantee it's validated.
|
||||
start_after: Option<String>,
|
||||
@@ -354,12 +354,12 @@ pub enum QueryMsg {
|
||||
// since `delegator` is user-provided input, we can't use `Addr` as we
|
||||
// can't guarantee it's validated.
|
||||
delegator: String,
|
||||
start_after: Option<(NodeId, OwnerProxySubKey)>,
|
||||
start_after: Option<(MixId, OwnerProxySubKey)>,
|
||||
limit: Option<u32>,
|
||||
},
|
||||
// gets delegation associated with particular mixnode, delegator pair
|
||||
GetDelegationDetails {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
delegator: String,
|
||||
proxy: Option<String>,
|
||||
},
|
||||
@@ -374,21 +374,21 @@ pub enum QueryMsg {
|
||||
address: String,
|
||||
},
|
||||
GetPendingMixNodeOperatorReward {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
},
|
||||
GetPendingDelegatorReward {
|
||||
address: String,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
proxy: Option<String>,
|
||||
},
|
||||
// given the provided performance, estimate the reward at the end of the current epoch
|
||||
GetEstimatedCurrentEpochOperatorReward {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
estimated_performance: Performance,
|
||||
},
|
||||
GetEstimatedCurrentEpochDelegatorReward {
|
||||
address: String,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
proxy: Option<String>,
|
||||
estimated_performance: Performance,
|
||||
},
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use crate::mixnode::MixNodeCostParams;
|
||||
use crate::reward_params::IntervalRewardingParamsUpdate;
|
||||
use crate::{EpochEventId, IntervalEventId, NodeId};
|
||||
use crate::{EpochEventId, IntervalEventId, MixId};
|
||||
use cosmwasm_std::{Addr, Coin};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -19,17 +19,17 @@ pub enum PendingEpochEventData {
|
||||
// `cumulative_reward_ratio` ahead of time
|
||||
Delegate {
|
||||
owner: Addr,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
amount: Coin,
|
||||
proxy: Option<Addr>,
|
||||
},
|
||||
Undelegate {
|
||||
owner: Addr,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
proxy: Option<Addr>,
|
||||
},
|
||||
UnbondMixnode {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
},
|
||||
UpdateActiveSetSize {
|
||||
new_size: u32,
|
||||
@@ -54,7 +54,7 @@ pub struct PendingIntervalEvent {
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
pub enum PendingIntervalEventData {
|
||||
ChangeMixCostParams {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
new_costs: MixNodeCostParams,
|
||||
},
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ pub type SphinxKey = String;
|
||||
pub type SphinxKeyRef<'a> = &'a str;
|
||||
pub type EpochId = u32;
|
||||
pub type IntervalId = u32;
|
||||
pub type NodeId = u32;
|
||||
pub type MixId = u32;
|
||||
pub type EpochEventId = u32;
|
||||
pub type IntervalEventId = u32;
|
||||
|
||||
@@ -202,8 +202,8 @@ pub struct ContractStateParams {
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, JsonSchema)]
|
||||
pub struct PagedRewardedSetResponse {
|
||||
pub nodes: Vec<(NodeId, RewardedSetNodeStatus)>,
|
||||
pub start_next_after: Option<NodeId>,
|
||||
pub nodes: Vec<(MixId, RewardedSetNodeStatus)>,
|
||||
pub start_next_after: Option<MixId>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
use cosmwasm_std::{Addr, Coin, Timestamp, Uint128};
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -74,13 +74,13 @@ impl OriginalVestingResponse {
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone, JsonSchema)]
|
||||
pub struct VestingDelegation {
|
||||
pub account_id: u32,
|
||||
pub mix_id: NodeId,
|
||||
pub mix_id: MixId,
|
||||
pub block_timestamp: u64,
|
||||
pub amount: Uint128,
|
||||
}
|
||||
|
||||
impl VestingDelegation {
|
||||
pub fn storage_key(&self) -> (u32, NodeId, u64) {
|
||||
pub fn storage_key(&self) -> (u32, MixId, u64) {
|
||||
(self.account_id, self.mix_id, self.block_timestamp)
|
||||
}
|
||||
}
|
||||
@@ -89,12 +89,12 @@ impl VestingDelegation {
|
||||
pub struct DelegationTimesResponse {
|
||||
pub owner: Addr,
|
||||
pub account_id: u32,
|
||||
pub mix_id: NodeId,
|
||||
pub mix_id: MixId,
|
||||
pub delegation_timestamps: Vec<u64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone, JsonSchema)]
|
||||
pub struct AllDelegationsResponse {
|
||||
pub delegations: Vec<VestingDelegation>,
|
||||
pub start_next_after: Option<(u32, NodeId, u64)>,
|
||||
pub start_next_after: Option<(u32, MixId, u64)>,
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use cosmwasm_std::{Coin, Timestamp, Uint128};
|
||||
use mixnet_contract_common::{
|
||||
mixnode::{MixNodeConfigUpdate, MixNodeCostParams},
|
||||
Gateway, MixNode, NodeId,
|
||||
Gateway, MixId, MixNode,
|
||||
};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -61,7 +61,7 @@ pub enum ExecuteMsg {
|
||||
},
|
||||
ClaimOperatorReward {},
|
||||
ClaimDelegatorReward {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
},
|
||||
UpdateMixnodeCostParams {
|
||||
new_costs: MixNodeCostParams,
|
||||
@@ -73,11 +73,11 @@ pub enum ExecuteMsg {
|
||||
address: String,
|
||||
},
|
||||
DelegateToMixnode {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
amount: Coin,
|
||||
},
|
||||
UndelegateFromMixnode {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
},
|
||||
CreateAccount {
|
||||
owner_address: String,
|
||||
@@ -89,7 +89,7 @@ pub enum ExecuteMsg {
|
||||
},
|
||||
TrackUndelegation {
|
||||
owner: String,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
amount: Coin,
|
||||
},
|
||||
BondMixnode {
|
||||
@@ -204,10 +204,10 @@ pub enum QueryMsg {
|
||||
GetLockedPledgeCap {},
|
||||
GetDelegationTimes {
|
||||
address: String,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
},
|
||||
GetAllDelegations {
|
||||
start_after: Option<(u32, NodeId, u64)>,
|
||||
start_after: Option<(u32, MixId, u64)>,
|
||||
limit: Option<u32>,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ pub fn nym_topology_from_detailed(
|
||||
);
|
||||
continue;
|
||||
}
|
||||
let mix_id = bond.id;
|
||||
let mix_id = bond.mix_id;
|
||||
let mix_identity = bond.mix_node.identity_key.clone();
|
||||
|
||||
let layer_entry = mixes.entry(layer).or_insert_with(Vec::new);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use crate::{filter, NetworkAddress};
|
||||
use crypto::asymmetric::{encryption, identity};
|
||||
use mixnet_contract_common::{Layer, MixNodeBond, NodeId};
|
||||
use mixnet_contract_common::{Layer, MixId, MixNodeBond};
|
||||
use nymsphinx_addressing::nodes::NymNodeRoutingAddress;
|
||||
use nymsphinx_types::Node as SphinxNode;
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
@@ -68,7 +68,7 @@ impl Display for MixnodeConversionError {
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Node {
|
||||
pub mix_id: NodeId,
|
||||
pub mix_id: MixId,
|
||||
pub owner: String,
|
||||
pub host: NetworkAddress,
|
||||
// we're keeping this as separate resolved field since we do not want to be resolving the potential
|
||||
@@ -113,7 +113,7 @@ impl<'a> TryFrom<&'a MixNodeBond> for Node {
|
||||
})?[0];
|
||||
|
||||
Ok(Node {
|
||||
mix_id: bond.id,
|
||||
mix_id: bond.mix_id,
|
||||
owner: bond.owner.as_str().to_owned(),
|
||||
host,
|
||||
mix_host,
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::deprecated::DelegationEvent;
|
||||
use crate::error::TypesError;
|
||||
use crate::mixnode::MixNodeCostParams;
|
||||
use cosmwasm_std::Decimal;
|
||||
use mixnet_contract_common::{Delegation as MixnetContractDelegation, NodeId};
|
||||
use mixnet_contract_common::{Delegation as MixnetContractDelegation, MixId};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -15,7 +15,7 @@ use serde::{Deserialize, Serialize};
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, JsonSchema)]
|
||||
pub struct Delegation {
|
||||
pub owner: String,
|
||||
pub mix_id: NodeId,
|
||||
pub mix_id: MixId,
|
||||
pub amount: DecCoin,
|
||||
pub height: u64,
|
||||
pub proxy: Option<String>, // proxy address used to delegate the funds on behalf of another address
|
||||
@@ -44,7 +44,7 @@ impl Delegation {
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, JsonSchema)]
|
||||
pub struct DelegationWithEverything {
|
||||
pub owner: String,
|
||||
pub mix_id: NodeId,
|
||||
pub mix_id: MixId,
|
||||
pub node_identity: String,
|
||||
pub amount: DecCoin,
|
||||
pub accumulated_by_delegates: Option<DecCoin>,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
use crate::currency::DecCoin;
|
||||
use crate::error::TypesError;
|
||||
use crate::pending_events::{PendingEpochEvent, PendingEpochEventData};
|
||||
use mixnet_contract_common::{IdentityKey, NodeId};
|
||||
use mixnet_contract_common::{IdentityKey, MixId};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -27,7 +27,7 @@ pub enum DelegationEventKind {
|
||||
#[derive(Clone, Deserialize, Serialize, PartialEq, Eq, JsonSchema, Debug)]
|
||||
pub struct DelegationEvent {
|
||||
pub kind: DelegationEventKind,
|
||||
pub mix_id: NodeId,
|
||||
pub mix_id: MixId,
|
||||
pub address: String,
|
||||
pub amount: Option<DecCoin>,
|
||||
pub proxy: Option<String>,
|
||||
|
||||
@@ -5,10 +5,10 @@ use crate::currency::{DecCoin, RegisteredCoins};
|
||||
use crate::error::TypesError;
|
||||
use cosmwasm_std::Decimal;
|
||||
use mixnet_contract_common::{
|
||||
EpochId, MixNode, MixNodeBond as MixnetContractMixNodeBond,
|
||||
EpochId, MixId, MixNode, MixNodeBond as MixnetContractMixNodeBond,
|
||||
MixNodeCostParams as MixnetContractMixNodeCostParams,
|
||||
MixNodeDetails as MixnetContractMixNodeDetails,
|
||||
MixNodeRewarding as MixnetContractMixNodeRewarding, NodeId, Percent,
|
||||
MixNodeRewarding as MixnetContractMixNodeRewarding, Percent,
|
||||
};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -49,7 +49,7 @@ impl MixNodeDetails {
|
||||
)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, JsonSchema)]
|
||||
pub struct MixNodeBond {
|
||||
pub id: NodeId,
|
||||
pub mix_id: MixId,
|
||||
pub owner: String,
|
||||
pub original_pledge: DecCoin,
|
||||
pub layer: String,
|
||||
@@ -65,7 +65,7 @@ impl MixNodeBond {
|
||||
reg: &RegisteredCoins,
|
||||
) -> Result<MixNodeBond, TypesError> {
|
||||
Ok(MixNodeBond {
|
||||
id: bond.id,
|
||||
mix_id: bond.mix_id,
|
||||
owner: bond.owner.into_string(),
|
||||
original_pledge: reg
|
||||
.attempt_convert_to_display_dec_coin(bond.original_pledge.into())?,
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::currency::{DecCoin, RegisteredCoins};
|
||||
use crate::error::TypesError;
|
||||
use crate::mixnode::MixNodeCostParams;
|
||||
use mixnet_contract_common::{
|
||||
EpochEventId, IntervalEventId, IntervalRewardingParamsUpdate, NodeId,
|
||||
EpochEventId, IntervalEventId, IntervalRewardingParamsUpdate, MixId,
|
||||
PendingEpochEvent as MixnetContractPendingEpochEvent,
|
||||
PendingEpochEventData as MixnetContractPendingEpochEventData,
|
||||
PendingIntervalEvent as MixnetContractPendingIntervalEvent,
|
||||
@@ -46,17 +46,17 @@ impl PendingEpochEvent {
|
||||
pub enum PendingEpochEventData {
|
||||
Delegate {
|
||||
owner: String,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
amount: DecCoin,
|
||||
proxy: Option<String>,
|
||||
},
|
||||
Undelegate {
|
||||
owner: String,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
proxy: Option<String>,
|
||||
},
|
||||
UnbondMixnode {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
},
|
||||
UpdateActiveSetSize {
|
||||
new_size: u32,
|
||||
@@ -130,7 +130,7 @@ impl PendingIntervalEvent {
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, JsonSchema)]
|
||||
pub enum PendingIntervalEventData {
|
||||
ChangeMixCostParams {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
new_costs: MixNodeCostParams,
|
||||
},
|
||||
|
||||
|
||||
@@ -12,13 +12,13 @@ use cosmwasm_std::StdResult;
|
||||
use cw_storage_plus::Bound;
|
||||
use mixnet_contract_common::delegation::{MixNodeDelegationResponse, OwnerProxySubKey};
|
||||
use mixnet_contract_common::{
|
||||
delegation, Delegation, NodeId, PagedAllDelegationsResponse, PagedDelegatorDelegationsResponse,
|
||||
delegation, Delegation, MixId, PagedAllDelegationsResponse, PagedDelegatorDelegationsResponse,
|
||||
PagedMixNodeDelegationsResponse,
|
||||
};
|
||||
|
||||
pub(crate) fn query_mixnode_delegations_paged(
|
||||
deps: Deps<'_>,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
start_after: Option<String>,
|
||||
limit: Option<u32>,
|
||||
) -> StdResult<PagedMixNodeDelegationsResponse> {
|
||||
@@ -50,7 +50,7 @@ pub(crate) fn query_mixnode_delegations_paged(
|
||||
pub(crate) fn query_delegator_delegations_paged(
|
||||
deps: Deps<'_>,
|
||||
delegation_owner: String,
|
||||
start_after: Option<(NodeId, OwnerProxySubKey)>,
|
||||
start_after: Option<(MixId, OwnerProxySubKey)>,
|
||||
limit: Option<u32>,
|
||||
) -> StdResult<PagedDelegatorDelegationsResponse> {
|
||||
let validated_owner = deps.api.addr_validate(&delegation_owner)?;
|
||||
@@ -85,7 +85,7 @@ pub(crate) fn query_delegator_delegations_paged(
|
||||
// queries for delegation value of given address for particular node
|
||||
pub(crate) fn query_mixnode_delegation(
|
||||
deps: Deps<'_>,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
delegation_owner: String,
|
||||
proxy: Option<String>,
|
||||
) -> StdResult<MixNodeDelegationResponse> {
|
||||
|
||||
@@ -6,15 +6,15 @@ use crate::constants::{
|
||||
};
|
||||
use cw_storage_plus::{Index, IndexList, IndexedMap, MultiIndex};
|
||||
use mixnet_contract_common::delegation::OwnerProxySubKey;
|
||||
use mixnet_contract_common::{Addr, Delegation, NodeId};
|
||||
use mixnet_contract_common::{Addr, Delegation, MixId};
|
||||
|
||||
// It's a composite key on node's id and delegator address
|
||||
type PrimaryKey = (NodeId, OwnerProxySubKey);
|
||||
type PrimaryKey = (MixId, OwnerProxySubKey);
|
||||
|
||||
pub(crate) struct DelegationIndex<'a> {
|
||||
pub(crate) owner: MultiIndex<'a, Addr, Delegation, PrimaryKey>,
|
||||
|
||||
pub(crate) mixnode: MultiIndex<'a, NodeId, Delegation, PrimaryKey>,
|
||||
pub(crate) mixnode: MultiIndex<'a, MixId, Delegation, PrimaryKey>,
|
||||
}
|
||||
|
||||
impl<'a> IndexList<Delegation> for DelegationIndex<'a> {
|
||||
|
||||
@@ -12,12 +12,12 @@ use mixnet_contract_common::events::{
|
||||
new_pending_delegation_event, new_pending_undelegation_event,
|
||||
};
|
||||
use mixnet_contract_common::pending_events::PendingEpochEventData;
|
||||
use mixnet_contract_common::{Delegation, NodeId};
|
||||
use mixnet_contract_common::{Delegation, MixId};
|
||||
|
||||
pub(crate) fn try_delegate_to_mixnode(
|
||||
deps: DepsMut<'_>,
|
||||
info: MessageInfo,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<Response, MixnetContractError> {
|
||||
_try_delegate_to_mixnode(deps, mix_id, info.sender, info.funds, None)
|
||||
}
|
||||
@@ -25,7 +25,7 @@ pub(crate) fn try_delegate_to_mixnode(
|
||||
pub(crate) fn try_delegate_to_mixnode_on_behalf(
|
||||
deps: DepsMut<'_>,
|
||||
info: MessageInfo,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
delegate: String,
|
||||
) -> Result<Response, MixnetContractError> {
|
||||
let delegate = deps.api.addr_validate(&delegate)?;
|
||||
@@ -34,7 +34,7 @@ pub(crate) fn try_delegate_to_mixnode_on_behalf(
|
||||
|
||||
pub(crate) fn _try_delegate_to_mixnode(
|
||||
deps: DepsMut<'_>,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
delegate: Addr,
|
||||
amount: Vec<Coin>,
|
||||
proxy: Option<Addr>,
|
||||
@@ -73,7 +73,7 @@ pub(crate) fn _try_delegate_to_mixnode(
|
||||
pub(crate) fn try_remove_delegation_from_mixnode(
|
||||
deps: DepsMut<'_>,
|
||||
info: MessageInfo,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<Response, MixnetContractError> {
|
||||
_try_remove_delegation_from_mixnode(deps, mix_id, info.sender, None)
|
||||
}
|
||||
@@ -81,7 +81,7 @@ pub(crate) fn try_remove_delegation_from_mixnode(
|
||||
pub(crate) fn try_remove_delegation_from_mixnode_on_behalf(
|
||||
deps: DepsMut<'_>,
|
||||
info: MessageInfo,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
delegate: String,
|
||||
) -> Result<Response, MixnetContractError> {
|
||||
let delegate = deps.api.addr_validate(&delegate)?;
|
||||
@@ -90,7 +90,7 @@ pub(crate) fn try_remove_delegation_from_mixnode_on_behalf(
|
||||
|
||||
pub(crate) fn _try_remove_delegation_from_mixnode(
|
||||
deps: DepsMut<'_>,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
delegate: Addr,
|
||||
proxy: Option<Addr>,
|
||||
) -> Result<Response, MixnetContractError> {
|
||||
|
||||
@@ -19,7 +19,7 @@ use mixnet_contract_common::events::{
|
||||
use mixnet_contract_common::mixnode::MixNodeCostParams;
|
||||
use mixnet_contract_common::pending_events::{PendingEpochEventData, PendingIntervalEventData};
|
||||
use mixnet_contract_common::reward_params::IntervalRewardingParamsUpdate;
|
||||
use mixnet_contract_common::{Delegation, NodeId};
|
||||
use mixnet_contract_common::{Delegation, MixId};
|
||||
use vesting_contract_common::messages::ExecuteMsg as VestingContractExecuteMsg;
|
||||
|
||||
pub(crate) trait ContractExecutableEvent {
|
||||
@@ -33,7 +33,7 @@ pub(crate) fn delegate(
|
||||
deps: DepsMut<'_>,
|
||||
env: &Env,
|
||||
owner: Addr,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
amount: Coin,
|
||||
proxy: Option<Addr>,
|
||||
) -> Result<Response, MixnetContractError> {
|
||||
@@ -131,7 +131,7 @@ pub(crate) fn delegate(
|
||||
pub(crate) fn undelegate(
|
||||
deps: DepsMut<'_>,
|
||||
owner: Addr,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
proxy: Option<Addr>,
|
||||
) -> Result<Response, MixnetContractError> {
|
||||
// see if the delegation still exists (in case of impatient user who decided to send multiple
|
||||
@@ -177,7 +177,7 @@ pub(crate) fn undelegate(
|
||||
pub(crate) fn unbond_mixnode(
|
||||
deps: DepsMut<'_>,
|
||||
env: &Env,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<Response, MixnetContractError> {
|
||||
// if we're here it means user executed `_try_remove_mixnode` and as a result node was set to be
|
||||
// in unbonding state and thus nothing could have been done to it (such as attempting to double unbond it)
|
||||
@@ -270,7 +270,7 @@ impl ContractExecutableEvent for PendingEpochEventData {
|
||||
|
||||
pub(crate) fn change_mix_cost_params(
|
||||
deps: DepsMut<'_>,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
new_costs: MixNodeCostParams,
|
||||
) -> Result<Response, MixnetContractError> {
|
||||
// almost an entire interval might have passed since the request was issued -> check if the
|
||||
|
||||
@@ -11,7 +11,7 @@ use cosmwasm_std::{Deps, Env, Order, StdResult};
|
||||
use cw_storage_plus::Bound;
|
||||
use mixnet_contract_common::pending_events::{PendingEpochEvent, PendingIntervalEvent};
|
||||
use mixnet_contract_common::{
|
||||
CurrentIntervalResponse, EpochEventId, IntervalEventId, NodeId, PagedRewardedSetResponse,
|
||||
CurrentIntervalResponse, EpochEventId, IntervalEventId, MixId, PagedRewardedSetResponse,
|
||||
PendingEpochEventsResponse, PendingIntervalEventsResponse,
|
||||
};
|
||||
|
||||
@@ -26,7 +26,7 @@ pub fn query_current_interval_details(
|
||||
|
||||
pub fn query_rewarded_set_paged(
|
||||
deps: Deps<'_>,
|
||||
start_after: Option<NodeId>,
|
||||
start_after: Option<MixId>,
|
||||
limit: Option<u32>,
|
||||
) -> StdResult<PagedRewardedSetResponse> {
|
||||
let limit = limit
|
||||
|
||||
@@ -10,12 +10,12 @@ use cosmwasm_std::{Order, StdResult, Storage};
|
||||
use cw_storage_plus::{Item, Map};
|
||||
use mixnet_contract_common::pending_events::{PendingEpochEventData, PendingIntervalEventData};
|
||||
use mixnet_contract_common::{
|
||||
EpochEventId, Interval, IntervalEventId, NodeId, RewardedSetNodeStatus,
|
||||
EpochEventId, Interval, IntervalEventId, MixId, RewardedSetNodeStatus,
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub(crate) const CURRENT_INTERVAL: Item<'_, Interval> = Item::new(CURRENT_INTERVAL_KEY);
|
||||
pub(crate) const REWARDED_SET: Map<NodeId, RewardedSetNodeStatus> = Map::new(REWARDED_SET_KEY);
|
||||
pub(crate) const REWARDED_SET: Map<MixId, RewardedSetNodeStatus> = Map::new(REWARDED_SET_KEY);
|
||||
|
||||
pub(crate) const EPOCH_EVENT_ID_COUNTER: Item<EpochEventId> = Item::new(EPOCH_EVENT_ID_COUNTER_KEY);
|
||||
pub(crate) const INTERVAL_EVENT_ID_COUNTER: Item<IntervalEventId> =
|
||||
@@ -81,7 +81,7 @@ pub(crate) fn push_new_interval_event(
|
||||
pub(crate) fn update_rewarded_set(
|
||||
storage: &mut dyn Storage,
|
||||
active_set_size: u32,
|
||||
new_set: Vec<NodeId>,
|
||||
new_set: Vec<MixId>,
|
||||
) -> StdResult<()> {
|
||||
// our goal is to reduce the number of reads and writes to the underlying storage,
|
||||
// whilst completely overwriting the current rewarded set.
|
||||
@@ -138,7 +138,7 @@ mod tests {
|
||||
use cosmwasm_std::testing::mock_dependencies;
|
||||
use cosmwasm_std::Order;
|
||||
|
||||
fn read_entire_set(storage: &mut dyn Storage) -> HashMap<NodeId, RewardedSetNodeStatus> {
|
||||
fn read_entire_set(storage: &mut dyn Storage) -> HashMap<MixId, RewardedSetNodeStatus> {
|
||||
REWARDED_SET
|
||||
.range(storage, None, None, Order::Ascending)
|
||||
.map(|r| r.unwrap())
|
||||
|
||||
@@ -16,7 +16,7 @@ use mixnet_contract_common::events::{
|
||||
new_reconcile_pending_events,
|
||||
};
|
||||
use mixnet_contract_common::pending_events::PendingIntervalEventData;
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
// those two should be called in separate tx (from advancing epoch),
|
||||
@@ -162,7 +162,7 @@ pub fn try_reconcile_epoch_events(
|
||||
|
||||
fn update_rewarded_set(
|
||||
storage: &mut dyn Storage,
|
||||
new_rewarded_set: Vec<NodeId>,
|
||||
new_rewarded_set: Vec<MixId>,
|
||||
expected_active_set_size: u32,
|
||||
) -> Result<(), MixnetContractError> {
|
||||
let reward_params = rewards_storage::REWARDING_PARAMS.load(storage)?;
|
||||
@@ -202,7 +202,7 @@ pub fn try_advance_epoch(
|
||||
mut deps: DepsMut<'_>,
|
||||
env: Env,
|
||||
info: MessageInfo,
|
||||
new_rewarded_set: Vec<NodeId>,
|
||||
new_rewarded_set: Vec<MixId>,
|
||||
expected_active_set_size: u32,
|
||||
) -> Result<Response, MixnetContractError> {
|
||||
// Only rewarding validator can attempt to advance epoch
|
||||
@@ -307,7 +307,7 @@ mod tests {
|
||||
for i in 0..n {
|
||||
let dummy_action = PendingEpochEventData::Undelegate {
|
||||
owner: Addr::unchecked("foomp"),
|
||||
mix_id: i as NodeId,
|
||||
mix_id: i as MixId,
|
||||
proxy: None,
|
||||
};
|
||||
storage::push_new_epoch_event(test.deps_mut().storage, &dummy_action).unwrap();
|
||||
@@ -319,7 +319,7 @@ mod tests {
|
||||
// it will return an empty response, but will not fail
|
||||
for i in 0..n {
|
||||
let dummy_action = PendingIntervalEventData::ChangeMixCostParams {
|
||||
mix_id: i as NodeId,
|
||||
mix_id: i as MixId,
|
||||
new_costs: fixtures::mix_node_cost_params_fixture(),
|
||||
};
|
||||
storage::push_new_interval_event(test.deps_mut().storage, &dummy_action).unwrap();
|
||||
|
||||
@@ -10,7 +10,7 @@ use mixnet_contract_common::error::MixnetContractError;
|
||||
use mixnet_contract_common::mixnode::{
|
||||
MixNodeCostParams, MixNodeDetails, MixNodeRewarding, UnbondedMixnode,
|
||||
};
|
||||
use mixnet_contract_common::{Layer, MixNode, MixNodeBond, NodeId};
|
||||
use mixnet_contract_common::{Layer, MixId, MixNode, MixNodeBond};
|
||||
|
||||
pub(crate) fn must_get_mixnode_bond_by_owner(
|
||||
store: &dyn Storage,
|
||||
@@ -28,12 +28,12 @@ pub(crate) fn must_get_mixnode_bond_by_owner(
|
||||
|
||||
pub(crate) fn get_mixnode_details_by_id(
|
||||
store: &dyn Storage,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> StdResult<Option<MixNodeDetails>> {
|
||||
if let Some(bond_information) = storage::mixnode_bonds().may_load(store, mix_id)? {
|
||||
// if bond exists, rewarding details MUST also exist
|
||||
let rewarding_details =
|
||||
rewards_storage::MIXNODE_REWARDING.load(store, bond_information.id)?;
|
||||
rewards_storage::MIXNODE_REWARDING.load(store, bond_information.mix_id)?;
|
||||
Ok(Some(MixNodeDetails::new(
|
||||
bond_information,
|
||||
rewarding_details,
|
||||
@@ -55,7 +55,7 @@ pub(crate) fn get_mixnode_details_by_owner(
|
||||
{
|
||||
// if bond exists, rewarding details MUST also exist
|
||||
let rewarding_details =
|
||||
rewards_storage::MIXNODE_REWARDING.load(store, bond_information.id)?;
|
||||
rewards_storage::MIXNODE_REWARDING.load(store, bond_information.mix_id)?;
|
||||
Ok(Some(MixNodeDetails::new(
|
||||
bond_information,
|
||||
rewarding_details,
|
||||
@@ -73,14 +73,14 @@ pub(crate) fn save_new_mixnode(
|
||||
owner: Addr,
|
||||
proxy: Option<Addr>,
|
||||
pledge: Coin,
|
||||
) -> Result<(NodeId, Layer), MixnetContractError> {
|
||||
) -> Result<(MixId, Layer), MixnetContractError> {
|
||||
let layer = assign_layer(storage)?;
|
||||
let node_id = next_mixnode_id_counter(storage)?;
|
||||
let mix_id = next_mixnode_id_counter(storage)?;
|
||||
let current_epoch = interval_storage::current_interval(storage)?.current_epoch_absolute_id();
|
||||
|
||||
let mixnode_rewarding = MixNodeRewarding::initialise_new(cost_params, &pledge, current_epoch);
|
||||
let mixnode_bond = MixNodeBond::new(
|
||||
node_id,
|
||||
mix_id,
|
||||
owner,
|
||||
pledge,
|
||||
layer,
|
||||
@@ -91,12 +91,12 @@ pub(crate) fn save_new_mixnode(
|
||||
|
||||
// save mixnode bond data
|
||||
// note that this implicitly checks for uniqueness on identity key, sphinx key and owner
|
||||
storage::mixnode_bonds().save(storage, node_id, &mixnode_bond)?;
|
||||
storage::mixnode_bonds().save(storage, mix_id, &mixnode_bond)?;
|
||||
|
||||
// save rewarding data
|
||||
rewards_storage::MIXNODE_REWARDING.save(storage, node_id, &mixnode_rewarding)?;
|
||||
rewards_storage::MIXNODE_REWARDING.save(storage, mix_id, &mixnode_rewarding)?;
|
||||
|
||||
Ok((node_id, layer))
|
||||
Ok((mix_id, layer))
|
||||
}
|
||||
|
||||
pub(crate) fn cleanup_post_unbond_mixnode_storage(
|
||||
@@ -104,13 +104,13 @@ pub(crate) fn cleanup_post_unbond_mixnode_storage(
|
||||
env: &Env,
|
||||
current_details: &MixNodeDetails,
|
||||
) -> Result<(), MixnetContractError> {
|
||||
let node_id = current_details.bond_information.id;
|
||||
let mix_id = current_details.bond_information.mix_id;
|
||||
// remove all bond information (we don't need it anymore
|
||||
// note that "normal" remove is `may_load` followed by `replace` with a `None`
|
||||
// and we have already loaded the data from the storage
|
||||
storage::mixnode_bonds().replace(
|
||||
storage,
|
||||
node_id,
|
||||
mix_id,
|
||||
None,
|
||||
Some(¤t_details.bond_information),
|
||||
)?;
|
||||
@@ -118,14 +118,14 @@ pub(crate) fn cleanup_post_unbond_mixnode_storage(
|
||||
// if there are no pending delegations to return, we can also
|
||||
// purge all information regarding rewarding parameters
|
||||
if current_details.rewarding_details.unique_delegations == 0 {
|
||||
rewards_storage::MIXNODE_REWARDING.remove(storage, node_id);
|
||||
rewards_storage::MIXNODE_REWARDING.remove(storage, mix_id);
|
||||
} else {
|
||||
// otherwise just set operator's tokens to zero as to indicate they have unbonded
|
||||
// and already claimed those
|
||||
let mut zeroed = current_details.rewarding_details.clone();
|
||||
zeroed.operator = Decimal::zero();
|
||||
|
||||
rewards_storage::MIXNODE_REWARDING.save(storage, node_id, &zeroed)?;
|
||||
rewards_storage::MIXNODE_REWARDING.save(storage, mix_id, &zeroed)?;
|
||||
}
|
||||
|
||||
let identity = current_details.bond_information.identity().to_owned();
|
||||
@@ -135,7 +135,7 @@ pub(crate) fn cleanup_post_unbond_mixnode_storage(
|
||||
// save minimal information about this mixnode
|
||||
storage::unbonded_mixnodes().save(
|
||||
storage,
|
||||
node_id,
|
||||
mix_id,
|
||||
&UnbondedMixnode {
|
||||
identity_key: identity,
|
||||
owner,
|
||||
@@ -161,7 +161,7 @@ mod tests {
|
||||
const OWNER_UNBONDED_LEFTOVER: &str = "mix-owner-unbonded-leftover";
|
||||
|
||||
// create a mixnode that is bonded, unbonded, in the process of unbonding and unbonded with leftover mix rewarding details
|
||||
fn setup_mix_combinations(test: &mut TestSetup) -> Vec<NodeId> {
|
||||
fn setup_mix_combinations(test: &mut TestSetup) -> Vec<MixId> {
|
||||
let mix_id_exists = test.add_dummy_mixnode(OWNER_EXISTS, None);
|
||||
let mix_id_unbonding = test.add_dummy_mixnode(OWNER_UNBONDING, None);
|
||||
let mix_id_unbonded = test.add_dummy_mixnode(OWNER_UNBONDED, None);
|
||||
@@ -206,11 +206,11 @@ mod tests {
|
||||
|
||||
// if this is a normally bonded mixnode, all should be fine
|
||||
let res = must_get_mixnode_bond_by_owner(test.deps().storage, &owner_exists).unwrap();
|
||||
assert_eq!(res.id, mix_id_exists);
|
||||
assert_eq!(res.mix_id, mix_id_exists);
|
||||
|
||||
// if node is in the process of unbonding, we still should be capable of retrieving its details
|
||||
let res = must_get_mixnode_bond_by_owner(test.deps().storage, &owner_unbonding).unwrap();
|
||||
assert_eq!(res.id, mix_id_unbonding);
|
||||
assert_eq!(res.mix_id, mix_id_unbonding);
|
||||
|
||||
// but if node has unbonded, the information is purged and query fails
|
||||
let res = must_get_mixnode_bond_by_owner(test.deps().storage, &owner_unbonded);
|
||||
@@ -243,12 +243,12 @@ mod tests {
|
||||
let res = get_mixnode_details_by_id(test.deps().storage, mix_id_exists)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
assert_eq!(res.bond_information.id, mix_id_exists);
|
||||
assert_eq!(res.bond_information.mix_id, mix_id_exists);
|
||||
|
||||
let res = get_mixnode_details_by_id(test.deps().storage, mix_id_unbonding)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
assert_eq!(res.bond_information.id, mix_id_unbonding);
|
||||
assert_eq!(res.bond_information.mix_id, mix_id_unbonding);
|
||||
|
||||
let res = get_mixnode_details_by_id(test.deps().storage, mix_id_unbonded).unwrap();
|
||||
assert!(res.is_none());
|
||||
@@ -274,13 +274,13 @@ mod tests {
|
||||
let res = get_mixnode_details_by_owner(test.deps().storage, owner_exists)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
assert_eq!(res.bond_information.id, mix_id_exists);
|
||||
assert_eq!(res.bond_information.mix_id, mix_id_exists);
|
||||
|
||||
// if node is in the process of unbonding, we still should be capable of retrieving its details
|
||||
let res = get_mixnode_details_by_owner(test.deps().storage, owner_unbonding)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
assert_eq!(res.bond_information.id, mix_id_unbonding);
|
||||
assert_eq!(res.bond_information.mix_id, mix_id_unbonding);
|
||||
|
||||
// but if node has unbonded, the information is purged and query fails
|
||||
let res = get_mixnode_details_by_owner(test.deps().storage, owner_unbonded).unwrap();
|
||||
|
||||
@@ -16,13 +16,13 @@ use mixnet_contract_common::mixnode::{
|
||||
PagedUnbondedMixnodesResponse, StakeSaturationResponse, UnbondedMixnodeResponse,
|
||||
};
|
||||
use mixnet_contract_common::{
|
||||
IdentityKey, LayerDistribution, MixOwnershipResponse, MixnodeDetailsResponse, NodeId,
|
||||
IdentityKey, LayerDistribution, MixId, MixOwnershipResponse, MixnodeDetailsResponse,
|
||||
PagedMixnodeBondsResponse,
|
||||
};
|
||||
|
||||
pub fn query_mixnode_bonds_paged(
|
||||
deps: Deps<'_>,
|
||||
start_after: Option<NodeId>,
|
||||
start_after: Option<MixId>,
|
||||
limit: Option<u32>,
|
||||
) -> StdResult<PagedMixnodeBondsResponse> {
|
||||
let limit = limit
|
||||
@@ -37,7 +37,7 @@ pub fn query_mixnode_bonds_paged(
|
||||
.map(|res| res.map(|item| item.1))
|
||||
.collect::<StdResult<Vec<MixNodeBond>>>()?;
|
||||
|
||||
let start_next_after = nodes.last().map(|node| node.id);
|
||||
let start_next_after = nodes.last().map(|node| node.mix_id);
|
||||
|
||||
Ok(PagedMixnodeBondsResponse::new(
|
||||
nodes,
|
||||
@@ -48,14 +48,14 @@ pub fn query_mixnode_bonds_paged(
|
||||
|
||||
fn attach_rewarding_info(
|
||||
storage: &dyn Storage,
|
||||
read_bond: StdResult<(NodeId, MixNodeBond)>,
|
||||
read_bond: StdResult<(MixId, MixNodeBond)>,
|
||||
) -> StdResult<MixNodeDetails> {
|
||||
match read_bond {
|
||||
Ok((_, bond)) => {
|
||||
// if we managed to read the bond we MUST be able to also read rewarding information.
|
||||
// if we fail, this is a hard error and the query should definitely fail and we should investigate
|
||||
// the reasons for that.
|
||||
let mix_rewarding = rewards_storage::MIXNODE_REWARDING.load(storage, bond.id)?;
|
||||
let mix_rewarding = rewards_storage::MIXNODE_REWARDING.load(storage, bond.mix_id)?;
|
||||
Ok(MixNodeDetails::new(bond, mix_rewarding))
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
@@ -64,7 +64,7 @@ fn attach_rewarding_info(
|
||||
|
||||
pub fn query_mixnodes_details_paged(
|
||||
deps: Deps<'_>,
|
||||
start_after: Option<NodeId>,
|
||||
start_after: Option<MixId>,
|
||||
limit: Option<u32>,
|
||||
) -> StdResult<PagedMixnodesDetailsResponse> {
|
||||
let limit = limit
|
||||
@@ -90,7 +90,7 @@ pub fn query_mixnodes_details_paged(
|
||||
|
||||
pub fn query_unbonded_mixnodes_paged(
|
||||
deps: Deps<'_>,
|
||||
start_after: Option<NodeId>,
|
||||
start_after: Option<MixId>,
|
||||
limit: Option<u32>,
|
||||
) -> StdResult<PagedUnbondedMixnodesResponse> {
|
||||
let limit = limit
|
||||
@@ -116,7 +116,7 @@ pub fn query_unbonded_mixnodes_paged(
|
||||
pub fn query_unbonded_mixnodes_by_owner_paged(
|
||||
deps: Deps<'_>,
|
||||
owner: String,
|
||||
start_after: Option<NodeId>,
|
||||
start_after: Option<MixId>,
|
||||
limit: Option<u32>,
|
||||
) -> StdResult<PagedUnbondedMixnodesResponse> {
|
||||
let owner = deps.api.addr_validate(&owner)?;
|
||||
@@ -147,7 +147,7 @@ pub fn query_unbonded_mixnodes_by_owner_paged(
|
||||
pub fn query_unbonded_mixnodes_by_identity_paged(
|
||||
deps: Deps<'_>,
|
||||
identity_key: String,
|
||||
start_after: Option<NodeId>,
|
||||
start_after: Option<MixId>,
|
||||
limit: Option<u32>,
|
||||
) -> StdResult<PagedUnbondedMixnodesResponse> {
|
||||
let limit = limit
|
||||
@@ -183,7 +183,7 @@ pub fn query_owned_mixnode(deps: Deps<'_>, address: String) -> StdResult<MixOwne
|
||||
})
|
||||
}
|
||||
|
||||
pub fn query_mixnode_details(deps: Deps<'_>, mix_id: NodeId) -> StdResult<MixnodeDetailsResponse> {
|
||||
pub fn query_mixnode_details(deps: Deps<'_>, mix_id: MixId) -> StdResult<MixnodeDetailsResponse> {
|
||||
let mixnode_details = get_mixnode_details_by_id(deps.storage, mix_id)?;
|
||||
|
||||
Ok(MixnodeDetailsResponse {
|
||||
@@ -204,7 +204,7 @@ pub fn query_mixnode_details_by_identity(
|
||||
{
|
||||
// if bond exists, rewarding details MUST also exist
|
||||
let rewarding_details =
|
||||
rewards_storage::MIXNODE_REWARDING.load(deps.storage, bond_information.id)?;
|
||||
rewards_storage::MIXNODE_REWARDING.load(deps.storage, bond_information.mix_id)?;
|
||||
Ok(Some(MixNodeDetails::new(
|
||||
bond_information,
|
||||
rewarding_details,
|
||||
@@ -216,7 +216,7 @@ pub fn query_mixnode_details_by_identity(
|
||||
|
||||
pub fn query_mixnode_rewarding_details(
|
||||
deps: Deps<'_>,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> StdResult<MixnodeRewardingDetailsResponse> {
|
||||
let rewarding_details = rewards_storage::MIXNODE_REWARDING.may_load(deps.storage, mix_id)?;
|
||||
|
||||
@@ -226,10 +226,7 @@ pub fn query_mixnode_rewarding_details(
|
||||
})
|
||||
}
|
||||
|
||||
pub fn query_unbonded_mixnode(
|
||||
deps: Deps<'_>,
|
||||
mix_id: NodeId,
|
||||
) -> StdResult<UnbondedMixnodeResponse> {
|
||||
pub fn query_unbonded_mixnode(deps: Deps<'_>, mix_id: MixId) -> StdResult<UnbondedMixnodeResponse> {
|
||||
let unbonded_info = storage::unbonded_mixnodes().may_load(deps.storage, mix_id)?;
|
||||
|
||||
Ok(UnbondedMixnodeResponse {
|
||||
@@ -238,10 +235,7 @@ pub fn query_unbonded_mixnode(
|
||||
})
|
||||
}
|
||||
|
||||
pub fn query_stake_saturation(
|
||||
deps: Deps<'_>,
|
||||
mix_id: NodeId,
|
||||
) -> StdResult<StakeSaturationResponse> {
|
||||
pub fn query_stake_saturation(deps: Deps<'_>, mix_id: MixId) -> StdResult<StakeSaturationResponse> {
|
||||
let mix_rewarding = match rewards_storage::MIXNODE_REWARDING.may_load(deps.storage, mix_id)? {
|
||||
Some(mix_rewarding) => mix_rewarding,
|
||||
None => {
|
||||
@@ -566,7 +560,7 @@ pub(crate) mod tests {
|
||||
|
||||
#[test]
|
||||
fn pagination_works() {
|
||||
fn add_unbonded(storage: &mut dyn Storage, id: NodeId) {
|
||||
fn add_unbonded(storage: &mut dyn Storage, id: MixId) {
|
||||
storage::unbonded_mixnodes()
|
||||
.save(
|
||||
storage,
|
||||
@@ -632,7 +626,7 @@ pub(crate) mod tests {
|
||||
use cosmwasm_std::Addr;
|
||||
use mixnet_contract_common::mixnode::UnbondedMixnode;
|
||||
|
||||
fn add_unbonded_with_owner(storage: &mut dyn Storage, id: NodeId, owner: &str) {
|
||||
fn add_unbonded_with_owner(storage: &mut dyn Storage, id: MixId, owner: &str) {
|
||||
storage::unbonded_mixnodes()
|
||||
.save(
|
||||
storage,
|
||||
@@ -879,7 +873,7 @@ pub(crate) mod tests {
|
||||
use cosmwasm_std::Addr;
|
||||
use mixnet_contract_common::mixnode::UnbondedMixnode;
|
||||
|
||||
fn add_unbonded_with_identity(storage: &mut dyn Storage, id: NodeId, identity: &str) {
|
||||
fn add_unbonded_with_identity(storage: &mut dyn Storage, id: MixId, identity: &str) {
|
||||
storage::unbonded_mixnodes()
|
||||
.save(
|
||||
storage,
|
||||
@@ -1202,7 +1196,7 @@ pub(crate) mod tests {
|
||||
test_helpers::add_mixnode(&mut rng, deps.as_mut(), env, "foomp", good_mixnode_pledge());
|
||||
let res = query_mixnode_details(deps.as_ref(), mix_id).unwrap();
|
||||
let details = res.mixnode_details.unwrap();
|
||||
assert_eq!(mix_id, details.bond_information.id);
|
||||
assert_eq!(mix_id, details.bond_information.mix_id);
|
||||
assert_eq!(
|
||||
good_mixnode_pledge()[0],
|
||||
details.bond_information.original_pledge
|
||||
|
||||
@@ -12,16 +12,16 @@ use cw_storage_plus::{Index, IndexList, IndexedMap, Item, MultiIndex, UniqueInde
|
||||
use mixnet_contract_common::error::MixnetContractError;
|
||||
use mixnet_contract_common::mixnode::UnbondedMixnode;
|
||||
use mixnet_contract_common::SphinxKey;
|
||||
use mixnet_contract_common::{Addr, IdentityKey, Layer, LayerDistribution, MixNodeBond, NodeId};
|
||||
use mixnet_contract_common::{Addr, IdentityKey, Layer, LayerDistribution, MixId, MixNodeBond};
|
||||
|
||||
// keeps track of `node_id -> IdentityKey, Owner, unbonding_height` so we'd known a bit more about past mixnodes
|
||||
// if we ever decide it's too bloaty, we can deprecate it and start removing all data in
|
||||
// subsequent migrations
|
||||
|
||||
pub(crate) struct UnbondedMixnodeIndex<'a> {
|
||||
pub(crate) owner: MultiIndex<'a, Addr, UnbondedMixnode, NodeId>,
|
||||
pub(crate) owner: MultiIndex<'a, Addr, UnbondedMixnode, MixId>,
|
||||
|
||||
pub(crate) identity_key: MultiIndex<'a, IdentityKey, UnbondedMixnode, NodeId>,
|
||||
pub(crate) identity_key: MultiIndex<'a, IdentityKey, UnbondedMixnode, MixId>,
|
||||
}
|
||||
|
||||
impl<'a> IndexList<UnbondedMixnode> for UnbondedMixnodeIndex<'a> {
|
||||
@@ -32,7 +32,7 @@ impl<'a> IndexList<UnbondedMixnode> for UnbondedMixnodeIndex<'a> {
|
||||
}
|
||||
|
||||
pub(crate) fn unbonded_mixnodes<'a>(
|
||||
) -> IndexedMap<'a, NodeId, UnbondedMixnode, UnbondedMixnodeIndex<'a>> {
|
||||
) -> IndexedMap<'a, MixId, UnbondedMixnode, UnbondedMixnodeIndex<'a>> {
|
||||
let indexes = UnbondedMixnodeIndex {
|
||||
owner: MultiIndex::new(
|
||||
|d| d.owner.clone(),
|
||||
@@ -49,7 +49,7 @@ pub(crate) fn unbonded_mixnodes<'a>(
|
||||
}
|
||||
|
||||
pub(crate) const LAYERS: Item<'_, LayerDistribution> = Item::new(LAYER_DISTRIBUTION_KEY);
|
||||
pub const MIXNODE_ID_COUNTER: Item<NodeId> = Item::new(NODE_ID_COUNTER_KEY);
|
||||
pub const MIXNODE_ID_COUNTER: Item<MixId> = Item::new(NODE_ID_COUNTER_KEY);
|
||||
|
||||
pub(crate) struct MixnodeBondIndex<'a> {
|
||||
pub(crate) owner: UniqueIndex<'a, Addr, MixNodeBond>,
|
||||
@@ -70,7 +70,7 @@ impl<'a> IndexList<MixNodeBond> for MixnodeBondIndex<'a> {
|
||||
}
|
||||
|
||||
// mixnode_bonds() is the storage access function.
|
||||
pub(crate) fn mixnode_bonds<'a>() -> IndexedMap<'a, NodeId, MixNodeBond, MixnodeBondIndex<'a>> {
|
||||
pub(crate) fn mixnode_bonds<'a>() -> IndexedMap<'a, MixId, MixNodeBond, MixnodeBondIndex<'a>> {
|
||||
let indexes = MixnodeBondIndex {
|
||||
owner: UniqueIndex::new(|d| d.owner.clone(), MIXNODES_OWNER_IDX_NAMESPACE),
|
||||
identity_key: UniqueIndex::new(
|
||||
@@ -109,8 +109,8 @@ pub(crate) fn assign_layer(store: &mut dyn Storage) -> StdResult<Layer> {
|
||||
Ok(fewest)
|
||||
}
|
||||
|
||||
pub(crate) fn next_mixnode_id_counter(store: &mut dyn Storage) -> StdResult<NodeId> {
|
||||
let id: NodeId = MIXNODE_ID_COUNTER.may_load(store)?.unwrap_or_default() + 1;
|
||||
pub(crate) fn next_mixnode_id_counter(store: &mut dyn Storage) -> StdResult<MixId> {
|
||||
let id: MixId = MIXNODE_ID_COUNTER.may_load(store)?.unwrap_or_default() + 1;
|
||||
MIXNODE_ID_COUNTER.save(store, &id)?;
|
||||
Ok(id)
|
||||
}
|
||||
|
||||
@@ -155,14 +155,14 @@ pub(crate) fn _try_remove_mixnode(
|
||||
updated_bond.is_unbonding = true;
|
||||
storage::mixnode_bonds().replace(
|
||||
deps.storage,
|
||||
existing_bond.id,
|
||||
existing_bond.mix_id,
|
||||
Some(&updated_bond),
|
||||
Some(&existing_bond),
|
||||
)?;
|
||||
|
||||
// push the event to execute it at the end of the epoch
|
||||
let epoch_event = PendingEpochEventData::UnbondMixnode {
|
||||
mix_id: existing_bond.id,
|
||||
mix_id: existing_bond.mix_id,
|
||||
};
|
||||
interval_storage::push_new_epoch_event(deps.storage, &epoch_event)?;
|
||||
|
||||
@@ -171,7 +171,7 @@ pub(crate) fn _try_remove_mixnode(
|
||||
&existing_bond.owner,
|
||||
&existing_bond.proxy,
|
||||
existing_bond.identity(),
|
||||
existing_bond.id,
|
||||
existing_bond.mix_id,
|
||||
)),
|
||||
)
|
||||
}
|
||||
@@ -208,7 +208,7 @@ pub(crate) fn _try_update_mixnode_config(
|
||||
ensure_proxy_match(&proxy, &existing_bond.proxy)?;
|
||||
|
||||
let cfg_update_event =
|
||||
new_mixnode_config_update_event(existing_bond.id, &owner, &proxy, &new_config);
|
||||
new_mixnode_config_update_event(existing_bond.mix_id, &owner, &proxy, &new_config);
|
||||
|
||||
let mut updated_bond = existing_bond.clone();
|
||||
updated_bond.mix_node.host = new_config.host;
|
||||
@@ -219,7 +219,7 @@ pub(crate) fn _try_update_mixnode_config(
|
||||
|
||||
storage::mixnode_bonds().replace(
|
||||
deps.storage,
|
||||
existing_bond.id,
|
||||
existing_bond.mix_id,
|
||||
Some(&updated_bond),
|
||||
Some(&existing_bond),
|
||||
)?;
|
||||
@@ -259,12 +259,16 @@ pub(crate) fn _try_update_mixnode_cost_params(
|
||||
ensure_proxy_match(&proxy, &existing_bond.proxy)?;
|
||||
ensure_bonded(&existing_bond)?;
|
||||
|
||||
let cosmos_event =
|
||||
new_mixnode_pending_cost_params_update_event(existing_bond.id, &owner, &proxy, &new_costs);
|
||||
let cosmos_event = new_mixnode_pending_cost_params_update_event(
|
||||
existing_bond.mix_id,
|
||||
&owner,
|
||||
&proxy,
|
||||
&new_costs,
|
||||
);
|
||||
|
||||
// push the interval event
|
||||
let interval_event = PendingIntervalEventData::ChangeMixCostParams {
|
||||
mix_id: existing_bond.id,
|
||||
mix_id: existing_bond.mix_id,
|
||||
new_costs,
|
||||
};
|
||||
push_new_interval_event(deps.storage, &interval_event)?;
|
||||
@@ -387,7 +391,7 @@ pub mod tests {
|
||||
// make sure we got assigned the next id (note: we have already bonded a mixnode before in this test)
|
||||
let bond = must_get_mixnode_bond_by_owner(deps.as_ref().storage, &Addr::unchecked(sender2))
|
||||
.unwrap();
|
||||
assert_eq!(2, bond.id);
|
||||
assert_eq!(2, bond.mix_id);
|
||||
|
||||
// and make sure we're on layer 2 (because it was the next empty one)
|
||||
assert_eq!(Layer::Two, bond.layer);
|
||||
|
||||
@@ -13,7 +13,7 @@ use mixnet_contract_common::rewarding::helpers::truncate_reward;
|
||||
use mixnet_contract_common::rewarding::{
|
||||
EstimatedCurrentEpochRewardResponse, PendingRewardResponse,
|
||||
};
|
||||
use mixnet_contract_common::{Delegation, NodeId};
|
||||
use mixnet_contract_common::{Delegation, MixId};
|
||||
|
||||
pub(crate) fn query_rewarding_params(deps: Deps<'_>) -> StdResult<RewardingParams> {
|
||||
storage::REWARDING_PARAMS.load(deps.storage)
|
||||
@@ -44,7 +44,7 @@ pub fn query_pending_operator_reward(
|
||||
|
||||
pub fn query_pending_mixnode_operator_reward(
|
||||
deps: Deps,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> StdResult<PendingRewardResponse> {
|
||||
// in order to determine operator's reward we need to know its original pledge and thus
|
||||
// we have to load the entire thing
|
||||
@@ -55,7 +55,7 @@ pub fn query_pending_mixnode_operator_reward(
|
||||
pub fn query_pending_delegator_reward(
|
||||
deps: Deps,
|
||||
owner: String,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
proxy: Option<String>,
|
||||
) -> StdResult<PendingRewardResponse> {
|
||||
let owner_address = deps.api.addr_validate(&owner)?;
|
||||
@@ -103,7 +103,7 @@ fn zero_reward(
|
||||
|
||||
pub(crate) fn query_estimated_current_epoch_operator_reward(
|
||||
deps: Deps<'_>,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
estimated_performance: Performance,
|
||||
) -> StdResult<EstimatedCurrentEpochRewardResponse> {
|
||||
let mix_details = match mixnodes::helpers::get_mixnode_details_by_id(deps.storage, mix_id)? {
|
||||
@@ -157,7 +157,7 @@ pub(crate) fn query_estimated_current_epoch_operator_reward(
|
||||
pub(crate) fn query_estimated_current_epoch_delegator_reward(
|
||||
deps: Deps<'_>,
|
||||
owner: String,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
proxy: Option<String>,
|
||||
estimated_performance: Performance,
|
||||
) -> StdResult<EstimatedCurrentEpochRewardResponse> {
|
||||
@@ -620,7 +620,7 @@ mod tests {
|
||||
|
||||
fn expected_current_operator(
|
||||
test: &TestSetup,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
initial_stake: Uint128,
|
||||
) -> EstimatedCurrentEpochRewardResponse {
|
||||
let mix_rewarding = test.mix_rewarding(mix_id);
|
||||
@@ -779,7 +779,7 @@ mod tests {
|
||||
|
||||
fn expected_current_delegator(
|
||||
test: &TestSetup,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
owner: &str,
|
||||
) -> EstimatedCurrentEpochRewardResponse {
|
||||
let mix_rewarding = test.mix_rewarding(mix_id);
|
||||
|
||||
@@ -10,14 +10,14 @@ use cw_storage_plus::{Item, Map};
|
||||
use mixnet_contract_common::error::MixnetContractError;
|
||||
use mixnet_contract_common::mixnode::MixNodeRewarding;
|
||||
use mixnet_contract_common::reward_params::RewardingParams;
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
|
||||
// current parameters used for rewarding purposes
|
||||
pub(crate) const REWARDING_PARAMS: Item<'_, RewardingParams> = Item::new(REWARDING_PARAMS_KEY);
|
||||
pub(crate) const PENDING_REWARD_POOL_CHANGE: Item<'_, RewardPoolChange> =
|
||||
Item::new(PENDING_REWARD_POOL_KEY);
|
||||
|
||||
pub const MIXNODE_REWARDING: Map<NodeId, MixNodeRewarding> =
|
||||
pub const MIXNODE_REWARDING: Map<MixId, MixNodeRewarding> =
|
||||
Map::new(MIXNODES_REWARDING_PK_NAMESPACE);
|
||||
|
||||
pub fn reward_accounting(
|
||||
|
||||
@@ -26,14 +26,14 @@ use mixnet_contract_common::pending_events::{PendingEpochEventData, PendingInter
|
||||
use mixnet_contract_common::reward_params::{
|
||||
IntervalRewardingParamsUpdate, NodeRewardParams, Performance,
|
||||
};
|
||||
use mixnet_contract_common::{Delegation, NodeId};
|
||||
use mixnet_contract_common::{Delegation, MixId};
|
||||
use vesting_contract_common::messages::ExecuteMsg as VestingContractExecuteMsg;
|
||||
|
||||
pub(crate) fn try_reward_mixnode(
|
||||
deps: DepsMut<'_>,
|
||||
env: Env,
|
||||
info: MessageInfo,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
node_performance: Performance,
|
||||
) -> Result<Response, MixnetContractError> {
|
||||
ensure_is_authorized(info.sender, deps.storage)?;
|
||||
@@ -184,7 +184,7 @@ pub(crate) fn _try_withdraw_operator_reward(
|
||||
pub(crate) fn try_withdraw_delegator_reward(
|
||||
deps: DepsMut<'_>,
|
||||
info: MessageInfo,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<Response, MixnetContractError> {
|
||||
_try_withdraw_delegator_reward(deps, mix_id, info.sender, None)
|
||||
}
|
||||
@@ -192,7 +192,7 @@ pub(crate) fn try_withdraw_delegator_reward(
|
||||
pub(crate) fn try_withdraw_delegator_reward_on_behalf(
|
||||
deps: DepsMut<'_>,
|
||||
info: MessageInfo,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
owner: String,
|
||||
) -> Result<Response, MixnetContractError> {
|
||||
let proxy = info.sender;
|
||||
@@ -202,7 +202,7 @@ pub(crate) fn try_withdraw_delegator_reward_on_behalf(
|
||||
|
||||
pub(crate) fn _try_withdraw_delegator_reward(
|
||||
deps: DepsMut<'_>,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
owner: Addr,
|
||||
proxy: Option<Addr>,
|
||||
) -> Result<Response, MixnetContractError> {
|
||||
|
||||
@@ -152,7 +152,9 @@ pub(crate) fn ensure_proxy_match(
|
||||
|
||||
pub(crate) fn ensure_bonded(bond: &MixNodeBond) -> Result<(), MixnetContractError> {
|
||||
if bond.is_unbonding {
|
||||
return Err(MixnetContractError::MixnodeIsUnbonding { mix_id: bond.id });
|
||||
return Err(MixnetContractError::MixnodeIsUnbonding {
|
||||
mix_id: bond.mix_id,
|
||||
});
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ pub mod test_helpers {
|
||||
use mixnet_contract_common::rewarding::simulator::Simulator;
|
||||
use mixnet_contract_common::rewarding::RewardDistribution;
|
||||
use mixnet_contract_common::{
|
||||
Delegation, Gateway, InitialRewardingParams, InstantiateMsg, Interval, MixNode, NodeId,
|
||||
Delegation, Gateway, InitialRewardingParams, InstantiateMsg, Interval, MixId, MixNode,
|
||||
Percent, RewardedSetNodeStatus,
|
||||
};
|
||||
use rand_chacha::rand_core::{CryptoRng, RngCore, SeedableRng};
|
||||
@@ -141,14 +141,14 @@ pub mod test_helpers {
|
||||
interval_storage::current_interval(self.deps().storage).unwrap()
|
||||
}
|
||||
|
||||
pub fn rewarded_set(&self) -> Vec<(NodeId, RewardedSetNodeStatus)> {
|
||||
pub fn rewarded_set(&self) -> Vec<(MixId, RewardedSetNodeStatus)> {
|
||||
interval_storage::REWARDED_SET
|
||||
.range(self.deps().storage, None, None, Order::Ascending)
|
||||
.map(|res| res.unwrap())
|
||||
.collect::<Vec<_>>()
|
||||
}
|
||||
|
||||
pub fn add_dummy_mixnode(&mut self, owner: &str, stake: Option<Uint128>) -> NodeId {
|
||||
pub fn add_dummy_mixnode(&mut self, owner: &str, stake: Option<Uint128>) -> MixId {
|
||||
let stake = match stake {
|
||||
Some(amount) => {
|
||||
let denom = rewarding_denom(self.deps().storage).unwrap();
|
||||
@@ -166,7 +166,7 @@ pub mod test_helpers {
|
||||
owner: &str,
|
||||
stake: Option<Uint128>,
|
||||
proxy: Addr,
|
||||
) -> NodeId {
|
||||
) -> MixId {
|
||||
let stake = match stake {
|
||||
Some(amount) => {
|
||||
let denom = rewarding_denom(self.deps().storage).unwrap();
|
||||
@@ -210,7 +210,7 @@ pub mod test_helpers {
|
||||
current_id_counter + 1
|
||||
}
|
||||
|
||||
pub fn start_unbonding_mixnode(&mut self, mix_id: NodeId) {
|
||||
pub fn start_unbonding_mixnode(&mut self, mix_id: MixId) {
|
||||
let bond_details = mixnodes_storage::mixnode_bonds()
|
||||
.load(self.deps().storage, mix_id)
|
||||
.unwrap();
|
||||
@@ -219,7 +219,7 @@ pub mod test_helpers {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub fn immediately_unbond_mixnode(&mut self, mix_id: NodeId) {
|
||||
pub fn immediately_unbond_mixnode(&mut self, mix_id: MixId) {
|
||||
let env = self.env();
|
||||
pending_events::unbond_mixnode(self.deps_mut(), &env, mix_id).unwrap();
|
||||
}
|
||||
@@ -228,7 +228,7 @@ pub mod test_helpers {
|
||||
&mut self,
|
||||
delegator: &str,
|
||||
amount: impl Into<Uint128>,
|
||||
target: NodeId,
|
||||
target: MixId,
|
||||
) {
|
||||
let denom = rewarding_denom(self.deps().storage).unwrap();
|
||||
let amount = Coin {
|
||||
@@ -251,7 +251,7 @@ pub mod test_helpers {
|
||||
&mut self,
|
||||
delegator: &str,
|
||||
amount: impl Into<Uint128>,
|
||||
target: NodeId,
|
||||
target: MixId,
|
||||
proxy: Addr,
|
||||
) {
|
||||
let denom = rewarding_denom(self.deps().storage).unwrap();
|
||||
@@ -275,7 +275,7 @@ pub mod test_helpers {
|
||||
&mut self,
|
||||
delegator: &str,
|
||||
amount: impl Into<Uint128>,
|
||||
target: NodeId,
|
||||
target: MixId,
|
||||
) {
|
||||
let denom = rewarding_denom(self.deps().storage).unwrap();
|
||||
let amount = Coin {
|
||||
@@ -285,7 +285,7 @@ pub mod test_helpers {
|
||||
delegate(self.deps_mut(), delegator, vec![amount], target)
|
||||
}
|
||||
|
||||
pub fn remove_immediate_delegation(&mut self, delegator: &str, target: NodeId) {
|
||||
pub fn remove_immediate_delegation(&mut self, delegator: &str, target: MixId) {
|
||||
pending_events::undelegate(self.deps_mut(), Addr::unchecked(delegator), target, None)
|
||||
.unwrap();
|
||||
}
|
||||
@@ -326,7 +326,7 @@ pub mod test_helpers {
|
||||
interval_storage::save_interval(self.deps_mut().storage, &advanced).unwrap()
|
||||
}
|
||||
|
||||
pub fn update_rewarded_set(&mut self, nodes: Vec<NodeId>) {
|
||||
pub fn update_rewarded_set(&mut self, nodes: Vec<MixId>) {
|
||||
let active_set_size = rewards_storage::REWARDING_PARAMS
|
||||
.load(self.deps().storage)
|
||||
.unwrap()
|
||||
@@ -335,7 +335,7 @@ pub mod test_helpers {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub fn instantiate_simulator(&self, node: NodeId) -> Simulator {
|
||||
pub fn instantiate_simulator(&self, node: MixId) -> Simulator {
|
||||
simulator_from_state(self.deps(), node)
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ pub mod test_helpers {
|
||||
|
||||
pub fn reward_with_distribution(
|
||||
&mut self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
performance: Performance,
|
||||
) -> RewardDistribution {
|
||||
let env = self.env();
|
||||
@@ -391,7 +391,7 @@ pub mod test_helpers {
|
||||
|
||||
pub fn read_delegation(
|
||||
&mut self,
|
||||
mix: NodeId,
|
||||
mix: MixId,
|
||||
owner: &str,
|
||||
proxy: Option<&str>,
|
||||
) -> Delegation {
|
||||
@@ -404,18 +404,18 @@ pub mod test_helpers {
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn mix_rewarding(&self, node: NodeId) -> MixNodeRewarding {
|
||||
pub fn mix_rewarding(&self, node: MixId) -> MixNodeRewarding {
|
||||
rewards_storage::MIXNODE_REWARDING
|
||||
.load(self.deps().storage, node)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn delegation(&self, mix: NodeId, owner: &str, proxy: &Option<Addr>) -> Delegation {
|
||||
pub fn delegation(&self, mix: MixId, owner: &str, proxy: &Option<Addr>) -> Delegation {
|
||||
read_delegation(self.deps().storage, mix, &Addr::unchecked(owner), proxy).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn simulator_from_state(deps: Deps<'_>, node: NodeId) -> Simulator {
|
||||
pub fn simulator_from_state(deps: Deps<'_>, node: MixId) -> Simulator {
|
||||
let mix_rewarding = rewards_storage::MIXNODE_REWARDING
|
||||
.load(deps.storage, node)
|
||||
.unwrap();
|
||||
@@ -539,7 +539,7 @@ pub mod test_helpers {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn add_dummy_delegations(mut deps: DepsMut<'_>, env: Env, mix_id: NodeId, n: usize) {
|
||||
pub fn add_dummy_delegations(mut deps: DepsMut<'_>, env: Env, mix_id: MixId, n: usize) {
|
||||
for i in 0..n {
|
||||
pending_events::delegate(
|
||||
deps.branch(),
|
||||
@@ -630,7 +630,7 @@ pub mod test_helpers {
|
||||
deps: DepsMut<'_>,
|
||||
identity_key: Option<&str>,
|
||||
owner: &str,
|
||||
) -> NodeId {
|
||||
) -> MixId {
|
||||
let id = loop {
|
||||
let candidate = rng.next_u32();
|
||||
if !mixnodes_storage::unbonded_mixnodes().has(deps.storage, candidate) {
|
||||
@@ -668,7 +668,7 @@ pub mod test_helpers {
|
||||
env: Env,
|
||||
sender: &str,
|
||||
stake: Vec<Coin>,
|
||||
) -> NodeId {
|
||||
) -> MixId {
|
||||
let keypair = crypto::asymmetric::identity::KeyPair::new(&mut rng);
|
||||
let owner_signature = keypair
|
||||
.private_key()
|
||||
@@ -763,14 +763,14 @@ pub mod test_helpers {
|
||||
deps
|
||||
}
|
||||
|
||||
pub fn delegate(deps: DepsMut<'_>, sender: &str, stake: Vec<Coin>, mix_id: NodeId) {
|
||||
pub fn delegate(deps: DepsMut<'_>, sender: &str, stake: Vec<Coin>, mix_id: MixId) {
|
||||
let info = mock_info(sender, &stake);
|
||||
try_delegate_to_mixnode(deps, info, mix_id).unwrap();
|
||||
}
|
||||
|
||||
pub(crate) fn read_delegation(
|
||||
storage: &dyn Storage,
|
||||
mix: NodeId,
|
||||
mix: MixId,
|
||||
owner: &Addr,
|
||||
proxy: &Option<Addr>,
|
||||
) -> Option<Delegation> {
|
||||
|
||||
@@ -14,7 +14,7 @@ use cosmwasm_std::{
|
||||
};
|
||||
use cw_storage_plus::Bound;
|
||||
use mixnet_contract_common::mixnode::{MixNodeConfigUpdate, MixNodeCostParams};
|
||||
use mixnet_contract_common::{Gateway, MixNode, NodeId};
|
||||
use mixnet_contract_common::{Gateway, MixId, MixNode};
|
||||
use vesting_contract_common::events::{
|
||||
new_ownership_transfer_event, new_periodic_vesting_account_event,
|
||||
new_staking_address_update_event, new_track_gateway_unbond_event,
|
||||
@@ -363,7 +363,7 @@ fn try_track_reward(
|
||||
/// Track undelegation, invoked by the mixnet contract after sucessful undelegation, message contains coins returned with any accrued rewards.
|
||||
fn try_track_undelegation(
|
||||
address: &str,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
amount: Coin,
|
||||
info: MessageInfo,
|
||||
deps: DepsMut<'_>,
|
||||
@@ -379,7 +379,7 @@ fn try_track_undelegation(
|
||||
|
||||
/// Delegate to mixnode, sends [mixnet_contract_common::ExecuteMsg::DelegateToMixnodeOnBehalf] to [crate::storage::MIXNET_CONTRACT_ADDRESS]..
|
||||
fn try_delegate_to_mixnode(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
amount: Coin,
|
||||
info: MessageInfo,
|
||||
env: Env,
|
||||
@@ -405,7 +405,7 @@ fn try_claim_operator_reward(
|
||||
fn try_claim_delegator_reward(
|
||||
deps: DepsMut<'_>,
|
||||
info: MessageInfo,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<Response, ContractError> {
|
||||
let account = account_from_address(info.sender.as_str(), deps.storage, deps.api)?;
|
||||
|
||||
@@ -414,7 +414,7 @@ fn try_claim_delegator_reward(
|
||||
|
||||
/// Undelegates from a mixnode, sends [mixnet_contract_common::ExecuteMsg::UndelegateFromMixnodeOnBehalf] to [crate::storage::MIXNET_CONTRACT_ADDRESS].
|
||||
fn try_undelegate_from_mixnode(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
info: MessageInfo,
|
||||
deps: DepsMut<'_>,
|
||||
) -> Result<Response, ContractError> {
|
||||
@@ -695,7 +695,7 @@ pub fn try_get_delegated_vesting(
|
||||
pub fn try_get_delegation_times(
|
||||
deps: Deps<'_>,
|
||||
vesting_account_address: &str,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<DelegationTimesResponse, ContractError> {
|
||||
let owner = deps.api.addr_validate(vesting_account_address)?;
|
||||
let account = account_from_address(vesting_account_address, deps.storage, deps.api)?;
|
||||
@@ -715,7 +715,7 @@ pub fn try_get_delegation_times(
|
||||
|
||||
pub fn try_get_all_delegations(
|
||||
deps: Deps<'_>,
|
||||
start_after: Option<(u32, NodeId, BlockTimestampSecs)>,
|
||||
start_after: Option<(u32, MixId, BlockTimestampSecs)>,
|
||||
limit: Option<u32>,
|
||||
) -> Result<AllDelegationsResponse, ContractError> {
|
||||
let limit = limit.unwrap_or(100).min(200) as usize;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use cosmwasm_std::{Addr, StdError, Uint128};
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug, PartialEq)]
|
||||
@@ -31,7 +31,7 @@ pub enum ContractError {
|
||||
#[error("VESTING ({}): Received multiple denoms, expected 1", line!())]
|
||||
MultipleDenoms,
|
||||
#[error("VESTING ({}): No delegations found for account {0}, mix_identity {1}", line!())]
|
||||
NoSuchDelegation(Addr, NodeId),
|
||||
NoSuchDelegation(Addr, MixId),
|
||||
#[error("VESTING ({}): Only mixnet contract can perform this operation, got {0}", line!())]
|
||||
NotMixnetContract(Addr),
|
||||
#[error("VESTING ({}): Calculation underflowed", line!())]
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::vesting::Account;
|
||||
use crate::{contract::INITIAL_LOCKED_PLEDGE_CAP, errors::ContractError};
|
||||
use cosmwasm_std::{Addr, Api, Storage, Uint128};
|
||||
use cw_storage_plus::{Item, Map};
|
||||
use mixnet_contract_common::{IdentityKey, NodeId};
|
||||
use mixnet_contract_common::{IdentityKey, MixId};
|
||||
use vesting_contract_common::PledgeData;
|
||||
|
||||
pub(crate) type BlockTimestampSecs = u64;
|
||||
@@ -16,7 +16,7 @@ const BOND_PLEDGES: Map<'_, u32, PledgeData> = Map::new("bnd");
|
||||
const GATEWAY_PLEDGES: Map<'_, u32, PledgeData> = Map::new("gtw");
|
||||
pub const _OLD_DELEGATIONS: Map<'_, (u32, IdentityKey, BlockTimestampSecs), Uint128> =
|
||||
Map::new("dlg");
|
||||
pub const DELEGATIONS: Map<'_, (u32, NodeId, BlockTimestampSecs), Uint128> = Map::new("dlg_v2");
|
||||
pub const DELEGATIONS: Map<'_, (u32, MixId, BlockTimestampSecs), Uint128> = Map::new("dlg_v2");
|
||||
pub const ADMIN: Item<'_, String> = Item::new("adm");
|
||||
pub const MIXNET_CONTRACT_ADDRESS: Item<'_, String> = Item::new("mix");
|
||||
pub const MIX_DENOM: Item<'_, String> = Item::new("den");
|
||||
@@ -37,7 +37,7 @@ pub fn update_locked_pledge_cap(
|
||||
}
|
||||
|
||||
pub fn save_delegation(
|
||||
key: (u32, NodeId, BlockTimestampSecs),
|
||||
key: (u32, MixId, BlockTimestampSecs),
|
||||
amount: Uint128,
|
||||
storage: &mut dyn Storage,
|
||||
) -> Result<(), ContractError> {
|
||||
@@ -46,7 +46,7 @@ pub fn save_delegation(
|
||||
}
|
||||
|
||||
pub fn remove_delegation(
|
||||
key: (u32, NodeId, BlockTimestampSecs),
|
||||
key: (u32, MixId, BlockTimestampSecs),
|
||||
storage: &mut dyn Storage,
|
||||
) -> Result<(), ContractError> {
|
||||
DELEGATIONS.remove(storage, key);
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
use crate::errors::ContractError;
|
||||
use cosmwasm_std::{Coin, Env, Response, Storage, Uint128};
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
|
||||
pub trait DelegatingAccount {
|
||||
fn try_claim_delegator_reward(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
storage: &dyn Storage,
|
||||
) -> Result<Response, ContractError>;
|
||||
|
||||
fn try_delegate_to_mixnode(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
amount: Coin,
|
||||
env: &Env,
|
||||
storage: &mut dyn Storage,
|
||||
@@ -19,7 +19,7 @@ pub trait DelegatingAccount {
|
||||
|
||||
fn try_undelegate_from_mixnode(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
storage: &dyn Storage,
|
||||
) -> Result<Response, ContractError>;
|
||||
|
||||
@@ -30,7 +30,7 @@ pub trait DelegatingAccount {
|
||||
fn track_delegation(
|
||||
&self,
|
||||
block_height: u64,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
// Save some gas by passing it in
|
||||
current_balance: Uint128,
|
||||
delegation: Coin,
|
||||
@@ -40,7 +40,7 @@ pub trait DelegatingAccount {
|
||||
// vesting account performs an undelegation.
|
||||
fn track_undelegation(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
amount: Coin,
|
||||
storage: &mut dyn Storage,
|
||||
) -> Result<(), ContractError>;
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::traits::DelegatingAccount;
|
||||
use crate::traits::VestingAccount;
|
||||
use cosmwasm_std::{wasm_execute, Coin, Env, Response, Storage, Uint128};
|
||||
use mixnet_contract_common::ExecuteMsg as MixnetExecuteMsg;
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
use vesting_contract_common::events::{
|
||||
new_vesting_delegation_event, new_vesting_undelegation_event,
|
||||
};
|
||||
@@ -16,7 +16,7 @@ use super::Account;
|
||||
impl DelegatingAccount for Account {
|
||||
fn try_claim_delegator_reward(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
storage: &dyn Storage,
|
||||
) -> Result<Response, ContractError> {
|
||||
let msg = MixnetExecuteMsg::WithdrawDelegatorRewardOnBehalf {
|
||||
@@ -32,7 +32,7 @@ impl DelegatingAccount for Account {
|
||||
|
||||
fn try_delegate_to_mixnode(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
coin: Coin,
|
||||
env: &Env,
|
||||
storage: &mut dyn Storage,
|
||||
@@ -79,7 +79,7 @@ impl DelegatingAccount for Account {
|
||||
|
||||
fn try_undelegate_from_mixnode(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
storage: &dyn Storage,
|
||||
) -> Result<Response, ContractError> {
|
||||
if !self.any_delegation_for_mix(mix_id, storage) {
|
||||
@@ -104,7 +104,7 @@ impl DelegatingAccount for Account {
|
||||
fn track_delegation(
|
||||
&self,
|
||||
block_timestamp_secs: u64,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
current_balance: Uint128,
|
||||
delegation: Coin,
|
||||
storage: &mut dyn Storage,
|
||||
@@ -121,7 +121,7 @@ impl DelegatingAccount for Account {
|
||||
|
||||
fn track_undelegation(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
amount: Coin,
|
||||
storage: &mut dyn Storage,
|
||||
) -> Result<(), ContractError> {
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::storage::{
|
||||
};
|
||||
use cosmwasm_std::{Addr, Coin, Order, Storage, Timestamp, Uint128};
|
||||
use cw_storage_plus::Bound;
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use vesting_contract_common::{Period, PledgeData};
|
||||
@@ -198,7 +198,7 @@ impl Account {
|
||||
remove_gateway_pledge(self.storage_key(), storage)
|
||||
}
|
||||
|
||||
pub fn any_delegation_for_mix(&self, mix_id: NodeId, storage: &dyn Storage) -> bool {
|
||||
pub fn any_delegation_for_mix(&self, mix_id: MixId, storage: &dyn Storage) -> bool {
|
||||
DELEGATIONS
|
||||
.prefix((self.storage_key(), mix_id))
|
||||
.range(storage, None, None, Order::Ascending)
|
||||
@@ -208,7 +208,7 @@ impl Account {
|
||||
|
||||
pub fn remove_delegations_for_mix(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
storage: &mut dyn Storage,
|
||||
) -> Result<(), ContractError> {
|
||||
let limit = 50;
|
||||
@@ -245,7 +245,7 @@ impl Account {
|
||||
|
||||
pub fn total_delegations_for_mix(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
storage: &dyn Storage,
|
||||
) -> Result<Uint128, ContractError> {
|
||||
Ok(DELEGATIONS
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
use super::models::SummedDelegations;
|
||||
use crate::client::ThreadsafeValidatorClient;
|
||||
use itertools::Itertools;
|
||||
use mixnet_contract_common::{Delegation, NodeId};
|
||||
use mixnet_contract_common::{Delegation, MixId};
|
||||
|
||||
pub(crate) async fn get_single_mixnode_delegations(
|
||||
client: &ThreadsafeValidatorClient,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Vec<Delegation> {
|
||||
match client
|
||||
.0
|
||||
@@ -25,7 +25,7 @@ pub(crate) async fn get_single_mixnode_delegations(
|
||||
|
||||
pub(crate) async fn get_single_mixnode_delegations_summed(
|
||||
client: &ThreadsafeValidatorClient,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Vec<SummedDelegations> {
|
||||
let delegations_by_owner = get_single_mixnode_delegations(client, mix_id)
|
||||
.await
|
||||
|
||||
@@ -5,11 +5,11 @@ use crate::client::ThreadsafeValidatorClient;
|
||||
use crate::helpers::best_effort_small_dec_to_f64;
|
||||
use crate::mix_node::models::EconomicDynamicsStats;
|
||||
use mixnet_contract_common::rewarding::helpers::truncate_decimal;
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
|
||||
pub(crate) async fn retrieve_mixnode_econ_stats(
|
||||
client: &ThreadsafeValidatorClient,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Option<EconomicDynamicsStats> {
|
||||
let stake_saturation = client
|
||||
.0
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::mix_node::models::{
|
||||
EconomicDynamicsStats, NodeDescription, NodeStats, PrettyDetailedMixNodeBond, SummedDelegations,
|
||||
};
|
||||
use crate::state::ExplorerApiStateContext;
|
||||
use mixnet_contract_common::{Delegation, NodeId};
|
||||
use mixnet_contract_common::{Delegation, MixId};
|
||||
use reqwest::Error as ReqwestError;
|
||||
use rocket::response::status::NotFound;
|
||||
use rocket::serde::json::Json;
|
||||
@@ -46,7 +46,7 @@ async fn get_mix_node_stats(host: &str, port: u16) -> Result<NodeStats, ReqwestE
|
||||
#[openapi(tag = "mix_nodes")]
|
||||
#[get("/<mix_id>")]
|
||||
pub(crate) async fn get_by_id(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
state: &State<ExplorerApiStateContext>,
|
||||
) -> Result<Json<PrettyDetailedMixNodeBond>, NotFound<String>> {
|
||||
match state.inner.mixnodes.get_detailed_mixnode(mix_id).await {
|
||||
@@ -58,7 +58,7 @@ pub(crate) async fn get_by_id(
|
||||
#[openapi(tag = "mix_node")]
|
||||
#[get("/<mix_id>/delegations")]
|
||||
pub(crate) async fn get_delegations(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
state: &State<ExplorerApiStateContext>,
|
||||
) -> Json<Vec<Delegation>> {
|
||||
Json(get_single_mixnode_delegations(&state.inner.validator_client, mix_id).await)
|
||||
@@ -67,7 +67,7 @@ pub(crate) async fn get_delegations(
|
||||
#[openapi(tag = "mix_node")]
|
||||
#[get("/<mix_id>/delegations/summed")]
|
||||
pub(crate) async fn get_delegations_summed(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
state: &State<ExplorerApiStateContext>,
|
||||
) -> Json<Vec<SummedDelegations>> {
|
||||
Json(get_single_mixnode_delegations_summed(&state.inner.validator_client, mix_id).await)
|
||||
@@ -76,7 +76,7 @@ pub(crate) async fn get_delegations_summed(
|
||||
#[openapi(tag = "mix_node")]
|
||||
#[get("/<mix_id>/description")]
|
||||
pub(crate) async fn get_description(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
state: &State<ExplorerApiStateContext>,
|
||||
) -> Option<Json<NodeDescription>> {
|
||||
match state.inner.mixnode.clone().get_description(mix_id).await {
|
||||
@@ -124,7 +124,7 @@ pub(crate) async fn get_description(
|
||||
#[openapi(tag = "mix_node")]
|
||||
#[get("/<mix_id>/stats")]
|
||||
pub(crate) async fn get_stats(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
state: &State<ExplorerApiStateContext>,
|
||||
) -> Option<Json<NodeStats>> {
|
||||
match state.inner.mixnode.get_node_stats(mix_id).await {
|
||||
@@ -169,7 +169,7 @@ pub(crate) async fn get_stats(
|
||||
#[openapi(tag = "mix_node")]
|
||||
#[get("/<mix_id>/economic-dynamics-stats")]
|
||||
pub(crate) async fn get_economic_dynamics_stats(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
state: &State<ExplorerApiStateContext>,
|
||||
) -> Option<Json<EconomicDynamicsStats>> {
|
||||
match state.inner.mixnode.get_econ_stats(mix_id).await {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
use crate::cache::Cache;
|
||||
use crate::mix_nodes::location::Location;
|
||||
use mixnet_contract_common::Delegation;
|
||||
use mixnet_contract_common::{Addr, Coin, Layer, MixNode, NodeId};
|
||||
use mixnet_contract_common::{Addr, Coin, Layer, MixId, MixNode};
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use std::sync::Arc;
|
||||
@@ -40,7 +40,7 @@ pub(crate) struct PrettyDetailedMixNodeBond {
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, JsonSchema)]
|
||||
pub struct SummedDelegations {
|
||||
pub owner: Addr,
|
||||
pub mix_id: NodeId,
|
||||
pub mix_id: MixId,
|
||||
pub amount: Coin,
|
||||
}
|
||||
|
||||
@@ -66,9 +66,9 @@ impl SummedDelegations {
|
||||
}
|
||||
|
||||
pub(crate) struct MixNodeCache {
|
||||
pub(crate) descriptions: Cache<NodeId, NodeDescription>,
|
||||
pub(crate) node_stats: Cache<NodeId, NodeStats>,
|
||||
pub(crate) econ_stats: Cache<NodeId, EconomicDynamicsStats>,
|
||||
pub(crate) descriptions: Cache<MixId, NodeDescription>,
|
||||
pub(crate) node_stats: Cache<MixId, NodeStats>,
|
||||
pub(crate) econ_stats: Cache<MixId, EconomicDynamicsStats>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -87,19 +87,19 @@ impl ThreadsafeMixNodeCache {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn get_description(&self, mix_id: NodeId) -> Option<NodeDescription> {
|
||||
pub(crate) async fn get_description(&self, mix_id: MixId) -> Option<NodeDescription> {
|
||||
self.inner.read().await.descriptions.get(&mix_id)
|
||||
}
|
||||
|
||||
pub(crate) async fn get_node_stats(&self, mix_id: NodeId) -> Option<NodeStats> {
|
||||
pub(crate) async fn get_node_stats(&self, mix_id: MixId) -> Option<NodeStats> {
|
||||
self.inner.read().await.node_stats.get(&mix_id)
|
||||
}
|
||||
|
||||
pub(crate) async fn get_econ_stats(&self, mix_id: NodeId) -> Option<EconomicDynamicsStats> {
|
||||
pub(crate) async fn get_econ_stats(&self, mix_id: MixId) -> Option<EconomicDynamicsStats> {
|
||||
self.inner.read().await.econ_stats.get(&mix_id)
|
||||
}
|
||||
|
||||
pub(crate) async fn set_description(&self, mix_id: NodeId, description: NodeDescription) {
|
||||
pub(crate) async fn set_description(&self, mix_id: MixId, description: NodeDescription) {
|
||||
self.inner
|
||||
.write()
|
||||
.await
|
||||
@@ -107,11 +107,11 @@ impl ThreadsafeMixNodeCache {
|
||||
.set(mix_id, description);
|
||||
}
|
||||
|
||||
pub(crate) async fn set_node_stats(&self, mix_id: NodeId, node_stats: NodeStats) {
|
||||
pub(crate) async fn set_node_stats(&self, mix_id: MixId, node_stats: NodeStats) {
|
||||
self.inner.write().await.node_stats.set(mix_id, node_stats);
|
||||
}
|
||||
|
||||
pub(crate) async fn set_econ_stats(&self, mix_id: NodeId, econ_stats: EconomicDynamicsStats) {
|
||||
pub(crate) async fn set_econ_stats(&self, mix_id: MixId, econ_stats: EconomicDynamicsStats) {
|
||||
self.inner.write().await.econ_stats.set(mix_id, econ_stats);
|
||||
}
|
||||
}
|
||||
@@ -172,7 +172,7 @@ fn get_common_owner(delegations: &[Delegation]) -> Option<Addr> {
|
||||
Some(owner)
|
||||
}
|
||||
|
||||
fn get_common_mix_id(delegations: &[Delegation]) -> Option<NodeId> {
|
||||
fn get_common_mix_id(delegations: &[Delegation]) -> Option<MixId> {
|
||||
let mix_id = delegations.iter().next()?.mix_id;
|
||||
if delegations
|
||||
.iter()
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::geo_ip::location;
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
pub(crate) type LocationCache = HashMap<NodeId, LocationCacheItem>;
|
||||
pub(crate) type LocationCache = HashMap<MixId, LocationCacheItem>;
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::sync::Arc;
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
use mixnet_contract_common::rewarding::helpers::truncate_reward;
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
use serde::Serialize;
|
||||
use tokio::sync::{RwLock, RwLockReadGuard};
|
||||
|
||||
@@ -33,9 +33,9 @@ pub(crate) struct MixNodeSummary {
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) struct MixNodesResult {
|
||||
pub(crate) valid_until: SystemTime,
|
||||
pub(crate) all_mixnodes: HashMap<NodeId, MixNodeBondAnnotated>,
|
||||
active_mixnodes: HashSet<NodeId>,
|
||||
rewarded_mixnodes: HashSet<NodeId>,
|
||||
pub(crate) all_mixnodes: HashMap<MixId, MixNodeBondAnnotated>,
|
||||
active_mixnodes: HashSet<MixId>,
|
||||
rewarded_mixnodes: HashSet<MixId>,
|
||||
}
|
||||
|
||||
impl MixNodesResult {
|
||||
@@ -48,7 +48,7 @@ impl MixNodesResult {
|
||||
}
|
||||
}
|
||||
|
||||
fn determine_node_status(&self, mix_id: NodeId) -> MixnodeStatus {
|
||||
fn determine_node_status(&self, mix_id: MixId) -> MixnodeStatus {
|
||||
if self.active_mixnodes.contains(&mix_id) {
|
||||
MixnodeStatus::Active
|
||||
} else if self.rewarded_mixnodes.contains(&mix_id) {
|
||||
@@ -62,7 +62,7 @@ impl MixNodesResult {
|
||||
self.valid_until >= SystemTime::now()
|
||||
}
|
||||
|
||||
fn get_mixnode(&self, mix_id: NodeId) -> Option<MixNodeBondAnnotated> {
|
||||
fn get_mixnode(&self, mix_id: MixId) -> Option<MixNodeBondAnnotated> {
|
||||
if self.is_valid() {
|
||||
self.all_mixnodes.get(&mix_id).cloned()
|
||||
} else {
|
||||
@@ -70,7 +70,7 @@ impl MixNodesResult {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_mixnodes(&self) -> Option<HashMap<NodeId, MixNodeBondAnnotated>> {
|
||||
fn get_mixnodes(&self) -> Option<HashMap<MixId, MixNodeBondAnnotated>> {
|
||||
if self.is_valid() {
|
||||
Some(self.all_mixnodes.clone())
|
||||
} else {
|
||||
@@ -100,7 +100,7 @@ impl ThreadsafeMixNodesCache {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn is_location_valid(&self, mix_id: NodeId) -> bool {
|
||||
pub(crate) async fn is_location_valid(&self, mix_id: MixId) -> bool {
|
||||
self.locations
|
||||
.read()
|
||||
.await
|
||||
@@ -114,7 +114,7 @@ impl ThreadsafeMixNodesCache {
|
||||
self.locations.read().await.clone()
|
||||
}
|
||||
|
||||
pub(crate) async fn set_location(&self, mix_id: NodeId, location: Option<Location>) {
|
||||
pub(crate) async fn set_location(&self, mix_id: MixId, location: Option<Location>) {
|
||||
// cache the location for this mix node so that it can be used when the mix node list is refreshed
|
||||
self.locations
|
||||
.write()
|
||||
@@ -122,7 +122,7 @@ impl ThreadsafeMixNodesCache {
|
||||
.insert(mix_id, LocationCacheItem::new_from_location(location));
|
||||
}
|
||||
|
||||
pub(crate) async fn get_mixnode(&self, mix_id: NodeId) -> Option<MixNodeBondAnnotated> {
|
||||
pub(crate) async fn get_mixnode(&self, mix_id: MixId) -> Option<MixNodeBondAnnotated> {
|
||||
self.mixnodes.read().await.get_mixnode(mix_id)
|
||||
}
|
||||
|
||||
@@ -139,13 +139,13 @@ impl ThreadsafeMixNodesCache {
|
||||
None
|
||||
}
|
||||
|
||||
pub(crate) async fn get_mixnodes(&self) -> Option<HashMap<NodeId, MixNodeBondAnnotated>> {
|
||||
pub(crate) async fn get_mixnodes(&self) -> Option<HashMap<MixId, MixNodeBondAnnotated>> {
|
||||
self.mixnodes.read().await.get_mixnodes()
|
||||
}
|
||||
|
||||
fn create_detailed_mixnode(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
mixnodes_guard: &RwLockReadGuard<'_, MixNodesResult>,
|
||||
location: Option<&LocationCacheItem>,
|
||||
node: &MixNodeBondAnnotated,
|
||||
@@ -170,7 +170,7 @@ impl ThreadsafeMixNodesCache {
|
||||
|
||||
pub(crate) async fn get_detailed_mixnode(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Option<PrettyDetailedMixNodeBond> {
|
||||
let mixnodes_guard = self.mixnodes.read().await;
|
||||
let location_guard = self.locations.read().await;
|
||||
@@ -198,8 +198,8 @@ impl ThreadsafeMixNodesCache {
|
||||
pub(crate) async fn update_cache(
|
||||
&self,
|
||||
all_bonds: Vec<MixNodeBondAnnotated>,
|
||||
rewarded_nodes: HashSet<NodeId>,
|
||||
active_nodes: HashSet<NodeId>,
|
||||
rewarded_nodes: HashSet<MixId>,
|
||||
active_nodes: HashSet<MixId>,
|
||||
) {
|
||||
let mut guard = self.mixnodes.write().await;
|
||||
guard.all_mixnodes = all_bonds
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::path::Path;
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use log::info;
|
||||
use mixnet_contract_common::{IdentityKeyRef, NodeId};
|
||||
use mixnet_contract_common::{IdentityKeyRef, MixId};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::client::ThreadsafeValidatorClient;
|
||||
@@ -38,7 +38,7 @@ pub struct ExplorerApiState {
|
||||
}
|
||||
|
||||
impl ExplorerApiState {
|
||||
pub(crate) async fn get_mix_node(&self, mix_id: NodeId) -> Option<MixNodeBondAnnotated> {
|
||||
pub(crate) async fn get_mix_node(&self, mix_id: MixId) -> Option<MixNodeBondAnnotated> {
|
||||
self.mixnodes.get_mixnode(mix_id).await
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
use crate::error::BackendError;
|
||||
use crate::state::WalletState;
|
||||
use crate::{nymd_client, Gateway, MixNode};
|
||||
use mixnet_contract_common::{MixNodeConfigUpdate, NodeId};
|
||||
use mixnet_contract_common::{MixId, MixNodeConfigUpdate};
|
||||
use nym_types::currency::DecCoin;
|
||||
use nym_types::gateway::GatewayBond;
|
||||
use nym_types::mixnode::{MixNodeCostParams, MixNodeDetails};
|
||||
@@ -216,7 +216,7 @@ pub async fn mixnode_bond_details(
|
||||
log::info!(
|
||||
"<<< mix_id/identity_key = {:?}",
|
||||
details.as_ref().map(|r| (
|
||||
r.bond_information.id,
|
||||
r.bond_information.mix_id,
|
||||
&r.bond_information.mix_node.identity_key
|
||||
))
|
||||
);
|
||||
@@ -289,7 +289,7 @@ pub async fn get_pending_operator_rewards(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_number_of_mixnode_delegators(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
state: tauri::State<'_, WalletState>,
|
||||
) -> Result<usize, BackendError> {
|
||||
Ok(nymd_client!(state)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
use crate::error::BackendError;
|
||||
use crate::state::WalletState;
|
||||
use crate::vesting::delegate::vesting_undelegate_from_mixnode;
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
use nym_types::currency::DecCoin;
|
||||
use nym_types::delegation::{Delegation, DelegationWithEverything, DelegationsSummaryResponse};
|
||||
use nym_types::deprecated::{
|
||||
@@ -64,7 +64,7 @@ pub async fn get_pending_delegation_events(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn delegate_to_mixnode(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
amount: DecCoin,
|
||||
fee: Option<Fee>,
|
||||
state: tauri::State<'_, WalletState>,
|
||||
@@ -94,7 +94,7 @@ pub async fn delegate_to_mixnode(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn undelegate_from_mixnode(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
fee: Option<Fee>,
|
||||
state: tauri::State<'_, WalletState>,
|
||||
) -> Result<TransactionExecuteResult, BackendError> {
|
||||
@@ -120,7 +120,7 @@ pub async fn undelegate_from_mixnode(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn undelegate_all_from_mixnode(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
uses_vesting_contract_tokens: bool,
|
||||
fee_liquid: Option<Fee>,
|
||||
fee_vesting: Option<Fee>,
|
||||
@@ -291,7 +291,7 @@ pub async fn get_all_mix_delegations(
|
||||
}
|
||||
|
||||
fn filter_pending_events(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
pending_events: &[WrappedDelegationEvent],
|
||||
) -> Vec<DelegationEvent> {
|
||||
pending_events
|
||||
@@ -305,7 +305,7 @@ fn filter_pending_events(
|
||||
#[tauri::command]
|
||||
pub async fn get_pending_delegator_rewards(
|
||||
address: String,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
proxy: Option<String>,
|
||||
state: tauri::State<'_, WalletState>,
|
||||
) -> Result<DecCoin, BackendError> {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::error::BackendError;
|
||||
use crate::state::WalletState;
|
||||
use crate::vesting::rewards::vesting_claim_delegator_reward;
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
use nym_types::transaction::TransactionExecuteResult;
|
||||
use validator_client::nymd::traits::{MixnetQueryClient, MixnetSigningClient};
|
||||
use validator_client::nymd::Fee;
|
||||
@@ -29,7 +29,7 @@ pub async fn claim_operator_reward(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn claim_delegator_reward(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
fee: Option<Fee>,
|
||||
state: tauri::State<'_, WalletState>,
|
||||
) -> Result<TransactionExecuteResult, BackendError> {
|
||||
@@ -50,7 +50,7 @@ pub async fn claim_delegator_reward(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn claim_locked_and_unlocked_delegator_reward(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
fee: Option<Fee>,
|
||||
state: tauri::State<'_, WalletState>,
|
||||
) -> Result<Vec<TransactionExecuteResult>, BackendError> {
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::error::BackendError;
|
||||
use crate::operations::simulate::FeeDetails;
|
||||
use crate::WalletState;
|
||||
use mixnet_contract_common::MixNodeConfigUpdate;
|
||||
use mixnet_contract_common::{ExecuteMsg, Gateway, MixNode, NodeId};
|
||||
use mixnet_contract_common::{ExecuteMsg, Gateway, MixId, MixNode};
|
||||
use nym_types::currency::DecCoin;
|
||||
use nym_types::mixnode::MixNodeCostParams;
|
||||
|
||||
@@ -123,7 +123,7 @@ pub async fn simulate_update_mixnode_config(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn simulate_delegate_to_mixnode(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
amount: DecCoin,
|
||||
state: tauri::State<'_, WalletState>,
|
||||
) -> Result<FeeDetails, BackendError> {
|
||||
@@ -137,7 +137,7 @@ pub async fn simulate_delegate_to_mixnode(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn simulate_undelegate_from_mixnode(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
state: tauri::State<'_, WalletState>,
|
||||
) -> Result<FeeDetails, BackendError> {
|
||||
simulate_mixnet_operation(ExecuteMsg::UndelegateFromMixnode { mix_id }, None, &state).await
|
||||
@@ -152,7 +152,7 @@ pub async fn simulate_claim_operator_reward(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn simulate_claim_delegator_reward(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
state: tauri::State<'_, WalletState>,
|
||||
) -> Result<FeeDetails, BackendError> {
|
||||
simulate_mixnet_operation(ExecuteMsg::WithdrawDelegatorReward { mix_id }, None, &state).await
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::error::BackendError;
|
||||
use crate::operations::simulate::FeeDetails;
|
||||
use crate::WalletState;
|
||||
use mixnet_contract_common::MixNodeConfigUpdate;
|
||||
use mixnet_contract_common::{Gateway, MixNode, NodeId};
|
||||
use mixnet_contract_common::{Gateway, MixId, MixNode};
|
||||
use nym_types::currency::DecCoin;
|
||||
use nym_types::mixnode::MixNodeCostParams;
|
||||
use vesting_contract_common::ExecuteMsg;
|
||||
@@ -130,7 +130,7 @@ pub async fn simulate_vesting_update_mixnode_config(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn simulate_vesting_delegate_to_mixnode(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
amount: DecCoin,
|
||||
state: tauri::State<'_, WalletState>,
|
||||
) -> Result<FeeDetails, BackendError> {
|
||||
@@ -147,7 +147,7 @@ pub async fn simulate_vesting_delegate_to_mixnode(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn simulate_vesting_undelegate_from_mixnode(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
state: tauri::State<'_, WalletState>,
|
||||
) -> Result<FeeDetails, BackendError> {
|
||||
simulate_vesting_operation(ExecuteMsg::UndelegateFromMixnode { mix_id }, None, &state).await
|
||||
@@ -172,7 +172,7 @@ pub async fn simulate_vesting_claim_operator_reward(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn simulate_vesting_claim_delegator_reward(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
state: tauri::State<'_, WalletState>,
|
||||
) -> Result<FeeDetails, BackendError> {
|
||||
simulate_vesting_operation(ExecuteMsg::ClaimDelegatorReward { mix_id }, None, &state).await
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
use crate::api_client;
|
||||
use crate::error::BackendError;
|
||||
use crate::state::WalletState;
|
||||
use mixnet_contract_common::{IdentityKeyRef, NodeId};
|
||||
use mixnet_contract_common::{IdentityKeyRef, MixId};
|
||||
use validator_client::models::{
|
||||
GatewayCoreStatusResponse, InclusionProbabilityResponse, MixnodeCoreStatusResponse,
|
||||
MixnodeStatusResponse, RewardEstimationResponse, StakeSaturationResponse,
|
||||
@@ -12,7 +12,7 @@ use validator_client::models::{
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn mixnode_core_node_status(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
since: Option<i64>,
|
||||
state: tauri::State<'_, WalletState>,
|
||||
) -> Result<MixnodeCoreStatusResponse, BackendError> {
|
||||
@@ -34,7 +34,7 @@ pub async fn gateway_core_node_status(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn mixnode_status(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
state: tauri::State<'_, WalletState>,
|
||||
) -> Result<MixnodeStatusResponse, BackendError> {
|
||||
Ok(api_client!(state).get_mixnode_status(mix_id).await?)
|
||||
@@ -42,7 +42,7 @@ pub async fn mixnode_status(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn mixnode_reward_estimation(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
state: tauri::State<'_, WalletState>,
|
||||
) -> Result<RewardEstimationResponse, BackendError> {
|
||||
Ok(api_client!(state)
|
||||
@@ -52,7 +52,7 @@ pub async fn mixnode_reward_estimation(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn mixnode_stake_saturation(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
state: tauri::State<'_, WalletState>,
|
||||
) -> Result<StakeSaturationResponse, BackendError> {
|
||||
Ok(api_client!(state)
|
||||
@@ -62,7 +62,7 @@ pub async fn mixnode_stake_saturation(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn mixnode_inclusion_probability(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
state: tauri::State<'_, WalletState>,
|
||||
) -> Result<InclusionProbabilityResponse, BackendError> {
|
||||
Ok(api_client!(state)
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
|
||||
use crate::error::BackendError;
|
||||
use crate::state::WalletState;
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
use nym_types::currency::DecCoin;
|
||||
use nym_types::transaction::TransactionExecuteResult;
|
||||
use validator_client::nymd::{Fee, VestingSigningClient};
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn vesting_delegate_to_mixnode(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
amount: DecCoin,
|
||||
fee: Option<Fee>,
|
||||
state: tauri::State<'_, WalletState>,
|
||||
@@ -40,7 +40,7 @@ pub async fn vesting_delegate_to_mixnode(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn vesting_undelegate_from_mixnode(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
fee: Option<Fee>,
|
||||
state: tauri::State<'_, WalletState>,
|
||||
) -> Result<TransactionExecuteResult, BackendError> {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use crate::error::BackendError;
|
||||
use crate::state::WalletState;
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
use nym_types::transaction::TransactionExecuteResult;
|
||||
use validator_client::nymd::Fee;
|
||||
|
||||
@@ -29,7 +29,7 @@ pub async fn vesting_claim_operator_reward(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn vesting_claim_delegator_reward(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
fee: Option<Fee>,
|
||||
state: tauri::State<'_, WalletState>,
|
||||
) -> Result<TransactionExecuteResult, BackendError> {
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::error::BackendError;
|
||||
use crate::nymd_client;
|
||||
use crate::state::WalletState;
|
||||
use cosmwasm_std::Decimal;
|
||||
use mixnet_contract_common::{IdentityKey, NodeId, Percent};
|
||||
use mixnet_contract_common::{IdentityKey, MixId, Percent};
|
||||
use nym_types::currency::DecCoin;
|
||||
use nym_types::mixnode::MixNodeCostParams;
|
||||
use nym_wallet_types::app::AppEnv;
|
||||
@@ -51,7 +51,7 @@ pub async fn owns_gateway(state: tauri::State<'_, WalletState>) -> Result<bool,
|
||||
pub async fn try_convert_pubkey_to_mix_id(
|
||||
state: tauri::State<'_, WalletState>,
|
||||
mix_identity: IdentityKey,
|
||||
) -> Result<Option<NodeId>, BackendError> {
|
||||
) -> Result<Option<MixId>, BackendError> {
|
||||
let res = nymd_client!(state)
|
||||
.get_mixnode_details_by_identity(mix_identity)
|
||||
.await?;
|
||||
|
||||
@@ -237,11 +237,11 @@ export const BondingContextProvider = ({ children }: { children?: React.ReactNod
|
||||
const {
|
||||
bond_information,
|
||||
rewarding_details,
|
||||
bond_information: { id },
|
||||
bond_information: { mix_id },
|
||||
} = data;
|
||||
|
||||
const { status, stakeSaturation, operatorCost, estimatedRewards } = await getAdditionalMixnodeDetails(id);
|
||||
const setProbabilities = await getSetProbabilities(id);
|
||||
const { status, stakeSaturation, operatorCost, estimatedRewards } = await getAdditionalMixnodeDetails(mix_id);
|
||||
const setProbabilities = await getSetProbabilities(mix_id);
|
||||
const nodeDescription = await getNodeDescription(
|
||||
bond_information.mix_node.host,
|
||||
bond_information.mix_node.http_api_port,
|
||||
@@ -250,7 +250,6 @@ export const BondingContextProvider = ({ children }: { children?: React.ReactNod
|
||||
setBondedNode({
|
||||
name: nodeDescription?.name,
|
||||
identityKey: bond_information.mix_node.identity_key,
|
||||
ip: bond_information.id,
|
||||
stake: {
|
||||
amount: calculateStake(rewarding_details.operator, rewarding_details.delegates),
|
||||
denom: bond_information.original_pledge.denom,
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { DecCoin } from './DecCoin';
|
||||
import type { MixNode } from './Mixnode';
|
||||
|
||||
export interface MixNodeBond {
|
||||
id: number;
|
||||
mix_id: number;
|
||||
owner: string;
|
||||
original_pledge: DecCoin;
|
||||
layer: string;
|
||||
|
||||
@@ -8,7 +8,7 @@ use anyhow::Result;
|
||||
use mixnet_contract_common::mixnode::MixNodeDetails;
|
||||
use mixnet_contract_common::reward_params::{Performance, RewardingParams};
|
||||
use mixnet_contract_common::{
|
||||
GatewayBond, IdentityKey, Interval, MixNodeBond, NodeId, RewardedSetNodeStatus,
|
||||
GatewayBond, IdentityKey, Interval, MixId, MixNodeBond, RewardedSetNodeStatus,
|
||||
};
|
||||
use okapi::openapi3::OpenApi;
|
||||
use rocket::fairing::AdHoc;
|
||||
@@ -59,7 +59,7 @@ struct ValidatorCacheInner {
|
||||
mixnodes: Cache<Vec<MixNodeBondAnnotated>>,
|
||||
gateways: Cache<Vec<GatewayBond>>,
|
||||
|
||||
mixnodes_blacklist: Cache<HashSet<NodeId>>,
|
||||
mixnodes_blacklist: Cache<HashSet<MixId>>,
|
||||
gateways_blacklist: Cache<HashSet<IdentityKey>>,
|
||||
|
||||
rewarded_set: Cache<Vec<MixNodeBondAnnotated>>,
|
||||
@@ -119,7 +119,7 @@ impl<C> ValidatorCacheRefresher<C> {
|
||||
}
|
||||
}
|
||||
|
||||
async fn get_performance(&self, mix_id: NodeId, epoch: Interval) -> Option<Performance> {
|
||||
async fn get_performance(&self, mix_id: MixId, epoch: Interval) -> Option<Performance> {
|
||||
self.storage
|
||||
.as_ref()?
|
||||
.get_average_mixnode_uptime_in_the_last_24hrs(
|
||||
@@ -140,7 +140,7 @@ impl<C> ValidatorCacheRefresher<C> {
|
||||
mixnodes: Vec<MixNodeDetails>,
|
||||
interval_reward_params: RewardingParams,
|
||||
current_interval: Interval,
|
||||
rewarded_set: &HashMap<NodeId, RewardedSetNodeStatus>,
|
||||
rewarded_set: &HashMap<MixId, RewardedSetNodeStatus>,
|
||||
) -> Vec<MixNodeBondAnnotated> {
|
||||
let mut annotated = Vec::new();
|
||||
for mixnode in mixnodes {
|
||||
@@ -186,7 +186,7 @@ impl<C> ValidatorCacheRefresher<C> {
|
||||
annotated
|
||||
}
|
||||
|
||||
async fn get_rewarded_set_map(&self) -> HashMap<NodeId, RewardedSetNodeStatus>
|
||||
async fn get_rewarded_set_map(&self) -> HashMap<MixId, RewardedSetNodeStatus>
|
||||
where
|
||||
C: CosmWasmClient + Sync + Send,
|
||||
{
|
||||
@@ -199,7 +199,7 @@ impl<C> ValidatorCacheRefresher<C> {
|
||||
|
||||
fn collect_rewarded_and_active_set_details(
|
||||
all_mixnodes: &[MixNodeBondAnnotated],
|
||||
rewarded_set_nodes: &HashMap<NodeId, RewardedSetNodeStatus>,
|
||||
rewarded_set_nodes: &HashMap<MixId, RewardedSetNodeStatus>,
|
||||
) -> (Vec<MixNodeBondAnnotated>, Vec<MixNodeBondAnnotated>) {
|
||||
let mut active_set = Vec::new();
|
||||
let mut rewarded_set = Vec::new();
|
||||
@@ -346,7 +346,7 @@ impl ValidatorCache {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn mixnodes_blacklist(&self) -> Option<Cache<HashSet<NodeId>>> {
|
||||
pub async fn mixnodes_blacklist(&self) -> Option<Cache<HashSet<MixId>>> {
|
||||
match time::timeout(Duration::from_millis(100), self.inner.read()).await {
|
||||
Ok(cache) => Some(cache.mixnodes_blacklist.clone()),
|
||||
Err(e) => {
|
||||
@@ -366,18 +366,18 @@ impl ValidatorCache {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn update_mixnodes_blacklist(&self, add: HashSet<NodeId>, remove: HashSet<NodeId>) {
|
||||
pub async fn update_mixnodes_blacklist(&self, add: HashSet<MixId>, remove: HashSet<MixId>) {
|
||||
let blacklist = self.mixnodes_blacklist().await;
|
||||
if let Some(blacklist) = blacklist {
|
||||
let mut blacklist = blacklist
|
||||
.value
|
||||
.union(&add)
|
||||
.cloned()
|
||||
.collect::<HashSet<NodeId>>();
|
||||
.collect::<HashSet<MixId>>();
|
||||
let to_remove = blacklist
|
||||
.intersection(&remove)
|
||||
.cloned()
|
||||
.collect::<HashSet<NodeId>>();
|
||||
.collect::<HashSet<MixId>>();
|
||||
for key in to_remove {
|
||||
blacklist.remove(&key);
|
||||
}
|
||||
@@ -560,7 +560,7 @@ impl ValidatorCache {
|
||||
|
||||
pub async fn mixnode_details(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> (Option<MixNodeBondAnnotated>, MixnodeStatus) {
|
||||
// it might not be the most optimal to possibly iterate the entire vector to find (or not)
|
||||
// the relevant value. However, the vectors are relatively small (< 10_000 elements, < 1000 for active set)
|
||||
@@ -583,7 +583,7 @@ impl ValidatorCache {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn mixnode_status(&self, mix_id: NodeId) -> MixnodeStatus {
|
||||
pub async fn mixnode_status(&self, mix_id: MixId) -> MixnodeStatus {
|
||||
self.mixnode_details(mix_id).await.1
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
use crate::contract_cache::ValidatorCache;
|
||||
use mixnet_contract_common::mixnode::MixNodeDetails;
|
||||
use mixnet_contract_common::reward_params::RewardingParams;
|
||||
use mixnet_contract_common::{GatewayBond, Interval, NodeId};
|
||||
use mixnet_contract_common::{GatewayBond, Interval, MixId};
|
||||
use rocket::serde::json::Json;
|
||||
use rocket::State;
|
||||
use rocket_okapi::openapi;
|
||||
@@ -63,7 +63,7 @@ pub async fn get_active_set_detailed(
|
||||
#[get("/mixnodes/blacklisted")]
|
||||
pub async fn get_blacklisted_mixnodes(
|
||||
cache: &State<ValidatorCache>,
|
||||
) -> Json<Option<HashSet<NodeId>>> {
|
||||
) -> Json<Option<HashSet<MixId>>> {
|
||||
Json(cache.mixnodes_blacklist().await.map(|c| c.value))
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ use crate::nymd_client::Client;
|
||||
use crate::storage::models::RewardingReport;
|
||||
use crate::storage::ValidatorApiStorage;
|
||||
use mixnet_contract_common::{
|
||||
reward_params::Performance, CurrentIntervalResponse, ExecuteMsg, Interval, NodeId,
|
||||
reward_params::Performance, CurrentIntervalResponse, ExecuteMsg, Interval, MixId,
|
||||
};
|
||||
use rand::prelude::SliceRandom;
|
||||
use rand::rngs::OsRng;
|
||||
@@ -36,7 +36,7 @@ use task::ShutdownListener;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub(crate) struct MixnodeToReward {
|
||||
pub(crate) mix_id: NodeId,
|
||||
pub(crate) mix_id: MixId,
|
||||
|
||||
pub(crate) performance: Performance,
|
||||
}
|
||||
@@ -82,7 +82,7 @@ impl RewardedSetUpdater {
|
||||
&self,
|
||||
mixnodes: Vec<MixNodeDetails>,
|
||||
nodes_to_select: u32,
|
||||
) -> Vec<NodeId> {
|
||||
) -> Vec<MixId> {
|
||||
if mixnodes.is_empty() {
|
||||
return Vec::new();
|
||||
}
|
||||
@@ -153,7 +153,7 @@ impl RewardedSetUpdater {
|
||||
async fn nodes_to_reward(&self, interval: Interval) -> Vec<MixnodeToReward> {
|
||||
// try to get current up to date view of the network bypassing the cache
|
||||
// in case the epochs were significantly shortened for the purposes of testing
|
||||
let rewarded_set: Vec<NodeId> = match self.nymd_client.get_rewarded_set_mixnodes().await {
|
||||
let rewarded_set: Vec<MixId> = match self.nymd_client.get_rewarded_set_mixnodes().await {
|
||||
Ok(nodes) => nodes.into_iter().map(|(id, _)| id).collect::<Vec<_>>(),
|
||||
Err(err) => {
|
||||
warn!("failed to obtain the current rewarded set - {}. falling back to the cached version", err);
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::network_monitor::test_packet::{NodeType, TestPacket};
|
||||
use crate::network_monitor::test_route::TestRoute;
|
||||
use crypto::asymmetric::{encryption, identity};
|
||||
use log::info;
|
||||
use mixnet_contract_common::{Addr, GatewayBond, Layer, MixNodeBond, NodeId};
|
||||
use mixnet_contract_common::{Addr, GatewayBond, Layer, MixId, MixNodeBond};
|
||||
use nymsphinx::addressing::clients::Recipient;
|
||||
use nymsphinx::forwarding::packet::MixPacket;
|
||||
use rand::seq::SliceRandom;
|
||||
@@ -49,7 +49,7 @@ impl Display for InvalidNode {
|
||||
}
|
||||
|
||||
impl InvalidNode {
|
||||
pub(crate) fn mix_id(&self) -> Option<NodeId> {
|
||||
pub(crate) fn mix_id(&self) -> Option<MixId> {
|
||||
match self {
|
||||
InvalidNode::Outdated(_, _, node_type, _) => node_type.mix_id(),
|
||||
InvalidNode::Malformed(_, _, node_type) => node_type.mix_id(),
|
||||
@@ -79,7 +79,7 @@ pub(crate) struct TestedNode {
|
||||
}
|
||||
|
||||
impl TestedNode {
|
||||
pub(crate) fn mix_id(&self) -> Option<NodeId> {
|
||||
pub(crate) fn mix_id(&self) -> Option<MixId> {
|
||||
self.node_type.mix_id()
|
||||
}
|
||||
}
|
||||
@@ -398,7 +398,7 @@ impl PacketPreparer {
|
||||
invalid_nodes.push(InvalidNode::Malformed(
|
||||
mixnode.mix_node.identity_key,
|
||||
mixnode.owner,
|
||||
NodeType::Mixnode(mixnode.id),
|
||||
NodeType::Mixnode(mixnode.mix_id),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
use crate::network_monitor::monitor::preparer::{InvalidNode, TestedNode};
|
||||
use crate::network_monitor::test_packet::{NodeType, TestPacket};
|
||||
use crate::network_monitor::test_route::TestRoute;
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::{Display, Formatter};
|
||||
|
||||
@@ -23,14 +23,14 @@ const UNRELIABLE_THRESHOLD: u8 = 1; // 1 - 60
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct MixnodeResult {
|
||||
pub(crate) mix_id: NodeId,
|
||||
pub(crate) mix_id: MixId,
|
||||
pub(crate) identity: String,
|
||||
pub(crate) owner: String,
|
||||
pub(crate) reliability: u8,
|
||||
}
|
||||
|
||||
impl MixnodeResult {
|
||||
pub(crate) fn new(mix_id: NodeId, identity: String, owner: String, reliability: u8) -> Self {
|
||||
pub(crate) fn new(mix_id: MixId, identity: String, owner: String, reliability: u8) -> Self {
|
||||
MixnodeResult {
|
||||
mix_id,
|
||||
identity,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use crate::network_monitor::monitor::preparer::TestedNode;
|
||||
use crypto::asymmetric::identity;
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
use std::convert::TryInto;
|
||||
use std::fmt::{self, Display, Formatter};
|
||||
use std::hash::{Hash, Hasher};
|
||||
@@ -17,19 +17,19 @@ const GATEWAY_TYPE: u8 = 1;
|
||||
#[repr(u8)]
|
||||
#[derive(Eq, PartialEq, Debug, Hash, Clone, Copy)]
|
||||
pub(crate) enum NodeType {
|
||||
Mixnode(NodeId),
|
||||
Mixnode(MixId),
|
||||
Gateway,
|
||||
}
|
||||
|
||||
impl NodeType {
|
||||
fn size(&self) -> usize {
|
||||
match self {
|
||||
NodeType::Mixnode(_) => 1 + mem::size_of::<NodeId>(),
|
||||
NodeType::Mixnode(_) => 1 + mem::size_of::<MixId>(),
|
||||
NodeType::Gateway => 1,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn mix_id(&self) -> Option<NodeId> {
|
||||
pub(crate) fn mix_id(&self) -> Option<MixId> {
|
||||
match self {
|
||||
NodeType::Mixnode(mix_id) => Some(*mix_id),
|
||||
NodeType::Gateway => None,
|
||||
@@ -54,11 +54,11 @@ impl NodeType {
|
||||
}
|
||||
match b[0] {
|
||||
t if t == MIXNODE_TYPE => {
|
||||
if b.len() < (1 + mem::size_of::<NodeId>()) {
|
||||
if b.len() < (1 + mem::size_of::<MixId>()) {
|
||||
return Err(TestPacketError::InvalidNodeType);
|
||||
}
|
||||
Ok(NodeType::Mixnode(NodeId::from_be_bytes(
|
||||
b[1..1 + mem::size_of::<NodeId>()].try_into().unwrap(),
|
||||
Ok(NodeType::Mixnode(MixId::from_be_bytes(
|
||||
b[1..1 + mem::size_of::<MixId>()].try_into().unwrap(),
|
||||
)))
|
||||
}
|
||||
t if t == GATEWAY_TYPE => Ok(NodeType::Gateway),
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use crate::contract_cache::{Cache, CacheNotification, ValidatorCache};
|
||||
use mixnet_contract_common::rewarding::helpers::truncate_decimal;
|
||||
use mixnet_contract_common::{MixNodeDetails, NodeId, RewardingParams};
|
||||
use mixnet_contract_common::{MixId, MixNodeDetails, RewardingParams};
|
||||
use rocket::fairing::AdHoc;
|
||||
use serde::Serialize;
|
||||
use std::{sync::Arc, time::Duration};
|
||||
@@ -46,8 +46,10 @@ pub(crate) struct InclusionProbabilities {
|
||||
}
|
||||
|
||||
impl InclusionProbabilities {
|
||||
pub fn node(&self, mix_id: NodeId) -> Option<&InclusionProbability> {
|
||||
self.inclusion_probabilities.iter().find(|x| x.id == mix_id)
|
||||
pub fn node(&self, mix_id: MixId) -> Option<&InclusionProbability> {
|
||||
self.inclusion_probabilities
|
||||
.iter()
|
||||
.find(|x| x.mix_id == mix_id)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,7 +230,7 @@ fn compute_inclusion_probabilities(
|
||||
})
|
||||
}
|
||||
|
||||
fn unzip_into_mixnode_ids_and_total_bonds(mixnodes: &[MixNodeDetails]) -> (Vec<NodeId>, Vec<u128>) {
|
||||
fn unzip_into_mixnode_ids_and_total_bonds(mixnodes: &[MixNodeDetails]) -> (Vec<MixId>, Vec<u128>) {
|
||||
mixnodes
|
||||
.iter()
|
||||
.map(|m| (m.mix_id(), truncate_decimal(m.total_stake()).u128()))
|
||||
@@ -236,14 +238,14 @@ fn unzip_into_mixnode_ids_and_total_bonds(mixnodes: &[MixNodeDetails]) -> (Vec<N
|
||||
}
|
||||
|
||||
fn zip_ids_together_with_results(
|
||||
ids: &[NodeId],
|
||||
ids: &[MixId],
|
||||
results: &inclusion_probability::SelectionProbability,
|
||||
) -> Vec<InclusionProbability> {
|
||||
ids.iter()
|
||||
.zip(results.active_set_probability.iter())
|
||||
.zip(results.reserve_set_probability.iter())
|
||||
.map(|((&id, a), r)| InclusionProbability {
|
||||
id,
|
||||
.map(|((&mix_id, a), r)| InclusionProbability {
|
||||
mix_id,
|
||||
in_active: *a,
|
||||
in_reserve: *r,
|
||||
})
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::storage::ValidatorApiStorage;
|
||||
use crate::{NodeStatusCache, ValidatorCache};
|
||||
use cosmwasm_std::Decimal;
|
||||
use mixnet_contract_common::reward_params::Performance;
|
||||
use mixnet_contract_common::{Interval, NodeId, RewardedSetNodeStatus};
|
||||
use mixnet_contract_common::{Interval, MixId, RewardedSetNodeStatus};
|
||||
use rocket::http::Status;
|
||||
use rocket::State;
|
||||
use validator_api_requests::models::{
|
||||
@@ -18,7 +18,7 @@ use validator_api_requests::models::{
|
||||
|
||||
pub(crate) async fn _mixnode_report(
|
||||
storage: &ValidatorApiStorage,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<MixnodeStatusReport, ErrorResponse> {
|
||||
storage
|
||||
.construct_mixnode_report(mix_id)
|
||||
@@ -28,7 +28,7 @@ pub(crate) async fn _mixnode_report(
|
||||
|
||||
pub(crate) async fn _mixnode_uptime_history(
|
||||
storage: &ValidatorApiStorage,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<MixnodeUptimeHistory, ErrorResponse> {
|
||||
storage
|
||||
.get_mixnode_uptime_history(mix_id)
|
||||
@@ -38,7 +38,7 @@ pub(crate) async fn _mixnode_uptime_history(
|
||||
|
||||
pub(crate) async fn _mixnode_core_status_count(
|
||||
storage: &State<ValidatorApiStorage>,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
since: Option<i64>,
|
||||
) -> Result<MixnodeCoreStatusResponse, ErrorResponse> {
|
||||
let count = storage
|
||||
@@ -51,7 +51,7 @@ pub(crate) async fn _mixnode_core_status_count(
|
||||
|
||||
pub(crate) async fn _get_mixnode_status(
|
||||
cache: &ValidatorCache,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> MixnodeStatusResponse {
|
||||
MixnodeStatusResponse {
|
||||
status: cache.mixnode_status(mix_id).await,
|
||||
@@ -60,7 +60,7 @@ pub(crate) async fn _get_mixnode_status(
|
||||
|
||||
pub(crate) async fn _get_mixnode_reward_estimation(
|
||||
cache: &State<ValidatorCache>,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<RewardEstimationResponse, ErrorResponse> {
|
||||
let (mixnode, status) = cache.mixnode_details(mix_id).await;
|
||||
if let Some(mixnode) = mixnode {
|
||||
@@ -98,7 +98,7 @@ pub(crate) async fn _get_mixnode_reward_estimation(
|
||||
}
|
||||
|
||||
async fn average_mixnode_performance(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
current_interval: Interval,
|
||||
storage: &ValidatorApiStorage,
|
||||
) -> Result<Performance, ErrorResponse> {
|
||||
@@ -115,7 +115,7 @@ async fn average_mixnode_performance(
|
||||
pub(crate) async fn _compute_mixnode_reward_estimation(
|
||||
user_reward_param: ComputeRewardEstParam,
|
||||
cache: &ValidatorCache,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<RewardEstimationResponse, ErrorResponse> {
|
||||
let (mixnode, actual_status) = cache.mixnode_details(mix_id).await;
|
||||
if let Some(mut mixnode) = mixnode {
|
||||
@@ -198,7 +198,7 @@ pub(crate) async fn _compute_mixnode_reward_estimation(
|
||||
|
||||
pub(crate) async fn _get_mixnode_stake_saturation(
|
||||
cache: &ValidatorCache,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<StakeSaturationResponse, ErrorResponse> {
|
||||
let (mixnode, _) = cache.mixnode_details(mix_id).await;
|
||||
if let Some(mixnode) = mixnode {
|
||||
@@ -231,7 +231,7 @@ pub(crate) async fn _get_mixnode_stake_saturation(
|
||||
|
||||
pub(crate) async fn _get_mixnode_inclusion_probability(
|
||||
cache: &NodeStatusCache,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<InclusionProbabilityResponse, ErrorResponse> {
|
||||
cache
|
||||
.inclusion_probabilities()
|
||||
@@ -248,7 +248,7 @@ pub(crate) async fn _get_mixnode_inclusion_probability(
|
||||
pub(crate) async fn _get_mixnode_avg_uptime(
|
||||
cache: &ValidatorCache,
|
||||
storage: &ValidatorApiStorage,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<UptimeResponse, ErrorResponse> {
|
||||
let current_interval = cache
|
||||
.current_interval()
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
use crate::node_status_api::utils::NodeUptimes;
|
||||
use crate::storage::models::NodeStatus;
|
||||
use mixnet_contract_common::reward_params::Performance;
|
||||
use mixnet_contract_common::{IdentityKey, NodeId};
|
||||
use mixnet_contract_common::{IdentityKey, MixId};
|
||||
use okapi::openapi3::{Responses, SchemaObject};
|
||||
use rocket::http::{ContentType, Status};
|
||||
use rocket::response::{self, Responder, Response};
|
||||
@@ -115,7 +115,7 @@ impl From<Uptime> for Performance {
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, JsonSchema)]
|
||||
pub struct MixnodeStatusReport {
|
||||
pub(crate) mix_id: NodeId,
|
||||
pub(crate) mix_id: MixId,
|
||||
pub(crate) identity: IdentityKey,
|
||||
pub(crate) owner: String,
|
||||
|
||||
@@ -128,7 +128,7 @@ pub struct MixnodeStatusReport {
|
||||
impl MixnodeStatusReport {
|
||||
pub(crate) fn construct_from_last_day_reports(
|
||||
report_time: OffsetDateTime,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
identity: IdentityKey,
|
||||
owner: String,
|
||||
last_day: Vec<NodeStatus>,
|
||||
@@ -192,7 +192,7 @@ impl GatewayStatusReport {
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, JsonSchema)]
|
||||
pub struct MixnodeUptimeHistory {
|
||||
pub(crate) mix_id: NodeId,
|
||||
pub(crate) mix_id: MixId,
|
||||
pub(crate) identity: String,
|
||||
pub(crate) owner: String,
|
||||
|
||||
@@ -201,7 +201,7 @@ pub struct MixnodeUptimeHistory {
|
||||
|
||||
impl MixnodeUptimeHistory {
|
||||
pub(crate) fn new(
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
identity: String,
|
||||
owner: String,
|
||||
history: Vec<HistoricalUptime>,
|
||||
@@ -305,9 +305,9 @@ impl OpenApiResponderInner for ErrorResponse {
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum ValidatorApiStorageError {
|
||||
MixnodeReportNotFound(NodeId),
|
||||
MixnodeReportNotFound(MixId),
|
||||
GatewayReportNotFound(String),
|
||||
MixnodeUptimeHistoryNotFound(NodeId),
|
||||
MixnodeUptimeHistoryNotFound(MixId),
|
||||
GatewayUptimeHistoryNotFound(String),
|
||||
|
||||
// I don't think we want to expose errors to the user about what really happened
|
||||
|
||||
@@ -14,7 +14,7 @@ use crate::node_status_api::models::{
|
||||
};
|
||||
use crate::storage::ValidatorApiStorage;
|
||||
use crate::ValidatorCache;
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
use rocket::http::Status;
|
||||
use rocket::serde::json::Json;
|
||||
use rocket::State;
|
||||
@@ -73,7 +73,7 @@ pub(crate) async fn gateway_core_status_count(
|
||||
#[get("/mixnode/<mix_id>/report")]
|
||||
pub(crate) async fn mixnode_report(
|
||||
storage: &State<ValidatorApiStorage>,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<Json<MixnodeStatusReport>, ErrorResponse> {
|
||||
Ok(Json(_mixnode_report(storage, mix_id).await?))
|
||||
}
|
||||
@@ -82,7 +82,7 @@ pub(crate) async fn mixnode_report(
|
||||
#[get("/mixnode/<mix_id>/history")]
|
||||
pub(crate) async fn mixnode_uptime_history(
|
||||
storage: &State<ValidatorApiStorage>,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<Json<MixnodeUptimeHistory>, ErrorResponse> {
|
||||
Ok(Json(_mixnode_uptime_history(storage, mix_id).await?))
|
||||
}
|
||||
@@ -91,7 +91,7 @@ pub(crate) async fn mixnode_uptime_history(
|
||||
#[get("/mixnode/<mix_id>/core-status-count?<since>")]
|
||||
pub(crate) async fn mixnode_core_status_count(
|
||||
storage: &State<ValidatorApiStorage>,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
since: Option<i64>,
|
||||
) -> Result<Json<MixnodeCoreStatusResponse>, ErrorResponse> {
|
||||
Ok(Json(
|
||||
@@ -103,7 +103,7 @@ pub(crate) async fn mixnode_core_status_count(
|
||||
#[get("/mixnode/<mix_id>/status")]
|
||||
pub(crate) async fn get_mixnode_status(
|
||||
cache: &State<ValidatorCache>,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Json<MixnodeStatusResponse> {
|
||||
Json(_get_mixnode_status(cache, mix_id).await)
|
||||
}
|
||||
@@ -112,7 +112,7 @@ pub(crate) async fn get_mixnode_status(
|
||||
#[get("/mixnode/<mix_id>/reward-estimation")]
|
||||
pub(crate) async fn get_mixnode_reward_estimation(
|
||||
cache: &State<ValidatorCache>,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<Json<RewardEstimationResponse>, ErrorResponse> {
|
||||
Ok(Json(_get_mixnode_reward_estimation(cache, mix_id).await?))
|
||||
}
|
||||
@@ -125,7 +125,7 @@ pub(crate) async fn get_mixnode_reward_estimation(
|
||||
pub(crate) async fn compute_mixnode_reward_estimation(
|
||||
user_reward_param: Json<ComputeRewardEstParam>,
|
||||
cache: &State<ValidatorCache>,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<Json<RewardEstimationResponse>, ErrorResponse> {
|
||||
Ok(Json(
|
||||
_compute_mixnode_reward_estimation(user_reward_param.into_inner(), cache, mix_id).await?,
|
||||
@@ -136,7 +136,7 @@ pub(crate) async fn compute_mixnode_reward_estimation(
|
||||
#[get("/mixnode/<mix_id>/stake-saturation")]
|
||||
pub(crate) async fn get_mixnode_stake_saturation(
|
||||
cache: &State<ValidatorCache>,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<Json<StakeSaturationResponse>, ErrorResponse> {
|
||||
Ok(Json(_get_mixnode_stake_saturation(cache, mix_id).await?))
|
||||
}
|
||||
@@ -145,7 +145,7 @@ pub(crate) async fn get_mixnode_stake_saturation(
|
||||
#[get("/mixnode/<mix_id>/inclusion-probability")]
|
||||
pub(crate) async fn get_mixnode_inclusion_probability(
|
||||
cache: &State<NodeStatusCache>,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<Json<InclusionProbabilityResponse>, ErrorResponse> {
|
||||
Ok(Json(
|
||||
_get_mixnode_inclusion_probability(cache, mix_id).await?,
|
||||
@@ -157,7 +157,7 @@ pub(crate) async fn get_mixnode_inclusion_probability(
|
||||
pub(crate) async fn get_mixnode_avg_uptime(
|
||||
cache: &State<ValidatorCache>,
|
||||
storage: &State<ValidatorApiStorage>,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<Json<UptimeResponse>, ErrorResponse> {
|
||||
Ok(Json(_get_mixnode_avg_uptime(cache, storage, mix_id).await?))
|
||||
}
|
||||
|
||||
@@ -5,13 +5,13 @@ use crate::node_status_api::models::Uptime;
|
||||
use crate::node_status_api::{FIFTEEN_MINUTES, ONE_HOUR};
|
||||
use crate::storage::models::NodeStatus;
|
||||
use log::warn;
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
use std::convert::TryInto;
|
||||
use time::OffsetDateTime;
|
||||
|
||||
// A temporary helper structs used to produce reports for active nodes.
|
||||
pub(crate) struct ActiveMixnodeStatuses {
|
||||
pub(crate) mix_id: NodeId,
|
||||
pub(crate) mix_id: MixId,
|
||||
|
||||
pub(crate) identity: String,
|
||||
pub(crate) owner: String,
|
||||
|
||||
@@ -7,7 +7,7 @@ use config::defaults::{NymNetworkDetails, DEFAULT_VALIDATOR_API_PORT};
|
||||
use mixnet_contract_common::mixnode::MixNodeDetails;
|
||||
use mixnet_contract_common::reward_params::RewardingParams;
|
||||
use mixnet_contract_common::{
|
||||
CurrentIntervalResponse, ExecuteMsg, GatewayBond, NodeId, RewardedSetNodeStatus,
|
||||
CurrentIntervalResponse, ExecuteMsg, GatewayBond, MixId, RewardedSetNodeStatus,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
@@ -168,7 +168,7 @@ impl<C> Client<C> {
|
||||
|
||||
pub(crate) async fn get_rewarded_set_mixnodes(
|
||||
&self,
|
||||
) -> Result<Vec<(NodeId, RewardedSetNodeStatus)>, ValidatorClientError>
|
||||
) -> Result<Vec<(MixId, RewardedSetNodeStatus)>, ValidatorClientError>
|
||||
where
|
||||
C: CosmWasmClient + Sync + Send,
|
||||
{
|
||||
@@ -225,7 +225,7 @@ impl<C> Client<C> {
|
||||
|
||||
pub(crate) async fn advance_current_epoch(
|
||||
&self,
|
||||
new_rewarded_set: Vec<NodeId>,
|
||||
new_rewarded_set: Vec<MixId>,
|
||||
expected_active_set_size: u32,
|
||||
) -> Result<(), ValidatorClientError>
|
||||
where
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::node_status_api::utils::{ActiveGatewayStatuses, ActiveMixnodeStatuses
|
||||
use crate::storage::models::{
|
||||
ActiveGateway, ActiveMixnode, NodeStatus, RewardingReport, TestingRoute,
|
||||
};
|
||||
use mixnet_contract_common::{EpochId, IdentityKey, NodeId};
|
||||
use mixnet_contract_common::{EpochId, IdentityKey, MixId};
|
||||
use std::convert::TryFrom;
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -15,12 +15,12 @@ pub(crate) struct StorageManager {
|
||||
}
|
||||
|
||||
pub struct AvgMixnodeReliability {
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
value: Option<f32>,
|
||||
}
|
||||
|
||||
impl AvgMixnodeReliability {
|
||||
pub fn mix_id(&self) -> NodeId {
|
||||
pub fn mix_id(&self) -> MixId {
|
||||
self.mix_id
|
||||
}
|
||||
|
||||
@@ -49,9 +49,9 @@ impl StorageManager {
|
||||
pub(super) async fn get_mixnode_mix_ids_by_identity(
|
||||
&self,
|
||||
identity: &str,
|
||||
) -> Result<Vec<NodeId>, sqlx::Error> {
|
||||
) -> Result<Vec<MixId>, sqlx::Error> {
|
||||
let ids = sqlx::query!(
|
||||
r#"SELECT mix_id as "mix_id: NodeId" FROM mixnode_details WHERE identity_key = ?"#,
|
||||
r#"SELECT mix_id as "mix_id: MixId" FROM mixnode_details WHERE identity_key = ?"#,
|
||||
identity
|
||||
)
|
||||
.fetch_all(&self.connection_pool)
|
||||
@@ -90,7 +90,7 @@ impl StorageManager {
|
||||
AvgMixnodeReliability,
|
||||
r#"
|
||||
SELECT
|
||||
d.mix_id as "mix_id: NodeId",
|
||||
d.mix_id as "mix_id: MixId",
|
||||
AVG(s.reliability) as "value: f32"
|
||||
FROM
|
||||
mixnode_details d
|
||||
@@ -144,7 +144,7 @@ impl StorageManager {
|
||||
/// * `mix_id`: mix-id (as assigned by the smart contract) of the mixnode.
|
||||
pub(super) async fn get_mixnode_database_id(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<Option<i64>, sqlx::Error> {
|
||||
let id = sqlx::query!("SELECT id FROM mixnode_details WHERE mix_id = ?", mix_id)
|
||||
.fetch_optional(&self.connection_pool)
|
||||
@@ -178,7 +178,7 @@ impl StorageManager {
|
||||
/// * `mix_id`: mix-id (as assigned by the smart contract) of the mixnode.
|
||||
pub(super) async fn get_mixnode_owner(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<Option<String>, sqlx::Error> {
|
||||
let owner = sqlx::query!("SELECT owner FROM mixnode_details WHERE mix_id = ?", mix_id)
|
||||
.fetch_optional(&self.connection_pool)
|
||||
@@ -195,7 +195,7 @@ impl StorageManager {
|
||||
/// * `mix_id`: mix-id (as assigned by the smart contract) of the mixnode.
|
||||
pub(super) async fn get_mixnode_identity_key(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<Option<IdentityKey>, sqlx::Error> {
|
||||
let identity_key = sqlx::query!(
|
||||
"SELECT identity_key FROM mixnode_details WHERE mix_id = ?",
|
||||
@@ -237,7 +237,7 @@ impl StorageManager {
|
||||
/// * `timestamp`: unix timestamp of the lower bound of the selection.
|
||||
pub(super) async fn get_mixnode_statuses_since(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
timestamp: i64,
|
||||
) -> Result<Vec<NodeStatus>, sqlx::Error> {
|
||||
sqlx::query_as!(
|
||||
@@ -291,7 +291,7 @@ impl StorageManager {
|
||||
/// * `mix_id`: mix-id (as assigned by the smart contract) of the mixnode.
|
||||
pub(super) async fn get_mixnode_historical_uptimes(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<Vec<HistoricalUptime>, sqlx::Error> {
|
||||
let uptimes = sqlx::query!(
|
||||
r#"
|
||||
@@ -563,11 +563,11 @@ impl StorageManager {
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `mixnode_id`: id (as saved in the database) of the mixnode.
|
||||
/// * `db_mixnode_id`: id (as saved in the database) of the mixnode.
|
||||
/// * `since`: unix timestamp indicating the lower bound interval of the selection.
|
||||
pub(super) async fn get_mixnode_testing_route_presence_count_since(
|
||||
&self,
|
||||
mixnode_id: i64,
|
||||
db_mixnode_id: i64,
|
||||
since: i64,
|
||||
) -> Result<i32, sqlx::Error> {
|
||||
let count = sqlx::query!(
|
||||
@@ -586,9 +586,9 @@ impl StorageManager {
|
||||
) monitor_run
|
||||
ON monitor_run.id = testing_route.monitor_run_id;
|
||||
"#,
|
||||
mixnode_id,
|
||||
mixnode_id,
|
||||
mixnode_id,
|
||||
db_mixnode_id,
|
||||
db_mixnode_id,
|
||||
db_mixnode_id,
|
||||
since,
|
||||
).fetch_one(&self.connection_pool)
|
||||
.await?
|
||||
@@ -658,13 +658,13 @@ impl StorageManager {
|
||||
/// * `uptime`: the actual uptime of the node during the specified day.
|
||||
pub(super) async fn insert_mixnode_historical_uptime(
|
||||
&self,
|
||||
node_id: i64,
|
||||
mix_id: i64,
|
||||
date: &str,
|
||||
uptime: u8,
|
||||
) -> Result<(), sqlx::Error> {
|
||||
sqlx::query!(
|
||||
"INSERT INTO mixnode_historical_uptime(mixnode_details_id, date, uptime) VALUES (?, ?, ?)",
|
||||
node_id,
|
||||
mix_id,
|
||||
date,
|
||||
uptime,
|
||||
).execute(&self.connection_pool).await?;
|
||||
@@ -680,13 +680,13 @@ impl StorageManager {
|
||||
/// * `uptime`: the actual uptime of the node during the specified day.
|
||||
pub(super) async fn insert_gateway_historical_uptime(
|
||||
&self,
|
||||
node_id: i64,
|
||||
mix_id: i64,
|
||||
date: &str,
|
||||
uptime: u8,
|
||||
) -> Result<(), sqlx::Error> {
|
||||
sqlx::query!(
|
||||
"INSERT INTO gateway_historical_uptime(gateway_details_id, date, uptime) VALUES (?, ?, ?)",
|
||||
node_id,
|
||||
mix_id,
|
||||
date,
|
||||
uptime,
|
||||
).execute(&self.connection_pool).await?;
|
||||
@@ -779,7 +779,7 @@ impl StorageManager {
|
||||
sqlx::query_as!(
|
||||
ActiveMixnode,
|
||||
r#"
|
||||
SELECT DISTINCT identity_key, mix_id as "mix_id: NodeId", owner, id
|
||||
SELECT DISTINCT identity_key, mix_id as "mix_id: MixId", owner, id
|
||||
FROM mixnode_details
|
||||
JOIN mixnode_status
|
||||
ON mixnode_details.id = mixnode_status.mixnode_details_id
|
||||
|
||||
@@ -10,7 +10,7 @@ use crate::node_status_api::models::{
|
||||
use crate::node_status_api::{ONE_DAY, ONE_HOUR};
|
||||
use crate::storage::manager::StorageManager;
|
||||
use crate::storage::models::{NodeStatus, RewardingReport, TestingRoute};
|
||||
use mixnet_contract_common::{EpochId, NodeId};
|
||||
use mixnet_contract_common::{EpochId, MixId};
|
||||
use rocket::fairing::AdHoc;
|
||||
use sqlx::ConnectOptions;
|
||||
use std::path::PathBuf;
|
||||
@@ -75,7 +75,7 @@ impl ValidatorApiStorage {
|
||||
pub(crate) async fn mix_identity_to_mix_ids(
|
||||
&self,
|
||||
identity: &str,
|
||||
) -> Result<Vec<NodeId>, ValidatorApiStorageError> {
|
||||
) -> Result<Vec<MixId>, ValidatorApiStorageError> {
|
||||
Ok(self
|
||||
.manager
|
||||
.get_mixnode_mix_ids_by_identity(identity)
|
||||
@@ -86,7 +86,7 @@ impl ValidatorApiStorage {
|
||||
pub(crate) async fn mix_identity_to_latest_mix_id(
|
||||
&self,
|
||||
identity: &str,
|
||||
) -> Result<Option<NodeId>, ValidatorApiStorageError> {
|
||||
) -> Result<Option<MixId>, ValidatorApiStorageError> {
|
||||
Ok(self
|
||||
.mix_identity_to_mix_ids(identity)
|
||||
.await?
|
||||
@@ -127,7 +127,7 @@ impl ValidatorApiStorage {
|
||||
/// * `since`: unix timestamp indicating the lower bound interval of the selection.
|
||||
async fn get_mixnode_statuses(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
since: i64,
|
||||
) -> Result<Vec<NodeStatus>, ValidatorApiStorageError> {
|
||||
let statuses = self
|
||||
@@ -165,7 +165,7 @@ impl ValidatorApiStorage {
|
||||
/// * `mix_id`: mix-id (as assigned by the smart contract) of the mixnode.
|
||||
pub(crate) async fn construct_mixnode_report(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<MixnodeStatusReport, ValidatorApiStorageError> {
|
||||
let now = OffsetDateTime::now_utc();
|
||||
let day_ago = (now - ONE_DAY).unix_timestamp();
|
||||
@@ -248,7 +248,7 @@ impl ValidatorApiStorage {
|
||||
|
||||
pub(crate) async fn get_mixnode_uptime_history(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
) -> Result<MixnodeUptimeHistory, ValidatorApiStorageError> {
|
||||
let history = self.manager.get_mixnode_historical_uptimes(mix_id).await?;
|
||||
|
||||
@@ -305,7 +305,7 @@ impl ValidatorApiStorage {
|
||||
|
||||
pub(crate) async fn get_average_mixnode_uptime_in_the_last_24hrs(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
end_ts_secs: i64,
|
||||
) -> Result<Uptime, ValidatorApiStorageError> {
|
||||
let start = end_ts_secs - 86400;
|
||||
@@ -323,7 +323,7 @@ impl ValidatorApiStorage {
|
||||
/// * `end`: unix timestamp indicating the upper bound interval of the selection.
|
||||
pub(crate) async fn get_average_mixnode_uptime_in_time_interval(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
start: i64,
|
||||
end: i64,
|
||||
) -> Result<Uptime, ValidatorApiStorageError> {
|
||||
@@ -495,7 +495,7 @@ impl ValidatorApiStorage {
|
||||
/// * `since`: optional unix timestamp indicating the lower bound interval of the selection.
|
||||
pub(crate) async fn get_core_mixnode_status_count(
|
||||
&self,
|
||||
mix_id: NodeId,
|
||||
mix_id: MixId,
|
||||
since: Option<i64>,
|
||||
) -> Result<i32, ValidatorApiStorageError> {
|
||||
let db_id = self
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use mixnet_contract_common::NodeId;
|
||||
use mixnet_contract_common::MixId;
|
||||
|
||||
// Internally used struct to catch results from the database to calculate uptimes for given mixnode/gateway
|
||||
pub(crate) struct NodeStatus {
|
||||
@@ -22,7 +22,7 @@ impl NodeStatus {
|
||||
// Internally used structs to catch results from the database to find active mixnodes
|
||||
pub(crate) struct ActiveMixnode {
|
||||
pub(crate) id: i64,
|
||||
pub(crate) mix_id: NodeId,
|
||||
pub(crate) mix_id: MixId,
|
||||
pub(crate) identity_key: String,
|
||||
pub(crate) owner: String,
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use cosmwasm_std::{Coin, Decimal};
|
||||
use mixnet_contract_common::mixnode::MixNodeDetails;
|
||||
use mixnet_contract_common::reward_params::{Performance, RewardingParams};
|
||||
use mixnet_contract_common::rewarding::RewardEstimate;
|
||||
use mixnet_contract_common::{Interval, MixNode, NodeId, Percent, RewardedSetNodeStatus};
|
||||
use mixnet_contract_common::{Interval, MixId, MixNode, Percent, RewardedSetNodeStatus};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{fmt, time::Duration};
|
||||
@@ -48,7 +48,7 @@ impl MixnodeStatus {
|
||||
ts(export_to = "ts-packages/types/src/types/rust/MixnodeCoreStatusResponse.ts")
|
||||
)]
|
||||
pub struct MixnodeCoreStatusResponse {
|
||||
pub mix_id: NodeId,
|
||||
pub mix_id: MixId,
|
||||
pub count: i32,
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ impl MixNodeBondAnnotated {
|
||||
&self.mixnode_details.bond_information.mix_node
|
||||
}
|
||||
|
||||
pub fn mix_id(&self) -> NodeId {
|
||||
pub fn mix_id(&self) -> MixId {
|
||||
self.mixnode_details.mix_id()
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ pub struct RewardEstimationResponse {
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct UptimeResponse {
|
||||
pub mix_id: NodeId,
|
||||
pub mix_id: MixId,
|
||||
pub avg_uptime: u8,
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ pub struct AllInclusionProbabilitiesResponse {
|
||||
|
||||
#[derive(Clone, Serialize, schemars::JsonSchema)]
|
||||
pub struct InclusionProbability {
|
||||
pub id: NodeId,
|
||||
pub mix_id: MixId,
|
||||
pub in_active: f64,
|
||||
pub in_reserve: f64,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user