Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/1.0.0 pre1 #931

Merged
merged 3 commits into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ contracts/mixnet/code_id
contracts/mixnet/Justfile
contracts/mixnet/Makefile
validator-config
*.patch
*.patch
validator-api-config.toml
15 changes: 9 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ default-members = [
"service-providers/network-requester",
"mixnode",
"validator-api",
"explorer-api",
]

exclude = ["explorer", "contracts", "tokenomics-py"]
2 changes: 1 addition & 1 deletion common/client-libs/validator-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ prost = { version = "0.9", default-features = false, optional = true }
flate2 = { version = "1.0.20", optional = true }
sha2 = { version = "0.9.5", optional = true }
itertools = { version = "0.10", optional = true }
cosmwasm-std = { git = "https://github.com/jstuczyn/cosmwasm", branch="0.14.1-updatedk256", optional = true }
cosmwasm-std = { version = "1.0.0-beta2", optional = true }
ts-rs = {version = "5.1", optional = true}

[features]
Expand Down
43 changes: 9 additions & 34 deletions common/client-libs/validator-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ use mixnet_contract::ContractSettingsParams;

use crate::{validator_api, ValidatorClientError};
use coconut_interface::{BlindSignRequestBody, BlindedSignatureResponse, VerificationKeyResponse};
use mixnet_contract::{GatewayBond, MixNodeBond};
use mixnet_contract::{Delegation, GatewayBond, MixNodeBond};
#[cfg(feature = "nymd-client")]
use mixnet_contract::{
MixnetContractVersion, MixnodeRewardingStatusResponse, RawDelegationData,
RewardingIntervalResponse,
MixnetContractVersion, MixnodeRewardingStatusResponse, RewardingIntervalResponse,
};
use url::Url;

Expand Down Expand Up @@ -312,9 +311,7 @@ impl<C> Client<C> {
Ok(delegations)
}

pub async fn get_all_nymd_mixnode_delegations(
&self,
) -> Result<Vec<mixnet_contract::UnpackedDelegation<RawDelegationData>>, ValidatorClientError>
pub async fn get_all_network_delegations(&self) -> Result<Vec<Delegation>, ValidatorClientError>
where
C: CosmWasmClient + Sync,
{
Expand All @@ -323,7 +320,7 @@ impl<C> Client<C> {
loop {
let mut paged_response = self
.nymd
.get_all_mix_delegations_paged(
.get_all_network_delegations_paged(
start_after.take(),
self.mixnode_delegations_page_limit,
)
Expand All @@ -340,10 +337,10 @@ impl<C> Client<C> {
Ok(delegations)
}

pub async fn get_all_nymd_reverse_mixnode_delegations(
pub async fn get_all_delegator_delegations(
&self,
delegation_owner: &cosmrs::AccountId,
) -> Result<Vec<mixnet_contract::IdentityKey>, ValidatorClientError>
) -> Result<Vec<Delegation>, ValidatorClientError>
where
C: CosmWasmClient + Sync,
{
Expand All @@ -352,13 +349,13 @@ impl<C> Client<C> {
loop {
let mut paged_response = self
.nymd
.get_reverse_mix_delegations_paged(
mixnet_contract::Addr::unchecked(delegation_owner.as_ref()),
.get_delegator_delegations_paged(
delegation_owner.to_string(),
start_after.take(),
self.mixnode_delegations_page_limit,
)
.await?;
delegations.append(&mut paged_response.delegated_nodes);
delegations.append(&mut paged_response.delegations);

if let Some(start_after_res) = paged_response.start_next_after {
start_after = Some(start_after_res)
Expand All @@ -370,28 +367,6 @@ impl<C> Client<C> {
Ok(delegations)
}

pub async fn get_all_nymd_mixnode_delegations_of_owner(
&self,
delegation_owner: &cosmrs::AccountId,
) -> Result<Vec<mixnet_contract::Delegation>, ValidatorClientError>
where
C: CosmWasmClient + Sync,
{
let mut delegations = Vec::new();
for node_identity in self
.get_all_nymd_reverse_mixnode_delegations(delegation_owner)
.await?
{
let delegation = self
.nymd
.get_mix_delegation(node_identity, delegation_owner)
.await?;
delegations.push(delegation);
}

Ok(delegations)
}

pub async fn blind_sign(
&self,
request_body: &BlindSignRequestBody,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub(crate) fn find_attribute<'a>(
) -> Option<&'a cosmwasm_std::Attribute> {
logs.iter()
.flat_map(|log| log.events.iter())
.find(|event| event.kind == event_type)?
.find(|event| event.ty == event_type)?
.attributes
.iter()
.find(|attr| attr.key == attribute_key)
Expand Down Expand Up @@ -61,7 +61,7 @@ mod tests {
assert_eq!(parsed.len(), 1);
assert_eq!(parsed[0].msg_index, 0);
assert_eq!(parsed[0].events.len(), 1);
assert_eq!(parsed[0].events[0].kind, "message");
assert_eq!(parsed[0].events[0].ty, "message");
assert_eq!(parsed[0].events[0].attributes[3].key, "code_id");
assert_eq!(parsed[0].events[0].attributes[3].value, "1");
}
Expand All @@ -76,12 +76,12 @@ mod tests {
assert_eq!(parsed[2].msg_index, 2);

assert_eq!(parsed[0].events.len(), 1);
assert_eq!(parsed[0].events[0].kind, "message");
assert_eq!(parsed[0].events[0].ty, "message");
assert_eq!(parsed[0].events[0].attributes[3].key, "code_id");
assert_eq!(parsed[0].events[0].attributes[3].value, "9");

assert_eq!(parsed[2].events.len(), 1);
assert_eq!(parsed[2].events[0].kind, "message");
assert_eq!(parsed[2].events[0].ty, "message");
assert_eq!(parsed[2].events[0].attributes[2].key, "signer");
assert_eq!(
parsed[2].events[0].attributes[2].value,
Expand Down
2 changes: 1 addition & 1 deletion common/client-libs/validator-client/src/nymd/gas_price.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl<'a> Mul<Gas> for &'a GasPrice {
// however, realistically that is impossible to happen as the resultant value
// would have to be way higher than our token limit of 10^15 (1 billion of tokens * 1 million for denomination)
// and max value of u128 is approximately 10^38
if limit_uint128.u128() * gas_price_numerator > amount.u128() * gas_price_denominator {
if limit_uint128 * gas_price_numerator > amount * gas_price_denominator {
amount += Uint128::new(1);
}

Expand Down
44 changes: 21 additions & 23 deletions common/client-libs/validator-client/src/nymd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ use cosmrs::rpc::endpoint::broadcast;
use cosmrs::rpc::{Error as TendermintRpcError, HttpClientUrl};
use cosmwasm_std::{Coin, Uint128};
use mixnet_contract::{
Addr, ContractSettingsParams, Delegation, ExecuteMsg, Gateway, GatewayOwnershipResponse,
IdentityKey, LayerDistribution, MixNode, MixOwnershipResponse, MixnetContractVersion,
MixnodeRewardingStatusResponse, PagedAllDelegationsResponse, PagedGatewayResponse,
PagedMixDelegationsResponse, PagedMixnodeResponse, PagedReverseMixDelegationsResponse,
QueryMsg, RawDelegationData, RewardingIntervalResponse,
ContractSettingsParams, Delegation, ExecuteMsg, Gateway, GatewayOwnershipResponse, IdentityKey,
LayerDistribution, MixNode, MixOwnershipResponse, MixnetContractVersion,
MixnodeRewardingStatusResponse, PagedAllDelegationsResponse, PagedDelegatorDelegationsResponse,
PagedGatewayResponse, PagedMixDelegationsResponse, PagedMixnodeResponse, QueryMsg,
RewardingIntervalResponse,
};
use serde::Serialize;
use std::collections::HashMap;
Expand Down Expand Up @@ -313,7 +313,7 @@ impl<C> NymdClient<C> {
C: CosmWasmClient + Sync,
{
let request = QueryMsg::OwnsMixnode {
address: Addr::unchecked(address.as_ref()),
address: address.to_string(),
};
let response: MixOwnershipResponse = self
.client
Expand All @@ -328,7 +328,7 @@ impl<C> NymdClient<C> {
C: CosmWasmClient + Sync,
{
let request = QueryMsg::OwnsGateway {
address: Addr::unchecked(address.as_ref()),
address: address.to_string(),
};
let response: GatewayOwnershipResponse = self
.client
Expand Down Expand Up @@ -375,14 +375,13 @@ impl<C> NymdClient<C> {
pub async fn get_mix_delegations_paged(
&self,
mix_identity: IdentityKey,
// I really hate mixing cosmwasm and cosmos-sdk types here...
start_after: Option<Addr>,
start_after: Option<String>,
page_limit: Option<u32>,
) -> Result<PagedMixDelegationsResponse, NymdError>
where
C: CosmWasmClient + Sync,
{
let request = QueryMsg::GetMixDelegations {
let request = QueryMsg::GetMixnodeDelegations {
mix_identity: mix_identity.to_owned(),
start_after,
limit: page_limit,
Expand All @@ -393,16 +392,15 @@ impl<C> NymdClient<C> {
}

/// Gets list of all mixnode delegations on particular page.
pub async fn get_all_mix_delegations_paged(
pub async fn get_all_network_delegations_paged(
&self,
// I really hate mixing cosmwasm and cosmos-sdk types here...
start_after: Option<Vec<u8>>,
start_after: Option<(IdentityKey, String)>,
page_limit: Option<u32>,
) -> Result<PagedAllDelegationsResponse<RawDelegationData>, NymdError>
) -> Result<PagedAllDelegationsResponse, NymdError>
where
C: CosmWasmClient + Sync,
{
let request = QueryMsg::GetAllMixDelegations {
let request = QueryMsg::GetAllNetworkDelegations {
start_after,
limit: page_limit,
};
Expand All @@ -412,17 +410,17 @@ impl<C> NymdClient<C> {
}

/// Gets list of all the mixnodes on which a particular address delegated.
pub async fn get_reverse_mix_delegations_paged(
pub async fn get_delegator_delegations_paged(
&self,
delegation_owner: Addr,
delegator: String,
start_after: Option<IdentityKey>,
page_limit: Option<u32>,
) -> Result<PagedReverseMixDelegationsResponse, NymdError>
) -> Result<PagedDelegatorDelegationsResponse, NymdError>
where
C: CosmWasmClient + Sync,
{
let request = QueryMsg::GetReverseMixDelegations {
delegation_owner,
let request = QueryMsg::GetDelegatorDelegations {
delegator,
start_after,
limit: page_limit,
};
Expand All @@ -432,17 +430,17 @@ impl<C> NymdClient<C> {
}

/// Checks value of delegation of given client towards particular mixnode.
pub async fn get_mix_delegation(
pub async fn get_delegation_details(
&self,
mix_identity: IdentityKey,
delegator: &AccountId,
) -> Result<Delegation, NymdError>
where
C: CosmWasmClient + Sync,
{
let request = QueryMsg::GetMixDelegation {
let request = QueryMsg::GetDelegationDetails {
mix_identity,
address: Addr::unchecked(delegator.as_ref()),
delegator: delegator.to_string(),
};
self.client
.query_contract_smart(self.contract_address()?, &request)
Expand Down
4 changes: 1 addition & 3 deletions common/mixnet-contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
# this branch is identical to 0.14.1 with addition of updated k256 dependency required to help poor cargo choose correct version
cosmwasm-std = { git = "https://github.com/jstuczyn/cosmwasm", branch = "0.14.1-updatedk256" }
#cosmwasm-std = { version = "0.14.1" }
cosmwasm-std = "1.0.0-beta2"

serde = { version = "1.0", features = ["derive"] }
serde_repr = "0.1"
Expand Down