diff --git a/common/client-libs/validator-client/src/nyxd/contract_traits/dkg_query_client.rs b/common/client-libs/validator-client/src/nyxd/contract_traits/dkg_query_client.rs index fc6dcdb38a..5916718c03 100644 --- a/common/client-libs/validator-client/src/nyxd/contract_traits/dkg_query_client.rs +++ b/common/client-libs/validator-client/src/nyxd/contract_traits/dkg_query_client.rs @@ -7,17 +7,18 @@ use crate::nyxd::error::NyxdError; use crate::nyxd::CosmWasmClient; use async_trait::async_trait; use cosmrs::AccountId; +use nym_coconut_dkg_common::types::ChunkIndex; use serde::Deserialize; pub use nym_coconut_dkg_common::{ - dealer::{ - DealerDetailsResponse, DealingResponse, DealingStatusResponse, PagedDealerResponse, - PagedDealingsResponse, + dealer::{DealerDetailsResponse, PagedDealerResponse}, + dealing::{ + DealingChunkResponse, DealingChunkStatusResponse, DealingMetadataResponse, + DealingStatusResponse, }, msg::QueryMsg as DkgQueryMsg, types::{ - DealerDetails, DealingIndex, Epoch, EpochId, EpochState, InitialReplacementData, - PartialContractDealing, State, + DealerDetails, DealingIndex, Epoch, EpochId, EpochState, InitialReplacementData, State, }, verification_key::{ContractVKShare, PagedVKSharesResponse, VkShareResponse}, }; @@ -77,6 +78,21 @@ pub trait DkgQueryClient { self.query_dkg_contract(request).await } + async fn get_dealings_metadata( + &self, + epoch_id: EpochId, + dealer: String, + dealing_index: DealingIndex, + ) -> Result { + let request = DkgQueryMsg::GetDealingsMetadata { + epoch_id, + dealer, + dealing_index, + }; + + self.query_dkg_contract(request).await + } + async fn get_dealing_status( &self, epoch_id: EpochId, @@ -92,34 +108,37 @@ pub trait DkgQueryClient { self.query_dkg_contract(request).await } - async fn get_dealing( + async fn get_dealing_chunk_status( &self, epoch_id: EpochId, dealer: String, dealing_index: DealingIndex, - ) -> Result { - let request = DkgQueryMsg::GetDealing { + chunk_index: ChunkIndex, + ) -> Result { + let request = DkgQueryMsg::GetDealingChunkStatus { epoch_id, dealer, dealing_index, + chunk_index, }; self.query_dkg_contract(request).await } - async fn get_dealer_dealings_paged( + async fn get_dealing_chunk( &self, epoch_id: EpochId, - dealer: &str, - start_after: Option, - limit: Option, - ) -> Result { - let request = DkgQueryMsg::GetDealings { + dealer: String, + dealing_index: DealingIndex, + chunk_index: ChunkIndex, + ) -> Result { + let request = DkgQueryMsg::GetDealingChunk { epoch_id, - dealer: dealer.to_string(), - limit, - start_after, + dealer, + dealing_index, + chunk_index, }; + self.query_dkg_contract(request).await } @@ -165,14 +184,6 @@ pub trait PagedDkgQueryClient: DkgQueryClient { collect_paged!(self, get_past_dealers_paged, dealers) } - async fn get_all_dealer_dealings( - &self, - epoch_id: EpochId, - dealer: &str, - ) -> Result, NyxdError> { - collect_paged!(self, get_dealer_dealings_paged, dealings, epoch_id, dealer) - } - async fn get_all_verification_key_shares( &self, epoch_id: EpochId, @@ -236,18 +247,28 @@ mod tests { } => client .get_dealing_status(epoch_id, dealer, dealing_index) .ignore(), - DkgQueryMsg::GetDealing { + DkgQueryMsg::GetDealingsMetadata { epoch_id, dealer, dealing_index, - } => client.get_dealing(epoch_id, dealer, dealing_index).ignore(), - DkgQueryMsg::GetDealings { + } => client + .get_dealings_metadata(epoch_id, dealer, dealing_index) + .ignore(), + DkgQueryMsg::GetDealingChunkStatus { epoch_id, dealer, - limit, - start_after, + dealing_index, + chunk_index, } => client - .get_dealer_dealings_paged(epoch_id, &dealer, limit, start_after) + .get_dealing_chunk_status(epoch_id, dealer, dealing_index, chunk_index) + .ignore(), + DkgQueryMsg::GetDealingChunk { + epoch_id, + dealer, + dealing_index, + chunk_index, + } => client + .get_dealing_chunk(epoch_id, dealer, dealing_index, chunk_index) .ignore(), DkgQueryMsg::GetVerificationKey { epoch_id, owner } => { client.get_vk_share(epoch_id, owner).ignore() diff --git a/common/client-libs/validator-client/src/nyxd/contract_traits/dkg_signing_client.rs b/common/client-libs/validator-client/src/nyxd/contract_traits/dkg_signing_client.rs index 04007f6ec9..47b4a3d256 100644 --- a/common/client-libs/validator-client/src/nyxd/contract_traits/dkg_signing_client.rs +++ b/common/client-libs/validator-client/src/nyxd/contract_traits/dkg_signing_client.rs @@ -8,9 +8,9 @@ use crate::nyxd::{Coin, Fee, SigningCosmWasmClient}; use crate::signing::signer::OfflineSigner; use async_trait::async_trait; use cosmrs::AccountId; -use cosmwasm_std::Addr; +use nym_coconut_dkg_common::dealing::{DealingChunkInfo, PartialContractDealing}; use nym_coconut_dkg_common::msg::ExecuteMsg as DkgExecuteMsg; -use nym_coconut_dkg_common::types::{EncodedBTEPublicKeyWithProof, PartialContractDealing}; +use nym_coconut_dkg_common::types::{DealingIndex, EncodedBTEPublicKeyWithProof}; use nym_coconut_dkg_common::verification_key::VerificationKeyShare; use nym_contracts_common::IdentityKey; @@ -65,15 +65,32 @@ pub trait DkgSigningClient { .await } - async fn submit_dealing_bytes( + async fn submit_dealing_metadata( &self, - dealing: PartialContractDealing, + dealing_index: DealingIndex, + chunks: Vec, resharing: bool, fee: Option, ) -> Result { - let req = DkgExecuteMsg::CommitDealing { dealing, resharing }; + let req = DkgExecuteMsg::CommitDealingsMetadata { + dealing_index, + chunks, + resharing, + }; - self.execute_dkg_contract(fee, req, "dealing commitment".to_string(), vec![]) + self.execute_dkg_contract(fee, req, "dealing metadata commitment".to_string(), vec![]) + .await + } + + async fn submit_dealing_chunk( + &self, + chunk: PartialContractDealing, + resharing: bool, + fee: Option, + ) -> Result { + let req = DkgExecuteMsg::CommitDealingsChunk { chunk, resharing }; + + self.execute_dkg_contract(fee, req, "dealing chunk commitment".to_string(), vec![]) .await } @@ -100,9 +117,10 @@ pub trait DkgSigningClient { resharing: bool, fee: Option, ) -> Result { - // the call to unchecked is fine as we're converting from pre-validated `AccountId` - let owner = Addr::unchecked(owner.to_string()); - let req = DkgExecuteMsg::VerifyVerificationKeyShare { owner, resharing }; + let req = DkgExecuteMsg::VerifyVerificationKeyShare { + owner: owner.to_string(), + resharing, + }; self.execute_dkg_contract( fee, @@ -167,18 +185,21 @@ mod tests { None, ) .ignore(), - DkgExecuteMsg::CommitDealing { dealing, resharing } => client - .submit_dealing_bytes(dealing, resharing, None) + DkgExecuteMsg::CommitDealingsMetadata { + dealing_index, + chunks, + resharing, + } => client + .submit_dealing_metadata(dealing_index, chunks, resharing, None) .ignore(), + DkgExecuteMsg::CommitDealingsChunk { chunk, resharing } => { + client.submit_dealing_chunk(chunk, resharing, None).ignore() + } DkgExecuteMsg::CommitVerificationKeyShare { share, resharing } => client .submit_verification_key_share(share, resharing, None) .ignore(), DkgExecuteMsg::VerifyVerificationKeyShare { owner, resharing } => client - .verify_verification_key_share( - &owner.into_string().parse().unwrap(), - resharing, - None, - ) + .verify_verification_key_share(&owner.parse().unwrap(), resharing, None) .ignore(), DkgExecuteMsg::SurpassedThreshold {} => client.surpass_threshold(None).ignore(), DkgExecuteMsg::AdvanceEpochState {} => client.advance_dkg_epoch_state(None).ignore(),