Remove everywhere sp contract is used
This commit is contained in:
@@ -7,7 +7,6 @@ use nym_mixnet_contract_common::{
|
||||
families::FamilyHead, GatewayBond, IdentityKey, Interval, MixId, MixNodeDetails,
|
||||
RewardingParams,
|
||||
};
|
||||
use nym_service_provider_directory_common::Service;
|
||||
use nym_validator_client::nyxd::AccountId;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
@@ -26,8 +25,6 @@ pub(crate) struct ValidatorCacheData {
|
||||
|
||||
pub(crate) mix_to_family: Cache<Vec<(IdentityKey, FamilyHead)>>,
|
||||
|
||||
pub(crate) service_providers: Cache<Vec<Service>>,
|
||||
|
||||
pub(crate) contracts_info: Cache<CachedContractsInfo>,
|
||||
}
|
||||
|
||||
@@ -43,7 +40,6 @@ impl ValidatorCacheData {
|
||||
current_interval: Cache::default(),
|
||||
current_reward_params: Cache::default(),
|
||||
mix_to_family: Cache::default(),
|
||||
service_providers: Cache::default(),
|
||||
contracts_info: Cache::default(),
|
||||
}
|
||||
}
|
||||
|
||||
-16
@@ -9,7 +9,6 @@ use nym_mixnet_contract_common::{
|
||||
families::FamilyHead, GatewayBond, IdentityKey, Interval, MixId, MixNodeBond, MixNodeDetails,
|
||||
RewardingParams,
|
||||
};
|
||||
use nym_service_provider_directory_common::Service;
|
||||
use rocket::fairing::AdHoc;
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
@@ -55,7 +54,6 @@ impl NymContractCache {
|
||||
rewarding_params: RewardingParams,
|
||||
current_interval: Interval,
|
||||
mix_to_family: Vec<(IdentityKey, FamilyHead)>,
|
||||
services: Option<Vec<Service>>,
|
||||
nym_contracts_info: CachedContractsInfo,
|
||||
) {
|
||||
match time::timeout(Duration::from_millis(100), self.inner.write()).await {
|
||||
@@ -71,10 +69,6 @@ impl NymContractCache {
|
||||
.current_interval
|
||||
.unchecked_update(Some(current_interval));
|
||||
cache.mix_to_family.unchecked_update(mix_to_family);
|
||||
// Just return empty lists when these are not available
|
||||
cache
|
||||
.service_providers
|
||||
.unchecked_update(services.unwrap_or_default());
|
||||
cache.contracts_info.unchecked_update(nym_contracts_info)
|
||||
}
|
||||
Err(err) => {
|
||||
@@ -307,16 +301,6 @@ impl NymContractCache {
|
||||
self.mixnode_details(mix_id).await.1
|
||||
}
|
||||
|
||||
pub(crate) async fn services(&self) -> Cache<Vec<Service>> {
|
||||
match time::timeout(Duration::from_millis(100), self.inner.read()).await {
|
||||
Ok(cache) => cache.service_providers.clone_cache(),
|
||||
Err(err) => {
|
||||
error!("{err}");
|
||||
Cache::new(Vec::new())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn initialised(&self) -> bool {
|
||||
self.initialised.load(Ordering::Relaxed)
|
||||
}
|
||||
|
||||
+3
-30
@@ -10,8 +10,7 @@ use futures::future::join_all;
|
||||
use nym_mixnet_contract_common::{MixId, MixNodeDetails, RewardedSetNodeStatus};
|
||||
use nym_task::TaskClient;
|
||||
use nym_validator_client::nyxd::contract_traits::{
|
||||
MixnetQueryClient, NymContractsProvider, PagedSpDirectoryQueryClient, SpDirectoryQueryClient,
|
||||
VestingQueryClient,
|
||||
MixnetQueryClient, NymContractsProvider, VestingQueryClient,
|
||||
};
|
||||
use nym_validator_client::nyxd::CosmWasmClient;
|
||||
use std::{collections::HashMap, sync::atomic::Ordering, time::Duration};
|
||||
@@ -55,7 +54,6 @@ impl NymContractCacheRefresher {
|
||||
|
||||
let mixnet = query_guard!(client_guard, mixnet_contract_address());
|
||||
let vesting = query_guard!(client_guard, vesting_contract_address());
|
||||
let service_provider = query_guard!(client_guard, service_provider_contract_address());
|
||||
let coconut_bandwidth = query_guard!(client_guard, coconut_bandwidth_contract_address());
|
||||
let coconut_dkg = query_guard!(client_guard, dkg_contract_address());
|
||||
let group = query_guard!(client_guard, group_contract_address());
|
||||
@@ -64,7 +62,6 @@ impl NymContractCacheRefresher {
|
||||
// get cw2 versions
|
||||
let mixnet_cw2_future = query_guard!(client_guard, get_mixnet_contract_cw2_version());
|
||||
let vesting_cw2_future = query_guard!(client_guard, get_vesting_contract_cw2_version());
|
||||
let service_provider_cw2_future = query_guard!(client_guard, get_sp_contract_cw2_version());
|
||||
|
||||
// group and multisig contract save that information in their storage but don't expose it via queries
|
||||
// so a temporary workaround...
|
||||
@@ -93,38 +90,17 @@ impl NymContractCacheRefresher {
|
||||
None
|
||||
};
|
||||
|
||||
let mut cw2_info = join_all(vec![
|
||||
mixnet_cw2_future,
|
||||
vesting_cw2_future,
|
||||
service_provider_cw2_future,
|
||||
])
|
||||
.await;
|
||||
let mut cw2_info = join_all(vec![mixnet_cw2_future, vesting_cw2_future]).await;
|
||||
|
||||
// get detailed build info
|
||||
let mixnet_detailed_future = query_guard!(client_guard, get_mixnet_contract_version());
|
||||
let vesting_detailed_future = query_guard!(client_guard, get_vesting_contract_version());
|
||||
let service_provider_detailed_future =
|
||||
query_guard!(client_guard, get_sp_contract_version());
|
||||
|
||||
let mut build_info = join_all(vec![
|
||||
mixnet_detailed_future,
|
||||
vesting_detailed_future,
|
||||
service_provider_detailed_future,
|
||||
])
|
||||
.await;
|
||||
let mut build_info = join_all(vec![mixnet_detailed_future, vesting_detailed_future]).await;
|
||||
|
||||
// the below unwraps are fine as we definitely have the specified number of entries
|
||||
// Note to whoever updates this code in the future: `pop` removes **LAST** element,
|
||||
// so make sure you call them in correct order, depending on what's specified in the `join_all`
|
||||
updated.insert(
|
||||
"nym-service-provider-directory-contract".to_string(),
|
||||
CachedContractInfo::new(
|
||||
service_provider,
|
||||
cw2_info.pop().unwrap().ok(),
|
||||
build_info.pop().unwrap().ok(),
|
||||
),
|
||||
);
|
||||
|
||||
updated.insert(
|
||||
"nym-vesting-contract".to_string(),
|
||||
CachedContractInfo::new(
|
||||
@@ -176,8 +152,6 @@ impl NymContractCacheRefresher {
|
||||
let (rewarded_set, active_set) =
|
||||
Self::collect_rewarded_and_active_set_details(&mixnodes, &rewarded_set_map);
|
||||
|
||||
// The service providers and names are optional
|
||||
let services = self.nyxd_client.get_all_services().await.ok();
|
||||
let contract_info = self.get_nym_contracts_info().await?;
|
||||
|
||||
info!(
|
||||
@@ -195,7 +169,6 @@ impl NymContractCacheRefresher {
|
||||
rewarding_params,
|
||||
current_interval,
|
||||
mix_to_family,
|
||||
services,
|
||||
contract_info,
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -27,7 +27,6 @@ pub(crate) fn nym_contract_cache_routes(settings: &OpenApiSettings) -> (Vec<Rout
|
||||
routes::get_blacklisted_gateways,
|
||||
routes::get_interval_reward_params,
|
||||
routes::get_current_epoch,
|
||||
routes::get_services,
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ use nym_mixnet_contract_common::{
|
||||
mixnode::MixNodeDetails, reward_params::RewardingParams, GatewayBond, Interval, MixId,
|
||||
};
|
||||
|
||||
use nym_service_provider_directory_common::response::ServicesListResponse;
|
||||
use rocket::{serde::json::Json, State};
|
||||
use rocket_okapi::openapi;
|
||||
use std::collections::HashSet;
|
||||
@@ -126,10 +125,3 @@ pub async fn get_interval_reward_params(
|
||||
pub async fn get_current_epoch(cache: &State<NymContractCache>) -> Json<Option<Interval>> {
|
||||
Json(*cache.current_interval().await)
|
||||
}
|
||||
|
||||
#[openapi(tag = "contract-cache")]
|
||||
#[get("/services")]
|
||||
pub async fn get_services(cache: &State<NymContractCache>) -> Json<ServicesListResponse> {
|
||||
let services = cache.services().await.clone();
|
||||
Json(services.as_slice().into())
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ use nym_mixnet_contract_common::{
|
||||
CurrentIntervalResponse, EpochStatus, ExecuteMsg, GatewayBond, IdentityKey, LayerAssignment,
|
||||
MixId, RewardedSetNodeStatus,
|
||||
};
|
||||
use nym_service_provider_directory_common::msg::QueryMsg as SpQueryMsg;
|
||||
use nym_validator_client::nyxd::contract_traits::PagedDkgQueryClient;
|
||||
use nym_validator_client::nyxd::error::NyxdError;
|
||||
use nym_validator_client::nyxd::{
|
||||
@@ -38,7 +37,7 @@ use nym_validator_client::nyxd::{
|
||||
CoconutBandwidthQueryClient, DkgQueryClient, DkgSigningClient, GroupQueryClient,
|
||||
MixnetQueryClient, MixnetSigningClient, MultisigQueryClient, MultisigSigningClient,
|
||||
NymContractsProvider, PagedMixnetQueryClient, PagedMultisigQueryClient,
|
||||
PagedVestingQueryClient, SpDirectoryQueryClient,
|
||||
PagedVestingQueryClient,
|
||||
},
|
||||
cosmwasm_client::types::ExecuteResult,
|
||||
CosmWasmClient, Fee,
|
||||
@@ -600,16 +599,3 @@ impl DkgQueryClient for Client {
|
||||
nyxd_query!(self, query_dkg_contract(query).await)
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl SpDirectoryQueryClient for Client {
|
||||
async fn query_service_provider_contract<T>(
|
||||
&self,
|
||||
query: SpQueryMsg,
|
||||
) -> std::result::Result<T, NyxdError>
|
||||
where
|
||||
for<'a> T: Deserialize<'a>,
|
||||
{
|
||||
nyxd_query!(self, query_service_provider_contract(query).await)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user