diff --git a/packages/dapi-grpc/build.rs b/packages/dapi-grpc/build.rs
index 4bd36542e8..f70b685fbd 100644
--- a/packages/dapi-grpc/build.rs
+++ b/packages/dapi-grpc/build.rs
@@ -47,7 +47,7 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig {
// Derive features for versioned messages
//
// "GetConsensusParamsRequest" is excluded as this message does not support proofs
- const VERSIONED_REQUESTS: [&str; 29] = [
+ const VERSIONED_REQUESTS: [&str; 30] = [
"GetDataContractHistoryRequest",
"GetDataContractRequest",
"GetDataContractsRequest",
@@ -77,9 +77,13 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig {
"GetTotalCreditsInPlatformRequest",
"GetEvonodesProposedEpochBlocksByIdsRequest",
"GetEvonodesProposedEpochBlocksByRangeRequest",
+ "GetStatusRequest",
];
- // "GetConsensusParamsResponse" is excluded as this message does not support proofs
+ // The following responses are excluded as they don't support proofs:
+ // - "GetConsensusParamsResponse"
+ // - "GetStatusResponse"
+ //
// "GetEvonodesProposedEpochBlocksResponse" is used for 2 Requests
const VERSIONED_RESPONSES: [&str; 29] = [
"GetDataContractHistoryResponse",
@@ -213,6 +217,7 @@ impl MappingConfig {
///
/// * `protobuf_file` - Path to the protobuf file to use as input.
/// * `out_dir` - Output directory where subdirectories for generated files will be created.
+ ///
/// Depending on the features, either `client`, `server` or `client_server` subdirectory
/// will be created inside `out_dir`.
fn new(protobuf_file: PathBuf, out_dir: PathBuf) -> Self {
diff --git a/packages/rs-dapi-client/src/address_list.rs b/packages/rs-dapi-client/src/address_list.rs
index ab4e2ba0eb..bf09b1af8c 100644
--- a/packages/rs-dapi-client/src/address_list.rs
+++ b/packages/rs-dapi-client/src/address_list.rs
@@ -85,7 +85,7 @@ pub enum AddressListError {
/// A structure to manage DAPI addresses to select from
/// for [DapiRequest](crate::DapiRequest) execution.
-#[derive(Debug)]
+#[derive(Debug, Clone)]
pub struct AddressList {
addresses: HashSet
,
base_ban_period: Duration,
@@ -221,3 +221,12 @@ impl FromIterator for AddressList {
address_list
}
}
+
+impl IntoIterator for AddressList {
+ type Item = Address;
+ type IntoIter = std::collections::hash_set::IntoIter;
+
+ fn into_iter(self) -> Self::IntoIter {
+ self.addresses.into_iter()
+ }
+}
diff --git a/packages/rs-dapi-client/src/dapi_client.rs b/packages/rs-dapi-client/src/dapi_client.rs
index 8e5a3d660b..17748ab2b0 100644
--- a/packages/rs-dapi-client/src/dapi_client.rs
+++ b/packages/rs-dapi-client/src/dapi_client.rs
@@ -112,6 +112,11 @@ impl DapiClient {
dump_dir: None,
}
}
+
+ /// Return the [DapiClient] address list.
+ pub fn address_list(&self) -> &Arc> {
+ &self.address_list
+ }
}
#[async_trait]
diff --git a/packages/rs-dapi-client/src/dump.rs b/packages/rs-dapi-client/src/dump.rs
index c81399395b..a1e23d1ff2 100644
--- a/packages/rs-dapi-client/src/dump.rs
+++ b/packages/rs-dapi-client/src/dump.rs
@@ -189,7 +189,6 @@ impl DapiClient {
response: &MockResult,
dump_dir: Option,
) where
- R: Mockable,
::Response: Mockable,
{
let path = match dump_dir {
diff --git a/packages/rs-dapi-client/src/lib.rs b/packages/rs-dapi-client/src/lib.rs
index e4f5836e29..976537097e 100644
--- a/packages/rs-dapi-client/src/lib.rs
+++ b/packages/rs-dapi-client/src/lib.rs
@@ -14,6 +14,7 @@ pub mod transport;
pub use address_list::Address;
pub use address_list::AddressList;
+pub use connection_pool::ConnectionPool;
pub use dapi_client::DapiRequestExecutor;
pub use dapi_client::{DapiClient, DapiClientError};
use dapi_grpc::mock::Mockable;
diff --git a/packages/rs-dapi-client/src/transport/grpc.rs b/packages/rs-dapi-client/src/transport/grpc.rs
index 4cfa0c2649..98976ed08e 100644
--- a/packages/rs-dapi-client/src/transport/grpc.rs
+++ b/packages/rs-dapi-client/src/transport/grpc.rs
@@ -421,3 +421,12 @@ impl_transport_request_grpc!(
},
subscribe_to_transactions_with_proofs
);
+
+// rpc getStatus(GetStatusRequest) returns (GetStatusResponse);
+impl_transport_request_grpc!(
+ platform_proto::GetStatusRequest,
+ platform_proto::GetStatusResponse,
+ PlatformGrpcClient,
+ RequestSettings::default(),
+ get_status
+);
diff --git a/packages/rs-drive-proof-verifier/src/proof.rs b/packages/rs-drive-proof-verifier/src/proof.rs
index 57dec66d31..89fef81360 100644
--- a/packages/rs-drive-proof-verifier/src/proof.rs
+++ b/packages/rs-drive-proof-verifier/src/proof.rs
@@ -2,13 +2,16 @@ use crate::from_request::TryFromRequest;
use crate::provider::DataContractProvider;
use crate::verify::verify_tenderdash_proof;
use crate::{types, types::*, ContextProvider, Error};
+use dapi_grpc::platform::v0::get_evonodes_proposed_epoch_blocks_by_range_request::get_evonodes_proposed_epoch_blocks_by_range_request_v0::Start;
use dapi_grpc::platform::v0::get_identities_contract_keys_request::GetIdentitiesContractKeysRequestV0;
use dapi_grpc::platform::v0::get_path_elements_request::GetPathElementsRequestV0;
use dapi_grpc::platform::v0::get_protocol_version_upgrade_vote_status_request::{
self, GetProtocolVersionUpgradeVoteStatusRequestV0,
};
use dapi_grpc::platform::v0::security_level_map::KeyKindRequestType as GrpcKeyKind;
-use dapi_grpc::platform::v0::{get_contested_resource_identity_votes_request, get_data_contract_history_request, get_data_contract_request, get_data_contracts_request, get_epochs_info_request, get_evonodes_proposed_epoch_blocks_by_ids_request, get_evonodes_proposed_epoch_blocks_by_range_request, get_identities_balances_request, get_identities_contract_keys_request, get_identity_balance_and_revision_request, get_identity_balance_request, get_identity_by_public_key_hash_request, get_identity_contract_nonce_request, get_identity_keys_request, get_identity_nonce_request, get_identity_request, get_path_elements_request, get_prefunded_specialized_balance_request, GetContestedResourceVotersForIdentityRequest, GetContestedResourceVotersForIdentityResponse, GetPathElementsRequest, GetPathElementsResponse, GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeStateResponse, GetProtocolVersionUpgradeVoteStatusRequest, GetProtocolVersionUpgradeVoteStatusResponse, Proof, ResponseMetadata};
+use dapi_grpc::platform::v0::{
+ get_contested_resource_identity_votes_request, get_data_contract_history_request, get_data_contract_request, get_data_contracts_request, get_epochs_info_request, get_evonodes_proposed_epoch_blocks_by_ids_request, get_evonodes_proposed_epoch_blocks_by_range_request, get_identities_balances_request, get_identities_contract_keys_request, get_identity_balance_and_revision_request, get_identity_balance_request, get_identity_by_public_key_hash_request, get_identity_contract_nonce_request, get_identity_keys_request, get_identity_nonce_request, get_identity_request, get_path_elements_request, get_prefunded_specialized_balance_request, GetContestedResourceVotersForIdentityRequest, GetContestedResourceVotersForIdentityResponse, GetPathElementsRequest, GetPathElementsResponse, GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeStateResponse, GetProtocolVersionUpgradeVoteStatusRequest, GetProtocolVersionUpgradeVoteStatusResponse, Proof, ResponseMetadata
+};
use dapi_grpc::platform::{
v0::{self as platform, key_request_type, KeyRequestType as GrpcKeyType},
VersionedGrpcResponse,
@@ -35,6 +38,7 @@ use drive::drive::identity::key::fetch::{
use drive::drive::Drive;
use drive::error::proof::ProofError;
use drive::query::contested_resource_votes_given_by_identity_query::ContestedResourceVotesGivenByIdentityQuery;
+use drive::query::proposer_block_count_query::ProposerQueryType;
use drive::query::vote_poll_contestant_votes_query::ContestedDocumentVotePollVotesDriveQuery;
use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQuery;
use drive::query::vote_polls_by_document_type_query::VotePollsByDocumentTypeQuery;
@@ -42,8 +46,6 @@ use drive::query::{DriveDocumentQuery, VotePollsByEndDateDriveQuery};
use std::array::TryFromSliceError;
use std::collections::BTreeMap;
use std::num::TryFromIntError;
-use dapi_grpc::platform::v0::get_evonodes_proposed_epoch_blocks_by_range_request::get_evonodes_proposed_epoch_blocks_by_range_request_v0::Start;
-use drive::query::proposer_block_count_query::ProposerQueryType;
/// Parse and verify the received proof and retrieve the requested object, if any.
///
@@ -78,7 +80,7 @@ pub trait FromProof {
///
/// * `Ok(Some(object, metadata))` when the requested object was found in the proof.
/// * `Ok(None)` when the requested object was not found in the proof; this can be interpreted as proof of non-existence.
- /// For collections, returns Ok(None) if none of the requested objects were found.
+ /// For collections, returns Ok(None) if none of the requested objects were found.
/// * `Err(Error)` when either the provided data is invalid or proof validation failed.
fn maybe_from_proof<'a, I: Into, O: Into>(
request: I,
@@ -108,7 +110,7 @@ pub trait FromProof {
///
/// * `Ok(Some((object, metadata)))` when the requested object was found in the proof.
/// * `Ok(None)` when the requested object was not found in the proof; this can be interpreted as proof of non-existence.
- /// For collections, returns Ok(None) if none of the requested objects were found.
+ /// For collections, returns Ok(None) if none of the requested objects were found.
/// * `Err(Error)` when either the provided data is invalid or proof validation failed.
fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>(
request: I,
@@ -1714,7 +1716,6 @@ impl FromProof for TotalCreditsInPla
))
}
}
-
impl FromProof for ProposerBlockCounts {
type Request = platform::GetEvonodesProposedEpochBlocksByIdsRequest;
type Response = platform::GetEvonodesProposedEpochBlocksResponse;
diff --git a/packages/rs-drive-proof-verifier/src/types.rs b/packages/rs-drive-proof-verifier/src/types.rs
index d28ba69302..d49301720b 100644
--- a/packages/rs-drive-proof-verifier/src/types.rs
+++ b/packages/rs-drive-proof-verifier/src/types.rs
@@ -5,6 +5,10 @@
//! In this case, the [FromProof](crate::FromProof) trait is implemented for dedicated object type
//! defined in this module.
+mod evonode_status;
+
+use dpp::block::block_info::BlockInfo;
+use dpp::core_types::validator_set::ValidatorSet;
use dpp::data_contract::document_type::DocumentType;
use dpp::fee::Credits;
use dpp::platform_value::Value;
@@ -13,6 +17,7 @@ use dpp::version::PlatformVersion;
pub use dpp::version::ProtocolVersionVoteCount;
use dpp::voting::contender_structs::{Contender, ContenderWithSerializedDocument};
use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice;
+use dpp::voting::vote_info_storage::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo;
use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll;
use dpp::voting::vote_polls::VotePoll;
use dpp::voting::votes::resource_vote::ResourceVote;
@@ -24,14 +29,10 @@ use dpp::{
prelude::{DataContract, Identifier, IdentityPublicKey, Revision},
util::deserializer::ProtocolVersion,
};
+use drive::grovedb::query_result_type::Path;
use drive::grovedb::Element;
use std::collections::{BTreeMap, BTreeSet};
-use dpp::block::block_info::BlockInfo;
-use dpp::core_types::validator_set::ValidatorSet;
-use dpp::dashcore::QuorumHash;
-use dpp::voting::vote_info_storage::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo;
-use drive::grovedb::query_result_type::Path;
#[cfg(feature = "mocks")]
use {
bincode::{Decode, Encode},
@@ -40,6 +41,8 @@ use {
platform_serialization_derive::{PlatformDeserialize, PlatformSerialize},
};
+pub use evonode_status::*;
+
/// A data structure that holds a set of objects of a generic type `O`, indexed by a key of type `K`.
///
/// This type is typically returned by functions that operate on multiple objects, such as fetching multiple objects
diff --git a/packages/rs-drive-proof-verifier/src/types/evonode_status.rs b/packages/rs-drive-proof-verifier/src/types/evonode_status.rs
new file mode 100644
index 0000000000..87831de0f6
--- /dev/null
+++ b/packages/rs-drive-proof-verifier/src/types/evonode_status.rs
@@ -0,0 +1,382 @@
+//! Status details of EvoNode, like version, current height, etc.
+
+use crate::Error;
+use dapi_grpc::platform::v0::{
+ get_status_response::{self},
+ GetStatusResponse,
+};
+
+#[cfg(feature = "mocks")]
+use {
+ bincode::{Decode, Encode},
+ dpp::{version as platform_version, ProtocolError},
+ platform_serialization_derive::{PlatformDeserialize, PlatformSerialize},
+};
+
+#[derive(Debug, Clone, Default)]
+#[cfg_attr(
+ feature = "mocks",
+ derive(Encode, Decode, PlatformSerialize, PlatformDeserialize),
+ platform_serialize(unversioned)
+)]
+/// The status of an EvoNode.
+pub struct EvoNodeStatus {
+ /// Information about protocol and software components versions.
+ pub version: Version,
+ /// Information about the node.
+ pub node: Node,
+ /// Layer 2 blockchain information
+ pub chain: Chain,
+ /// Node networking information.
+ pub network: Network,
+ /// Information about state synchronization progress.
+ pub state_sync: StateSync,
+ /// Information about current time used by the node.
+ pub time: Time,
+}
+#[derive(Debug, Clone, Default)]
+#[cfg_attr(
+ feature = "mocks",
+ derive(Encode, Decode, PlatformSerialize, PlatformDeserialize),
+ platform_serialize(unversioned)
+)]
+
+/// Information about protocol and software components versions.
+pub struct Version {
+ /// Information about software components versions.
+ pub software: Option,
+ /// Information about protocol version.
+ pub protocol: Option,
+}
+#[derive(Debug, Clone, Default)]
+#[cfg_attr(
+ feature = "mocks",
+ derive(Encode, Decode, PlatformSerialize, PlatformDeserialize),
+ platform_serialize(unversioned)
+)]
+/// Information about software components versions.
+pub struct Software {
+ /// DAPI version, semver-compatible string.
+ pub dapi: String,
+ /// Drive version, semver-compatible string.
+ pub drive: Option,
+ /// Tenderdash version, semver-compatible string.
+ pub tenderdash: Option,
+}
+#[derive(Debug, Clone, Default)]
+#[cfg_attr(
+ feature = "mocks",
+ derive(Encode, Decode, PlatformSerialize, PlatformDeserialize),
+ platform_serialize(unversioned)
+)]
+/// Information about protocol-level versions used by the node
+pub struct Protocol {
+ /// Tenderdash protocols version.
+ pub tenderdash: Option,
+ /// Drive protocols version.
+ pub drive: Option,
+}
+#[derive(Debug, Clone, Default)]
+#[cfg_attr(
+ feature = "mocks",
+ derive(Encode, Decode, PlatformSerialize, PlatformDeserialize),
+ platform_serialize(unversioned)
+)]
+/// Tenderdash protocol versions.
+pub struct TenderdashProtocol {
+ /// Tenderdash P2P protocol version.
+ pub p2p: u32,
+ /// Tenderdash block protocol version.
+ pub block: u32,
+}
+
+#[derive(Debug, Clone, Default)]
+#[cfg_attr(
+ feature = "mocks",
+ derive(Encode, Decode, PlatformSerialize, PlatformDeserialize),
+ platform_serialize(unversioned)
+)]
+
+/// Drive protocol versions.
+pub struct DriveProtocol {
+ /// Latest version supported by the node.
+ pub latest: u32,
+ /// Current version used by the node.
+ pub current: u32,
+}
+#[derive(Debug, Clone, Default)]
+#[cfg_attr(
+ feature = "mocks",
+ derive(Encode, Decode, PlatformSerialize, PlatformDeserialize),
+ platform_serialize(unversioned)
+)]
+
+/// Information about current time used by the node.
+pub struct Time {
+ /// Local time of the node. Unix timestamp since epoch.
+ pub local: u64,
+ /// Time of the last block. Unix timestamp since epoch.
+ pub block: Option,
+ /// Genesis time. Unix timestamp since epoch.
+ pub genesis: Option,
+ /// Epoch number
+ pub epoch: Option,
+}
+
+#[derive(Debug, Clone, Default)]
+#[cfg_attr(
+ feature = "mocks",
+ derive(Encode, Decode, PlatformSerialize, PlatformDeserialize),
+ platform_serialize(unversioned)
+)]
+
+/// Evo node identification information.
+pub struct Node {
+ /// Node ID
+ pub id: Vec,
+ /// ProTxHash of masternode; None for full nodes
+ pub pro_tx_hash: Option>,
+}
+#[derive(Debug, Clone, Default)]
+#[cfg_attr(
+ feature = "mocks",
+ derive(Encode, Decode, PlatformSerialize, PlatformDeserialize),
+ platform_serialize(unversioned)
+)]
+
+/// Layer 2 blockchain information
+pub struct Chain {
+ /// Whether the node is catching up with the network.
+ pub catching_up: bool,
+ /// Block hash of the latest block on the node.
+ pub latest_block_hash: Vec,
+ /// Latest app hash of the node, as visible in the latest block.
+ pub latest_app_hash: Vec,
+ /// Block hash of the earliest block available on the node.
+ pub earliest_block_hash: Vec,
+ /// Earliest app hash of the node, as visible in the earliest block.
+ pub earliest_app_hash: Vec,
+ /// Height of the latest block available on the node.
+ pub latest_block_height: u64,
+ /// Height of the earliest block available on the node.
+ pub earliest_block_height: u64,
+ /// Maximum block height of the peers connected to the node.
+ pub max_peer_block_height: u64,
+ /// Current core chain locked height.
+ pub core_chain_locked_height: Option,
+}
+#[derive(Debug, Clone, Default)]
+#[cfg_attr(
+ feature = "mocks",
+ derive(Encode, Decode, PlatformSerialize, PlatformDeserialize),
+ platform_serialize(unversioned)
+)]
+/// Node networking information.
+pub struct Network {
+ /// Identifier of chain the node is member of.
+ pub chain_id: String,
+ /// Number of peers in the address book.
+ pub peers_count: u32,
+ /// Whether the node is listening for incoming connections.
+ pub listening: bool,
+}
+
+#[derive(Debug, Clone, Default)]
+#[cfg_attr(
+ feature = "mocks",
+ derive(Encode, Decode, PlatformSerialize, PlatformDeserialize),
+ platform_serialize(unversioned)
+)]
+/// Information about state synchronization progress.
+pub struct StateSync {
+ /// Total time spent on state synchronization.
+ pub total_synced_time: u64,
+ /// Estimated remaining time to finish state synchronization.
+ pub remaining_time: u64,
+ /// Total number of snapshots available.
+ pub total_snapshots: u32,
+ /// Average time spent on processing a chunk of snapshot data.
+ pub chunk_process_avg_time: u64,
+ /// Height of the latest snapshot.
+ pub snapshot_height: u64,
+ /// Number of chunks in the latest snapshot.
+ pub snapshot_chunks_count: u64,
+ /// Number of backfilled blocks.
+ pub backfilled_blocks: u64,
+ /// Total number of blocks to backfill.
+ pub backfill_blocks_total: u64,
+}
+
+impl TryFrom for EvoNodeStatus {
+ type Error = Error;
+
+ fn try_from(response: GetStatusResponse) -> Result {
+ Ok(Self {
+ version: Version::try_from(&response)?,
+ node: Node::try_from(&response)?,
+ chain: Chain::try_from(&response)?,
+ network: Network::try_from(&response)?,
+ state_sync: StateSync::try_from(&response)?,
+ time: Time::try_from(&response)?,
+ })
+ }
+}
+
+impl TryFrom<&GetStatusResponse> for Version {
+ type Error = Error;
+
+ fn try_from(response: &GetStatusResponse) -> Result {
+ match &response.version {
+ Some(get_status_response::Version::V0(v0)) => {
+ let software = v0
+ .version
+ .as_ref()
+ .and_then(|v| v.software.clone())
+ .map(|s| Software {
+ dapi: s.dapi,
+ drive: s.drive,
+ tenderdash: s.tenderdash,
+ });
+
+ let protocol = v0
+ .version
+ .as_ref()
+ .and_then(|v| v.protocol.clone())
+ .map(|p| Protocol {
+ tenderdash: p.tenderdash.map(|t| TenderdashProtocol {
+ p2p: t.p2p,
+ block: t.block,
+ }),
+ drive: p.drive.map(|d| DriveProtocol {
+ latest: d.latest,
+ current: d.current,
+ }),
+ });
+
+ Ok(Self { software, protocol })
+ }
+ _ => Err(Error::EmptyVersion),
+ }
+ }
+}
+
+impl TryFrom<&GetStatusResponse> for Node {
+ type Error = Error;
+
+ fn try_from(response: &GetStatusResponse) -> Result {
+ match &response.version {
+ Some(get_status_response::Version::V0(v0)) => {
+ let node = v0
+ .node
+ .as_ref()
+ .map(|n| Self {
+ id: n.id.clone(),
+ pro_tx_hash: n.pro_tx_hash.clone(),
+ })
+ .unwrap_or_default();
+ Ok(node)
+ }
+ _ => Err(Error::EmptyVersion),
+ }
+ }
+}
+
+impl TryFrom<&GetStatusResponse> for Chain {
+ type Error = Error;
+
+ fn try_from(response: &GetStatusResponse) -> Result {
+ match &response.version {
+ Some(get_status_response::Version::V0(v0)) => {
+ let chain = v0
+ .chain
+ .as_ref()
+ .map(|c| Self {
+ catching_up: c.catching_up,
+ latest_block_hash: c.latest_block_hash.clone(),
+ latest_app_hash: c.latest_app_hash.clone(),
+ earliest_block_hash: c.earliest_block_hash.clone(),
+ earliest_app_hash: c.earliest_app_hash.clone(),
+ latest_block_height: c.latest_block_height,
+ earliest_block_height: c.earliest_block_height,
+ max_peer_block_height: c.max_peer_block_height,
+ core_chain_locked_height: c.core_chain_locked_height,
+ })
+ .unwrap_or_default();
+ Ok(chain)
+ }
+ _ => Err(Error::EmptyVersion),
+ }
+ }
+}
+
+impl TryFrom<&GetStatusResponse> for Network {
+ type Error = Error;
+
+ fn try_from(response: &GetStatusResponse) -> Result {
+ match &response.version {
+ Some(get_status_response::Version::V0(v0)) => {
+ let network = v0
+ .network
+ .as_ref()
+ .map(|n| Self {
+ chain_id: n.chain_id.clone(),
+ peers_count: n.peers_count,
+ listening: n.listening,
+ })
+ .unwrap_or_default();
+ Ok(network)
+ }
+ _ => Err(Error::EmptyVersion),
+ }
+ }
+}
+
+impl TryFrom<&GetStatusResponse> for StateSync {
+ type Error = Error;
+
+ fn try_from(response: &GetStatusResponse) -> Result {
+ match &response.version {
+ Some(get_status_response::Version::V0(v0)) => {
+ let state_sync = v0
+ .state_sync
+ .as_ref()
+ .map(|s| Self {
+ total_synced_time: s.total_synced_time,
+ remaining_time: s.remaining_time,
+ total_snapshots: s.total_snapshots,
+ chunk_process_avg_time: s.chunk_process_avg_time,
+ snapshot_height: s.snapshot_height,
+ snapshot_chunks_count: s.snapshot_chunks_count,
+ backfilled_blocks: s.backfilled_blocks,
+ backfill_blocks_total: s.backfill_blocks_total,
+ })
+ .unwrap_or_default();
+ Ok(state_sync)
+ }
+ _ => Err(Error::EmptyVersion),
+ }
+ }
+}
+
+impl TryFrom<&GetStatusResponse> for Time {
+ type Error = Error;
+
+ fn try_from(response: &GetStatusResponse) -> Result {
+ match &response.version {
+ Some(get_status_response::Version::V0(v0)) => {
+ let time = v0
+ .time
+ .as_ref()
+ .map(|t| Self {
+ local: t.local,
+ block: t.block,
+ genesis: t.genesis,
+ epoch: t.epoch,
+ })
+ .unwrap_or_default();
+ Ok(time)
+ }
+ _ => Err(Error::EmptyVersion),
+ }
+ }
+}
diff --git a/packages/rs-drive-proof-verifier/src/unproved.rs b/packages/rs-drive-proof-verifier/src/unproved.rs
index c2f30c6452..d9fd37009c 100644
--- a/packages/rs-drive-proof-verifier/src/unproved.rs
+++ b/packages/rs-drive-proof-verifier/src/unproved.rs
@@ -1,7 +1,8 @@
-use crate::types::CurrentQuorumsInfo;
+use crate::types::{CurrentQuorumsInfo, EvoNodeStatus};
use crate::Error;
use dapi_grpc::platform::v0::ResponseMetadata;
use dapi_grpc::platform::v0::{self as platform};
+use dapi_grpc::tonic::async_trait;
use dpp::bls_signatures::PublicKey as BlsPublicKey;
use dpp::core_types::validator::v0::ValidatorV0;
use dpp::core_types::validator_set::v0::ValidatorSetV0;
@@ -273,3 +274,23 @@ impl FromUnproved for CurrentQuorumsInfo
Ok((Some(info), metadata))
}
}
+
+#[async_trait]
+impl FromUnproved for EvoNodeStatus {
+ type Request = platform::GetStatusRequest;
+ type Response = platform::GetStatusResponse;
+
+ fn maybe_from_unproved_with_metadata, O: Into>(
+ _request: I,
+ response: O,
+ _network: Network,
+ _platform_version: &PlatformVersion,
+ ) -> Result<(Option, ResponseMetadata), Error>
+ where
+ Self: Sized,
+ {
+ let status = Self::try_from(response.into())?;
+ // we use default response metadata, as this request does not return any metadata
+ Ok((Some(status), Default::default()))
+ }
+}
diff --git a/packages/rs-sdk/Cargo.toml b/packages/rs-sdk/Cargo.toml
index 8934df17dc..b2efa71805 100644
--- a/packages/rs-sdk/Cargo.toml
+++ b/packages/rs-sdk/Cargo.toml
@@ -26,7 +26,7 @@ serde = { version = "1.0.197", default-features = false, features = [
], optional = true }
serde_json = { version = "1.0", features = ["preserve_order"], optional = true }
tracing = { version = "0.1.40" }
-hex = { version = "0.4.3"}
+hex = { version = "0.4.3" }
dotenvy = { version = "0.15.7", optional = true }
envy = { version = "0.4.2", optional = true }
futures = { version = "0.3.30" }
diff --git a/packages/rs-sdk/README.md b/packages/rs-sdk/README.md
index 4d543c5857..c14b9bbd59 100644
--- a/packages/rs-sdk/README.md
+++ b/packages/rs-sdk/README.md
@@ -97,9 +97,9 @@ Run the offline test using the following command:
cargo test -p dash-platform-sdk
```
-## Implementing Fetch and FetchAny on new objects
+## Implementing Fetch and FetchMany on new objects
-How to implement `Fetch` and `FetchAny` trait on new object types (`Object`).
+How to implement `Fetch` and `FetchMany` trait on new object types (`Object`).
It's basically copy-paste and tweaking of existing implementation for another object type.
@@ -114,7 +114,7 @@ Definitions:
Checklist:
1. [ ] Ensure protobuf messages are defined in `packages/dapi-grpc/protos/platform/v0/platform.proto` and generated
- correctly in `packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs`.
+ correctly in `packages/dapi-grpc/src/platform/client/org.dash.platform.dapi.v0.rs`.
2. [ ] In `packages/dapi-grpc/build.rs`, add `Request` to `VERSIONED_REQUESTS` and response `Response` to `VERSIONED_RESPONSES`.
This should add derive of `VersionedGrpcMessage` (and some more) in `org.dash.platform.dapi.v0.rs`.
3. [ ] Link request and response type to dapi-client by adding appropriate invocation of `impl_transport_request_grpc!` macro
@@ -123,7 +123,7 @@ in `packages/rs-dapi-client/src/transport/grpc.rs`.
used internally.
If you intend to implement `FetchMany`, you should define type returned by `fetch_many()` using `RetrievedObjects`
- that will store collection of returned objects, indexd by some key.
+ that will store collection of returned objects, indexed by some key.
5. [ ] Implement `FromProof` trait for the `Object` (or type defined in `types.rs`) in `packages/rs-drive-proof-verifier/src/proof.rs`.
6. [ ] Implement `Query` trait for the `Request` in `packages/rs-sdk/src/platform/query.rs`.
7. [ ] Implement `Fetch` trait for the `Object` (or type defined in `types.rs`), with inner type Request = `Request`,
diff --git a/packages/rs-sdk/src/lib.rs b/packages/rs-sdk/src/lib.rs
index e09eb4d3bb..d165a211a5 100644
--- a/packages/rs-sdk/src/lib.rs
+++ b/packages/rs-sdk/src/lib.rs
@@ -32,8 +32,8 @@
//!
//! 1. [`Identifier`](crate::platform::Identifier) - fetches an object by its identifier
//! 2. [`DocumentQuery`](crate::platform::DocumentQuery) - fetches documents based on search conditions; see
-//! [query syntax documentation](https://docs.dash.org/projects/platform/en/stable/docs/reference/query-syntax.html)
-//! for more details.
+//! [query syntax documentation](https://docs.dash.org/projects/platform/en/stable/docs/reference/query-syntax.html)
+//! for more details.
//! 3. [`DriveQuery`](crate::platform::DriveDocumentQuery) - can be used to build more complex queries
//!
//! ## Testability
diff --git a/packages/rs-sdk/src/mock.rs b/packages/rs-sdk/src/mock.rs
index b3f1b69c63..7ad4dc7ccd 100644
--- a/packages/rs-sdk/src/mock.rs
+++ b/packages/rs-sdk/src/mock.rs
@@ -32,7 +32,6 @@ pub mod sdk;
// Otherwise dapi_grpc_macros::Mockable fails.
// TODO: move Mockable to some crate that can be shared between dapi-grpc, rs-dapi-client, and dash-sdk
pub use dapi_grpc::mock::Mockable;
-
// MockResponse is needed even if mocks feature is disabled - it just does nothing.
#[cfg(not(feature = "mocks"))]
pub use noop::MockResponse;
diff --git a/packages/rs-sdk/src/mock/requests.rs b/packages/rs-sdk/src/mock/requests.rs
index 879fe88bb4..d29e48d410 100644
--- a/packages/rs-sdk/src/mock/requests.rs
+++ b/packages/rs-sdk/src/mock/requests.rs
@@ -15,9 +15,10 @@ use dpp::{
voting::votes::{resource_vote::ResourceVote, Vote},
};
use drive_proof_verifier::types::{
- Contenders, ContestedResources, ElementFetchRequestItem, IdentityBalanceAndRevision,
- MasternodeProtocolVote, PrefundedSpecializedBalance, ProposerBlockCounts,
- RetrievedIntegerValue, TotalCreditsInPlatform, VotePollsGroupedByTimestamp, Voters,
+ Contenders, ContestedResources, CurrentQuorumsInfo, ElementFetchRequestItem, EvoNodeStatus,
+ IdentityBalanceAndRevision, MasternodeProtocolVote, PrefundedSpecializedBalance,
+ ProposerBlockCounts, RetrievedIntegerValue, TotalCreditsInPlatform,
+ VotePollsGroupedByTimestamp, Voters,
};
use std::collections::BTreeMap;
@@ -243,3 +244,5 @@ impl_mock_response!(VotePollsGroupedByTimestamp);
impl_mock_response!(PrefundedSpecializedBalance);
impl_mock_response!(TotalCreditsInPlatform);
impl_mock_response!(ElementFetchRequestItem);
+impl_mock_response!(EvoNodeStatus);
+impl_mock_response!(CurrentQuorumsInfo);
diff --git a/packages/rs-sdk/src/mock/sdk.rs b/packages/rs-sdk/src/mock/sdk.rs
index 0f37c7dd36..02258c0cd1 100644
--- a/packages/rs-sdk/src/mock/sdk.rs
+++ b/packages/rs-sdk/src/mock/sdk.rs
@@ -2,7 +2,10 @@
//!
//! See [MockDashPlatformSdk] for more details.
use crate::{
- platform::{types::identity::IdentityRequest, DocumentQuery, Fetch, FetchMany, Query},
+ platform::{
+ types::{evonode::EvoNode, identity::IdentityRequest},
+ DocumentQuery, Fetch, FetchMany, Query,
+ },
Error, Sdk,
};
use arc_swap::ArcSwapOption;
@@ -201,9 +204,10 @@ impl MockDashPlatformSdk {
self.load_expectation::(filename)
.await?
}
+ "EvoNode" => self.load_expectation::(filename).await?,
_ => {
return Err(Error::Config(format!(
- "unknown request type {} in {}",
+ "unknown request type {} in {}, missing match arm in load_expectations?",
request_type,
filename.display()
)))
diff --git a/packages/rs-sdk/src/platform.rs b/packages/rs-sdk/src/platform.rs
index aab3d2153a..a4c0fb83f4 100644
--- a/packages/rs-sdk/src/platform.rs
+++ b/packages/rs-sdk/src/platform.rs
@@ -32,5 +32,6 @@ pub use {
document_query::DocumentQuery,
fetch::Fetch,
fetch_many::FetchMany,
+ fetch_unproved::FetchUnproved,
query::{LimitQuery, Query, QueryStartInfo, DEFAULT_EPOCH_QUERY_LIMIT},
};
diff --git a/packages/rs-sdk/src/platform/fetch_unproved.rs b/packages/rs-sdk/src/platform/fetch_unproved.rs
index d25fc86b50..9e89ad163a 100644
--- a/packages/rs-sdk/src/platform/fetch_unproved.rs
+++ b/packages/rs-sdk/src/platform/fetch_unproved.rs
@@ -1,8 +1,12 @@
+use super::{types::evonode::EvoNode, Query};
use crate::error::Error;
-use crate::platform::proto;
+use crate::mock::MockResponse;
use crate::Sdk;
-use dapi_grpc::platform::v0::get_current_quorums_info_request::GetCurrentQuorumsInfoRequestV0;
-use dapi_grpc::platform::v0::{self as platform_proto};
+use dapi_grpc::platform::v0::{
+ self as platform_proto, GetStatusRequest, GetStatusResponse, ResponseMetadata,
+};
+use dpp::{dashcore::Network, version::PlatformVersion};
+use drive_proof_verifier::types::EvoNodeStatus;
use drive_proof_verifier::unproved::FromUnproved;
use rs_dapi_client::{transport::TransportRequest, DapiRequest, RequestSettings};
use std::fmt::Debug;
@@ -10,7 +14,7 @@ use std::fmt::Debug;
#[async_trait::async_trait]
pub trait FetchUnproved
where
- Self: Sized + Debug,
+ Self: Sized + Debug + MockResponse,
{
/// Type of request used to fetch data from Platform.
type Request: TransportRequest;
@@ -19,20 +23,34 @@ where
///
/// ## Parameters
/// - `sdk`: An instance of [Sdk].
+ /// - `query`: Query used to fetch data from the Platform.
///
/// ## Returns
/// Returns:
/// * `Ok(Some(Self))` when object is found.
/// * `Ok(None)` when object is not found.
/// * [`Err(Error)`](Error) when an error occurs.
- async fn fetch_unproved(sdk: &Sdk) -> Result