Merge branch 'release/v1.1.8' of github.com:nymtech/nym into release/v1.1.8

This commit is contained in:
farbanas
2023-01-31 14:05:53 +01:00
3 changed files with 31 additions and 17 deletions
+9 -6
View File
@@ -5,6 +5,7 @@ use crate::coconut::dkg::client::DkgClient;
use crate::coconut::dkg::complaints::ComplaintReason;
use crate::coconut::dkg::state::{ConsistentState, State};
use crate::coconut::error::CoconutError;
use crate::coconut::helpers::accepted_vote_err;
use coconut_dkg_common::event_attributes::DKG_PROPOSAL_ID;
use coconut_dkg_common::types::{NodeIndex, TOTAL_DEALINGS};
use coconut_dkg_common::verification_key::owner_from_cosmos_msgs;
@@ -203,21 +204,23 @@ pub(crate) async fn verification_key_validation(
.iter()
.position(|node_index| contract_share.node_index == *node_index)
{
if !check_vk_pairing(&params, &recovered_partials[idx], &vk) {
let ret = if !check_vk_pairing(&params, &recovered_partials[idx], &vk) {
dkg_client
.vote_verification_key_share(proposal_id, false)
.await?;
.await
} else {
dkg_client
.vote_verification_key_share(proposal_id, true)
.await?;
}
.await
};
accepted_vote_err(ret)?;
}
}
Err(_) => {
dkg_client
let ret = dkg_client
.vote_verification_key_share(proposal_id, false)
.await?
.await;
accepted_vote_err(ret)?;
}
}
}
+18
View File
@@ -0,0 +1,18 @@
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
use crate::coconut::error::CoconutError;
use validator_client::nyxd::error::NyxdError::AbciError;
// If the result is already established, the vote might be redundant and
// thus the transaction might fail
pub(crate) fn accepted_vote_err(ret: Result<(), CoconutError>) -> Result<(), CoconutError> {
if let Err(CoconutError::NyxdError(AbciError { ref log, .. })) = ret {
let accepted_err = multisig_contract_common::error::ContractError::NotOpen {}.to_string();
// If redundant voting is not the case, error out on all other error variants
if !log.value().contains(&accepted_err) {
ret?;
}
}
Ok(())
}
+4 -11
View File
@@ -5,6 +5,7 @@ use self::comm::APICommunicationChannel;
use crate::coconut::client::Client as LocalClient;
use crate::coconut::deposit::extract_encryption_key;
use crate::coconut::error::{CoconutError, Result};
use crate::coconut::helpers::accepted_vote_err;
use crate::support::storage::NymApiStorage;
use coconut_bandwidth_contract_common::spend_credential::{
funds_from_cosmos_msgs, SpendCredentialStatus,
@@ -33,7 +34,6 @@ use rocket::State as RocketState;
use std::sync::Arc;
use tokio::sync::Mutex;
use validator_client::nym_api::routes::{BANDWIDTH, COCONUT_ROUTES};
use validator_client::nyxd::error::NyxdError::AbciError;
use validator_client::nyxd::{Coin, Fee};
pub(crate) mod client;
@@ -41,6 +41,7 @@ pub(crate) mod comm;
mod deposit;
pub(crate) mod dkg;
pub(crate) mod error;
pub(crate) mod helpers;
pub(crate) mod keypair;
#[cfg(test)]
pub(crate) mod tests;
@@ -301,6 +302,7 @@ pub async fn verify_bandwidth_credential(
state.mix_denom.clone(),
);
// Vote yes or no on the proposal based on the verification result
let ret = state
.client
.vote_proposal(
@@ -313,16 +315,7 @@ pub async fn verify_bandwidth_credential(
)),
)
.await;
// Vote yes or no on the proposal based on the verification result
// If the result is already established, the vote might be redundant and
// thus the transaction might fail
if let Err(CoconutError::NyxdError(AbciError { ref log, .. })) = ret {
let accepted_err = multisig_contract_common::error::ContractError::NotOpen {}.to_string();
// If redundant voting is not the case, error out on all other error variants
if !log.value().contains(&accepted_err) {
ret?;
}
}
accepted_vote_err(ret)?;
Ok(Json(VerifyCredentialResponse::new(vote_yes)))
}