From ea2a5adf9c6bd62b405982fddf8b5683977e1c8a Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 2 Aug 2024 05:05:05 +0700 Subject: [PATCH 01/33] start work --- packages/dapi-grpc/build.rs | 6 +- .../protos/platform/v0/platform.proto | 25 +++++ packages/rs-dapi-client/src/transport/grpc.rs | 19 ++++ packages/rs-drive-abci/src/query/service.rs | 32 ++----- .../rs-drive-abci/src/query/system/mod.rs | 1 + .../system/total_credits_in_platform/mod.rs | 54 +++++++++++ .../total_credits_in_platform/v0/mod.rs | 93 +++++++++++++++++++ packages/rs-drive-proof-verifier/src/proof.rs | 35 ++++++- packages/rs-drive-proof-verifier/src/types.rs | 34 ++++++- packages/rs-drive/src/drive/balances/mod.rs | 15 +++ packages/rs-drive/src/drive/mod.rs | 4 +- packages/rs-drive/src/drive/system/mod.rs | 4 +- packages/rs-drive/src/verify/system/mod.rs | 1 + .../src/verify/system/verify_elements/mod.rs | 4 +- .../verify/system/verify_elements/v0/mod.rs | 2 +- .../verify_total_credits_in_system/mod.rs | 41 ++++++++ .../verify_total_credits_in_system/v0/mod.rs | 60 ++++++++++++ .../src/version/drive_abci_versions.rs | 1 + .../src/version/drive_versions.rs | 1 + .../src/version/mocks/v2_test.rs | 6 ++ .../src/version/mocks/v3_test.rs | 6 ++ .../rs-platform-version/src/version/v1.rs | 6 ++ packages/rs-sdk/src/mock/requests.rs | 10 +- packages/rs-sdk/src/mock/sdk.rs | 8 ++ packages/rs-sdk/src/platform/fetch.rs | 4 + packages/rs-sdk/src/platform/fetch_many.rs | 10 +- packages/rs-sdk/src/platform/query.rs | 47 ++++++++-- .../rs-sdk/src/platform/types/identity.rs | 9 +- 28 files changed, 479 insertions(+), 59 deletions(-) create mode 100644 packages/rs-drive-abci/src/query/system/total_credits_in_platform/mod.rs create mode 100644 packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs create mode 100644 packages/rs-drive/src/verify/system/verify_total_credits_in_system/mod.rs create mode 100644 packages/rs-drive/src/verify/system/verify_total_credits_in_system/v0/mod.rs diff --git a/packages/dapi-grpc/build.rs b/packages/dapi-grpc/build.rs index 6392c84e38..0b613a8c12 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; 25] = [ + const VERSIONED_REQUESTS: [&str; 26] = [ "GetDataContractHistoryRequest", "GetDataContractRequest", "GetDataContractsRequest", @@ -73,10 +73,11 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig { "GetContestedResourceVotersForIdentityRequest", "GetContestedResourceIdentityVotesRequest", "GetVotePollsByEndDateRequest", + "GetTotalCreditsInPlatformRequest", ]; // "GetConsensusParamsResponse" is excluded as this message does not support proofs - const VERSIONED_RESPONSES: [&str; 26] = [ + const VERSIONED_RESPONSES: [&str; 27] = [ "GetDataContractHistoryResponse", "GetDataContractResponse", "GetDataContractsResponse", @@ -103,6 +104,7 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig { "GetContestedResourceVotersForIdentityResponse", "GetContestedResourceIdentityVotesResponse", "GetVotePollsByEndDateResponse", + "GetTotalCreditsInPlatformResponse", ]; check_unique(&VERSIONED_REQUESTS).expect("VERSIONED_REQUESTS"); diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index cf17a805fb..ca940cf221 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -45,6 +45,7 @@ service Platform { // What vote polls will end soon? rpc getVotePollsByEndDate(GetVotePollsByEndDateRequest) returns (GetVotePollsByEndDateResponse); rpc getPrefundedSpecializedBalance(GetPrefundedSpecializedBalanceRequest) returns (GetPrefundedSpecializedBalanceResponse); + rpc getTotalCreditsInPlatform(GetTotalCreditsInPlatformRequest) returns (GetTotalCreditsInPlatformResponse); rpc getPathElements(GetPathElementsRequest) returns (GetPathElementsResponse); } @@ -945,6 +946,30 @@ message GetPrefundedSpecializedBalanceResponse { oneof version { GetPrefundedSpecializedBalanceResponseV0 v0 = 1; } } +message GetTotalCreditsInPlatformRequest { + message GetTotalCreditsInPlatformRequestV0 { + bool prove = 1; + } + + oneof version { + GetTotalCreditsInPlatformRequestV0 v0 = 1; + } +} + +message GetTotalCreditsInPlatformResponse { + message GetTotalCreditsInPlatformResponseV0 { + oneof result { + uint64 credits = 1; + + Proof proof = 2; + } + ResponseMetadata metadata = 3; + } + + oneof version { + GetTotalCreditsInPlatformResponseV0 v0 = 1; + } +} message GetPathElementsRequest { message GetPathElementsRequestV0 { diff --git a/packages/rs-dapi-client/src/transport/grpc.rs b/packages/rs-dapi-client/src/transport/grpc.rs index 316be9cc11..6f720c1615 100644 --- a/packages/rs-dapi-client/src/transport/grpc.rs +++ b/packages/rs-dapi-client/src/transport/grpc.rs @@ -333,6 +333,25 @@ impl_transport_request_grpc!( get_prefunded_specialized_balance ); +// rpc getPathElements(GetPathElementsRequest) returns (GetPathElementsResponse); +impl_transport_request_grpc!( + platform_proto::GetPathElementsRequest, + platform_proto::GetPathElementsResponse, + PlatformGrpcClient, + RequestSettings::default(), + get_path_elements +); + +// rpc getTotalCreditsInPlatform(GetTotalCreditsInPlatformRequest) returns (GetTotalCreditsInPlatformResponse); +impl_transport_request_grpc!( + platform_proto::GetTotalCreditsInPlatformRequest, + platform_proto::GetTotalCreditsInPlatformResponse, + PlatformGrpcClient, + RequestSettings::default(), + get_total_credits_in_platform +); + + // Link to each core gRPC request what client and method to use: impl_transport_request_grpc!( diff --git a/packages/rs-drive-abci/src/query/service.rs b/packages/rs-drive-abci/src/query/service.rs index 3c7b147ea0..1d12ed90e8 100644 --- a/packages/rs-drive-abci/src/query/service.rs +++ b/packages/rs-drive-abci/src/query/service.rs @@ -9,28 +9,7 @@ use crate::rpc::core::DefaultCoreRPC; use crate::utils::spawn_blocking_task_with_name_if_supported; use async_trait::async_trait; use dapi_grpc::platform::v0::platform_server::Platform as PlatformService; -use dapi_grpc::platform::v0::{ - BroadcastStateTransitionRequest, BroadcastStateTransitionResponse, GetConsensusParamsRequest, - GetConsensusParamsResponse, GetContestedResourceIdentityVotesRequest, - GetContestedResourceIdentityVotesResponse, GetContestedResourceVoteStateRequest, - GetContestedResourceVoteStateResponse, GetContestedResourceVotersForIdentityRequest, - GetContestedResourceVotersForIdentityResponse, GetContestedResourcesRequest, - GetContestedResourcesResponse, GetDataContractHistoryRequest, GetDataContractHistoryResponse, - GetDataContractRequest, GetDataContractResponse, GetDataContractsRequest, - GetDataContractsResponse, GetDocumentsRequest, GetDocumentsResponse, GetEpochsInfoRequest, - GetEpochsInfoResponse, GetIdentitiesContractKeysRequest, GetIdentitiesContractKeysResponse, - GetIdentityBalanceAndRevisionRequest, GetIdentityBalanceAndRevisionResponse, - GetIdentityBalanceRequest, GetIdentityBalanceResponse, GetIdentityByPublicKeyHashRequest, - GetIdentityByPublicKeyHashResponse, GetIdentityContractNonceRequest, - GetIdentityContractNonceResponse, GetIdentityKeysRequest, GetIdentityKeysResponse, - GetIdentityNonceRequest, GetIdentityNonceResponse, GetIdentityRequest, GetIdentityResponse, - GetPathElementsRequest, GetPathElementsResponse, GetPrefundedSpecializedBalanceRequest, - GetPrefundedSpecializedBalanceResponse, GetProofsRequest, GetProofsResponse, - GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeStateResponse, - GetProtocolVersionUpgradeVoteStatusRequest, GetProtocolVersionUpgradeVoteStatusResponse, - GetVotePollsByEndDateRequest, GetVotePollsByEndDateResponse, - WaitForStateTransitionResultRequest, WaitForStateTransitionResultResponse, -}; +use dapi_grpc::platform::v0::{BroadcastStateTransitionRequest, BroadcastStateTransitionResponse, GetConsensusParamsRequest, GetConsensusParamsResponse, GetContestedResourceIdentityVotesRequest, GetContestedResourceIdentityVotesResponse, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, GetContestedResourceVotersForIdentityRequest, GetContestedResourceVotersForIdentityResponse, GetContestedResourcesRequest, GetContestedResourcesResponse, GetDataContractHistoryRequest, GetDataContractHistoryResponse, GetDataContractRequest, GetDataContractResponse, GetDataContractsRequest, GetDataContractsResponse, GetDocumentsRequest, GetDocumentsResponse, GetEpochsInfoRequest, GetEpochsInfoResponse, GetIdentitiesContractKeysRequest, GetIdentitiesContractKeysResponse, GetIdentityBalanceAndRevisionRequest, GetIdentityBalanceAndRevisionResponse, GetIdentityBalanceRequest, GetIdentityBalanceResponse, GetIdentityByPublicKeyHashRequest, GetIdentityByPublicKeyHashResponse, GetIdentityContractNonceRequest, GetIdentityContractNonceResponse, GetIdentityKeysRequest, GetIdentityKeysResponse, GetIdentityNonceRequest, GetIdentityNonceResponse, GetIdentityRequest, GetIdentityResponse, GetPathElementsRequest, GetPathElementsResponse, GetPrefundedSpecializedBalanceRequest, GetPrefundedSpecializedBalanceResponse, GetProofsRequest, GetProofsResponse, GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeStateResponse, GetProtocolVersionUpgradeVoteStatusRequest, GetProtocolVersionUpgradeVoteStatusResponse, GetVotePollsByEndDateRequest, GetVotePollsByEndDateResponse, WaitForStateTransitionResultRequest, WaitForStateTransitionResultResponse, GetTotalCreditsInPlatformRequest, GetTotalCreditsInPlatformResponse}; use dapi_grpc::tonic::{Code, Request, Response, Status}; use dpp::version::PlatformVersion; use std::fmt::Debug; @@ -532,6 +511,15 @@ impl PlatformService for QueryService { ) .await } + + async fn get_total_credits_in_platform(&self, request: Request) -> Result, Status> { + self.handle_blocking_query( + request, + Platform::::query_total_credits_in_platform, + "get_total_credits_in_platform", + ) + .await + } } fn query_error_into_status(error: QueryError) -> Status { diff --git a/packages/rs-drive-abci/src/query/system/mod.rs b/packages/rs-drive-abci/src/query/system/mod.rs index 939d80f519..97d1890733 100644 --- a/packages/rs-drive-abci/src/query/system/mod.rs +++ b/packages/rs-drive-abci/src/query/system/mod.rs @@ -2,3 +2,4 @@ mod epoch_infos; mod path_elements; mod version_upgrade_state; mod version_upgrade_vote_status; +mod total_credits_in_platform; diff --git a/packages/rs-drive-abci/src/query/system/total_credits_in_platform/mod.rs b/packages/rs-drive-abci/src/query/system/total_credits_in_platform/mod.rs new file mode 100644 index 0000000000..d3a8af88d4 --- /dev/null +++ b/packages/rs-drive-abci/src/query/system/total_credits_in_platform/mod.rs @@ -0,0 +1,54 @@ +mod v0; + +use crate::error::query::QueryError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::platform_types::platform_state::PlatformState; +use crate::query::QueryValidationResult; +use dapi_grpc::platform::v0::get_total_credits_in_platform_request::Version as RequestVersion; +use dapi_grpc::platform::v0::get_total_credits_in_platform_response::Version as ResponseVersion; +use dapi_grpc::platform::v0::{GetTotalCreditsInPlatformRequest, GetTotalCreditsInPlatformResponse}; +use dpp::version::PlatformVersion; + +impl Platform { + /// Querying the total credits in platform + pub fn query_total_credits_in_platform( + &self, + GetTotalCreditsInPlatformRequest { version }: GetTotalCreditsInPlatformRequest, + platform_state: &PlatformState, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let Some(version) = version else { + return Ok(QueryValidationResult::new_with_error( + QueryError::DecodingError("could not decode epoch info request".to_string()), + )); + }; + + let feature_version_bounds = &platform_version.drive_abci.query.system.total_credits_in_platform; + + let feature_version = match &version { + RequestVersion::V0(_) => 0, + }; + if !feature_version_bounds.check_version(feature_version) { + return Ok(QueryValidationResult::new_with_error( + QueryError::UnsupportedQueryVersion( + "total_credits_in_platform".to_string(), + feature_version_bounds.min_version, + feature_version_bounds.max_version, + platform_version.protocol_version, + feature_version, + ), + )); + } + match version { + RequestVersion::V0(request_v0) => { + let result = + self.query_total_credits_in_platform_v0(request_v0, platform_state, platform_version)?; + + Ok(result.map(|response_v0| GetTotalCreditsInPlatformResponse { + version: Some(ResponseVersion::V0(response_v0)), + })) + } + } + } +} diff --git a/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs b/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs new file mode 100644 index 0000000000..c870b8187a --- /dev/null +++ b/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs @@ -0,0 +1,93 @@ +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::query::QueryValidationResult; +use dapi_grpc::platform::v0::get_total_credits_in_platform_request::GetTotalCreditsInPlatformRequestV0; +use dapi_grpc::platform::v0::get_total_credits_in_platform_response::{get_total_credits_in_platform_response_v0, GetTotalCreditsInPlatformResponseV0}; +use dpp::check_validation_result_with_data; + +use crate::platform_types::platform_state::PlatformState; +use dpp::validation::ValidationResult; +use dpp::version::PlatformVersion; +use drive::drive::balances::{total_credits_on_platform_path_query, TOTAL_SYSTEM_CREDITS_STORAGE_KEY}; +use drive::drive::system::misc_path; +use drive::util::grove_operations::DirectQueryType; + +impl Platform { + pub(super) fn query_total_credits_in_platform_v0( + &self, + GetTotalCreditsInPlatformRequestV0 { prove }: GetTotalCreditsInPlatformRequestV0, + platform_state: &PlatformState, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let path_query = total_credits_on_platform_path_query(); + + let response = if prove { + let proof = check_validation_result_with_data!(self.drive.grove_get_proved_path_query( + &path_query, + None, + &mut vec![], + &platform_version.drive, + )); + + GetTotalCreditsInPlatformResponseV0 { + result: Some(get_total_credits_in_platform_response_v0::Result::Proof( + self.response_proof_v0(platform_state, proof), + )), + metadata: Some(self.response_metadata_v0(platform_state)), + } + } else { + let path_holding_total_credits = misc_path(); + let total_credits_in_platform = self.drive + .grove_get_raw_value_u64_from_encoded_var_vec( + (&path_holding_total_credits).into(), + TOTAL_SYSTEM_CREDITS_STORAGE_KEY, + DirectQueryType::StatefulDirectQuery, + None, + &mut vec![], + &platform_version.drive, + )?.unwrap_or_default(); // 0 would mean we haven't initialized yet + + GetTotalCreditsInPlatformResponseV0 { + result: Some(get_total_credits_in_platform_response_v0::Result::Credits(total_credits_in_platform)), + metadata: Some(self.response_metadata_v0(platform_state)), + } + }; + + Ok(QueryValidationResult::new_with_data(response)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::query::tests::setup_platform; + #[test] + fn test_query_total_system_credits() { + let (platform, state, version) = setup_platform(false); + + let platform_version = PlatformVersion::latest(); + + platform + .drive + .add_to_system_credits(100, None, platform_version) + .expect("expected to insert identity"); + + let request = GetTotalCreditsInPlatformRequestV0 { + prove: false, + }; + + let response = platform + .query_total_credits_in_platform_v0(request, &state, version) + .expect("expected query to succeed"); + + let response_data = response.into_data().expect("expected data"); + + let get_total_credits_in_platform_response_v0::Result::Credits(credits) = + response_data.result.expect("expected a result") + else { + panic!("expected credits") + }; + + assert_eq!(credits, 100); + } +} diff --git a/packages/rs-drive-proof-verifier/src/proof.rs b/packages/rs-drive-proof-verifier/src/proof.rs index 14000f0a95..d0dbc2c321 100644 --- a/packages/rs-drive-proof-verifier/src/proof.rs +++ b/packages/rs-drive-proof-verifier/src/proof.rs @@ -51,7 +51,7 @@ use drive::query::{DriveDocumentQuery, VotePollsByEndDateDriveQuery}; use std::array::TryFromSliceError; use std::collections::BTreeMap; use std::num::TryFromIntError; - +use drive::drive::balances::total_credits_on_platform_path_query; use crate::verify::verify_tenderdash_proof; /// Parse and verify the received proof and retrieve the requested object, if any. @@ -1610,6 +1610,39 @@ impl FromProof for Vote { } } +impl FromProof for TotalCreditsOnPlatform { + + type Request = platform::GetTotalCreditsInPlatformRequest; + type Response = platform::GetTotalCreditsInPlatformResponse; + + fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( + _request: I, + response: O, + platform_version: &PlatformVersion, + provider: &'a dyn ContextProvider, + ) -> Result<(Option, ResponseMetadata, Proof), Error> + where + Self: Sized + 'a, + { + let response: Self::Response = response.into(); + // Parse response to read proof and metadata + let proof = response.proof().or(Err(Error::NoProofInResult))?; + let mtd = response.metadata().or(Err(Error::EmptyResponseMetadata))?; + + let (root_hash, credits) = Drive::verify_total_credits_in_system( + &proof.grovedb_proof, + platform_version, + ) + .map_err(|e| Error::DriveError { + error: e.to_string(), + })?; + + verify_tenderdash_proof(proof, mtd, &root_hash, provider)?; + + Ok((Some(TotalCreditsOnPlatform(credits)), mtd.clone(), proof.clone())) + } +} + /// Convert u32, if 0 return None, otherwise return Some(u16). /// Errors when value is out of range. fn u32_to_u16_opt(i: u32) -> Result, Error> { diff --git a/packages/rs-drive-proof-verifier/src/types.rs b/packages/rs-drive-proof-verifier/src/types.rs index df390d3cd2..79edb19bd3 100644 --- a/packages/rs-drive-proof-verifier/src/types.rs +++ b/packages/rs-drive-proof-verifier/src/types.rs @@ -24,7 +24,7 @@ use dpp::{ prelude::{DataContract, Identifier, IdentityPublicKey, Revision}, util::deserializer::ProtocolVersion, }; -use drive::grovedb::Element; +use drive::grovedb::{Element, Query, SizedQuery}; use std::collections::{BTreeMap, BTreeSet}; #[cfg(feature = "mocks")] @@ -34,6 +34,10 @@ use { platform_serialization::{PlatformVersionEncode, PlatformVersionedDecode}, platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}, }; +use drive::drive::balances::TOTAL_SYSTEM_CREDITS_STORAGE_KEY; +use drive::drive::RootTree; +use drive::grovedb::query_result_type::Path; +use drive::query::PathQuery; /// A data structure that holds a set of objects of a generic type `O`, indexed by a key of type `K`. /// @@ -156,6 +160,34 @@ pub type Elements = RetrievedObjects, Element>; /// Identity balance. pub type IdentityBalance = u64; + +/// Keys in a Path +#[derive(Debug, Clone)] +pub struct KeysInPath { + /// The path of the keys + pub path: Path, + /// The keys + pub keys: Vec>, +} + +/// The total credits on Platform. +#[derive(Debug, derive_more::From, Clone, Copy)] +#[cfg_attr( + feature = "mocks", + derive(Encode, Decode, PlatformSerialize, PlatformDeserialize), + platform_serialize(unversioned) +)] +pub struct TotalCreditsOnPlatform(pub Credits); + +/// The item of an element fetch request +#[derive(Debug, derive_more::From, Clone)] +#[cfg_attr( + feature = "mocks", + derive(Encode, Decode, PlatformSerialize, PlatformDeserialize), + platform_serialize(unversioned) +)] +pub struct ElementFetchRequestItem(pub Element); + /// Identity balance and revision of the identity. pub type IdentityBalanceAndRevision = (u64, Revision); diff --git a/packages/rs-drive/src/drive/balances/mod.rs b/packages/rs-drive/src/drive/balances/mod.rs index 38b6d2c13d..7bbe69b2f1 100644 --- a/packages/rs-drive/src/drive/balances/mod.rs +++ b/packages/rs-drive/src/drive/balances/mod.rs @@ -17,8 +17,10 @@ mod remove_from_system_credits_operations; #[cfg(feature = "server")] mod calculate_total_credits_balance; +use grovedb::{PathQuery, SizedQuery}; #[cfg(any(feature = "server", feature = "verify"))] use crate::drive::RootTree; +use crate::query::Query; /// Storage fee pool key #[cfg(any(feature = "server", feature = "verify"))] @@ -42,6 +44,19 @@ pub fn total_credits_path_vec() -> Vec> { ] } +/// A path query helper to get the total credits on Platform +#[cfg(any(feature = "server", feature = "verify"))] +pub fn total_credits_on_platform_path_query() -> PathQuery { + PathQuery { + path: vec![vec![RootTree::Misc as u8]], + query: SizedQuery { + query: Query::new_single_key(TOTAL_SYSTEM_CREDITS_STORAGE_KEY.to_vec()), + limit: Some(1), + offset: None, + }, + } +} + /// The path for the balances tree #[cfg(any(feature = "server", feature = "verify"))] pub(crate) fn balance_path() -> [&'static [u8]; 1] { diff --git a/packages/rs-drive/src/drive/mod.rs b/packages/rs-drive/src/drive/mod.rs index cf49c56e41..f5abb9f3c9 100644 --- a/packages/rs-drive/src/drive/mod.rs +++ b/packages/rs-drive/src/drive/mod.rs @@ -33,8 +33,10 @@ pub mod initialization; /// Protocol upgrade module #[cfg(any(feature = "server", feature = "verify"))] pub mod protocol_upgrade; + +/// System module #[cfg(feature = "server")] -mod system; +pub mod system; #[cfg(feature = "server")] mod asset_lock; diff --git a/packages/rs-drive/src/drive/system/mod.rs b/packages/rs-drive/src/drive/system/mod.rs index 34b56c324d..2e0b4d074b 100644 --- a/packages/rs-drive/src/drive/system/mod.rs +++ b/packages/rs-drive/src/drive/system/mod.rs @@ -9,11 +9,11 @@ pub mod protocol_version; use crate::drive::RootTree; /// misc path -pub(crate) fn misc_path() -> [&'static [u8]; 1] { +pub fn misc_path() -> [&'static [u8]; 1] { [Into::<&[u8; 1]>::into(RootTree::Misc)] } /// misc path vector -pub(crate) fn misc_path_vec() -> Vec> { +pub fn misc_path_vec() -> Vec> { vec![Into::<&[u8; 1]>::into(RootTree::Misc).to_vec()] } diff --git a/packages/rs-drive/src/verify/system/mod.rs b/packages/rs-drive/src/verify/system/mod.rs index 69dceb54a8..18d1400abf 100644 --- a/packages/rs-drive/src/verify/system/mod.rs +++ b/packages/rs-drive/src/verify/system/mod.rs @@ -2,3 +2,4 @@ mod verify_elements; mod verify_epoch_infos; mod verify_upgrade_state; mod verify_upgrade_vote_status; +mod verify_total_credits_in_system; diff --git a/packages/rs-drive/src/verify/system/verify_elements/mod.rs b/packages/rs-drive/src/verify/system/verify_elements/mod.rs index 5d17c97043..ddddd08d67 100644 --- a/packages/rs-drive/src/verify/system/verify_elements/mod.rs +++ b/packages/rs-drive/src/verify/system/verify_elements/mod.rs @@ -9,7 +9,7 @@ use std::collections::BTreeMap; mod v0; impl Drive { - /// Verifies a proof containing potentially multiple epoch infos. + /// Verifies a proof and returns elements matching keys for a path. /// /// # Parameters /// @@ -20,7 +20,7 @@ impl Drive { /// /// # Returns /// - /// Returns a `Result` with a tuple of `RootHash` and `Vec`. The `BTreeMap, Option>` + /// Returns a `Result` with a tuple of `RootHash` and `BTreeMap, Option>`. The `BTreeMap, Option>` /// is the map of elements we get back. /// /// # Errors diff --git a/packages/rs-drive/src/verify/system/verify_elements/v0/mod.rs b/packages/rs-drive/src/verify/system/verify_elements/v0/mod.rs index 6ae60b6e98..70c4b15f7a 100644 --- a/packages/rs-drive/src/verify/system/verify_elements/v0/mod.rs +++ b/packages/rs-drive/src/verify/system/verify_elements/v0/mod.rs @@ -9,7 +9,7 @@ use platform_version::version::PlatformVersion; use std::collections::BTreeMap; impl Drive { - /// Verifies that the contract is included in the proof. + /// Verifies a proof and returns elements matching keys for a path. /// /// # Parameters /// diff --git a/packages/rs-drive/src/verify/system/verify_total_credits_in_system/mod.rs b/packages/rs-drive/src/verify/system/verify_total_credits_in_system/mod.rs new file mode 100644 index 0000000000..667440850b --- /dev/null +++ b/packages/rs-drive/src/verify/system/verify_total_credits_in_system/mod.rs @@ -0,0 +1,41 @@ +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::verify::RootHash; +use dpp::version::PlatformVersion; +use dpp::fee::Credits; + +mod v0; + +impl Drive { + /// Verifies a proof containing the total credits in platform. + /// + /// # Parameters + /// + /// - `proof`: A byte slice representing the proof to be verified. + /// - `platform_version`: the platform version, + /// + /// # Returns + /// + /// Returns a `Result` with a tuple of `RootHash` and `Credits`. + /// + /// # Errors + /// + /// Returns an `Error` if: + /// + /// - The proof is corrupted. + /// - The GroveDb query fails. + pub fn verify_total_credits_in_system( + proof: &[u8], + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Credits), Error> { + match platform_version.drive.methods.verify.system.verify_total_credits_in_system { + 0 => Drive::verify_total_credits_in_system_v0(proof, platform_version), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "verify_total_credits_in_system".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/verify/system/verify_total_credits_in_system/v0/mod.rs b/packages/rs-drive/src/verify/system/verify_total_credits_in_system/v0/mod.rs new file mode 100644 index 0000000000..c18a5e30e4 --- /dev/null +++ b/packages/rs-drive/src/verify/system/verify_total_credits_in_system/v0/mod.rs @@ -0,0 +1,60 @@ +use grovedb::GroveDb; +use crate::drive::Drive; +use crate::error::Error; +use crate::verify::RootHash; +use platform_version::version::PlatformVersion; +use integer_encoding::VarInt; +use dpp::fee::Credits; +use crate::drive::balances::{total_credits_on_platform_path_query, TOTAL_SYSTEM_CREDITS_STORAGE_KEY}; +use crate::error::proof::ProofError; + +impl Drive { + /// Verifies a proof for the total credits in the system and returns + /// them if they are in the proof. + /// + /// # Parameters + /// + /// - `proof`: A byte slice representing the proof to be verified. + /// - `path`: The path where elements should be. + /// - `keys`: The requested keys. + /// + /// # Returns + /// + /// Returns a `Result` with a tuple of `RootHash` and `Credits`. + /// + /// # Errors + /// + /// Returns an `Error` if: + /// + /// - The proof is corrupted. + /// - The GroveDb query fails. + #[inline(always)] + pub(crate) fn verify_total_credits_in_system_v0( + proof: &[u8], + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Credits), Error> { + let path_query = total_credits_on_platform_path_query(); + + let (root_hash, mut proved_path_key_values) = + GroveDb::verify_query_raw(proof, &path_query, &platform_version.drive.grove_version)?; + if proved_path_key_values.len() > 1 { + return Err(Error::Proof(ProofError::TooManyElements("We should only get back at most 1 element in the proof for the total credits in the system"))); + } + + let Some(proved_path_key_value) = proved_path_key_values.pop() else { + return Err(Error::Proof(ProofError::IncorrectProof("This proof would show that Platform has not yet been initialized".to_string()))); + }; + + if proved_path_key_value.path != path_query.path { + return Err(Error::Proof(ProofError::CorruptedProof("The result of this proof is not what we asked for (path)".to_string()))); + } + + if proved_path_key_value.key != TOTAL_SYSTEM_CREDITS_STORAGE_KEY.to_vec() { + return Err(Error::Proof(ProofError::CorruptedProof("The result of this proof is not what we asked for (key)".to_string()))); + } + + let credits = Credits::decode_var(proved_path_key_value.value.as_slice()).ok_or(Error::Proof(ProofError::CorruptedProof("The result of this proof does not contain an encoded var integer for total credits".to_string())))?.0; + + Ok((root_hash, credits)) + } +} diff --git a/packages/rs-platform-version/src/version/drive_abci_versions.rs b/packages/rs-platform-version/src/version/drive_abci_versions.rs index 92ce6bdac8..9fd0d8e974 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions.rs @@ -60,6 +60,7 @@ pub struct DriveAbciQuerySystemVersions { pub version_upgrade_vote_status: FeatureVersionBounds, pub epoch_infos: FeatureVersionBounds, pub path_elements: FeatureVersionBounds, + pub total_credits_in_platform: FeatureVersionBounds, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 41a0061a79..25daa65f6a 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -145,6 +145,7 @@ pub struct DriveVerifyVoteMethodVersions { pub struct DriveVerifySystemMethodVersions { pub verify_epoch_infos: FeatureVersion, pub verify_elements: FeatureVersion, + pub verify_total_credits_in_system: FeatureVersion, pub verify_upgrade_state: FeatureVersion, pub verify_upgrade_vote_status: FeatureVersion, } diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 5540862126..0de2b01611 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -323,6 +323,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { system: DriveVerifySystemMethodVersions { verify_epoch_infos: 0, verify_elements: 0, + verify_total_credits_in_system: 0, verify_upgrade_state: 0, verify_upgrade_vote_status: 0, }, @@ -962,6 +963,11 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { max_version: 0, default_current_version: 0, }, + total_credits_in_platform: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, }, }, }, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index c6b940b88a..f8bd59a448 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -352,6 +352,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { system: DriveVerifySystemMethodVersions { verify_epoch_infos: 0, verify_elements: 0, + verify_total_credits_in_system: 0, verify_upgrade_state: 0, verify_upgrade_vote_status: 0, }, @@ -962,6 +963,11 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { max_version: 0, default_current_version: 0, }, + total_credits_in_platform: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, }, }, }, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index e0b890a43b..bca9f788e0 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -322,6 +322,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { system: DriveVerifySystemMethodVersions { verify_epoch_infos: 0, verify_elements: 0, + verify_total_credits_in_system: 0, verify_upgrade_state: 0, verify_upgrade_vote_status: 0, }, @@ -961,6 +962,11 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { max_version: 0, default_current_version: 0, }, + total_credits_in_platform: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, }, }, }, diff --git a/packages/rs-sdk/src/mock/requests.rs b/packages/rs-sdk/src/mock/requests.rs index 015da012bf..23f2ad535f 100644 --- a/packages/rs-sdk/src/mock/requests.rs +++ b/packages/rs-sdk/src/mock/requests.rs @@ -14,10 +14,7 @@ use dpp::{ }, voting::votes::{resource_vote::ResourceVote, Vote}, }; -use drive_proof_verifier::types::{ - Contenders, ContestedResources, IdentityBalanceAndRevision, MasternodeProtocolVote, - PrefundedSpecializedBalance, VotePollsGroupedByTimestamp, Voters, -}; +use drive_proof_verifier::types::{Contenders, ContestedResources, ElementFetchRequestItem, IdentityBalanceAndRevision, MasternodeProtocolVote, PrefundedSpecializedBalance, TotalCreditsOnPlatform, VotePollsGroupedByTimestamp, Voters}; use std::collections::BTreeMap; static BINCODE_CONFIG: bincode::config::Configuration = bincode::config::standard(); @@ -209,11 +206,14 @@ impl MockResponse for ProTxHash { } } + + impl_mock_response!(Identity); impl_mock_response!(IdentityPublicKey); impl_mock_response!(Identifier); impl_mock_response!(MasternodeProtocolVote); impl_mock_response!(ResourceVote); +impl_mock_response!(u8); impl_mock_response!(u16); impl_mock_response!(u32); impl_mock_response!(u64); @@ -225,3 +225,5 @@ impl_mock_response!(Contenders); impl_mock_response!(Voters); impl_mock_response!(VotePollsGroupedByTimestamp); impl_mock_response!(PrefundedSpecializedBalance); +impl_mock_response!(TotalCreditsOnPlatform); +impl_mock_response!(ElementFetchRequestItem); diff --git a/packages/rs-sdk/src/mock/sdk.rs b/packages/rs-sdk/src/mock/sdk.rs index d98b91aa32..cdc9d3a617 100644 --- a/packages/rs-sdk/src/mock/sdk.rs +++ b/packages/rs-sdk/src/mock/sdk.rs @@ -184,6 +184,14 @@ impl MockDashPlatformSdk { self.load_expectation::(filename) .await? } + "GetPathElementsRequest" => { + self.load_expectation::(filename) + .await? + } + "GetTotalCreditsInPlatformRequest" => { + self.load_expectation::(filename) + .await? + } _ => { return Err(Error::Config(format!( "unknown request type {} in {}", diff --git a/packages/rs-sdk/src/platform/fetch.rs b/packages/rs-sdk/src/platform/fetch.rs index c567b1fbc1..eee0a5a16d 100644 --- a/packages/rs-sdk/src/platform/fetch.rs +++ b/packages/rs-sdk/src/platform/fetch.rs @@ -251,6 +251,10 @@ impl Fetch for drive_proof_verifier::types::IdentityBalance { type Request = platform_proto::GetIdentityBalanceRequest; } +impl Fetch for drive_proof_verifier::types::TotalCreditsOnPlatform { + type Request = platform_proto::GetTotalCreditsInPlatformRequest; +} + impl Fetch for drive_proof_verifier::types::IdentityNonceFetcher { type Request = platform_proto::GetIdentityNonceRequest; } diff --git a/packages/rs-sdk/src/platform/fetch_many.rs b/packages/rs-sdk/src/platform/fetch_many.rs index b2891412c7..dec33ee2b6 100644 --- a/packages/rs-sdk/src/platform/fetch_many.rs +++ b/packages/rs-sdk/src/platform/fetch_many.rs @@ -28,16 +28,12 @@ use dpp::{ block::extended_epoch_info::ExtendedEpochInfo, voting::votes::resource_vote::ResourceVote, }; use dpp::{document::Document, voting::contender_structs::ContenderWithSerializedDocument}; -use drive_proof_verifier::types::{ - Contenders, ContestedResource, ContestedResources, DataContracts, ExtendedEpochInfos, - IdentityPublicKeys, MasternodeProtocolVote, MasternodeProtocolVotes, ProtocolVersionUpgrades, - ResourceVotesByIdentity, VotePollsGroupedByTimestamp, Voter, Voters, -}; +use drive_proof_verifier::types::{Contenders, ContestedResource, ContestedResources, DataContracts, ExtendedEpochInfos, IdentityPublicKeys, MasternodeProtocolVote, MasternodeProtocolVotes, ProtocolVersionUpgrades, ResourceVotesByIdentity, VotePollsGroupedByTimestamp, Voter, Voters}; use drive_proof_verifier::{types::Documents, FromProof}; use rs_dapi_client::{transport::TransportRequest, DapiRequest, RequestSettings}; use std::collections::BTreeMap; -use super::LimitQuery; +use super::{Fetch, LimitQuery}; /// Fetch multiple objects from Platform. /// @@ -372,4 +368,4 @@ impl FetchMany for ResourceVote { /// * [VotePollsByEndDateDriveQuery] impl FetchMany for VotePoll { type Request = GetVotePollsByEndDateRequest; -} +} \ No newline at end of file diff --git a/packages/rs-sdk/src/platform/query.rs b/packages/rs-sdk/src/platform/query.rs index 82ba292ca4..53c410e332 100644 --- a/packages/rs-sdk/src/platform/query.rs +++ b/packages/rs-sdk/src/platform/query.rs @@ -5,13 +5,7 @@ use dapi_grpc::mock::Mockable; use dapi_grpc::platform::v0::get_contested_resource_identity_votes_request::GetContestedResourceIdentityVotesRequestV0; use dapi_grpc::platform::v0::get_contested_resource_voters_for_identity_request::GetContestedResourceVotersForIdentityRequestV0; use dapi_grpc::platform::v0::get_contested_resources_request::GetContestedResourcesRequestV0; -use dapi_grpc::platform::v0::{ - self as proto, get_identity_keys_request, get_identity_keys_request::GetIdentityKeysRequestV0, - AllKeys, GetContestedResourceVoteStateRequest, GetContestedResourceVotersForIdentityRequest, - GetContestedResourcesRequest, GetEpochsInfoRequest, GetIdentityKeysRequest, - GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeVoteStatusRequest, - KeyRequestType, -}; +use dapi_grpc::platform::v0::{self as proto, get_identity_keys_request, get_identity_keys_request::GetIdentityKeysRequestV0, AllKeys, GetContestedResourceVoteStateRequest, GetContestedResourceVotersForIdentityRequest, GetContestedResourcesRequest, GetEpochsInfoRequest, GetIdentityKeysRequest, GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeVoteStatusRequest, KeyRequestType, GetPathElementsRequest, get_path_elements_request, GetTotalCreditsInPlatformRequest, get_total_credits_in_platform_request}; use dapi_grpc::platform::v0::{ GetContestedResourceIdentityVotesRequest, GetPrefundedSpecializedBalanceRequest, GetVotePollsByEndDateRequest, @@ -27,7 +21,11 @@ use drive::query::{DriveDocumentQuery, VotePollsByEndDateDriveQuery}; use drive_proof_verifier::from_request::TryFromRequest; use rs_dapi_client::transport::TransportRequest; use std::fmt::Debug; - +use dapi_grpc::platform::v0::get_path_elements_request::GetPathElementsRequestV0; +use dapi_grpc::platform::v0::get_total_credits_in_platform_request::GetTotalCreditsInPlatformRequestV0; +use drive::drive::balances::TOTAL_SYSTEM_CREDITS_STORAGE_KEY; +use drive::drive::RootTree; +use drive_proof_verifier::types::{KeysInPath, TotalCreditsOnPlatform}; use crate::{error::Error, platform::document_query::DocumentQuery}; use super::types::epoch::EpochQuery; @@ -544,3 +542,36 @@ impl Query for LimitQuery { .into()) } } + + +impl Query for KeysInPath { + fn query(self, prove: bool) -> Result { + if !prove { + unimplemented!("queries without proofs are not supported yet"); + } + + let request: GetPathElementsRequest = GetPathElementsRequest { + version: Some(get_path_elements_request::Version::V0( + GetPathElementsRequestV0 { path: self.path, keys: self.keys, prove }, + )), + }; + + Ok(request) + } +} + +impl Query for TotalCreditsOnPlatform { + fn query(self, prove: bool) -> Result { + if !prove { + unimplemented!("queries without proofs are not supported yet"); + } + + let request: GetTotalCreditsInPlatformRequest = GetTotalCreditsInPlatformRequest { + version: Some(get_total_credits_in_platform_request::Version::V0( + GetTotalCreditsInPlatformRequestV0{ prove }, + )), + }; + + Ok(request) + } +} diff --git a/packages/rs-sdk/src/platform/types/identity.rs b/packages/rs-sdk/src/platform/types/identity.rs index 1ae9f6e2cf..609b76eca5 100644 --- a/packages/rs-sdk/src/platform/types/identity.rs +++ b/packages/rs-sdk/src/platform/types/identity.rs @@ -6,15 +6,8 @@ use dapi_grpc::platform::v0::get_identity_by_public_key_hash_request::GetIdentit use dapi_grpc::platform::v0::get_identity_contract_nonce_request::GetIdentityContractNonceRequestV0; use dapi_grpc::platform::v0::get_identity_nonce_request::GetIdentityNonceRequestV0; use dapi_grpc::platform::v0::get_identity_request::GetIdentityRequestV0; -use dapi_grpc::platform::v0::{ - get_identity_balance_and_revision_request, get_identity_balance_request, - get_identity_by_public_key_hash_request, get_identity_contract_nonce_request, - get_identity_nonce_request, get_identity_request, GetIdentityBalanceAndRevisionRequest, - GetIdentityBalanceRequest, GetIdentityByPublicKeyHashRequest, GetIdentityContractNonceRequest, - GetIdentityNonceRequest, GetIdentityRequest, ResponseMetadata, -}; +use dapi_grpc::platform::v0::{get_identity_balance_and_revision_request, get_identity_balance_request, get_identity_by_public_key_hash_request, get_identity_contract_nonce_request, get_identity_nonce_request, get_identity_request, GetIdentityBalanceAndRevisionRequest, GetIdentityBalanceRequest, GetIdentityByPublicKeyHashRequest, GetIdentityContractNonceRequest, GetIdentityNonceRequest, GetIdentityRequest, ResponseMetadata}; use dpp::prelude::Identity; - use crate::delegate_enum; use crate::{ platform::{proto, Query}, From 78964fc68c0a0299655b7971d25d87fad3969430 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 2 Aug 2024 05:07:26 +0700 Subject: [PATCH 02/33] cleanup --- packages/rs-sdk/src/platform/fetch_many.rs | 2 +- packages/rs-sdk/src/platform/query.rs | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/rs-sdk/src/platform/fetch_many.rs b/packages/rs-sdk/src/platform/fetch_many.rs index dec33ee2b6..6069eb65ce 100644 --- a/packages/rs-sdk/src/platform/fetch_many.rs +++ b/packages/rs-sdk/src/platform/fetch_many.rs @@ -33,7 +33,7 @@ use drive_proof_verifier::{types::Documents, FromProof}; use rs_dapi_client::{transport::TransportRequest, DapiRequest, RequestSettings}; use std::collections::BTreeMap; -use super::{Fetch, LimitQuery}; +use super::LimitQuery; /// Fetch multiple objects from Platform. /// diff --git a/packages/rs-sdk/src/platform/query.rs b/packages/rs-sdk/src/platform/query.rs index 53c410e332..a0d907de38 100644 --- a/packages/rs-sdk/src/platform/query.rs +++ b/packages/rs-sdk/src/platform/query.rs @@ -23,8 +23,6 @@ use rs_dapi_client::transport::TransportRequest; use std::fmt::Debug; use dapi_grpc::platform::v0::get_path_elements_request::GetPathElementsRequestV0; use dapi_grpc::platform::v0::get_total_credits_in_platform_request::GetTotalCreditsInPlatformRequestV0; -use drive::drive::balances::TOTAL_SYSTEM_CREDITS_STORAGE_KEY; -use drive::drive::RootTree; use drive_proof_verifier::types::{KeysInPath, TotalCreditsOnPlatform}; use crate::{error::Error, platform::document_query::DocumentQuery}; From deb7ceb8ad85b06d5f75b3c5d42b2d3948f01c79 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 2 Aug 2024 10:24:03 +0700 Subject: [PATCH 03/33] more work --- packages/rs-dapi-client/src/transport/grpc.rs | 1 - .../mod.rs | 40 +++ .../v0/mod.rs | 74 ++++++ .../src}/core_subsidy/mod.rs | 4 +- packages/rs-dpp/src/lib.rs | 2 + packages/rs-drive-abci/src/config.rs | 17 +- packages/rs-drive-abci/src/error/mod.rs | 7 + .../mod.rs | 4 +- .../v0/mod.rs | 12 +- .../process_block_fees/v0/mod.rs | 2 +- .../block_fee_processing/tests.rs | 13 +- .../mod.rs | 44 ---- .../v0/mod.rs | 74 ------ .../v0/mod.rs | 12 +- .../src/execution/platform_events/mod.rs | 2 - .../state_transitions/documents_batch/mod.rs | 11 +- .../identity_credit_withdrawal/mod.rs | 7 +- .../state_transition/state_transitions/mod.rs | 43 --- packages/rs-drive-abci/src/query/service.rs | 31 ++- .../rs-drive-abci/src/query/system/mod.rs | 2 +- .../system/total_credits_in_platform/mod.rs | 17 +- .../total_credits_in_platform/v0/mod.rs | 246 ++++++++++++++++-- .../src/test/helpers/fast_forward_to_block.rs | 146 +++++++++++ .../rs-drive-abci/src/test/helpers/mod.rs | 4 +- packages/rs-drive-proof-verifier/src/proof.rs | 26 +- packages/rs-drive-proof-verifier/src/types.rs | 7 +- packages/rs-drive/src/drive/balances/mod.rs | 2 +- packages/rs-drive/src/verify/system/mod.rs | 2 +- .../verify_total_credits_in_system/mod.rs | 29 ++- .../verify_total_credits_in_system/v0/mod.rs | 168 ++++++++++-- .../src/version/dpp_versions.rs | 6 + .../src/version/drive_abci_versions.rs | 6 - .../src/version/mocks/v2_test.rs | 18 +- .../src/version/mocks/v3_test.rs | 20 +- .../rs-platform-version/src/version/v1.rs | 20 +- packages/rs-sdk/src/mock/requests.rs | 8 +- packages/rs-sdk/src/platform/fetch_many.rs | 8 +- packages/rs-sdk/src/platform/query.rs | 26 +- .../rs-sdk/src/platform/types/identity.rs | 18 +- 39 files changed, 859 insertions(+), 320 deletions(-) create mode 100644 packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/mod.rs create mode 100644 packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs rename packages/{rs-drive-abci/src/execution/platform_events => rs-dpp/src}/core_subsidy/mod.rs (81%) delete mode 100644 packages/rs-drive-abci/src/execution/platform_events/core_subsidy/epoch_core_reward_credits_for_distribution/mod.rs delete mode 100644 packages/rs-drive-abci/src/execution/platform_events/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs create mode 100644 packages/rs-drive-abci/src/test/helpers/fast_forward_to_block.rs diff --git a/packages/rs-dapi-client/src/transport/grpc.rs b/packages/rs-dapi-client/src/transport/grpc.rs index 6f720c1615..188c5f595c 100644 --- a/packages/rs-dapi-client/src/transport/grpc.rs +++ b/packages/rs-dapi-client/src/transport/grpc.rs @@ -351,7 +351,6 @@ impl_transport_request_grpc!( get_total_credits_in_platform ); - // Link to each core gRPC request what client and method to use: impl_transport_request_grpc!( diff --git a/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/mod.rs b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/mod.rs new file mode 100644 index 0000000000..3aa676b633 --- /dev/null +++ b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/mod.rs @@ -0,0 +1,40 @@ +mod v0; + +use crate::core_subsidy::epoch_core_reward_credits_for_distribution::v0::epoch_core_reward_credits_for_distribution_v0; +use crate::fee::Credits; +use crate::ProtocolError; +use platform_version::version::PlatformVersion; + +/// Gets the amount of core reward fees to be distributed for the Epoch. +/// +/// # Arguments +/// +/// * `epoch_start_block_core_height` - The height of the core block at the start of the epoch. +/// * `next_epoch_start_block_core_height` - The height of the core block at the start of the next epoch. +/// +/// # Returns +/// +/// * `Result` - If the operation is successful, it returns `Ok(Credits)`. If there is an error, it returns `Error`. +pub fn epoch_core_reward_credits_for_distribution( + epoch_start_block_core_height: u32, + next_epoch_start_block_core_height: u32, + distribution_multiplier: u16, + platform_version: &PlatformVersion, +) -> Result { + match platform_version + .dpp + .methods + .epoch_core_reward_credits_for_distribution + { + 0 => epoch_core_reward_credits_for_distribution_v0( + epoch_start_block_core_height, + next_epoch_start_block_core_height, + distribution_multiplier, + ), + version => Err(ProtocolError::UnknownVersionMismatch { + method: "epoch_core_reward_credits_for_distribution".to_string(), + known_versions: vec![0], + received: version, + }), + } +} diff --git a/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs new file mode 100644 index 0000000000..cf74263d4f --- /dev/null +++ b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs @@ -0,0 +1,74 @@ +use crate::block::epoch::EpochIndex; +use crate::fee::Credits; + +use crate::core_subsidy::{CORE_GENESIS_BLOCK_SUBSIDY, CORE_SUBSIDY_HALVING_INTERVAL}; +use crate::ProtocolError; +use lazy_static::lazy_static; +use std::collections::HashMap; + +lazy_static! { + /// The Core reward halving distribution table for 100 years + /// Yearly decline of production by ~7.1% per year, projected ~18M coins max by year 2050+. + pub static ref CORE_HALVING_DISTRIBUTION: HashMap = { + let mut distribution = CORE_GENESIS_BLOCK_SUBSIDY; + (0..100).map(|i| { + let old_distribution = distribution; + distribution -= distribution / 14; + (i, old_distribution) + }).collect() + }; +} + +/// Gets the amount of core reward fees to be distributed for the Epoch. +pub(super) fn epoch_core_reward_credits_for_distribution_v0( + epoch_start_block_core_height: u32, + next_epoch_start_block_core_height: u32, + distribution_multiplier: u16, +) -> Result { + // Core is halving block rewards every year so we need to pay + // core block rewards according to halving ratio for the all years during + // the platform epoch payout period (unpaid epoch) + + // Calculate start and end years for the platform epoch payout period + // according to start and end core block heights + let start_core_reward_year = + (epoch_start_block_core_height / CORE_SUBSIDY_HALVING_INTERVAL) as EpochIndex; + let end_core_reward_year = + (next_epoch_start_block_core_height / CORE_SUBSIDY_HALVING_INTERVAL) as EpochIndex; + + let mut total_core_rewards = 0; + + // Calculate block rewards for each core reward year during the platform epoch payout period + for core_reward_year in start_core_reward_year..=end_core_reward_year { + // Calculate the block count per core reward year + + let core_reward_year_start_block = if core_reward_year == end_core_reward_year { + next_epoch_start_block_core_height + } else { + (core_reward_year + 1) as u32 * CORE_SUBSIDY_HALVING_INTERVAL + }; + + let core_reward_year_end_block = if core_reward_year == start_core_reward_year { + epoch_start_block_core_height + } else { + core_reward_year as u32 * CORE_SUBSIDY_HALVING_INTERVAL + }; + + let block_count = core_reward_year_start_block - core_reward_year_end_block; + + // Fetch the core block distribution for the corresponding epoch from the distribution table + // Default to 0 if the core reward year is more than 100 years in the future + let core_block_distribution_ratio = CORE_HALVING_DISTRIBUTION + .get(&core_reward_year) + .unwrap_or(&0); + + // Calculate the core rewards for this epoch and add to the total + total_core_rewards += block_count as Credits * *core_block_distribution_ratio; + } + + total_core_rewards + .checked_mul(distribution_multiplier as u64) + .ok_or(ProtocolError::Overflow( + "overflow in total core reward calculation", + )) +} diff --git a/packages/rs-drive-abci/src/execution/platform_events/core_subsidy/mod.rs b/packages/rs-dpp/src/core_subsidy/mod.rs similarity index 81% rename from packages/rs-drive-abci/src/execution/platform_events/core_subsidy/mod.rs rename to packages/rs-dpp/src/core_subsidy/mod.rs index 00cce37472..c26e920840 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/core_subsidy/mod.rs +++ b/packages/rs-dpp/src/core_subsidy/mod.rs @@ -1,6 +1,6 @@ -mod epoch_core_reward_credits_for_distribution; +pub mod epoch_core_reward_credits_for_distribution; -use dpp::fee::Credits; +use crate::fee::Credits; /// Actual number of core blocks per calendar year with DGW v3 is ~200700 (for example 449750 - 249050) pub const CORE_SUBSIDY_HALVING_INTERVAL: u32 = 210240; diff --git a/packages/rs-dpp/src/lib.rs b/packages/rs-dpp/src/lib.rs index e0318774ce..d2dc8b7f6e 100644 --- a/packages/rs-dpp/src/lib.rs +++ b/packages/rs-dpp/src/lib.rs @@ -38,6 +38,8 @@ pub mod tests; pub mod asset_lock; pub mod balances; pub mod block; +/// Core subsidy +pub mod core_subsidy; pub mod fee; pub mod nft; pub mod prefunded_specialized_balance; diff --git a/packages/rs-drive-abci/src/config.rs b/packages/rs-drive-abci/src/config.rs index c2368796ed..4d0365ffda 100644 --- a/packages/rs-drive-abci/src/config.rs +++ b/packages/rs-drive-abci/src/config.rs @@ -98,7 +98,7 @@ impl CheckTxCoreRpcConfig { } /// Configuration for Dash Core related things -#[derive(Clone, Debug, Serialize, Deserialize, Default)] +#[derive(Clone, Debug, Serialize, Deserialize)] #[serde(default)] pub struct CoreConfig { /// Core RPC config for consensus @@ -107,6 +107,21 @@ pub struct CoreConfig { /// Core RPC config for check tx #[serde(flatten)] pub check_tx_rpc: CheckTxCoreRpcConfig, + + /// The reward multiplier of core + /// This is 1 for mainnet + /// This is often 10 for other networks + pub reward_multiplier: u16, +} + +impl Default for CoreConfig { + fn default() -> Self { + Self { + reward_multiplier: 1, + consensus_rpc: Default::default(), + check_tx_rpc: Default::default(), + } + } } /// Configuration of the execution part of Dash Platform. diff --git a/packages/rs-drive-abci/src/error/mod.rs b/packages/rs-drive-abci/src/error/mod.rs index 3bf2c4aa97..5ada5f06b4 100644 --- a/packages/rs-drive-abci/src/error/mod.rs +++ b/packages/rs-drive-abci/src/error/mod.rs @@ -75,6 +75,13 @@ impl From for Error { } } +impl From for Error { + fn from(value: drive::grovedb::Error) -> Self { + let drive_error: DriveError = value.into(); + drive_error.into() + } +} + impl From for ResponseException { fn from(value: Error) -> Self { Self { diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/mod.rs index 189389678a..96bdf8d293 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/mod.rs @@ -1,7 +1,7 @@ mod v0; use dpp::version::PlatformVersion; -use drive::grovedb::Transaction; +use drive::grovedb::TransactionArg; use drive::util::batch::DriveOperation; use crate::error::Error; @@ -42,7 +42,7 @@ impl Platform { &self, block_execution_context: &BlockExecutionContext, block_fees: &BlockFees, - transaction: &Transaction, + transaction: TransactionArg, batch: &mut Vec, platform_version: &PlatformVersion, ) -> Result, Error> diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/v0/mod.rs index cd34051daa..1aa590cbc3 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/add_process_epoch_change_operations/v0/mod.rs @@ -39,7 +39,7 @@ use dpp::block::epoch::Epoch; use dpp::fee::epoch::{perpetual_storage_epochs, GENESIS_EPOCH_INDEX}; use dpp::version::PlatformVersion; use drive::error; -use drive::grovedb::Transaction; +use drive::grovedb::TransactionArg; use drive::util::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; use drive::util::batch::{DriveOperation, GroveDbOpBatch}; @@ -80,7 +80,7 @@ impl Platform { &self, block_execution_context: &BlockExecutionContext, block_fees: &BlockFees, - transaction: &Transaction, + transaction: TransactionArg, batch: &mut Vec, platform_version: &PlatformVersion, ) -> Result, Error> @@ -145,7 +145,7 @@ impl Platform { let storage_fee_distribution_outcome = self .add_distribute_storage_fee_to_epochs_operations( current_epoch.index, - Some(transaction), + transaction, &mut inner_batch, platform_version, )?; @@ -154,7 +154,7 @@ impl Platform { .add_delete_pending_epoch_refunds_except_specified_operations( &mut inner_batch, block_fees.refunds_per_epoch(), - Some(transaction), + transaction, &platform_version.drive, )?; @@ -182,7 +182,7 @@ mod tests { use crate::platform_types::platform_state::PlatformState; use dpp::block::block_info::BlockInfo; use dpp::fee::epoch::CreditsPerEpoch; - + use drive::grovedb::Transaction; use platform_version::version::INITIAL_PROTOCOL_VERSION; /// Process and validate an epoch change @@ -284,7 +284,7 @@ mod tests { .add_process_epoch_change_operations_v0( &block_execution_context.into(), &block_fees, - transaction, + Some(transaction), &mut batch, platform_version, ) diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/v0/mod.rs index fa97f7107b..731579b379 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/v0/mod.rs @@ -65,7 +65,7 @@ impl Platform { self.add_process_epoch_change_operations( block_execution_context, &block_fees, - transaction, + Some(transaction), &mut batch, platform_version, )? diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/tests.rs b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/tests.rs index a49b7caee9..0e50baab4f 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/tests.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/tests.rs @@ -1,11 +1,12 @@ #[cfg(test)] mod refund_tests { use crate::execution::validation::state_transition::tests::{ - fast_forward_to_block, fetch_expected_identity_balance, process_state_transitions, + fetch_expected_identity_balance, process_state_transitions, setup_identity_with_system_credits, }; use crate::platform_types::platform_state::v0::PlatformStateV0Methods; use crate::rpc::core::MockCoreRPCLike; + use crate::test::helpers::fast_forward_to_block::fast_forward_to_block; use crate::test::helpers::setup::{TempPlatform, TestPlatformBuilder}; use dpp::block::block_info::BlockInfo; use dpp::dash_to_credits; @@ -388,7 +389,7 @@ mod refund_tests { let (document, insertion_fee_result, current_user_balance) = setup_initial_document(&platform, profile, &mut rng, &identity, &key, &signer); - fast_forward_to_block(&platform, 1_200_000_000, 900, 1); //next epoch + fast_forward_to_block(&platform, 1_200_000_000, 900, 42, 1, false); //next epoch let documents_batch_delete_transition = DocumentsBatchTransition::new_document_deletion_transition_from_document( @@ -487,7 +488,7 @@ mod refund_tests { let (document, insertion_fee_result, current_user_balance) = setup_initial_document(&platform, profile, &mut rng, &identity, &key, &signer); - fast_forward_to_block(&platform, 1_200_000_000, 900, 40); //a year later + fast_forward_to_block(&platform, 1_200_000_000, 900, 42, 40, false); //a year later let documents_batch_delete_transition = DocumentsBatchTransition::new_document_deletion_transition_from_document( @@ -582,7 +583,7 @@ mod refund_tests { let (document, insertion_fee_result, current_user_balance) = setup_initial_document(&platform, profile, &mut rng, &identity, &key, &signer); - fast_forward_to_block(&platform, 10_200_000_000, 9000, 40 * 25); //25 years later + fast_forward_to_block(&platform, 10_200_000_000, 9000, 42, 40 * 25, false); //25 years later let documents_batch_delete_transition = DocumentsBatchTransition::new_document_deletion_transition_from_document( @@ -677,7 +678,7 @@ mod refund_tests { let (document, _, current_user_balance) = setup_initial_document(&platform, profile, &mut rng, &identity, &key, &signer); - fast_forward_to_block(&platform, 10_200_000_000, 9000, 40 * 50); //50 years later + fast_forward_to_block(&platform, 10_200_000_000, 9000, 42, 40 * 50, false); //50 years later let documents_batch_delete_transition = DocumentsBatchTransition::new_document_deletion_transition_from_document( @@ -773,7 +774,7 @@ mod refund_tests { let (document, insertion_fee_result, current_user_balance) = setup_initial_document(&platform, profile, &mut rng, &identity, &key, &signer); - fast_forward_to_block(&platform, 1_200_000_000, 900, 10); //next epoch + fast_forward_to_block(&platform, 1_200_000_000, 900, 42, 10, false); //next epoch let documents_batch_delete_transition = DocumentsBatchTransition::new_document_deletion_transition_from_document( diff --git a/packages/rs-drive-abci/src/execution/platform_events/core_subsidy/epoch_core_reward_credits_for_distribution/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/core_subsidy/epoch_core_reward_credits_for_distribution/mod.rs deleted file mode 100644 index 5e5aaca2cc..0000000000 --- a/packages/rs-drive-abci/src/execution/platform_events/core_subsidy/epoch_core_reward_credits_for_distribution/mod.rs +++ /dev/null @@ -1,44 +0,0 @@ -mod v0; - -use crate::error::execution::ExecutionError; -use crate::error::Error; - -use crate::platform_types::platform::Platform; - -use dpp::fee::Credits; -use dpp::version::PlatformVersion; - -impl Platform { - /// Gets the amount of core reward fees to be distributed for the Epoch. - /// - /// # Arguments - /// - /// * `epoch_start_block_core_height` - The height of the core block at the start of the epoch. - /// * `next_epoch_start_block_core_height` - The height of the core block at the start of the next epoch. - /// - /// # Returns - /// - /// * `Result` - If the operation is successful, it returns `Ok(Credits)`. If there is an error, it returns `Error`. - pub fn epoch_core_reward_credits_for_distribution( - epoch_start_block_core_height: u32, - next_epoch_start_block_core_height: u32, - platform_version: &PlatformVersion, - ) -> Result { - match platform_version - .drive_abci - .methods - .core_subsidy - .epoch_core_reward_credits_for_distribution - { - 0 => Self::epoch_core_reward_credits_for_distribution_v0( - epoch_start_block_core_height, - next_epoch_start_block_core_height, - ), - version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { - method: "epoch_core_reward_credits_for_distribution_v0".to_string(), - known_versions: vec![0], - received: version, - })), - } - } -} diff --git a/packages/rs-drive-abci/src/execution/platform_events/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs deleted file mode 100644 index 62ac9a6898..0000000000 --- a/packages/rs-drive-abci/src/execution/platform_events/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs +++ /dev/null @@ -1,74 +0,0 @@ -use crate::error::Error; -use crate::execution::platform_events::core_subsidy::{ - CORE_GENESIS_BLOCK_SUBSIDY, CORE_SUBSIDY_HALVING_INTERVAL, -}; -use crate::platform_types::platform::Platform; -use dpp::block::epoch::EpochIndex; -use dpp::fee::Credits; - -use lazy_static::lazy_static; -use std::collections::HashMap; - -lazy_static! { - /// The Core reward halving distribution table for 100 years - /// Yearly decline of production by ~7.1% per year, projected ~18M coins max by year 2050+. - pub static ref CORE_HALVING_DISTRIBUTION: HashMap = { - let mut distribution = CORE_GENESIS_BLOCK_SUBSIDY; - (0..100).map(|i| { - let old_distribution = distribution; - distribution -= distribution / 14; - (i, old_distribution) - }).collect() - }; -} - -impl Platform { - /// Gets the amount of core reward fees to be distributed for the Epoch. - pub(super) fn epoch_core_reward_credits_for_distribution_v0( - epoch_start_block_core_height: u32, - next_epoch_start_block_core_height: u32, - ) -> Result { - // Core is halving block rewards every year so we need to pay - // core block rewards according to halving ratio for the all years during - // the platform epoch payout period (unpaid epoch) - - // Calculate start and end years for the platform epoch payout period - // according to start and end core block heights - let start_core_reward_year = - (epoch_start_block_core_height / CORE_SUBSIDY_HALVING_INTERVAL) as EpochIndex; - let end_core_reward_year = - (next_epoch_start_block_core_height / CORE_SUBSIDY_HALVING_INTERVAL) as EpochIndex; - - let mut total_core_rewards = 0; - - // Calculate block rewards for each core reward year during the platform epoch payout period - for core_reward_year in start_core_reward_year..=end_core_reward_year { - // Calculate the block count per core reward year - - let core_reward_year_start_block = if core_reward_year == end_core_reward_year { - next_epoch_start_block_core_height - } else { - (core_reward_year + 1) as u32 * CORE_SUBSIDY_HALVING_INTERVAL - }; - - let core_reward_year_end_block = if core_reward_year == start_core_reward_year { - epoch_start_block_core_height - } else { - core_reward_year as u32 * CORE_SUBSIDY_HALVING_INTERVAL - }; - - let block_count = core_reward_year_start_block - core_reward_year_end_block; - - // Fetch the core block distribution for the corresponding epoch from the distribution table - // Default to 0 if the core reward year is more than 100 years in the future - let core_block_distribution_ratio = CORE_HALVING_DISTRIBUTION - .get(&core_reward_year) - .unwrap_or(&0); - - // Calculate the core rewards for this epoch and add to the total - total_core_rewards += block_count as Credits * *core_block_distribution_ratio; - } - - Ok(total_core_rewards) - } -} diff --git a/packages/rs-drive-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations/v0/mod.rs index ebdc6793e8..f0e763cc9c 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations/v0/mod.rs @@ -2,6 +2,7 @@ use crate::error::Error; use crate::execution::types::proposer_payouts; use crate::platform_types::platform::Platform; use dpp::block::epoch::Epoch; +use dpp::core_subsidy::epoch_core_reward_credits_for_distribution::epoch_core_reward_credits_for_distribution; use dpp::version::PlatformVersion; use drive::drive::credit_pools::epochs::operations_factory::EpochOperations; use drive::drive::credit_pools::operations::update_unpaid_epoch_index_operation; @@ -39,9 +40,10 @@ impl Platform { }; // Calculate core block reward for the unpaid epoch - let core_block_rewards = Self::epoch_core_reward_credits_for_distribution( + let core_block_rewards = epoch_core_reward_credits_for_distribution( unpaid_epoch.start_block_core_height, unpaid_epoch.next_epoch_start_block_core_height, + self.config.core.reward_multiplier, platform_version, )?; @@ -53,6 +55,14 @@ impl Platform { }, )); + tracing::info!( + "Core block rewards for epoch {} from height {} to height {} are {}", + unpaid_epoch.epoch_index, + unpaid_epoch.start_block_core_height, + unpaid_epoch.next_epoch_start_block_core_height, + core_block_rewards + ); + let unpaid_epoch = unpaid_epoch.into(); let proposers_paid_count = self.add_epoch_pool_to_proposers_payout_operations( diff --git a/packages/rs-drive-abci/src/execution/platform_events/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/mod.rs index 330c502c6b..41b64d63b1 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/mod.rs @@ -10,8 +10,6 @@ pub(in crate::execution) mod core_based_updates; pub(in crate::execution) mod core_chain_lock; /// Instant lock methods pub(in crate::execution) mod core_instant_send_lock; -/// Core subsidy -pub(in crate::execution) mod core_subsidy; /// Epoch based methods pub(in crate::execution) mod epoch; /// Fee pools module diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs index 12fa29bb97..ec5be3ce4b 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs @@ -292,9 +292,10 @@ mod tests { use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally; use drive::query::vote_poll_vote_state_query::ResolvedContestedDocumentVotePollDriveQuery; use drive::util::test_helpers::setup_contract; - use crate::execution::validation::state_transition::state_transitions::tests::{add_contender_to_dpns_name_contest, create_dpns_identity_name_contest, create_dpns_name_contest_give_key_info, fast_forward_to_block, perform_votes_multi}; + use crate::execution::validation::state_transition::state_transitions::tests::{add_contender_to_dpns_name_contest, create_dpns_identity_name_contest, create_dpns_name_contest_give_key_info, perform_votes_multi}; use crate::platform_types::platform_state::v0::PlatformStateV0Methods; use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult::PaidConsensusError; + use crate::test::helpers::fast_forward_to_block::fast_forward_to_block; #[test] fn test_document_creation() { @@ -976,7 +977,7 @@ mod tests { platform_version, ); - fast_forward_to_block(&platform, 500_000_000, 900, 0); //less than a week + fast_forward_to_block(&platform, 500_000_000, 900, 42, 0, false); //less than a week let platform_state = platform.state.load(); @@ -989,7 +990,7 @@ mod tests { platform_version, ); - fast_forward_to_block(&platform, 1_000_000_000, 900, 0); //more than a week, less than 2 weeks + fast_forward_to_block(&platform, 1_000_000_000, 900, 42, 0, false); //more than a week, less than 2 weeks let platform_state = platform.state.load(); @@ -1122,7 +1123,7 @@ mod tests { platform_version, ); - fast_forward_to_block(&platform, 200_000_000, 900, 0); //less than a week + fast_forward_to_block(&platform, 200_000_000, 900, 42, 0, false); //less than a week let platform_state = platform.state.load(); @@ -1135,7 +1136,7 @@ mod tests { platform_version, ); - fast_forward_to_block(&platform, 2_000_000_000, 900, 0); //more than two weeks + fast_forward_to_block(&platform, 2_000_000_000, 900, 42, 0, false); //more than two weeks let platform_state = platform.state.load(); diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/mod.rs index 8239908332..98a30ab30d 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/mod.rs @@ -119,10 +119,9 @@ impl StateTransitionStateValidationV0 for IdentityCreditWithdrawalTransition { #[cfg(test)] mod tests { use crate::config::{PlatformConfig, PlatformTestConfig}; - use crate::execution::validation::state_transition::tests::{ - fast_forward_to_block, setup_identity_with_withdrawal_key_and_system_credits, - }; + use crate::execution::validation::state_transition::tests::setup_identity_with_withdrawal_key_and_system_credits; use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult; + use crate::test::helpers::fast_forward_to_block::fast_forward_to_block; use crate::test::helpers::setup::TestPlatformBuilder; use assert_matches::assert_matches; use dpp::block::block_info::BlockInfo; @@ -156,7 +155,7 @@ mod tests { .build_with_mock_rpc() .set_initial_state_structure(); - fast_forward_to_block(&platform, 1_200_000_000, 900, 1); //next epoch + fast_forward_to_block(&platform, 1_200_000_000, 900, 42, 1, false); //next epoch let (identity, signer, _, withdrawal_key) = setup_identity_with_withdrawal_key_and_system_credits( diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/mod.rs index 218035d77f..5ca52a4e8a 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/mod.rs @@ -74,8 +74,6 @@ pub(crate) mod tests { use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::{get_contested_resource_vote_state_request_v0, GetContestedResourceVoteStateRequestV0}; use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0}; use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::get_contested_resource_vote_state_response_v0::FinishedVoteInfo; - use dpp::block::epoch::Epoch; - use dpp::block::extended_block_info::v0::ExtendedBlockInfoV0; use dpp::dash_to_credits; use dpp::dashcore::{ProTxHash, Txid}; use dpp::dashcore::hashes::Hash; @@ -1993,45 +1991,4 @@ pub(crate) mod tests { finished_vote_info, ) } - - pub(crate) fn fast_forward_to_block( - platform: &TempPlatform, - time_ms: u64, - height: u64, - epoch_index: u16, - ) { - let platform_state = platform.state.load(); - - let mut platform_state = (**platform_state).clone(); - - let protocol_version = platform_state.current_protocol_version_in_consensus(); - let platform_version = PlatformVersion::get(protocol_version).unwrap(); - - let block_info = BlockInfo { - time_ms, //less than 2 weeks - height, - core_height: 42, - epoch: Epoch::new(epoch_index).unwrap(), - }; - - platform_state.set_last_committed_block_info(Some( - ExtendedBlockInfoV0 { - basic_info: block_info, - app_hash: platform - .drive - .grove - .root_hash(None, &platform_version.drive.grove_version) - .unwrap() - .unwrap(), - quorum_hash: [0u8; 32], - block_id_hash: [0u8; 32], - proposer_pro_tx_hash: [0u8; 32], - signature: [0u8; 96], - round: 0, - } - .into(), - )); - - platform.state.store(Arc::new(platform_state)); - } } diff --git a/packages/rs-drive-abci/src/query/service.rs b/packages/rs-drive-abci/src/query/service.rs index 1d12ed90e8..af8d1b840a 100644 --- a/packages/rs-drive-abci/src/query/service.rs +++ b/packages/rs-drive-abci/src/query/service.rs @@ -9,7 +9,29 @@ use crate::rpc::core::DefaultCoreRPC; use crate::utils::spawn_blocking_task_with_name_if_supported; use async_trait::async_trait; use dapi_grpc::platform::v0::platform_server::Platform as PlatformService; -use dapi_grpc::platform::v0::{BroadcastStateTransitionRequest, BroadcastStateTransitionResponse, GetConsensusParamsRequest, GetConsensusParamsResponse, GetContestedResourceIdentityVotesRequest, GetContestedResourceIdentityVotesResponse, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, GetContestedResourceVotersForIdentityRequest, GetContestedResourceVotersForIdentityResponse, GetContestedResourcesRequest, GetContestedResourcesResponse, GetDataContractHistoryRequest, GetDataContractHistoryResponse, GetDataContractRequest, GetDataContractResponse, GetDataContractsRequest, GetDataContractsResponse, GetDocumentsRequest, GetDocumentsResponse, GetEpochsInfoRequest, GetEpochsInfoResponse, GetIdentitiesContractKeysRequest, GetIdentitiesContractKeysResponse, GetIdentityBalanceAndRevisionRequest, GetIdentityBalanceAndRevisionResponse, GetIdentityBalanceRequest, GetIdentityBalanceResponse, GetIdentityByPublicKeyHashRequest, GetIdentityByPublicKeyHashResponse, GetIdentityContractNonceRequest, GetIdentityContractNonceResponse, GetIdentityKeysRequest, GetIdentityKeysResponse, GetIdentityNonceRequest, GetIdentityNonceResponse, GetIdentityRequest, GetIdentityResponse, GetPathElementsRequest, GetPathElementsResponse, GetPrefundedSpecializedBalanceRequest, GetPrefundedSpecializedBalanceResponse, GetProofsRequest, GetProofsResponse, GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeStateResponse, GetProtocolVersionUpgradeVoteStatusRequest, GetProtocolVersionUpgradeVoteStatusResponse, GetVotePollsByEndDateRequest, GetVotePollsByEndDateResponse, WaitForStateTransitionResultRequest, WaitForStateTransitionResultResponse, GetTotalCreditsInPlatformRequest, GetTotalCreditsInPlatformResponse}; +use dapi_grpc::platform::v0::{ + BroadcastStateTransitionRequest, BroadcastStateTransitionResponse, GetConsensusParamsRequest, + GetConsensusParamsResponse, GetContestedResourceIdentityVotesRequest, + GetContestedResourceIdentityVotesResponse, GetContestedResourceVoteStateRequest, + GetContestedResourceVoteStateResponse, GetContestedResourceVotersForIdentityRequest, + GetContestedResourceVotersForIdentityResponse, GetContestedResourcesRequest, + GetContestedResourcesResponse, GetDataContractHistoryRequest, GetDataContractHistoryResponse, + GetDataContractRequest, GetDataContractResponse, GetDataContractsRequest, + GetDataContractsResponse, GetDocumentsRequest, GetDocumentsResponse, GetEpochsInfoRequest, + GetEpochsInfoResponse, GetIdentitiesContractKeysRequest, GetIdentitiesContractKeysResponse, + GetIdentityBalanceAndRevisionRequest, GetIdentityBalanceAndRevisionResponse, + GetIdentityBalanceRequest, GetIdentityBalanceResponse, GetIdentityByPublicKeyHashRequest, + GetIdentityByPublicKeyHashResponse, GetIdentityContractNonceRequest, + GetIdentityContractNonceResponse, GetIdentityKeysRequest, GetIdentityKeysResponse, + GetIdentityNonceRequest, GetIdentityNonceResponse, GetIdentityRequest, GetIdentityResponse, + GetPathElementsRequest, GetPathElementsResponse, GetPrefundedSpecializedBalanceRequest, + GetPrefundedSpecializedBalanceResponse, GetProofsRequest, GetProofsResponse, + GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeStateResponse, + GetProtocolVersionUpgradeVoteStatusRequest, GetProtocolVersionUpgradeVoteStatusResponse, + GetTotalCreditsInPlatformRequest, GetTotalCreditsInPlatformResponse, + GetVotePollsByEndDateRequest, GetVotePollsByEndDateResponse, + WaitForStateTransitionResultRequest, WaitForStateTransitionResultResponse, +}; use dapi_grpc::tonic::{Code, Request, Response, Status}; use dpp::version::PlatformVersion; use std::fmt::Debug; @@ -512,13 +534,16 @@ impl PlatformService for QueryService { .await } - async fn get_total_credits_in_platform(&self, request: Request) -> Result, Status> { + async fn get_total_credits_in_platform( + &self, + request: Request, + ) -> Result, Status> { self.handle_blocking_query( request, Platform::::query_total_credits_in_platform, "get_total_credits_in_platform", ) - .await + .await } } diff --git a/packages/rs-drive-abci/src/query/system/mod.rs b/packages/rs-drive-abci/src/query/system/mod.rs index 97d1890733..b317be8edf 100644 --- a/packages/rs-drive-abci/src/query/system/mod.rs +++ b/packages/rs-drive-abci/src/query/system/mod.rs @@ -1,5 +1,5 @@ mod epoch_infos; mod path_elements; +mod total_credits_in_platform; mod version_upgrade_state; mod version_upgrade_vote_status; -mod total_credits_in_platform; diff --git a/packages/rs-drive-abci/src/query/system/total_credits_in_platform/mod.rs b/packages/rs-drive-abci/src/query/system/total_credits_in_platform/mod.rs index d3a8af88d4..1bb352103f 100644 --- a/packages/rs-drive-abci/src/query/system/total_credits_in_platform/mod.rs +++ b/packages/rs-drive-abci/src/query/system/total_credits_in_platform/mod.rs @@ -7,7 +7,9 @@ use crate::platform_types::platform_state::PlatformState; use crate::query::QueryValidationResult; use dapi_grpc::platform::v0::get_total_credits_in_platform_request::Version as RequestVersion; use dapi_grpc::platform::v0::get_total_credits_in_platform_response::Version as ResponseVersion; -use dapi_grpc::platform::v0::{GetTotalCreditsInPlatformRequest, GetTotalCreditsInPlatformResponse}; +use dapi_grpc::platform::v0::{ + GetTotalCreditsInPlatformRequest, GetTotalCreditsInPlatformResponse, +}; use dpp::version::PlatformVersion; impl Platform { @@ -24,7 +26,11 @@ impl Platform { )); }; - let feature_version_bounds = &platform_version.drive_abci.query.system.total_credits_in_platform; + let feature_version_bounds = &platform_version + .drive_abci + .query + .system + .total_credits_in_platform; let feature_version = match &version { RequestVersion::V0(_) => 0, @@ -42,8 +48,11 @@ impl Platform { } match version { RequestVersion::V0(request_v0) => { - let result = - self.query_total_credits_in_platform_v0(request_v0, platform_state, platform_version)?; + let result = self.query_total_credits_in_platform_v0( + request_v0, + platform_state, + platform_version, + )?; Ok(result.map(|response_v0| GetTotalCreditsInPlatformResponse { version: Some(ResponseVersion::V0(response_v0)), diff --git a/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs b/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs index c870b8187a..0f40f3c4ec 100644 --- a/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs @@ -1,15 +1,27 @@ use crate::error::Error; use crate::platform_types::platform::Platform; +use crate::platform_types::platform_state::v0::PlatformStateV0Methods; +use crate::platform_types::platform_state::PlatformState; use crate::query::QueryValidationResult; use dapi_grpc::platform::v0::get_total_credits_in_platform_request::GetTotalCreditsInPlatformRequestV0; -use dapi_grpc::platform::v0::get_total_credits_in_platform_response::{get_total_credits_in_platform_response_v0, GetTotalCreditsInPlatformResponseV0}; +use dapi_grpc::platform::v0::get_total_credits_in_platform_response::{ + get_total_credits_in_platform_response_v0, GetTotalCreditsInPlatformResponseV0, +}; +use dpp::block::epoch::Epoch; use dpp::check_validation_result_with_data; - -use crate::platform_types::platform_state::PlatformState; +use dpp::core_subsidy::epoch_core_reward_credits_for_distribution::epoch_core_reward_credits_for_distribution; use dpp::validation::ValidationResult; use dpp::version::PlatformVersion; -use drive::drive::balances::{total_credits_on_platform_path_query, TOTAL_SYSTEM_CREDITS_STORAGE_KEY}; +use drive::drive::balances::{ + total_credits_on_platform_path_query, TOTAL_SYSTEM_CREDITS_STORAGE_KEY, +}; +use drive::drive::credit_pools::epochs::epoch_key_constants::KEY_START_BLOCK_CORE_HEIGHT; +use drive::drive::credit_pools::epochs::epochs_root_tree_key_constants::KEY_UNPAID_EPOCH_INDEX; +use drive::drive::credit_pools::epochs::paths::EpochProposers; use drive::drive::system::misc_path; +use drive::drive::RootTree; +use drive::error::proof::ProofError; +use drive::grovedb::{PathQuery, Query, SizedQuery}; use drive::util::grove_operations::DirectQueryType; impl Platform { @@ -19,15 +31,49 @@ impl Platform { platform_state: &PlatformState, platform_version: &PlatformVersion, ) -> Result, Error> { - let path_query = total_credits_on_platform_path_query(); - let response = if prove { + let mut total_credits_on_platform_path_query = total_credits_on_platform_path_query(); + + total_credits_on_platform_path_query.query.limit = None; + + let unpaid_epoch = self.drive.get_unpaid_epoch_index(None, platform_version)?; + + // we also need the path_query for the start_core_height of this unpaid epoch + let unpaid_epoch_index_path_query = PathQuery { + path: vec![vec![RootTree::Pools as u8]], + query: SizedQuery { + query: Query::new_single_key(KEY_UNPAID_EPOCH_INDEX.to_vec()), + limit: None, + offset: None, + }, + }; + + let epoch = Epoch::new(unpaid_epoch)?; + + let start_core_height_query = PathQuery { + path: epoch.get_path_vec(), + query: SizedQuery { + query: Query::new_single_key(KEY_START_BLOCK_CORE_HEIGHT.to_vec()), + limit: None, + offset: None, + }, + }; + + let path_query = PathQuery::merge( + vec![ + &total_credits_on_platform_path_query, + &unpaid_epoch_index_path_query, + &start_core_height_query, + ], + &platform_version.drive.grove_version, + )?; + let proof = check_validation_result_with_data!(self.drive.grove_get_proved_path_query( - &path_query, - None, - &mut vec![], - &platform_version.drive, - )); + &path_query, + None, + &mut vec![], + &platform_version.drive, + )); GetTotalCreditsInPlatformResponseV0 { result: Some(get_total_credits_in_platform_response_v0::Result::Proof( @@ -37,7 +83,8 @@ impl Platform { } } else { let path_holding_total_credits = misc_path(); - let total_credits_in_platform = self.drive + let total_credits_in_platform = self + .drive .grove_get_raw_value_u64_from_encoded_var_vec( (&path_holding_total_credits).into(), TOTAL_SYSTEM_CREDITS_STORAGE_KEY, @@ -45,10 +92,33 @@ impl Platform { None, &mut vec![], &platform_version.drive, - )?.unwrap_or_default(); // 0 would mean we haven't initialized yet + )? + .unwrap_or_default(); // 0 would mean we haven't initialized yet + + let unpaid_epoch_index = self.drive.get_unpaid_epoch_index(None, platform_version)?; + + let unpaid_epoch = Epoch::new(unpaid_epoch_index)?; + + let start_block_core_height = self.drive.get_epoch_start_block_core_height( + &unpaid_epoch, + None, + platform_version, + )?; + + let reward_credits_accumulated_during_current_epoch = + epoch_core_reward_credits_for_distribution( + start_block_core_height, + platform_state.last_committed_core_height(), + self.config.core.reward_multiplier, + platform_version, + )?; + + let total_credits_with_rewards = total_credits_in_platform.checked_add(reward_credits_accumulated_during_current_epoch).ok_or(drive::error::Error::Proof(ProofError::CorruptedProof("overflow while adding platform credits with reward credits accumulated during current epoch".to_string())))?; GetTotalCreditsInPlatformResponseV0 { - result: Some(get_total_credits_in_platform_response_v0::Result::Credits(total_credits_in_platform)), + result: Some(get_total_credits_in_platform_response_v0::Result::Credits( + total_credits_with_rewards, + )), metadata: Some(self.response_metadata_v0(platform_state)), } }; @@ -61,23 +131,53 @@ impl Platform { mod tests { use super::*; use crate::query::tests::setup_platform; - #[test] - fn test_query_total_system_credits() { - let (platform, state, version) = setup_platform(false); + use crate::test::helpers::fast_forward_to_block::fast_forward_to_block; + use dpp::block::epoch::EpochIndex; + use dpp::prelude::CoreBlockHeight; + use drive::drive::Drive; - let platform_version = PlatformVersion::latest(); + fn test_query_total_system_credits( + epoch_index: EpochIndex, + epoch_core_start_height: CoreBlockHeight, + current_core_height: CoreBlockHeight, + ) { + let (platform, _state, platform_version) = setup_platform(true); platform .drive .add_to_system_credits(100, None, platform_version) .expect("expected to insert identity"); - let request = GetTotalCreditsInPlatformRequestV0 { - prove: false, - }; + if epoch_index > 0 { + fast_forward_to_block( + &platform, + 5000, + 100, + epoch_core_start_height, + epoch_index - 1, + true, + ); + } else { + fast_forward_to_block(&platform, 0, 1, epoch_core_start_height, 0, true); + } + + if current_core_height > epoch_core_start_height { + fast_forward_to_block( + &platform, + 15000, + 200, + current_core_height, + epoch_index, + false, + ); + } + + let request = GetTotalCreditsInPlatformRequestV0 { prove: false }; + + let state = platform.state.load(); let response = platform - .query_total_credits_in_platform_v0(request, &state, version) + .query_total_credits_in_platform_v0(request, &state, platform_version) .expect("expected query to succeed"); let response_data = response.into_data().expect("expected data"); @@ -88,6 +188,106 @@ mod tests { panic!("expected credits") }; - assert_eq!(credits, 100); + let rewards = epoch_core_reward_credits_for_distribution( + epoch_core_start_height, + current_core_height, + 1, + platform_version, + ) + .expect("expected to get rewards"); + + assert_eq!(credits, 100 + rewards); + } + + fn test_proved_query_total_system_credits( + epoch_index: EpochIndex, + epoch_core_start_height: CoreBlockHeight, + current_core_height: CoreBlockHeight, + ) { + let (platform, _state, platform_version) = setup_platform(true); + + platform + .drive + .add_to_system_credits(100, None, platform_version) + .expect("expected to insert identity"); + + if epoch_index > 0 { + fast_forward_to_block( + &platform, + 5000, + 100, + epoch_core_start_height, + epoch_index - 1, + true, + ); + } else { + fast_forward_to_block(&platform, 0, 1, epoch_core_start_height, 0, true); + } + + if current_core_height > epoch_core_start_height { + fast_forward_to_block( + &platform, + 15000, + 200, + current_core_height, + epoch_index, + false, + ); + } + + let request = GetTotalCreditsInPlatformRequestV0 { prove: true }; + + let state = platform.state.load(); + + let response = platform + .query_total_credits_in_platform_v0(request, &state, platform_version) + .expect("expected query to succeed"); + + let response_data = response.into_data().expect("expected data"); + + let get_total_credits_in_platform_response_v0::Result::Proof(proof) = + response_data.result.expect("expected a result") + else { + panic!("expected proof") + }; + + let (_, credits) = Drive::verify_total_credits_in_system( + &proof.grovedb_proof, + 1, //todo: we need to set this based on network + current_core_height, + platform_version, + ) + .expect("expected to verify total credits in platform"); + + let rewards = epoch_core_reward_credits_for_distribution( + epoch_core_start_height, + current_core_height, + 1, + platform_version, + ) + .expect("expected to get rewards"); + + assert_eq!(credits, 100 + rewards); + } + + #[test] + fn test_query_total_system_credits_at_genesis() { + // let's say the genesis is 1500 + test_query_total_system_credits(0, 1500, 1500); + test_proved_query_total_system_credits(0, 1500, 1500); + } + + #[test] + fn test_query_total_system_credits_on_first_epoch_not_genesis() { + // let's say the genesis is 1500, we are height 1550 + test_query_total_system_credits(0, 1500, 1550); + test_proved_query_total_system_credits(0, 1500, 1550); + } + + #[test] + fn test_query_total_system_credits_not_genesis_epoch() { + // let's say the genesis is 1500, we are height 2500 + test_query_total_system_credits(1, 2000, 2500); + test_proved_query_total_system_credits(1, 2000, 2500); } } diff --git a/packages/rs-drive-abci/src/test/helpers/fast_forward_to_block.rs b/packages/rs-drive-abci/src/test/helpers/fast_forward_to_block.rs new file mode 100644 index 0000000000..ff7dc8c7bd --- /dev/null +++ b/packages/rs-drive-abci/src/test/helpers/fast_forward_to_block.rs @@ -0,0 +1,146 @@ +use crate::execution::types::block_execution_context::v0::BlockExecutionContextV0; +use crate::execution::types::block_execution_context::BlockExecutionContext; +use crate::execution::types::block_fees::v0::BlockFeesV0Methods; +use crate::execution::types::block_fees::BlockFees; +use crate::execution::types::block_state_info::v0::BlockStateInfoV0; +use crate::platform_types::epoch_info::v0::EpochInfoV0; +use crate::platform_types::epoch_info::EpochInfo; +use crate::platform_types::platform_state::v0::PlatformStateV0Methods; +use crate::platform_types::platform_state::PlatformState; +use crate::platform_types::withdrawal::unsigned_withdrawal_txs::v0::UnsignedWithdrawalTxs; +use crate::rpc::core::MockCoreRPCLike; +use crate::test::helpers::setup::TempPlatform; +use dpp::block::block_info::BlockInfo; +use dpp::block::epoch::Epoch; +use dpp::block::extended_block_info::v0::ExtendedBlockInfoV0; +use platform_version::version::PlatformVersion; +use std::sync::Arc; + +pub(crate) fn fast_forward_to_block( + platform: &TempPlatform, + time_ms: u64, + height: u64, + core_block_height: u32, + epoch_index: u16, + should_process_epoch_change: bool, +) { + let platform_state = platform.state.load(); + + let mut platform_state = (**platform_state).clone(); + + let protocol_version = platform_state.current_protocol_version_in_consensus(); + let platform_version = PlatformVersion::get(protocol_version).unwrap(); + + let block_info = BlockInfo { + time_ms, //less than 2 weeks + height, + core_height: core_block_height, + epoch: Epoch::new(epoch_index).unwrap(), + }; + + platform_state.set_last_committed_block_info(Some( + ExtendedBlockInfoV0 { + basic_info: block_info, + app_hash: platform + .drive + .grove + .root_hash(None, &platform_version.drive.grove_version) + .unwrap() + .unwrap(), + quorum_hash: [0u8; 32], + block_id_hash: [0u8; 32], + proposer_pro_tx_hash: [0u8; 32], + signature: [0u8; 96], + round: 0, + } + .into(), + )); + + platform.state.store(Arc::new(platform_state.clone())); + + if should_process_epoch_change { + process_epoch_change( + platform, + Some(platform_state), + time_ms, + height, + core_block_height, + epoch_index, + ) + } +} + +pub(crate) fn process_epoch_change( + platform: &TempPlatform, + platform_state: Option, + time_ms: u64, + height: u64, + core_block_height: u32, + epoch_index: u16, +) { + let platform_state = platform_state.unwrap_or_else(|| { + let platform_state = platform.state.load(); + + (**platform_state).clone() + }); + + let protocol_version = platform_state.current_protocol_version_in_consensus(); + let platform_version = PlatformVersion::get(protocol_version).unwrap(); + + let block_execution_context: BlockExecutionContext = BlockExecutionContextV0 { + block_state_info: BlockStateInfoV0 { + height, + round: 0, + block_time_ms: time_ms, + previous_block_time_ms: time_ms.checked_sub(3000), + proposer_pro_tx_hash: [0; 32], + core_chain_locked_height: core_block_height, + block_hash: Some([0; 32]), + app_hash: None, + } + .into(), + epoch_info: EpochInfo::V0(EpochInfoV0 { + current_epoch_index: epoch_index, + previous_epoch_index: epoch_index.checked_sub(1), + is_epoch_change: true, + }), + // TODO: It doesn't seem correct to use previous block count of hpmns. + // We currently not using this field in the codebase. We probably should just remove it. + hpmn_count: 100, + unsigned_withdrawal_transactions: UnsignedWithdrawalTxs::default(), + block_platform_state: platform_state, + proposer_results: None, + } + .into(); + + let block_fees: BlockFees = BlockFees::from_fees(0, 0); + + let mut operations = vec![]; + + platform + .add_process_epoch_change_operations( + &block_execution_context, + &block_fees, + None, + &mut operations, + platform_version, + ) + .expect("expected to process change operations"); + + platform + .drive + .apply_drive_operations( + operations, + true, + &BlockInfo { + time_ms, + height, + core_height: core_block_height, + epoch: Epoch::new(epoch_index).unwrap(), + }, + None, + platform_version, + None, + ) + .expect("expected to apply drive operations"); +} diff --git a/packages/rs-drive-abci/src/test/helpers/mod.rs b/packages/rs-drive-abci/src/test/helpers/mod.rs index ba5a25f76b..11a8dc90c9 100644 --- a/packages/rs-drive-abci/src/test/helpers/mod.rs +++ b/packages/rs-drive-abci/src/test/helpers/mod.rs @@ -1,6 +1,8 @@ +/// Test helpers +#[cfg(test)] +pub mod fast_forward_to_block; pub mod fee_pools; pub mod setup; - // TODO: Move tests to appropriate place #[cfg(test)] diff --git a/packages/rs-drive-proof-verifier/src/proof.rs b/packages/rs-drive-proof-verifier/src/proof.rs index d0dbc2c321..0cb276f4f0 100644 --- a/packages/rs-drive-proof-verifier/src/proof.rs +++ b/packages/rs-drive-proof-verifier/src/proof.rs @@ -1,5 +1,6 @@ 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_identities_contract_keys_request::GetIdentitiesContractKeysRequestV0; use dapi_grpc::platform::v0::get_path_elements_request::GetPathElementsRequestV0; @@ -51,8 +52,6 @@ use drive::query::{DriveDocumentQuery, VotePollsByEndDateDriveQuery}; use std::array::TryFromSliceError; use std::collections::BTreeMap; use std::num::TryFromIntError; -use drive::drive::balances::total_credits_on_platform_path_query; -use crate::verify::verify_tenderdash_proof; /// Parse and verify the received proof and retrieve the requested object, if any. /// @@ -1611,7 +1610,6 @@ impl FromProof for Vote { } impl FromProof for TotalCreditsOnPlatform { - type Request = platform::GetTotalCreditsInPlatformRequest; type Response = platform::GetTotalCreditsInPlatformResponse; @@ -1628,18 +1626,24 @@ impl FromProof for TotalCreditsOnPla // Parse response to read proof and metadata let proof = response.proof().or(Err(Error::NoProofInResult))?; let mtd = response.metadata().or(Err(Error::EmptyResponseMetadata))?; - + let (root_hash, credits) = Drive::verify_total_credits_in_system( - &proof.grovedb_proof, - platform_version, - ) - .map_err(|e| Error::DriveError { - error: e.to_string(), - })?; + &proof.grovedb_proof, + 1, //todo: we need to set this based on network + mtd.core_chain_locked_height, + platform_version, + ) + .map_err(|e| Error::DriveError { + error: e.to_string(), + })?; verify_tenderdash_proof(proof, mtd, &root_hash, provider)?; - Ok((Some(TotalCreditsOnPlatform(credits)), mtd.clone(), proof.clone())) + Ok(( + Some(TotalCreditsOnPlatform(credits)), + mtd.clone(), + proof.clone(), + )) } } diff --git a/packages/rs-drive-proof-verifier/src/types.rs b/packages/rs-drive-proof-verifier/src/types.rs index 79edb19bd3..52ba7049bb 100644 --- a/packages/rs-drive-proof-verifier/src/types.rs +++ b/packages/rs-drive-proof-verifier/src/types.rs @@ -24,9 +24,10 @@ use dpp::{ prelude::{DataContract, Identifier, IdentityPublicKey, Revision}, util::deserializer::ProtocolVersion, }; -use drive::grovedb::{Element, Query, SizedQuery}; +use drive::grovedb::Element; use std::collections::{BTreeMap, BTreeSet}; +use drive::grovedb::query_result_type::Path; #[cfg(feature = "mocks")] use { bincode::{Decode, Encode}, @@ -34,10 +35,6 @@ use { platform_serialization::{PlatformVersionEncode, PlatformVersionedDecode}, platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}, }; -use drive::drive::balances::TOTAL_SYSTEM_CREDITS_STORAGE_KEY; -use drive::drive::RootTree; -use drive::grovedb::query_result_type::Path; -use drive::query::PathQuery; /// A data structure that holds a set of objects of a generic type `O`, indexed by a key of type `K`. /// diff --git a/packages/rs-drive/src/drive/balances/mod.rs b/packages/rs-drive/src/drive/balances/mod.rs index 7bbe69b2f1..0af170831e 100644 --- a/packages/rs-drive/src/drive/balances/mod.rs +++ b/packages/rs-drive/src/drive/balances/mod.rs @@ -17,10 +17,10 @@ mod remove_from_system_credits_operations; #[cfg(feature = "server")] mod calculate_total_credits_balance; -use grovedb::{PathQuery, SizedQuery}; #[cfg(any(feature = "server", feature = "verify"))] use crate::drive::RootTree; use crate::query::Query; +use grovedb::{PathQuery, SizedQuery}; /// Storage fee pool key #[cfg(any(feature = "server", feature = "verify"))] diff --git a/packages/rs-drive/src/verify/system/mod.rs b/packages/rs-drive/src/verify/system/mod.rs index 18d1400abf..e0362df437 100644 --- a/packages/rs-drive/src/verify/system/mod.rs +++ b/packages/rs-drive/src/verify/system/mod.rs @@ -1,5 +1,5 @@ mod verify_elements; mod verify_epoch_infos; +mod verify_total_credits_in_system; mod verify_upgrade_state; mod verify_upgrade_vote_status; -mod verify_total_credits_in_system; diff --git a/packages/rs-drive/src/verify/system/verify_total_credits_in_system/mod.rs b/packages/rs-drive/src/verify/system/verify_total_credits_in_system/mod.rs index 667440850b..a6f18a50db 100644 --- a/packages/rs-drive/src/verify/system/verify_total_credits_in_system/mod.rs +++ b/packages/rs-drive/src/verify/system/verify_total_credits_in_system/mod.rs @@ -2,22 +2,25 @@ use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; use crate::verify::RootHash; -use dpp::version::PlatformVersion; use dpp::fee::Credits; +use dpp::prelude::CoreBlockHeight; +use dpp::version::PlatformVersion; mod v0; impl Drive { - /// Verifies a proof containing the total credits in platform. + /// Verifies a proof containing the total credits in the platform. /// /// # Parameters /// /// - `proof`: A byte slice representing the proof to be verified. - /// - `platform_version`: the platform version, + /// - `core_distribution_multiplier`: A multiplier for the core distribution. This is 1 for mainnet. And 10 for testnet. + /// - `current_core_height`: The current core block height. + /// - `platform_version`: The platform version. /// /// # Returns /// - /// Returns a `Result` with a tuple of `RootHash` and `Credits`. + /// Returns a `Result` containing a tuple of `RootHash` and `Credits`. /// /// # Errors /// @@ -25,12 +28,26 @@ impl Drive { /// /// - The proof is corrupted. /// - The GroveDb query fails. + /// - The platform version is unknown. pub fn verify_total_credits_in_system( proof: &[u8], + core_distribution_multiplier: u16, + current_core_height: CoreBlockHeight, platform_version: &PlatformVersion, ) -> Result<(RootHash, Credits), Error> { - match platform_version.drive.methods.verify.system.verify_total_credits_in_system { - 0 => Drive::verify_total_credits_in_system_v0(proof, platform_version), + match platform_version + .drive + .methods + .verify + .system + .verify_total_credits_in_system + { + 0 => Drive::verify_total_credits_in_system_v0( + proof, + core_distribution_multiplier, + current_core_height, + platform_version, + ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "verify_total_credits_in_system".to_string(), known_versions: vec![0], diff --git a/packages/rs-drive/src/verify/system/verify_total_credits_in_system/v0/mod.rs b/packages/rs-drive/src/verify/system/verify_total_credits_in_system/v0/mod.rs index c18a5e30e4..5a02026bec 100644 --- a/packages/rs-drive/src/verify/system/verify_total_credits_in_system/v0/mod.rs +++ b/packages/rs-drive/src/verify/system/verify_total_credits_in_system/v0/mod.rs @@ -1,12 +1,21 @@ -use grovedb::GroveDb; -use crate::drive::Drive; +use crate::drive::balances::{ + total_credits_on_platform_path_query, TOTAL_SYSTEM_CREDITS_STORAGE_KEY, +}; +use crate::drive::credit_pools::epochs::epoch_key_constants::KEY_START_BLOCK_CORE_HEIGHT; +use crate::drive::credit_pools::epochs::epochs_root_tree_key_constants::KEY_UNPAID_EPOCH_INDEX; +use crate::drive::credit_pools::epochs::paths::EpochProposers; +use crate::drive::{Drive, RootTree}; +use crate::error::proof::ProofError; use crate::error::Error; +use crate::query::Query; use crate::verify::RootHash; -use platform_version::version::PlatformVersion; -use integer_encoding::VarInt; +use dpp::block::epoch::{Epoch, EpochIndex}; +use dpp::core_subsidy::epoch_core_reward_credits_for_distribution::epoch_core_reward_credits_for_distribution; use dpp::fee::Credits; -use crate::drive::balances::{total_credits_on_platform_path_query, TOTAL_SYSTEM_CREDITS_STORAGE_KEY}; -use crate::error::proof::ProofError; +use dpp::prelude::CoreBlockHeight; +use grovedb::{Element, GroveDb, PathQuery, SizedQuery}; +use integer_encoding::VarInt; +use platform_version::version::PlatformVersion; impl Drive { /// Verifies a proof for the total credits in the system and returns @@ -31,30 +40,155 @@ impl Drive { #[inline(always)] pub(crate) fn verify_total_credits_in_system_v0( proof: &[u8], + core_distribution_multiplier: u16, + current_core_height: CoreBlockHeight, platform_version: &PlatformVersion, ) -> Result<(RootHash, Credits), Error> { - let path_query = total_credits_on_platform_path_query(); + let total_credits_on_platform_path_query = total_credits_on_platform_path_query(); - let (root_hash, mut proved_path_key_values) = - GroveDb::verify_query_raw(proof, &path_query, &platform_version.drive.grove_version)?; + let (root_hash, mut proved_path_key_values) = GroveDb::verify_subset_query( + proof, + &total_credits_on_platform_path_query, + &platform_version.drive.grove_version, + )?; if proved_path_key_values.len() > 1 { return Err(Error::Proof(ProofError::TooManyElements("We should only get back at most 1 element in the proof for the total credits in the system"))); } let Some(proved_path_key_value) = proved_path_key_values.pop() else { - return Err(Error::Proof(ProofError::IncorrectProof("This proof would show that Platform has not yet been initialized".to_string()))); + return Err(Error::Proof(ProofError::IncorrectProof( + "This proof would show that Platform has not yet been initialized".to_string(), + ))); + }; + + if proved_path_key_value.0 != total_credits_on_platform_path_query.path { + return Err(Error::Proof(ProofError::CorruptedProof( + "The result of this proof is not what we asked for (path)".to_string(), + ))); + } + + if proved_path_key_value.1 != TOTAL_SYSTEM_CREDITS_STORAGE_KEY.to_vec() { + return Err(Error::Proof(ProofError::CorruptedProof( + "The result of this proof is not what we asked for (key)".to_string(), + ))); + } + + let Some(Element::Item(bytes, _)) = proved_path_key_value.2 else { + return Err(Error::Proof(ProofError::CorruptedProof( + "We are expecting an item for the total credits in platform field".to_string(), + ))); + }; + + let credits = Credits::decode_var(bytes.as_slice()).ok_or(Error::Proof(ProofError::CorruptedProof("The result of this proof does not contain an encoded var integer for total credits".to_string())))?.0; + + // we also need the path_query for the start_core_height of this unpaid epoch + let unpaid_epoch_index = PathQuery { + path: vec![vec![RootTree::Pools as u8]], + query: SizedQuery { + query: Query::new_single_key(KEY_UNPAID_EPOCH_INDEX.to_vec()), + limit: Some(1), + offset: None, + }, + }; + + let (_, mut proved_path_key_values) = GroveDb::verify_subset_query( + proof, + &unpaid_epoch_index, + &platform_version.drive.grove_version, + )?; + + let Some(proved_path_key_value) = proved_path_key_values.pop() else { + return Err(Error::Proof(ProofError::IncorrectProof("This proof would show that Platform has not yet been initialized as we can not find a start index".to_string()))); + }; + + if proved_path_key_value.0 != unpaid_epoch_index.path { + return Err(Error::Proof(ProofError::CorruptedProof( + "The result of this proof is not what we asked for (unpaid epoch path)".to_string(), + ))); + } + + if proved_path_key_value.1 != KEY_UNPAID_EPOCH_INDEX.to_vec() { + return Err(Error::Proof(ProofError::CorruptedProof( + "The result of this proof is not what we asked for (unpaid epoch key)".to_string(), + ))); + } + + let Some(Element::Item(bytes, _)) = proved_path_key_value.2 else { + return Err(Error::Proof(ProofError::CorruptedProof( + "We are expecting an item for the epoch index".to_string(), + ))); + }; + + let epoch_index = EpochIndex::from_be_bytes(bytes.as_slice().try_into().map_err(|_| { + Error::Proof(ProofError::CorruptedProof( + "epoch index invalid length".to_string(), + )) + })?); + + let epoch = Epoch::new(epoch_index).map_err(|_| { + Error::Proof(ProofError::CorruptedProof( + "Epoch index out of bounds".to_string(), + )) + })?; + + let start_core_height_query = PathQuery { + path: epoch.get_path_vec(), + query: SizedQuery { + query: Query::new_single_key(KEY_START_BLOCK_CORE_HEIGHT.to_vec()), + limit: None, + offset: None, + }, + }; + + let (_, mut proved_path_key_values) = GroveDb::verify_subset_query( + proof, + &start_core_height_query, + &platform_version.drive.grove_version, + )?; + + let Some(proved_path_key_value) = proved_path_key_values.pop() else { + return Err(Error::Proof(ProofError::IncorrectProof( + "We can not find the start core height of the unpaid epoch".to_string(), + ))); }; - if proved_path_key_value.path != path_query.path { - return Err(Error::Proof(ProofError::CorruptedProof("The result of this proof is not what we asked for (path)".to_string()))); + if proved_path_key_value.0 != start_core_height_query.path { + return Err(Error::Proof(ProofError::CorruptedProof( + "The result of this proof is not what we asked for (start core height path)" + .to_string(), + ))); } - if proved_path_key_value.key != TOTAL_SYSTEM_CREDITS_STORAGE_KEY.to_vec() { - return Err(Error::Proof(ProofError::CorruptedProof("The result of this proof is not what we asked for (key)".to_string()))); + if proved_path_key_value.1 != KEY_START_BLOCK_CORE_HEIGHT.to_vec() { + return Err(Error::Proof(ProofError::CorruptedProof( + "The result of this proof is not what we asked for (start core height key)" + .to_string(), + ))); } - let credits = Credits::decode_var(proved_path_key_value.value.as_slice()).ok_or(Error::Proof(ProofError::CorruptedProof("The result of this proof does not contain an encoded var integer for total credits".to_string())))?.0; - - Ok((root_hash, credits)) + let Some(Element::Item(bytes, _)) = proved_path_key_value.2 else { + return Err(Error::Proof(ProofError::CorruptedProof( + "We are expecting an item for the start core height of the unpaid epoch" + .to_string(), + ))); + }; + + let start_core_height = u32::from_be_bytes(bytes.as_slice().try_into().map_err(|_| { + Error::Proof(ProofError::CorruptedProof( + "start core height invalid length".to_string(), + )) + })?); + + let reward_credits_accumulated_during_current_epoch = + epoch_core_reward_credits_for_distribution( + start_core_height, + current_core_height, + core_distribution_multiplier, + platform_version, + )?; + + let total_credits = credits.checked_add(reward_credits_accumulated_during_current_epoch).ok_or(Error::Proof(ProofError::CorruptedProof("overflow while adding platform credits with reward credits accumulated during current epoch".to_string())))?; + + Ok((root_hash, total_credits)) } } diff --git a/packages/rs-platform-version/src/version/dpp_versions.rs b/packages/rs-platform-version/src/version/dpp_versions.rs index 98254686ef..6a64561f6e 100644 --- a/packages/rs-platform-version/src/version/dpp_versions.rs +++ b/packages/rs-platform-version/src/version/dpp_versions.rs @@ -14,6 +14,7 @@ pub struct DPPVersion { pub identity_versions: IdentityVersions, pub voting_versions: VotingVersions, pub asset_lock_versions: AssetLockVersions, + pub methods: DPPMethodVersions, } #[derive(Clone, Debug, Default)] @@ -262,3 +263,8 @@ pub struct DocumentMethodVersions { pub get_raw_for_contract: FeatureVersion, pub get_raw_for_document_type: FeatureVersion, } + +#[derive(Clone, Debug, Default)] +pub struct DPPMethodVersions { + pub epoch_core_reward_credits_for_distribution: FeatureVersion, +} diff --git a/packages/rs-platform-version/src/version/drive_abci_versions.rs b/packages/rs-platform-version/src/version/drive_abci_versions.rs index 9fd0d8e974..a23a5c6e02 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions.rs @@ -80,7 +80,6 @@ pub struct DriveAbciMethodVersions { pub core_based_updates: DriveAbciCoreBasedUpdatesMethodVersions, pub protocol_upgrade: DriveAbciProtocolUpgradeMethodVersions, pub block_fee_processing: DriveAbciBlockFeeProcessingMethodVersions, - pub core_subsidy: DriveAbciCoreSubsidyMethodVersions, pub core_chain_lock: DriveAbciCoreChainLockMethodVersionsAndConstants, pub core_instant_send_lock: DriveAbciCoreInstantSendLockMethodVersions, pub fee_pool_inwards_distribution: DriveAbciFeePoolInwardsDistributionMethodVersions, @@ -253,11 +252,6 @@ pub struct DriveAbciBlockFeeProcessingMethodVersions { pub process_block_fees: FeatureVersion, } -#[derive(Clone, Debug, Default)] -pub struct DriveAbciCoreSubsidyMethodVersions { - pub epoch_core_reward_credits_for_distribution: FeatureVersion, -} - #[derive(Clone, Debug, Default)] pub struct DriveAbciCoreInstantSendLockMethodVersions { pub verify_recent_signature_locally: FeatureVersion, diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 0de2b01611..bfc55b570a 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -1,11 +1,11 @@ use crate::version::contracts::SystemDataContractVersions; use crate::version::dpp_versions::{ - AssetLockVersions, ContractVersions, CostVersions, DPPValidationVersions, DPPVersion, - DataContractMethodVersions, DataContractValidationVersions, DocumentFeatureVersionBounds, - DocumentMethodVersions, DocumentTransitionVersions, DocumentTypeClassMethodVersions, - DocumentTypeIndexVersions, DocumentTypeMethodVersions, DocumentTypeSchemaVersions, - DocumentTypeValidationVersions, DocumentTypeVersions, DocumentVersions, - DocumentsBatchTransitionValidationVersions, DocumentsBatchTransitionVersions, + AssetLockVersions, ContractVersions, CostVersions, DPPMethodVersions, DPPValidationVersions, + DPPVersion, DataContractMethodVersions, DataContractValidationVersions, + DocumentFeatureVersionBounds, DocumentMethodVersions, DocumentTransitionVersions, + DocumentTypeClassMethodVersions, DocumentTypeIndexVersions, DocumentTypeMethodVersions, + DocumentTypeSchemaVersions, DocumentTypeValidationVersions, DocumentTypeVersions, + DocumentVersions, DocumentsBatchTransitionValidationVersions, DocumentsBatchTransitionVersions, IdentityKeyTypeMethodVersions, IdentityTransitionAssetLockVersions, IdentityTransitionVersions, IdentityVersions, JsonSchemaValidatorVersions, PublicKeyInCreationMethodVersions, RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, @@ -16,7 +16,7 @@ use crate::version::drive_abci_versions::{ DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, - DriveAbciCoreInstantSendLockMethodVersions, DriveAbciCoreSubsidyMethodVersions, + DriveAbciCoreInstantSendLockMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, DriveAbciFeePoolInwardsDistributionMethodVersions, DriveAbciFeePoolOutwardsDistributionMethodVersions, @@ -633,9 +633,6 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { add_process_epoch_change_operations: 0, process_block_fees: 0, }, - core_subsidy: DriveAbciCoreSubsidyMethodVersions { - epoch_core_reward_credits_for_distribution: 0, - }, core_chain_lock: DriveAbciCoreChainLockMethodVersionsAndConstants { choose_quorum: 0, verify_chain_lock: 0, @@ -1227,6 +1224,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { default_current_version: 0, }, }, + methods: DPPMethodVersions { epoch_core_reward_credits_for_distribution: 0 }, }, system_data_contracts: SystemDataContractVersions { withdrawals: 1, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index f8bd59a448..73610024e3 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -1,11 +1,11 @@ use crate::version::contracts::SystemDataContractVersions; use crate::version::dpp_versions::{ - AssetLockVersions, ContractVersions, CostVersions, DPPValidationVersions, DPPVersion, - DataContractMethodVersions, DataContractValidationVersions, DocumentFeatureVersionBounds, - DocumentMethodVersions, DocumentTransitionVersions, DocumentTypeClassMethodVersions, - DocumentTypeIndexVersions, DocumentTypeMethodVersions, DocumentTypeSchemaVersions, - DocumentTypeValidationVersions, DocumentTypeVersions, DocumentVersions, - DocumentsBatchTransitionValidationVersions, DocumentsBatchTransitionVersions, + AssetLockVersions, ContractVersions, CostVersions, DPPMethodVersions, DPPValidationVersions, + DPPVersion, DataContractMethodVersions, DataContractValidationVersions, + DocumentFeatureVersionBounds, DocumentMethodVersions, DocumentTransitionVersions, + DocumentTypeClassMethodVersions, DocumentTypeIndexVersions, DocumentTypeMethodVersions, + DocumentTypeSchemaVersions, DocumentTypeValidationVersions, DocumentTypeVersions, + DocumentVersions, DocumentsBatchTransitionValidationVersions, DocumentsBatchTransitionVersions, IdentityKeyTypeMethodVersions, IdentityTransitionAssetLockVersions, IdentityTransitionVersions, IdentityVersions, JsonSchemaValidatorVersions, PublicKeyInCreationMethodVersions, RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, @@ -16,7 +16,7 @@ use crate::version::drive_abci_versions::{ DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, - DriveAbciCoreInstantSendLockMethodVersions, DriveAbciCoreSubsidyMethodVersions, + DriveAbciCoreInstantSendLockMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, DriveAbciFeePoolInwardsDistributionMethodVersions, DriveAbciFeePoolOutwardsDistributionMethodVersions, @@ -633,9 +633,6 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { add_process_epoch_change_operations: 0, process_block_fees: 0, }, - core_subsidy: DriveAbciCoreSubsidyMethodVersions { - epoch_core_reward_credits_for_distribution: 0, - }, core_chain_lock: DriveAbciCoreChainLockMethodVersionsAndConstants { choose_quorum: 0, verify_chain_lock: 0, @@ -1227,6 +1224,9 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { default_current_version: 0, }, }, + methods: DPPMethodVersions { + epoch_core_reward_credits_for_distribution: 0, + } }, system_data_contracts: SystemDataContractVersions { withdrawals: 1, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index bca9f788e0..edb0838895 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -1,11 +1,11 @@ use crate::version::contracts::SystemDataContractVersions; use crate::version::dpp_versions::{ - AssetLockVersions, ContractVersions, CostVersions, DPPValidationVersions, DPPVersion, - DataContractMethodVersions, DataContractValidationVersions, DocumentFeatureVersionBounds, - DocumentMethodVersions, DocumentTransitionVersions, DocumentTypeClassMethodVersions, - DocumentTypeIndexVersions, DocumentTypeMethodVersions, DocumentTypeSchemaVersions, - DocumentTypeValidationVersions, DocumentTypeVersions, DocumentVersions, - DocumentsBatchTransitionValidationVersions, DocumentsBatchTransitionVersions, + AssetLockVersions, ContractVersions, CostVersions, DPPMethodVersions, DPPValidationVersions, + DPPVersion, DataContractMethodVersions, DataContractValidationVersions, + DocumentFeatureVersionBounds, DocumentMethodVersions, DocumentTransitionVersions, + DocumentTypeClassMethodVersions, DocumentTypeIndexVersions, DocumentTypeMethodVersions, + DocumentTypeSchemaVersions, DocumentTypeValidationVersions, DocumentTypeVersions, + DocumentVersions, DocumentsBatchTransitionValidationVersions, DocumentsBatchTransitionVersions, IdentityKeyTypeMethodVersions, IdentityTransitionAssetLockVersions, IdentityTransitionVersions, IdentityVersions, JsonSchemaValidatorVersions, PublicKeyInCreationMethodVersions, RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, @@ -16,7 +16,7 @@ use crate::version::drive_abci_versions::{ DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, - DriveAbciCoreInstantSendLockMethodVersions, DriveAbciCoreSubsidyMethodVersions, + DriveAbciCoreInstantSendLockMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, DriveAbciFeePoolInwardsDistributionMethodVersions, DriveAbciFeePoolOutwardsDistributionMethodVersions, @@ -632,9 +632,6 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { add_process_epoch_change_operations: 0, process_block_fees: 0, }, - core_subsidy: DriveAbciCoreSubsidyMethodVersions { - epoch_core_reward_credits_for_distribution: 0, - }, core_chain_lock: DriveAbciCoreChainLockMethodVersionsAndConstants { choose_quorum: 0, verify_chain_lock: 0, @@ -1226,6 +1223,9 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { default_current_version: 0, }, }, + methods: DPPMethodVersions { + epoch_core_reward_credits_for_distribution: 0, + }, }, system_data_contracts: SystemDataContractVersions { withdrawals: 1, diff --git a/packages/rs-sdk/src/mock/requests.rs b/packages/rs-sdk/src/mock/requests.rs index 23f2ad535f..db66c71ea3 100644 --- a/packages/rs-sdk/src/mock/requests.rs +++ b/packages/rs-sdk/src/mock/requests.rs @@ -14,7 +14,11 @@ use dpp::{ }, voting::votes::{resource_vote::ResourceVote, Vote}, }; -use drive_proof_verifier::types::{Contenders, ContestedResources, ElementFetchRequestItem, IdentityBalanceAndRevision, MasternodeProtocolVote, PrefundedSpecializedBalance, TotalCreditsOnPlatform, VotePollsGroupedByTimestamp, Voters}; +use drive_proof_verifier::types::{ + Contenders, ContestedResources, ElementFetchRequestItem, IdentityBalanceAndRevision, + MasternodeProtocolVote, PrefundedSpecializedBalance, TotalCreditsOnPlatform, + VotePollsGroupedByTimestamp, Voters, +}; use std::collections::BTreeMap; static BINCODE_CONFIG: bincode::config::Configuration = bincode::config::standard(); @@ -206,8 +210,6 @@ impl MockResponse for ProTxHash { } } - - impl_mock_response!(Identity); impl_mock_response!(IdentityPublicKey); impl_mock_response!(Identifier); diff --git a/packages/rs-sdk/src/platform/fetch_many.rs b/packages/rs-sdk/src/platform/fetch_many.rs index 6069eb65ce..b2891412c7 100644 --- a/packages/rs-sdk/src/platform/fetch_many.rs +++ b/packages/rs-sdk/src/platform/fetch_many.rs @@ -28,7 +28,11 @@ use dpp::{ block::extended_epoch_info::ExtendedEpochInfo, voting::votes::resource_vote::ResourceVote, }; use dpp::{document::Document, voting::contender_structs::ContenderWithSerializedDocument}; -use drive_proof_verifier::types::{Contenders, ContestedResource, ContestedResources, DataContracts, ExtendedEpochInfos, IdentityPublicKeys, MasternodeProtocolVote, MasternodeProtocolVotes, ProtocolVersionUpgrades, ResourceVotesByIdentity, VotePollsGroupedByTimestamp, Voter, Voters}; +use drive_proof_verifier::types::{ + Contenders, ContestedResource, ContestedResources, DataContracts, ExtendedEpochInfos, + IdentityPublicKeys, MasternodeProtocolVote, MasternodeProtocolVotes, ProtocolVersionUpgrades, + ResourceVotesByIdentity, VotePollsGroupedByTimestamp, Voter, Voters, +}; use drive_proof_verifier::{types::Documents, FromProof}; use rs_dapi_client::{transport::TransportRequest, DapiRequest, RequestSettings}; use std::collections::BTreeMap; @@ -368,4 +372,4 @@ impl FetchMany for ResourceVote { /// * [VotePollsByEndDateDriveQuery] impl FetchMany for VotePoll { type Request = GetVotePollsByEndDateRequest; -} \ No newline at end of file +} diff --git a/packages/rs-sdk/src/platform/query.rs b/packages/rs-sdk/src/platform/query.rs index a0d907de38..36fd30685b 100644 --- a/packages/rs-sdk/src/platform/query.rs +++ b/packages/rs-sdk/src/platform/query.rs @@ -1,11 +1,21 @@ //! Query trait representing criteria for fetching data from Platform. //! //! [Query] trait is used to specify individual objects as well as search criteria for fetching multiple objects from Platform. +use crate::{error::Error, platform::document_query::DocumentQuery}; use dapi_grpc::mock::Mockable; use dapi_grpc::platform::v0::get_contested_resource_identity_votes_request::GetContestedResourceIdentityVotesRequestV0; use dapi_grpc::platform::v0::get_contested_resource_voters_for_identity_request::GetContestedResourceVotersForIdentityRequestV0; use dapi_grpc::platform::v0::get_contested_resources_request::GetContestedResourcesRequestV0; -use dapi_grpc::platform::v0::{self as proto, get_identity_keys_request, get_identity_keys_request::GetIdentityKeysRequestV0, AllKeys, GetContestedResourceVoteStateRequest, GetContestedResourceVotersForIdentityRequest, GetContestedResourcesRequest, GetEpochsInfoRequest, GetIdentityKeysRequest, GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeVoteStatusRequest, KeyRequestType, GetPathElementsRequest, get_path_elements_request, GetTotalCreditsInPlatformRequest, get_total_credits_in_platform_request}; +use dapi_grpc::platform::v0::get_path_elements_request::GetPathElementsRequestV0; +use dapi_grpc::platform::v0::get_total_credits_in_platform_request::GetTotalCreditsInPlatformRequestV0; +use dapi_grpc::platform::v0::{ + self as proto, get_identity_keys_request, get_identity_keys_request::GetIdentityKeysRequestV0, + get_path_elements_request, get_total_credits_in_platform_request, AllKeys, + GetContestedResourceVoteStateRequest, GetContestedResourceVotersForIdentityRequest, + GetContestedResourcesRequest, GetEpochsInfoRequest, GetIdentityKeysRequest, + GetPathElementsRequest, GetProtocolVersionUpgradeStateRequest, + GetProtocolVersionUpgradeVoteStatusRequest, GetTotalCreditsInPlatformRequest, KeyRequestType, +}; use dapi_grpc::platform::v0::{ GetContestedResourceIdentityVotesRequest, GetPrefundedSpecializedBalanceRequest, GetVotePollsByEndDateRequest, @@ -19,12 +29,9 @@ use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQuer use drive::query::vote_polls_by_document_type_query::VotePollsByDocumentTypeQuery; use drive::query::{DriveDocumentQuery, VotePollsByEndDateDriveQuery}; use drive_proof_verifier::from_request::TryFromRequest; +use drive_proof_verifier::types::{KeysInPath, TotalCreditsOnPlatform}; use rs_dapi_client::transport::TransportRequest; use std::fmt::Debug; -use dapi_grpc::platform::v0::get_path_elements_request::GetPathElementsRequestV0; -use dapi_grpc::platform::v0::get_total_credits_in_platform_request::GetTotalCreditsInPlatformRequestV0; -use drive_proof_verifier::types::{KeysInPath, TotalCreditsOnPlatform}; -use crate::{error::Error, platform::document_query::DocumentQuery}; use super::types::epoch::EpochQuery; /// Default limit of epoch records returned by Platform. @@ -541,7 +548,6 @@ impl Query for LimitQuery { } } - impl Query for KeysInPath { fn query(self, prove: bool) -> Result { if !prove { @@ -550,7 +556,11 @@ impl Query for KeysInPath { let request: GetPathElementsRequest = GetPathElementsRequest { version: Some(get_path_elements_request::Version::V0( - GetPathElementsRequestV0 { path: self.path, keys: self.keys, prove }, + GetPathElementsRequestV0 { + path: self.path, + keys: self.keys, + prove, + }, )), }; @@ -566,7 +576,7 @@ impl Query for TotalCreditsOnPlatform { let request: GetTotalCreditsInPlatformRequest = GetTotalCreditsInPlatformRequest { version: Some(get_total_credits_in_platform_request::Version::V0( - GetTotalCreditsInPlatformRequestV0{ prove }, + GetTotalCreditsInPlatformRequestV0 { prove }, )), }; diff --git a/packages/rs-sdk/src/platform/types/identity.rs b/packages/rs-sdk/src/platform/types/identity.rs index 609b76eca5..01599307c1 100644 --- a/packages/rs-sdk/src/platform/types/identity.rs +++ b/packages/rs-sdk/src/platform/types/identity.rs @@ -1,18 +1,24 @@ //! Identity related types and functions +use crate::delegate_enum; +use crate::{ + platform::{proto, Query}, + Error, +}; use dapi_grpc::platform::v0::get_identity_balance_and_revision_request::GetIdentityBalanceAndRevisionRequestV0; use dapi_grpc::platform::v0::get_identity_balance_request::GetIdentityBalanceRequestV0; use dapi_grpc::platform::v0::get_identity_by_public_key_hash_request::GetIdentityByPublicKeyHashRequestV0; use dapi_grpc::platform::v0::get_identity_contract_nonce_request::GetIdentityContractNonceRequestV0; use dapi_grpc::platform::v0::get_identity_nonce_request::GetIdentityNonceRequestV0; use dapi_grpc::platform::v0::get_identity_request::GetIdentityRequestV0; -use dapi_grpc::platform::v0::{get_identity_balance_and_revision_request, get_identity_balance_request, get_identity_by_public_key_hash_request, get_identity_contract_nonce_request, get_identity_nonce_request, get_identity_request, GetIdentityBalanceAndRevisionRequest, GetIdentityBalanceRequest, GetIdentityByPublicKeyHashRequest, GetIdentityContractNonceRequest, GetIdentityNonceRequest, GetIdentityRequest, ResponseMetadata}; -use dpp::prelude::Identity; -use crate::delegate_enum; -use crate::{ - platform::{proto, Query}, - Error, +use dapi_grpc::platform::v0::{ + get_identity_balance_and_revision_request, get_identity_balance_request, + get_identity_by_public_key_hash_request, get_identity_contract_nonce_request, + get_identity_nonce_request, get_identity_request, GetIdentityBalanceAndRevisionRequest, + GetIdentityBalanceRequest, GetIdentityByPublicKeyHashRequest, GetIdentityContractNonceRequest, + GetIdentityNonceRequest, GetIdentityRequest, ResponseMetadata, }; +use dpp::prelude::Identity; // Create enum [IdentityRequest] and [IdentityResponse] that will wrap all possible // request/response types for [Identity] object. From 456149e7905cf93aa769cdebd826430cafd83e29 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 2 Aug 2024 11:06:30 +0700 Subject: [PATCH 04/33] total credits on platform --- packages/rs-drive-proof-verifier/src/types.rs | 9 +++++ packages/rs-sdk/src/error.rs | 3 ++ packages/rs-sdk/src/platform.rs | 1 + .../platform/fetch_current_no_parameters.rs | 17 ++++++++++ packages/rs-sdk/src/platform/query.rs | 4 +-- packages/rs-sdk/src/platform/types.rs | 1 + packages/rs-sdk/src/platform/types/epoch.rs | 17 ++-------- .../types/total_credits_in_platform.rs | 33 +++++++++++++++++++ packages/rs-sdk/tests/fetch/epoch.rs | 3 +- 9 files changed, 70 insertions(+), 18 deletions(-) create mode 100644 packages/rs-sdk/src/platform/fetch_current_no_parameters.rs create mode 100644 packages/rs-sdk/src/platform/types/total_credits_in_platform.rs diff --git a/packages/rs-drive-proof-verifier/src/types.rs b/packages/rs-drive-proof-verifier/src/types.rs index 52ba7049bb..bd3288b8bc 100644 --- a/packages/rs-drive-proof-verifier/src/types.rs +++ b/packages/rs-drive-proof-verifier/src/types.rs @@ -176,6 +176,15 @@ pub struct KeysInPath { )] pub struct TotalCreditsOnPlatform(pub Credits); +/// A query with no parameters +#[derive(Debug, Clone, Copy)] +#[cfg_attr( + feature = "mocks", + derive(Encode, Decode, PlatformSerialize, PlatformDeserialize), + platform_serialize(unversioned) +)] +pub struct NoParamQuery; + /// The item of an element fetch request #[derive(Debug, derive_more::From, Clone)] #[cfg_attr( diff --git a/packages/rs-sdk/src/error.rs b/packages/rs-sdk/src/error.rs index 1ff0e73ddd..ce8b3f309a 100644 --- a/packages/rs-sdk/src/error.rs +++ b/packages/rs-sdk/src/error.rs @@ -46,6 +46,9 @@ pub enum Error { /// Dependency not found, for example data contract for a document not found #[error("Required {0} not found: {1}")] MissingDependency(String, String), + /// Total credits in Platform are not found; we must always have credits in Platform + #[error("Total credits in Platform are not found; it should never happen")] + TotalCreditsNotFound, /// Epoch not found; we must have at least one epoch #[error("No epoch found on Platform; it should never happen")] EpochNotFound, diff --git a/packages/rs-sdk/src/platform.rs b/packages/rs-sdk/src/platform.rs index e58649ab7b..4766201620 100644 --- a/packages/rs-sdk/src/platform.rs +++ b/packages/rs-sdk/src/platform.rs @@ -9,6 +9,7 @@ pub mod block_info_from_metadata; mod delegate; mod document_query; mod fetch; +pub mod fetch_current_no_parameters; mod fetch_many; mod identities_contract_keys_query; mod query; diff --git a/packages/rs-sdk/src/platform/fetch_current_no_parameters.rs b/packages/rs-sdk/src/platform/fetch_current_no_parameters.rs new file mode 100644 index 0000000000..9d87bc9ea8 --- /dev/null +++ b/packages/rs-sdk/src/platform/fetch_current_no_parameters.rs @@ -0,0 +1,17 @@ +use crate::{Error, Sdk}; +use async_trait::async_trait; +use dapi_grpc::platform::v0::{Proof, ResponseMetadata}; + +#[async_trait] + +/// Helper trait for managing Epoch information +pub trait FetchCurrent: Sized { + /// Fetch current (the latest) epoch from Platform. + async fn fetch_current(sdk: &Sdk) -> Result; + /// Fetch current (the latest) epoch from Platform with metadata. + async fn fetch_current_with_metadata(sdk: &Sdk) -> Result<(Self, ResponseMetadata), Error>; + /// Fetch current (the latest) epoch from Platform with metadata and proof. + async fn fetch_current_with_metadata_and_proof( + sdk: &Sdk, + ) -> Result<(Self, ResponseMetadata, Proof), Error>; +} diff --git a/packages/rs-sdk/src/platform/query.rs b/packages/rs-sdk/src/platform/query.rs index 36fd30685b..6e7de72013 100644 --- a/packages/rs-sdk/src/platform/query.rs +++ b/packages/rs-sdk/src/platform/query.rs @@ -29,7 +29,7 @@ use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQuer use drive::query::vote_polls_by_document_type_query::VotePollsByDocumentTypeQuery; use drive::query::{DriveDocumentQuery, VotePollsByEndDateDriveQuery}; use drive_proof_verifier::from_request::TryFromRequest; -use drive_proof_verifier::types::{KeysInPath, TotalCreditsOnPlatform}; +use drive_proof_verifier::types::{KeysInPath, NoParamQuery}; use rs_dapi_client::transport::TransportRequest; use std::fmt::Debug; @@ -568,7 +568,7 @@ impl Query for KeysInPath { } } -impl Query for TotalCreditsOnPlatform { +impl Query for NoParamQuery { fn query(self, prove: bool) -> Result { if !prove { unimplemented!("queries without proofs are not supported yet"); diff --git a/packages/rs-sdk/src/platform/types.rs b/packages/rs-sdk/src/platform/types.rs index dc4f4abbf4..13e49fafed 100644 --- a/packages/rs-sdk/src/platform/types.rs +++ b/packages/rs-sdk/src/platform/types.rs @@ -1,4 +1,5 @@ //! Type-specific implementation for various dpp object types to make queries more convenient and intuitive. pub mod epoch; pub mod identity; +mod total_credits_in_platform; pub mod version_votes; diff --git a/packages/rs-sdk/src/platform/types/epoch.rs b/packages/rs-sdk/src/platform/types/epoch.rs index b1ca7b15f1..7026f2e551 100644 --- a/packages/rs-sdk/src/platform/types/epoch.rs +++ b/packages/rs-sdk/src/platform/types/epoch.rs @@ -3,27 +3,14 @@ use async_trait::async_trait; use dapi_grpc::platform::v0::{GetEpochsInfoRequest, Proof, ResponseMetadata}; use dpp::block::{epoch::EpochIndex, extended_epoch_info::ExtendedEpochInfo}; +use crate::platform::fetch_current_no_parameters::FetchCurrent; use crate::{ platform::{Fetch, LimitQuery, Query}, Error, Sdk, }; #[async_trait] - -/// Helper trait for managing Epoch information -pub trait ExtendedEpochInfoEx: Sized { - /// Fetch current (the latest) epoch from Platform. - async fn fetch_current(sdk: &Sdk) -> Result; - /// Fetch current (the latest) epoch from Platform with metadata. - async fn fetch_current_with_metadata(sdk: &Sdk) -> Result<(Self, ResponseMetadata), Error>; - /// Fetch current (the latest) epoch from Platform with metadata and proof. - async fn fetch_current_with_metadata_and_proof( - sdk: &Sdk, - ) -> Result<(Self, ResponseMetadata, Proof), Error>; -} - -#[async_trait] -impl ExtendedEpochInfoEx for ExtendedEpochInfo { +impl FetchCurrent for ExtendedEpochInfo { async fn fetch_current(sdk: &Sdk) -> Result { let (epoch, _) = Self::fetch_current_with_metadata(sdk).await?; Ok(epoch) diff --git a/packages/rs-sdk/src/platform/types/total_credits_in_platform.rs b/packages/rs-sdk/src/platform/types/total_credits_in_platform.rs new file mode 100644 index 0000000000..14459901ee --- /dev/null +++ b/packages/rs-sdk/src/platform/types/total_credits_in_platform.rs @@ -0,0 +1,33 @@ +//! Epoch-related types and helpers +use crate::platform::fetch_current_no_parameters::FetchCurrent; +use crate::{platform::Fetch, Error, Sdk}; +use async_trait::async_trait; +use dapi_grpc::platform::v0::{Proof, ResponseMetadata}; +use drive_proof_verifier::types::{NoParamQuery, TotalCreditsOnPlatform}; + +#[async_trait] +impl FetchCurrent for TotalCreditsOnPlatform { + async fn fetch_current(sdk: &Sdk) -> Result { + let (total_credits_on_platform, _) = Self::fetch_current_with_metadata(sdk).await?; + Ok(total_credits_on_platform) + } + + async fn fetch_current_with_metadata(sdk: &Sdk) -> Result<(Self, ResponseMetadata), Error> { + let (total_credits_on_platform, metadata) = + Self::fetch_with_metadata(sdk, NoParamQuery {}, None).await?; + + Ok(( + total_credits_on_platform.ok_or(Error::TotalCreditsNotFound)?, + metadata, + )) + } + + async fn fetch_current_with_metadata_and_proof( + sdk: &Sdk, + ) -> Result<(Self, ResponseMetadata, Proof), Error> { + let (epoch, metadata, proof) = + Self::fetch_with_metadata_and_proof(sdk, NoParamQuery {}, None).await?; + + Ok((epoch.ok_or(Error::TotalCreditsNotFound)?, metadata, proof)) + } +} diff --git a/packages/rs-sdk/tests/fetch/epoch.rs b/packages/rs-sdk/tests/fetch/epoch.rs index efd64eef62..8080e3b344 100644 --- a/packages/rs-sdk/tests/fetch/epoch.rs +++ b/packages/rs-sdk/tests/fetch/epoch.rs @@ -7,7 +7,8 @@ use dapi_grpc::platform::{ }; use dash_sdk::{ platform::{ - types::epoch::ExtendedEpochInfoEx, Fetch, FetchMany, LimitQuery, DEFAULT_EPOCH_QUERY_LIMIT, + fetch_current_no_parameters::FetchCurrent, Fetch, FetchMany, LimitQuery, + DEFAULT_EPOCH_QUERY_LIMIT, }, Sdk, }; From a36056910b837a8cc2b1e23f1407f7de18c9ce43 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 2 Aug 2024 11:50:50 +0700 Subject: [PATCH 05/33] added JS dapi client for get total credits on platform --- .../dash/platform/dapi/v0/PlatformGrpc.java | 76 +- .../platform/v0/nodejs/platform_pbjs.js | 919 ++++++++++++++++++ .../platform/v0/nodejs/platform_protoc.js | 849 ++++++++++++++++ .../platform/v0/objective-c/Platform.pbobjc.h | 95 ++ .../platform/v0/objective-c/Platform.pbobjc.m | 243 +++++ .../platform/v0/objective-c/Platform.pbrpc.h | 13 + .../platform/v0/objective-c/Platform.pbrpc.m | 20 + .../platform/v0/python/platform_pb2.py | 247 ++++- .../platform/v0/python/platform_pb2_grpc.py | 33 + .../clients/platform/v0/web/platform_pb.d.ts | 117 +++ .../clients/platform/v0/web/platform_pb.js | 849 ++++++++++++++++ .../platform/v0/web/platform_pb_service.d.ts | 19 + .../platform/v0/web/platform_pb_service.js | 40 + .../GetTotalCreditsOnPlatformResponse.js | 46 + .../getTotalCreditsOnPlatformFactory.js | 67 ++ 15 files changed, 3616 insertions(+), 17 deletions(-) create mode 100644 packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/GetTotalCreditsOnPlatformResponse.js create mode 100644 packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/getTotalCreditsOnPlatformFactory.js diff --git a/packages/dapi-grpc/clients/platform/v0/java/org/dash/platform/dapi/v0/PlatformGrpc.java b/packages/dapi-grpc/clients/platform/v0/java/org/dash/platform/dapi/v0/PlatformGrpc.java index 93f559a7d0..908976e250 100644 --- a/packages/dapi-grpc/clients/platform/v0/java/org/dash/platform/dapi/v0/PlatformGrpc.java +++ b/packages/dapi-grpc/clients/platform/v0/java/org/dash/platform/dapi/v0/PlatformGrpc.java @@ -790,6 +790,37 @@ org.dash.platform.dapi.v0.PlatformOuterClass.GetPrefundedSpecializedBalanceRespo return getGetPrefundedSpecializedBalanceMethod; } + private static volatile io.grpc.MethodDescriptor getGetTotalCreditsInPlatformMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "getTotalCreditsInPlatform", + requestType = org.dash.platform.dapi.v0.PlatformOuterClass.GetTotalCreditsInPlatformRequest.class, + responseType = org.dash.platform.dapi.v0.PlatformOuterClass.GetTotalCreditsInPlatformResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getGetTotalCreditsInPlatformMethod() { + io.grpc.MethodDescriptor getGetTotalCreditsInPlatformMethod; + if ((getGetTotalCreditsInPlatformMethod = PlatformGrpc.getGetTotalCreditsInPlatformMethod) == null) { + synchronized (PlatformGrpc.class) { + if ((getGetTotalCreditsInPlatformMethod = PlatformGrpc.getGetTotalCreditsInPlatformMethod) == null) { + PlatformGrpc.getGetTotalCreditsInPlatformMethod = getGetTotalCreditsInPlatformMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "getTotalCreditsInPlatform")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.dash.platform.dapi.v0.PlatformOuterClass.GetTotalCreditsInPlatformRequest.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.dash.platform.dapi.v0.PlatformOuterClass.GetTotalCreditsInPlatformResponse.getDefaultInstance())) + .setSchemaDescriptor(new PlatformMethodDescriptorSupplier("getTotalCreditsInPlatform")) + .build(); + } + } + } + return getGetTotalCreditsInPlatformMethod; + } + private static volatile io.grpc.MethodDescriptor getGetPathElementsMethod; @@ -1059,6 +1090,13 @@ public void getPrefundedSpecializedBalance(org.dash.platform.dapi.v0.PlatformOut io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetPrefundedSpecializedBalanceMethod(), responseObserver); } + /** + */ + public void getTotalCreditsInPlatform(org.dash.platform.dapi.v0.PlatformOuterClass.GetTotalCreditsInPlatformRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetTotalCreditsInPlatformMethod(), responseObserver); + } + /** */ public void getPathElements(org.dash.platform.dapi.v0.PlatformOuterClass.GetPathElementsRequest request, @@ -1243,6 +1281,13 @@ public void getPathElements(org.dash.platform.dapi.v0.PlatformOuterClass.GetPath org.dash.platform.dapi.v0.PlatformOuterClass.GetPrefundedSpecializedBalanceRequest, org.dash.platform.dapi.v0.PlatformOuterClass.GetPrefundedSpecializedBalanceResponse>( this, METHODID_GET_PREFUNDED_SPECIALIZED_BALANCE))) + .addMethod( + getGetTotalCreditsInPlatformMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + org.dash.platform.dapi.v0.PlatformOuterClass.GetTotalCreditsInPlatformRequest, + org.dash.platform.dapi.v0.PlatformOuterClass.GetTotalCreditsInPlatformResponse>( + this, METHODID_GET_TOTAL_CREDITS_IN_PLATFORM))) .addMethod( getGetPathElementsMethod(), io.grpc.stub.ServerCalls.asyncUnaryCall( @@ -1483,6 +1528,14 @@ public void getPrefundedSpecializedBalance(org.dash.platform.dapi.v0.PlatformOut getChannel().newCall(getGetPrefundedSpecializedBalanceMethod(), getCallOptions()), request, responseObserver); } + /** + */ + public void getTotalCreditsInPlatform(org.dash.platform.dapi.v0.PlatformOuterClass.GetTotalCreditsInPlatformRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getGetTotalCreditsInPlatformMethod(), getCallOptions()), request, responseObserver); + } + /** */ public void getPathElements(org.dash.platform.dapi.v0.PlatformOuterClass.GetPathElementsRequest request, @@ -1696,6 +1749,13 @@ public org.dash.platform.dapi.v0.PlatformOuterClass.GetPrefundedSpecializedBalan getChannel(), getGetPrefundedSpecializedBalanceMethod(), getCallOptions(), request); } + /** + */ + public org.dash.platform.dapi.v0.PlatformOuterClass.GetTotalCreditsInPlatformResponse getTotalCreditsInPlatform(org.dash.platform.dapi.v0.PlatformOuterClass.GetTotalCreditsInPlatformRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getGetTotalCreditsInPlatformMethod(), getCallOptions(), request); + } + /** */ public org.dash.platform.dapi.v0.PlatformOuterClass.GetPathElementsResponse getPathElements(org.dash.platform.dapi.v0.PlatformOuterClass.GetPathElementsRequest request) { @@ -1933,6 +1993,14 @@ public com.google.common.util.concurrent.ListenableFuture getTotalCreditsInPlatform( + org.dash.platform.dapi.v0.PlatformOuterClass.GetTotalCreditsInPlatformRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getGetTotalCreditsInPlatformMethod(), getCallOptions()), request); + } + /** */ public com.google.common.util.concurrent.ListenableFuture getPathElements( @@ -1967,7 +2035,8 @@ public com.google.common.util.concurrent.ListenableFuture implements io.grpc.stub.ServerCalls.UnaryMethod, @@ -2086,6 +2155,10 @@ public void invoke(Req request, io.grpc.stub.StreamObserver responseObserv serviceImpl.getPrefundedSpecializedBalance((org.dash.platform.dapi.v0.PlatformOuterClass.GetPrefundedSpecializedBalanceRequest) request, (io.grpc.stub.StreamObserver) responseObserver); break; + case METHODID_GET_TOTAL_CREDITS_IN_PLATFORM: + serviceImpl.getTotalCreditsInPlatform((org.dash.platform.dapi.v0.PlatformOuterClass.GetTotalCreditsInPlatformRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; case METHODID_GET_PATH_ELEMENTS: serviceImpl.getPathElements((org.dash.platform.dapi.v0.PlatformOuterClass.GetPathElementsRequest) request, (io.grpc.stub.StreamObserver) responseObserver); @@ -2176,6 +2249,7 @@ public static io.grpc.ServiceDescriptor getServiceDescriptor() { .addMethod(getGetContestedResourceIdentityVotesMethod()) .addMethod(getGetVotePollsByEndDateMethod()) .addMethod(getGetPrefundedSpecializedBalanceMethod()) + .addMethod(getGetTotalCreditsInPlatformMethod()) .addMethod(getGetPathElementsMethod()) .build(); } diff --git a/packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js b/packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js index ad5b5842dd..d01a3839fe 100644 --- a/packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js +++ b/packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js @@ -911,6 +911,39 @@ $root.org = (function() { * @variation 2 */ + /** + * Callback as used by {@link org.dash.platform.dapi.v0.Platform#getTotalCreditsInPlatform}. + * @memberof org.dash.platform.dapi.v0.Platform + * @typedef getTotalCreditsInPlatformCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse} [response] GetTotalCreditsInPlatformResponse + */ + + /** + * Calls getTotalCreditsInPlatform. + * @function getTotalCreditsInPlatform + * @memberof org.dash.platform.dapi.v0.Platform + * @instance + * @param {org.dash.platform.dapi.v0.IGetTotalCreditsInPlatformRequest} request GetTotalCreditsInPlatformRequest message or plain object + * @param {org.dash.platform.dapi.v0.Platform.getTotalCreditsInPlatformCallback} callback Node-style callback called with the error, if any, and GetTotalCreditsInPlatformResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Platform.prototype.getTotalCreditsInPlatform = function getTotalCreditsInPlatform(request, callback) { + return this.rpcCall(getTotalCreditsInPlatform, $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest, $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse, request, callback); + }, "name", { value: "getTotalCreditsInPlatform" }); + + /** + * Calls getTotalCreditsInPlatform. + * @function getTotalCreditsInPlatform + * @memberof org.dash.platform.dapi.v0.Platform + * @instance + * @param {org.dash.platform.dapi.v0.IGetTotalCreditsInPlatformRequest} request GetTotalCreditsInPlatformRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + /** * Callback as used by {@link org.dash.platform.dapi.v0.Platform#getPathElements}. * @memberof org.dash.platform.dapi.v0.Platform @@ -35967,6 +36000,892 @@ $root.org = (function() { return GetPrefundedSpecializedBalanceResponse; })(); + v0.GetTotalCreditsInPlatformRequest = (function() { + + /** + * Properties of a GetTotalCreditsInPlatformRequest. + * @memberof org.dash.platform.dapi.v0 + * @interface IGetTotalCreditsInPlatformRequest + * @property {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.IGetTotalCreditsInPlatformRequestV0|null} [v0] GetTotalCreditsInPlatformRequest v0 + */ + + /** + * Constructs a new GetTotalCreditsInPlatformRequest. + * @memberof org.dash.platform.dapi.v0 + * @classdesc Represents a GetTotalCreditsInPlatformRequest. + * @implements IGetTotalCreditsInPlatformRequest + * @constructor + * @param {org.dash.platform.dapi.v0.IGetTotalCreditsInPlatformRequest=} [properties] Properties to set + */ + function GetTotalCreditsInPlatformRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetTotalCreditsInPlatformRequest v0. + * @member {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.IGetTotalCreditsInPlatformRequestV0|null|undefined} v0 + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest + * @instance + */ + GetTotalCreditsInPlatformRequest.prototype.v0 = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * GetTotalCreditsInPlatformRequest version. + * @member {"v0"|undefined} version + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest + * @instance + */ + Object.defineProperty(GetTotalCreditsInPlatformRequest.prototype, "version", { + get: $util.oneOfGetter($oneOfFields = ["v0"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new GetTotalCreditsInPlatformRequest instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest + * @static + * @param {org.dash.platform.dapi.v0.IGetTotalCreditsInPlatformRequest=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest} GetTotalCreditsInPlatformRequest instance + */ + GetTotalCreditsInPlatformRequest.create = function create(properties) { + return new GetTotalCreditsInPlatformRequest(properties); + }; + + /** + * Encodes the specified GetTotalCreditsInPlatformRequest message. Does not implicitly {@link org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest + * @static + * @param {org.dash.platform.dapi.v0.IGetTotalCreditsInPlatformRequest} message GetTotalCreditsInPlatformRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetTotalCreditsInPlatformRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.v0 != null && Object.hasOwnProperty.call(message, "v0")) + $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.encode(message.v0, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GetTotalCreditsInPlatformRequest message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest + * @static + * @param {org.dash.platform.dapi.v0.IGetTotalCreditsInPlatformRequest} message GetTotalCreditsInPlatformRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetTotalCreditsInPlatformRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetTotalCreditsInPlatformRequest message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest} GetTotalCreditsInPlatformRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetTotalCreditsInPlatformRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.v0 = $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetTotalCreditsInPlatformRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest} GetTotalCreditsInPlatformRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetTotalCreditsInPlatformRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetTotalCreditsInPlatformRequest message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetTotalCreditsInPlatformRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + properties.version = 1; + { + var error = $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.verify(message.v0); + if (error) + return "v0." + error; + } + } + return null; + }; + + /** + * Creates a GetTotalCreditsInPlatformRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest} GetTotalCreditsInPlatformRequest + */ + GetTotalCreditsInPlatformRequest.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest(); + if (object.v0 != null) { + if (typeof object.v0 !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.v0: object expected"); + message.v0 = $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.fromObject(object.v0); + } + return message; + }; + + /** + * Creates a plain object from a GetTotalCreditsInPlatformRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest + * @static + * @param {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest} message GetTotalCreditsInPlatformRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetTotalCreditsInPlatformRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + object.v0 = $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.toObject(message.v0, options); + if (options.oneofs) + object.version = "v0"; + } + return object; + }; + + /** + * Converts this GetTotalCreditsInPlatformRequest to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest + * @instance + * @returns {Object.} JSON object + */ + GetTotalCreditsInPlatformRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0 = (function() { + + /** + * Properties of a GetTotalCreditsInPlatformRequestV0. + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest + * @interface IGetTotalCreditsInPlatformRequestV0 + * @property {boolean|null} [prove] GetTotalCreditsInPlatformRequestV0 prove + */ + + /** + * Constructs a new GetTotalCreditsInPlatformRequestV0. + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest + * @classdesc Represents a GetTotalCreditsInPlatformRequestV0. + * @implements IGetTotalCreditsInPlatformRequestV0 + * @constructor + * @param {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.IGetTotalCreditsInPlatformRequestV0=} [properties] Properties to set + */ + function GetTotalCreditsInPlatformRequestV0(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetTotalCreditsInPlatformRequestV0 prove. + * @member {boolean} prove + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0 + * @instance + */ + GetTotalCreditsInPlatformRequestV0.prototype.prove = false; + + /** + * Creates a new GetTotalCreditsInPlatformRequestV0 instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.IGetTotalCreditsInPlatformRequestV0=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0} GetTotalCreditsInPlatformRequestV0 instance + */ + GetTotalCreditsInPlatformRequestV0.create = function create(properties) { + return new GetTotalCreditsInPlatformRequestV0(properties); + }; + + /** + * Encodes the specified GetTotalCreditsInPlatformRequestV0 message. Does not implicitly {@link org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.IGetTotalCreditsInPlatformRequestV0} message GetTotalCreditsInPlatformRequestV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetTotalCreditsInPlatformRequestV0.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.prove != null && Object.hasOwnProperty.call(message, "prove")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.prove); + return writer; + }; + + /** + * Encodes the specified GetTotalCreditsInPlatformRequestV0 message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.IGetTotalCreditsInPlatformRequestV0} message GetTotalCreditsInPlatformRequestV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetTotalCreditsInPlatformRequestV0.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetTotalCreditsInPlatformRequestV0 message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0} GetTotalCreditsInPlatformRequestV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetTotalCreditsInPlatformRequestV0.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.prove = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetTotalCreditsInPlatformRequestV0 message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0} GetTotalCreditsInPlatformRequestV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetTotalCreditsInPlatformRequestV0.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetTotalCreditsInPlatformRequestV0 message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0 + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetTotalCreditsInPlatformRequestV0.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.prove != null && message.hasOwnProperty("prove")) + if (typeof message.prove !== "boolean") + return "prove: boolean expected"; + return null; + }; + + /** + * Creates a GetTotalCreditsInPlatformRequestV0 message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0 + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0} GetTotalCreditsInPlatformRequestV0 + */ + GetTotalCreditsInPlatformRequestV0.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0(); + if (object.prove != null) + message.prove = Boolean(object.prove); + return message; + }; + + /** + * Creates a plain object from a GetTotalCreditsInPlatformRequestV0 message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0} message GetTotalCreditsInPlatformRequestV0 + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetTotalCreditsInPlatformRequestV0.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.prove = false; + if (message.prove != null && message.hasOwnProperty("prove")) + object.prove = message.prove; + return object; + }; + + /** + * Converts this GetTotalCreditsInPlatformRequestV0 to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0 + * @instance + * @returns {Object.} JSON object + */ + GetTotalCreditsInPlatformRequestV0.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GetTotalCreditsInPlatformRequestV0; + })(); + + return GetTotalCreditsInPlatformRequest; + })(); + + v0.GetTotalCreditsInPlatformResponse = (function() { + + /** + * Properties of a GetTotalCreditsInPlatformResponse. + * @memberof org.dash.platform.dapi.v0 + * @interface IGetTotalCreditsInPlatformResponse + * @property {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.IGetTotalCreditsInPlatformResponseV0|null} [v0] GetTotalCreditsInPlatformResponse v0 + */ + + /** + * Constructs a new GetTotalCreditsInPlatformResponse. + * @memberof org.dash.platform.dapi.v0 + * @classdesc Represents a GetTotalCreditsInPlatformResponse. + * @implements IGetTotalCreditsInPlatformResponse + * @constructor + * @param {org.dash.platform.dapi.v0.IGetTotalCreditsInPlatformResponse=} [properties] Properties to set + */ + function GetTotalCreditsInPlatformResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetTotalCreditsInPlatformResponse v0. + * @member {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.IGetTotalCreditsInPlatformResponseV0|null|undefined} v0 + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse + * @instance + */ + GetTotalCreditsInPlatformResponse.prototype.v0 = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * GetTotalCreditsInPlatformResponse version. + * @member {"v0"|undefined} version + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse + * @instance + */ + Object.defineProperty(GetTotalCreditsInPlatformResponse.prototype, "version", { + get: $util.oneOfGetter($oneOfFields = ["v0"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new GetTotalCreditsInPlatformResponse instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse + * @static + * @param {org.dash.platform.dapi.v0.IGetTotalCreditsInPlatformResponse=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse} GetTotalCreditsInPlatformResponse instance + */ + GetTotalCreditsInPlatformResponse.create = function create(properties) { + return new GetTotalCreditsInPlatformResponse(properties); + }; + + /** + * Encodes the specified GetTotalCreditsInPlatformResponse message. Does not implicitly {@link org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse + * @static + * @param {org.dash.platform.dapi.v0.IGetTotalCreditsInPlatformResponse} message GetTotalCreditsInPlatformResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetTotalCreditsInPlatformResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.v0 != null && Object.hasOwnProperty.call(message, "v0")) + $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.encode(message.v0, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GetTotalCreditsInPlatformResponse message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse + * @static + * @param {org.dash.platform.dapi.v0.IGetTotalCreditsInPlatformResponse} message GetTotalCreditsInPlatformResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetTotalCreditsInPlatformResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetTotalCreditsInPlatformResponse message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse} GetTotalCreditsInPlatformResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetTotalCreditsInPlatformResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.v0 = $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetTotalCreditsInPlatformResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse} GetTotalCreditsInPlatformResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetTotalCreditsInPlatformResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetTotalCreditsInPlatformResponse message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetTotalCreditsInPlatformResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + properties.version = 1; + { + var error = $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.verify(message.v0); + if (error) + return "v0." + error; + } + } + return null; + }; + + /** + * Creates a GetTotalCreditsInPlatformResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse} GetTotalCreditsInPlatformResponse + */ + GetTotalCreditsInPlatformResponse.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse(); + if (object.v0 != null) { + if (typeof object.v0 !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.v0: object expected"); + message.v0 = $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.fromObject(object.v0); + } + return message; + }; + + /** + * Creates a plain object from a GetTotalCreditsInPlatformResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse + * @static + * @param {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse} message GetTotalCreditsInPlatformResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetTotalCreditsInPlatformResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + object.v0 = $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.toObject(message.v0, options); + if (options.oneofs) + object.version = "v0"; + } + return object; + }; + + /** + * Converts this GetTotalCreditsInPlatformResponse to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse + * @instance + * @returns {Object.} JSON object + */ + GetTotalCreditsInPlatformResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0 = (function() { + + /** + * Properties of a GetTotalCreditsInPlatformResponseV0. + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse + * @interface IGetTotalCreditsInPlatformResponseV0 + * @property {number|Long|null} [credits] GetTotalCreditsInPlatformResponseV0 credits + * @property {org.dash.platform.dapi.v0.IProof|null} [proof] GetTotalCreditsInPlatformResponseV0 proof + * @property {org.dash.platform.dapi.v0.IResponseMetadata|null} [metadata] GetTotalCreditsInPlatformResponseV0 metadata + */ + + /** + * Constructs a new GetTotalCreditsInPlatformResponseV0. + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse + * @classdesc Represents a GetTotalCreditsInPlatformResponseV0. + * @implements IGetTotalCreditsInPlatformResponseV0 + * @constructor + * @param {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.IGetTotalCreditsInPlatformResponseV0=} [properties] Properties to set + */ + function GetTotalCreditsInPlatformResponseV0(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetTotalCreditsInPlatformResponseV0 credits. + * @member {number|Long} credits + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0 + * @instance + */ + GetTotalCreditsInPlatformResponseV0.prototype.credits = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * GetTotalCreditsInPlatformResponseV0 proof. + * @member {org.dash.platform.dapi.v0.IProof|null|undefined} proof + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0 + * @instance + */ + GetTotalCreditsInPlatformResponseV0.prototype.proof = null; + + /** + * GetTotalCreditsInPlatformResponseV0 metadata. + * @member {org.dash.platform.dapi.v0.IResponseMetadata|null|undefined} metadata + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0 + * @instance + */ + GetTotalCreditsInPlatformResponseV0.prototype.metadata = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * GetTotalCreditsInPlatformResponseV0 result. + * @member {"credits"|"proof"|undefined} result + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0 + * @instance + */ + Object.defineProperty(GetTotalCreditsInPlatformResponseV0.prototype, "result", { + get: $util.oneOfGetter($oneOfFields = ["credits", "proof"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new GetTotalCreditsInPlatformResponseV0 instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.IGetTotalCreditsInPlatformResponseV0=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} GetTotalCreditsInPlatformResponseV0 instance + */ + GetTotalCreditsInPlatformResponseV0.create = function create(properties) { + return new GetTotalCreditsInPlatformResponseV0(properties); + }; + + /** + * Encodes the specified GetTotalCreditsInPlatformResponseV0 message. Does not implicitly {@link org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.IGetTotalCreditsInPlatformResponseV0} message GetTotalCreditsInPlatformResponseV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetTotalCreditsInPlatformResponseV0.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.credits != null && Object.hasOwnProperty.call(message, "credits")) + writer.uint32(/* id 1, wireType 0 =*/8).uint64(message.credits); + if (message.proof != null && Object.hasOwnProperty.call(message, "proof")) + $root.org.dash.platform.dapi.v0.Proof.encode(message.proof, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata")) + $root.org.dash.platform.dapi.v0.ResponseMetadata.encode(message.metadata, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GetTotalCreditsInPlatformResponseV0 message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.IGetTotalCreditsInPlatformResponseV0} message GetTotalCreditsInPlatformResponseV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetTotalCreditsInPlatformResponseV0.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetTotalCreditsInPlatformResponseV0 message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} GetTotalCreditsInPlatformResponseV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetTotalCreditsInPlatformResponseV0.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.credits = reader.uint64(); + break; + case 2: + message.proof = $root.org.dash.platform.dapi.v0.Proof.decode(reader, reader.uint32()); + break; + case 3: + message.metadata = $root.org.dash.platform.dapi.v0.ResponseMetadata.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetTotalCreditsInPlatformResponseV0 message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} GetTotalCreditsInPlatformResponseV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetTotalCreditsInPlatformResponseV0.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetTotalCreditsInPlatformResponseV0 message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0 + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetTotalCreditsInPlatformResponseV0.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.credits != null && message.hasOwnProperty("credits")) { + properties.result = 1; + if (!$util.isInteger(message.credits) && !(message.credits && $util.isInteger(message.credits.low) && $util.isInteger(message.credits.high))) + return "credits: integer|Long expected"; + } + if (message.proof != null && message.hasOwnProperty("proof")) { + if (properties.result === 1) + return "result: multiple values"; + properties.result = 1; + { + var error = $root.org.dash.platform.dapi.v0.Proof.verify(message.proof); + if (error) + return "proof." + error; + } + } + if (message.metadata != null && message.hasOwnProperty("metadata")) { + var error = $root.org.dash.platform.dapi.v0.ResponseMetadata.verify(message.metadata); + if (error) + return "metadata." + error; + } + return null; + }; + + /** + * Creates a GetTotalCreditsInPlatformResponseV0 message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0 + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} GetTotalCreditsInPlatformResponseV0 + */ + GetTotalCreditsInPlatformResponseV0.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0(); + if (object.credits != null) + if ($util.Long) + (message.credits = $util.Long.fromValue(object.credits)).unsigned = true; + else if (typeof object.credits === "string") + message.credits = parseInt(object.credits, 10); + else if (typeof object.credits === "number") + message.credits = object.credits; + else if (typeof object.credits === "object") + message.credits = new $util.LongBits(object.credits.low >>> 0, object.credits.high >>> 0).toNumber(true); + if (object.proof != null) { + if (typeof object.proof !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.proof: object expected"); + message.proof = $root.org.dash.platform.dapi.v0.Proof.fromObject(object.proof); + } + if (object.metadata != null) { + if (typeof object.metadata !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.metadata: object expected"); + message.metadata = $root.org.dash.platform.dapi.v0.ResponseMetadata.fromObject(object.metadata); + } + return message; + }; + + /** + * Creates a plain object from a GetTotalCreditsInPlatformResponseV0 message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} message GetTotalCreditsInPlatformResponseV0 + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetTotalCreditsInPlatformResponseV0.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.metadata = null; + if (message.credits != null && message.hasOwnProperty("credits")) { + if (typeof message.credits === "number") + object.credits = options.longs === String ? String(message.credits) : message.credits; + else + object.credits = options.longs === String ? $util.Long.prototype.toString.call(message.credits) : options.longs === Number ? new $util.LongBits(message.credits.low >>> 0, message.credits.high >>> 0).toNumber(true) : message.credits; + if (options.oneofs) + object.result = "credits"; + } + if (message.proof != null && message.hasOwnProperty("proof")) { + object.proof = $root.org.dash.platform.dapi.v0.Proof.toObject(message.proof, options); + if (options.oneofs) + object.result = "proof"; + } + if (message.metadata != null && message.hasOwnProperty("metadata")) + object.metadata = $root.org.dash.platform.dapi.v0.ResponseMetadata.toObject(message.metadata, options); + return object; + }; + + /** + * Converts this GetTotalCreditsInPlatformResponseV0 to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0 + * @instance + * @returns {Object.} JSON object + */ + GetTotalCreditsInPlatformResponseV0.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GetTotalCreditsInPlatformResponseV0; + })(); + + return GetTotalCreditsInPlatformResponse; + })(); + v0.GetPathElementsRequest = (function() { /** diff --git a/packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js b/packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js index 8d995602b9..be474b049e 100644 --- a/packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js +++ b/packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js @@ -227,6 +227,13 @@ goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVote goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.VersionCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.VersionCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.ResultCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.VersionCase', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetVotePollsByEndDateRequest', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetVotePollsByEndDateRequest.GetVotePollsByEndDateRequestV0', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetVotePollsByEndDateRequest.GetVotePollsByEndDateRequestV0.EndAtTimeInfo', null, { proto }); @@ -3300,6 +3307,90 @@ if (goog.DEBUG && !COMPILED) { */ proto.org.dash.platform.dapi.v0.GetPrefundedSpecializedBalanceResponse.GetPrefundedSpecializedBalanceResponseV0.displayName = 'proto.org.dash.platform.dapi.v0.GetPrefundedSpecializedBalanceResponse.GetPrefundedSpecializedBalanceResponseV0'; } +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.displayName = 'proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.displayName = 'proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.displayName = 'proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.displayName = 'proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0'; +} /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -35132,6 +35223,764 @@ proto.org.dash.platform.dapi.v0.GetPrefundedSpecializedBalanceResponse.prototype +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest; + return proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.serializeBinaryToWriter + ); + } +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.toObject = function(includeInstance, msg) { + var f, obj = { + prove: jspb.Message.getBooleanFieldWithDefault(msg, 1, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0; + return proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getProve(); + if (f) { + writer.writeBool( + 1, + f + ); + } +}; + + +/** + * optional bool prove = 1; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 1, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 1, value); +}; + + +/** + * optional GetTotalCreditsInPlatformRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest} returns this +*/ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest} returns this + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.prototype.clearV0 = function() { + return this.setV0(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse; + return proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.serializeBinaryToWriter + ); + } +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.oneofGroups_ = [[1,2]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + CREDITS: 1, + PROOF: 2 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.ResultCase} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.toObject = function(includeInstance, msg) { + var f, obj = { + credits: jspb.Message.getFieldWithDefault(msg, 1, 0), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0; + return proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readUint64()); + msg.setCredits(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); + break; + case 3: + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeUint64( + 1, + f + ); + } + f = message.getProof(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter + ); + } + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter + ); + } +}; + + +/** + * optional uint64 credits = 1; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.getCredits = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.setCredits = function(value) { + return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.clearCredits = function() { + return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.oneofGroups_[0], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.hasCredits = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * optional GetTotalCreditsInPlatformResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse} returns this +*/ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse} returns this + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.prototype.clearV0 = function() { + return this.setV0(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + /** * Oneof group definitions for this message. Each group defines the field * numbers belonging to that group. When of these fields' value is set, all diff --git a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h index 9c5039270c..371160b030 100644 --- a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h +++ b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h @@ -112,6 +112,8 @@ CF_EXTERN_C_BEGIN @class GetProtocolVersionUpgradeVoteStatusResponse_GetProtocolVersionUpgradeVoteStatusResponseV0; @class GetProtocolVersionUpgradeVoteStatusResponse_GetProtocolVersionUpgradeVoteStatusResponseV0_VersionSignal; @class GetProtocolVersionUpgradeVoteStatusResponse_GetProtocolVersionUpgradeVoteStatusResponseV0_VersionSignals; +@class GetTotalCreditsInPlatformRequest_GetTotalCreditsInPlatformRequestV0; +@class GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0; @class GetVotePollsByEndDateRequest_GetVotePollsByEndDateRequestV0; @class GetVotePollsByEndDateRequest_GetVotePollsByEndDateRequestV0_EndAtTimeInfo; @class GetVotePollsByEndDateRequest_GetVotePollsByEndDateRequestV0_StartAtTimeInfo; @@ -3944,6 +3946,99 @@ GPB_FINAL @interface GetPrefundedSpecializedBalanceResponse_GetPrefundedSpeciali **/ void GetPrefundedSpecializedBalanceResponse_GetPrefundedSpecializedBalanceResponseV0_ClearResultOneOfCase(GetPrefundedSpecializedBalanceResponse_GetPrefundedSpecializedBalanceResponseV0 *message); +#pragma mark - GetTotalCreditsInPlatformRequest + +typedef GPB_ENUM(GetTotalCreditsInPlatformRequest_FieldNumber) { + GetTotalCreditsInPlatformRequest_FieldNumber_V0 = 1, +}; + +typedef GPB_ENUM(GetTotalCreditsInPlatformRequest_Version_OneOfCase) { + GetTotalCreditsInPlatformRequest_Version_OneOfCase_GPBUnsetOneOfCase = 0, + GetTotalCreditsInPlatformRequest_Version_OneOfCase_V0 = 1, +}; + +GPB_FINAL @interface GetTotalCreditsInPlatformRequest : GPBMessage + +@property(nonatomic, readonly) GetTotalCreditsInPlatformRequest_Version_OneOfCase versionOneOfCase; + +@property(nonatomic, readwrite, strong, null_resettable) GetTotalCreditsInPlatformRequest_GetTotalCreditsInPlatformRequestV0 *v0; + +@end + +/** + * Clears whatever value was set for the oneof 'version'. + **/ +void GetTotalCreditsInPlatformRequest_ClearVersionOneOfCase(GetTotalCreditsInPlatformRequest *message); + +#pragma mark - GetTotalCreditsInPlatformRequest_GetTotalCreditsInPlatformRequestV0 + +typedef GPB_ENUM(GetTotalCreditsInPlatformRequest_GetTotalCreditsInPlatformRequestV0_FieldNumber) { + GetTotalCreditsInPlatformRequest_GetTotalCreditsInPlatformRequestV0_FieldNumber_Prove = 1, +}; + +GPB_FINAL @interface GetTotalCreditsInPlatformRequest_GetTotalCreditsInPlatformRequestV0 : GPBMessage + +@property(nonatomic, readwrite) BOOL prove; + +@end + +#pragma mark - GetTotalCreditsInPlatformResponse + +typedef GPB_ENUM(GetTotalCreditsInPlatformResponse_FieldNumber) { + GetTotalCreditsInPlatformResponse_FieldNumber_V0 = 1, +}; + +typedef GPB_ENUM(GetTotalCreditsInPlatformResponse_Version_OneOfCase) { + GetTotalCreditsInPlatformResponse_Version_OneOfCase_GPBUnsetOneOfCase = 0, + GetTotalCreditsInPlatformResponse_Version_OneOfCase_V0 = 1, +}; + +GPB_FINAL @interface GetTotalCreditsInPlatformResponse : GPBMessage + +@property(nonatomic, readonly) GetTotalCreditsInPlatformResponse_Version_OneOfCase versionOneOfCase; + +@property(nonatomic, readwrite, strong, null_resettable) GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0 *v0; + +@end + +/** + * Clears whatever value was set for the oneof 'version'. + **/ +void GetTotalCreditsInPlatformResponse_ClearVersionOneOfCase(GetTotalCreditsInPlatformResponse *message); + +#pragma mark - GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0 + +typedef GPB_ENUM(GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0_FieldNumber) { + GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0_FieldNumber_Credits = 1, + GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0_FieldNumber_Proof = 2, + GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0_FieldNumber_Metadata = 3, +}; + +typedef GPB_ENUM(GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0_Result_OneOfCase) { + GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0_Result_OneOfCase_GPBUnsetOneOfCase = 0, + GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0_Result_OneOfCase_Credits = 1, + GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0_Result_OneOfCase_Proof = 2, +}; + +GPB_FINAL @interface GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0 : GPBMessage + +@property(nonatomic, readonly) GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0_Result_OneOfCase resultOneOfCase; + +@property(nonatomic, readwrite) uint64_t credits; + +@property(nonatomic, readwrite, strong, null_resettable) Proof *proof; + +@property(nonatomic, readwrite, strong, null_resettable) ResponseMetadata *metadata; +/** Test to see if @c metadata has been set. */ +@property(nonatomic, readwrite) BOOL hasMetadata; + +@end + +/** + * Clears whatever value was set for the oneof 'result'. + **/ +void GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0_ClearResultOneOfCase(GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0 *message); + #pragma mark - GetPathElementsRequest typedef GPB_ENUM(GetPathElementsRequest_FieldNumber) { diff --git a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.m b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.m index a9c0cf0362..2ff171f5a5 100644 --- a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.m +++ b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.m @@ -158,6 +158,10 @@ GPBObjCClassDeclaration(GetProtocolVersionUpgradeVoteStatusResponse_GetProtocolVersionUpgradeVoteStatusResponseV0); GPBObjCClassDeclaration(GetProtocolVersionUpgradeVoteStatusResponse_GetProtocolVersionUpgradeVoteStatusResponseV0_VersionSignal); GPBObjCClassDeclaration(GetProtocolVersionUpgradeVoteStatusResponse_GetProtocolVersionUpgradeVoteStatusResponseV0_VersionSignals); +GPBObjCClassDeclaration(GetTotalCreditsInPlatformRequest); +GPBObjCClassDeclaration(GetTotalCreditsInPlatformRequest_GetTotalCreditsInPlatformRequestV0); +GPBObjCClassDeclaration(GetTotalCreditsInPlatformResponse); +GPBObjCClassDeclaration(GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0); GPBObjCClassDeclaration(GetVotePollsByEndDateRequest); GPBObjCClassDeclaration(GetVotePollsByEndDateRequest_GetVotePollsByEndDateRequestV0); GPBObjCClassDeclaration(GetVotePollsByEndDateRequest_GetVotePollsByEndDateRequestV0_EndAtTimeInfo); @@ -9976,6 +9980,245 @@ void GetPrefundedSpecializedBalanceResponse_GetPrefundedSpecializedBalanceRespon GPBOneofDescriptor *oneof = [descriptor.oneofs objectAtIndex:0]; GPBClearOneof(message, oneof); } +#pragma mark - GetTotalCreditsInPlatformRequest + +@implementation GetTotalCreditsInPlatformRequest + +@dynamic versionOneOfCase; +@dynamic v0; + +typedef struct GetTotalCreditsInPlatformRequest__storage_ { + uint32_t _has_storage_[2]; + GetTotalCreditsInPlatformRequest_GetTotalCreditsInPlatformRequestV0 *v0; +} GetTotalCreditsInPlatformRequest__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "v0", + .dataTypeSpecific.clazz = GPBObjCClass(GetTotalCreditsInPlatformRequest_GetTotalCreditsInPlatformRequestV0), + .number = GetTotalCreditsInPlatformRequest_FieldNumber_V0, + .hasIndex = -1, + .offset = (uint32_t)offsetof(GetTotalCreditsInPlatformRequest__storage_, v0), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GetTotalCreditsInPlatformRequest class] + rootClass:[PlatformRoot class] + file:PlatformRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GetTotalCreditsInPlatformRequest__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)]; + static const char *oneofs[] = { + "version", + }; + [localDescriptor setupOneofs:oneofs + count:(uint32_t)(sizeof(oneofs) / sizeof(char*)) + firstHasIndex:-1]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +void GetTotalCreditsInPlatformRequest_ClearVersionOneOfCase(GetTotalCreditsInPlatformRequest *message) { + GPBDescriptor *descriptor = [GetTotalCreditsInPlatformRequest descriptor]; + GPBOneofDescriptor *oneof = [descriptor.oneofs objectAtIndex:0]; + GPBClearOneof(message, oneof); +} +#pragma mark - GetTotalCreditsInPlatformRequest_GetTotalCreditsInPlatformRequestV0 + +@implementation GetTotalCreditsInPlatformRequest_GetTotalCreditsInPlatformRequestV0 + +@dynamic prove; + +typedef struct GetTotalCreditsInPlatformRequest_GetTotalCreditsInPlatformRequestV0__storage_ { + uint32_t _has_storage_[1]; +} GetTotalCreditsInPlatformRequest_GetTotalCreditsInPlatformRequestV0__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "prove", + .dataTypeSpecific.clazz = Nil, + .number = GetTotalCreditsInPlatformRequest_GetTotalCreditsInPlatformRequestV0_FieldNumber_Prove, + .hasIndex = 0, + .offset = 1, // Stored in _has_storage_ to save space. + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeBool, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GetTotalCreditsInPlatformRequest_GetTotalCreditsInPlatformRequestV0 class] + rootClass:[PlatformRoot class] + file:PlatformRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GetTotalCreditsInPlatformRequest_GetTotalCreditsInPlatformRequestV0__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)]; + [localDescriptor setupContainingMessageClass:GPBObjCClass(GetTotalCreditsInPlatformRequest)]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - GetTotalCreditsInPlatformResponse + +@implementation GetTotalCreditsInPlatformResponse + +@dynamic versionOneOfCase; +@dynamic v0; + +typedef struct GetTotalCreditsInPlatformResponse__storage_ { + uint32_t _has_storage_[2]; + GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0 *v0; +} GetTotalCreditsInPlatformResponse__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "v0", + .dataTypeSpecific.clazz = GPBObjCClass(GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0), + .number = GetTotalCreditsInPlatformResponse_FieldNumber_V0, + .hasIndex = -1, + .offset = (uint32_t)offsetof(GetTotalCreditsInPlatformResponse__storage_, v0), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GetTotalCreditsInPlatformResponse class] + rootClass:[PlatformRoot class] + file:PlatformRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GetTotalCreditsInPlatformResponse__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)]; + static const char *oneofs[] = { + "version", + }; + [localDescriptor setupOneofs:oneofs + count:(uint32_t)(sizeof(oneofs) / sizeof(char*)) + firstHasIndex:-1]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +void GetTotalCreditsInPlatformResponse_ClearVersionOneOfCase(GetTotalCreditsInPlatformResponse *message) { + GPBDescriptor *descriptor = [GetTotalCreditsInPlatformResponse descriptor]; + GPBOneofDescriptor *oneof = [descriptor.oneofs objectAtIndex:0]; + GPBClearOneof(message, oneof); +} +#pragma mark - GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0 + +@implementation GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0 + +@dynamic resultOneOfCase; +@dynamic credits; +@dynamic proof; +@dynamic hasMetadata, metadata; + +typedef struct GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0__storage_ { + uint32_t _has_storage_[2]; + Proof *proof; + ResponseMetadata *metadata; + uint64_t credits; +} GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "credits", + .dataTypeSpecific.clazz = Nil, + .number = GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0_FieldNumber_Credits, + .hasIndex = -1, + .offset = (uint32_t)offsetof(GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0__storage_, credits), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeUInt64, + }, + { + .name = "proof", + .dataTypeSpecific.clazz = GPBObjCClass(Proof), + .number = GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0_FieldNumber_Proof, + .hasIndex = -1, + .offset = (uint32_t)offsetof(GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0__storage_, proof), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + { + .name = "metadata", + .dataTypeSpecific.clazz = GPBObjCClass(ResponseMetadata), + .number = GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0_FieldNumber_Metadata, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0__storage_, metadata), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0 class] + rootClass:[PlatformRoot class] + file:PlatformRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)]; + static const char *oneofs[] = { + "result", + }; + [localDescriptor setupOneofs:oneofs + count:(uint32_t)(sizeof(oneofs) / sizeof(char*)) + firstHasIndex:-1]; + [localDescriptor setupContainingMessageClass:GPBObjCClass(GetTotalCreditsInPlatformResponse)]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +void GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0_ClearResultOneOfCase(GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0 *message) { + GPBDescriptor *descriptor = [GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0 descriptor]; + GPBOneofDescriptor *oneof = [descriptor.oneofs objectAtIndex:0]; + GPBClearOneof(message, oneof); +} #pragma mark - GetPathElementsRequest @implementation GetPathElementsRequest diff --git a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbrpc.h b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbrpc.h index 2394e5f33e..dede490b71 100644 --- a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbrpc.h +++ b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbrpc.h @@ -62,6 +62,8 @@ @class GetProtocolVersionUpgradeStateResponse; @class GetProtocolVersionUpgradeVoteStatusRequest; @class GetProtocolVersionUpgradeVoteStatusResponse; +@class GetTotalCreditsInPlatformRequest; +@class GetTotalCreditsInPlatformResponse; @class GetVotePollsByEndDateRequest; @class GetVotePollsByEndDateResponse; @class WaitForStateTransitionResultRequest; @@ -211,6 +213,10 @@ NS_ASSUME_NONNULL_BEGIN - (GRPCUnaryProtoCall *)getPrefundedSpecializedBalanceWithMessage:(GetPrefundedSpecializedBalanceRequest *)message responseHandler:(id)handler callOptions:(GRPCCallOptions *_Nullable)callOptions; +#pragma mark getTotalCreditsInPlatform(GetTotalCreditsInPlatformRequest) returns (GetTotalCreditsInPlatformResponse) + +- (GRPCUnaryProtoCall *)getTotalCreditsInPlatformWithMessage:(GetTotalCreditsInPlatformRequest *)message responseHandler:(id)handler callOptions:(GRPCCallOptions *_Nullable)callOptions; + #pragma mark getPathElements(GetPathElementsRequest) returns (GetPathElementsResponse) - (GRPCUnaryProtoCall *)getPathElementsWithMessage:(GetPathElementsRequest *)message responseHandler:(id)handler callOptions:(GRPCCallOptions *_Nullable)callOptions; @@ -448,6 +454,13 @@ NS_ASSUME_NONNULL_BEGIN - (GRPCProtoCall *)RPCTogetPrefundedSpecializedBalanceWithRequest:(GetPrefundedSpecializedBalanceRequest *)request handler:(void(^)(GetPrefundedSpecializedBalanceResponse *_Nullable response, NSError *_Nullable error))handler; +#pragma mark getTotalCreditsInPlatform(GetTotalCreditsInPlatformRequest) returns (GetTotalCreditsInPlatformResponse) + +- (void)getTotalCreditsInPlatformWithRequest:(GetTotalCreditsInPlatformRequest *)request handler:(void(^)(GetTotalCreditsInPlatformResponse *_Nullable response, NSError *_Nullable error))handler; + +- (GRPCProtoCall *)RPCTogetTotalCreditsInPlatformWithRequest:(GetTotalCreditsInPlatformRequest *)request handler:(void(^)(GetTotalCreditsInPlatformResponse *_Nullable response, NSError *_Nullable error))handler; + + #pragma mark getPathElements(GetPathElementsRequest) returns (GetPathElementsResponse) - (void)getPathElementsWithRequest:(GetPathElementsRequest *)request handler:(void(^)(GetPathElementsResponse *_Nullable response, NSError *_Nullable error))handler; diff --git a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbrpc.m b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbrpc.m index 438ae4a602..24fe99cc69 100644 --- a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbrpc.m +++ b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbrpc.m @@ -635,6 +635,26 @@ - (GRPCUnaryProtoCall *)getPrefundedSpecializedBalanceWithMessage:(GetPrefundedS responseClass:[GetPrefundedSpecializedBalanceResponse class]]; } +#pragma mark getTotalCreditsInPlatform(GetTotalCreditsInPlatformRequest) returns (GetTotalCreditsInPlatformResponse) + +- (void)getTotalCreditsInPlatformWithRequest:(GetTotalCreditsInPlatformRequest *)request handler:(void(^)(GetTotalCreditsInPlatformResponse *_Nullable response, NSError *_Nullable error))handler{ + [[self RPCTogetTotalCreditsInPlatformWithRequest:request handler:handler] start]; +} +// Returns a not-yet-started RPC object. +- (GRPCProtoCall *)RPCTogetTotalCreditsInPlatformWithRequest:(GetTotalCreditsInPlatformRequest *)request handler:(void(^)(GetTotalCreditsInPlatformResponse *_Nullable response, NSError *_Nullable error))handler{ + return [self RPCToMethod:@"getTotalCreditsInPlatform" + requestsWriter:[GRXWriter writerWithValue:request] + responseClass:[GetTotalCreditsInPlatformResponse class] + responsesWriteable:[GRXWriteable writeableWithSingleHandler:handler]]; +} +- (GRPCUnaryProtoCall *)getTotalCreditsInPlatformWithMessage:(GetTotalCreditsInPlatformRequest *)message responseHandler:(id)handler callOptions:(GRPCCallOptions *_Nullable)callOptions { + return [self RPCToMethod:@"getTotalCreditsInPlatform" + message:message + responseHandler:handler + callOptions:callOptions + responseClass:[GetTotalCreditsInPlatformResponse class]]; +} + #pragma mark getPathElements(GetPathElementsRequest) returns (GetPathElementsResponse) - (void)getPathElementsWithRequest:(GetPathElementsRequest *)request handler:(void(^)(GetPathElementsResponse *_Nullable response, NSError *_Nullable error))handler{ diff --git a/packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py b/packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py index 8b4a2aa9ba..f27a207378 100644 --- a/packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py +++ b/packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py @@ -23,7 +23,7 @@ syntax='proto3', serialized_options=None, create_key=_descriptor._internal_create_key, - serialized_pb=b'\n\x0eplatform.proto\x12\x19org.dash.platform.dapi.v0\x1a\x1egoogle/protobuf/wrappers.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\x81\x01\n\x05Proof\x12\x15\n\rgrovedb_proof\x18\x01 \x01(\x0c\x12\x13\n\x0bquorum_hash\x18\x02 \x01(\x0c\x12\x11\n\tsignature\x18\x03 \x01(\x0c\x12\r\n\x05round\x18\x04 \x01(\r\x12\x15\n\rblock_id_hash\x18\x05 \x01(\x0c\x12\x13\n\x0bquorum_type\x18\x06 \x01(\r\"\x90\x01\n\x10ResponseMetadata\x12\x0e\n\x06height\x18\x01 \x01(\x04\x12 \n\x18\x63ore_chain_locked_height\x18\x02 \x01(\r\x12\r\n\x05\x65poch\x18\x03 \x01(\r\x12\x0f\n\x07time_ms\x18\x04 \x01(\x04\x12\x18\n\x10protocol_version\x18\x05 \x01(\r\x12\x10\n\x08\x63hain_id\x18\x06 \x01(\t\"L\n\x1dStateTransitionBroadcastError\x12\x0c\n\x04\x63ode\x18\x01 \x01(\r\x12\x0f\n\x07message\x18\x02 \x01(\t\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\x0c\";\n\x1f\x42roadcastStateTransitionRequest\x12\x18\n\x10state_transition\x18\x01 \x01(\x0c\"\"\n BroadcastStateTransitionResponse\"\xa4\x01\n\x12GetIdentityRequest\x12P\n\x02v0\x18\x01 \x01(\x0b\x32\x42.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0H\x00\x1a\x31\n\x14GetIdentityRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xc1\x01\n\x17GetIdentityNonceRequest\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetIdentityNonceRequest.GetIdentityNonceRequestV0H\x00\x1a?\n\x19GetIdentityNonceRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xf6\x01\n\x1fGetIdentityContractNonceRequest\x12j\n\x02v0\x18\x01 \x01(\x0b\x32\\.org.dash.platform.dapi.v0.GetIdentityContractNonceRequest.GetIdentityContractNonceRequestV0H\x00\x1a\\\n!GetIdentityContractNonceRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\x13\n\x0b\x63ontract_id\x18\x02 \x01(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xc0\x01\n\x19GetIdentityBalanceRequest\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0H\x00\x1a\x38\n\x1bGetIdentityBalanceRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xec\x01\n$GetIdentityBalanceAndRevisionRequest\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0H\x00\x1a\x43\n&GetIdentityBalanceAndRevisionRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x9e\x02\n\x13GetIdentityResponse\x12R\n\x02v0\x18\x01 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0H\x00\x1a\xa7\x01\n\x15GetIdentityResponseV0\x12\x12\n\x08identity\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb8\x02\n\x18GetIdentityNonceResponse\x12\\\n\x02v0\x18\x01 \x01(\x0b\x32N.org.dash.platform.dapi.v0.GetIdentityNonceResponse.GetIdentityNonceResponseV0H\x00\x1a\xb2\x01\n\x1aGetIdentityNonceResponseV0\x12\x18\n\x0eidentity_nonce\x18\x01 \x01(\x04H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xe1\x02\n GetIdentityContractNonceResponse\x12l\n\x02v0\x18\x01 \x01(\x0b\x32^.org.dash.platform.dapi.v0.GetIdentityContractNonceResponse.GetIdentityContractNonceResponseV0H\x00\x1a\xc3\x01\n\"GetIdentityContractNonceResponseV0\x12!\n\x17identity_contract_nonce\x18\x01 \x01(\x04H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb9\x02\n\x1aGetIdentityBalanceResponse\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0H\x00\x1a\xad\x01\n\x1cGetIdentityBalanceResponseV0\x12\x11\n\x07\x62\x61lance\x18\x01 \x01(\x04H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xa9\x04\n%GetIdentityBalanceAndRevisionResponse\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0H\x00\x1a\xfc\x02\n\'GetIdentityBalanceAndRevisionResponseV0\x12\x9b\x01\n\x14\x62\x61lance_and_revision\x18\x01 \x01(\x0b\x32{.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevisionH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x37\n\x12\x42\x61lanceAndRevision\x12\x0f\n\x07\x62\x61lance\x18\x01 \x01(\x04\x12\x10\n\x08revision\x18\x02 \x01(\x04\x42\x08\n\x06resultB\t\n\x07version\"\xd1\x01\n\x0eKeyRequestType\x12\x36\n\x08\x61ll_keys\x18\x01 \x01(\x0b\x32\".org.dash.platform.dapi.v0.AllKeysH\x00\x12@\n\rspecific_keys\x18\x02 \x01(\x0b\x32\'.org.dash.platform.dapi.v0.SpecificKeysH\x00\x12:\n\nsearch_key\x18\x03 \x01(\x0b\x32$.org.dash.platform.dapi.v0.SearchKeyH\x00\x42\t\n\x07request\"\t\n\x07\x41llKeys\"\x1f\n\x0cSpecificKeys\x12\x0f\n\x07key_ids\x18\x01 \x03(\r\"\xb6\x01\n\tSearchKey\x12I\n\x0bpurpose_map\x18\x01 \x03(\x0b\x32\x34.org.dash.platform.dapi.v0.SearchKey.PurposeMapEntry\x1a^\n\x0fPurposeMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\r\x12:\n\x05value\x18\x02 \x01(\x0b\x32+.org.dash.platform.dapi.v0.SecurityLevelMap:\x02\x38\x01\"\xbf\x02\n\x10SecurityLevelMap\x12]\n\x12security_level_map\x18\x01 \x03(\x0b\x32\x41.org.dash.platform.dapi.v0.SecurityLevelMap.SecurityLevelMapEntry\x1aw\n\x15SecurityLevelMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\r\x12M\n\x05value\x18\x02 \x01(\x0e\x32>.org.dash.platform.dapi.v0.SecurityLevelMap.KeyKindRequestType:\x02\x38\x01\"S\n\x12KeyKindRequestType\x12\x1f\n\x1b\x43URRENT_KEY_OF_KIND_REQUEST\x10\x00\x12\x1c\n\x18\x41LL_KEYS_OF_KIND_REQUEST\x10\x01\"\xda\x02\n\x16GetIdentityKeysRequest\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0H\x00\x1a\xda\x01\n\x18GetIdentityKeysRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12?\n\x0crequest_type\x18\x02 \x01(\x0b\x32).org.dash.platform.dapi.v0.KeyRequestType\x12+\n\x05limit\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12,\n\x06offset\x18\x04 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\t\n\x07version\"\x99\x03\n\x17GetIdentityKeysResponse\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0H\x00\x1a\x96\x02\n\x19GetIdentityKeysResponseV0\x12\x61\n\x04keys\x18\x01 \x01(\x0b\x32Q.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.KeysH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1a\n\x04Keys\x12\x12\n\nkeys_bytes\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version\"\xef\x02\n GetIdentitiesContractKeysRequest\x12l\n\x02v0\x18\x01 \x01(\x0b\x32^.org.dash.platform.dapi.v0.GetIdentitiesContractKeysRequest.GetIdentitiesContractKeysRequestV0H\x00\x1a\xd1\x01\n\"GetIdentitiesContractKeysRequestV0\x12\x16\n\x0eidentities_ids\x18\x01 \x03(\x0c\x12\x13\n\x0b\x63ontract_id\x18\x02 \x01(\x0c\x12\x1f\n\x12\x64ocument_type_name\x18\x03 \x01(\tH\x00\x88\x01\x01\x12\x37\n\x08purposes\x18\x04 \x03(\x0e\x32%.org.dash.platform.dapi.v0.KeyPurpose\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\x15\n\x13_document_type_nameB\t\n\x07version\"\xdf\x06\n!GetIdentitiesContractKeysResponse\x12n\n\x02v0\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetIdentitiesContractKeysResponse.GetIdentitiesContractKeysResponseV0H\x00\x1a\xbe\x05\n#GetIdentitiesContractKeysResponseV0\x12\x8a\x01\n\x0fidentities_keys\x18\x01 \x01(\x0b\x32o.org.dash.platform.dapi.v0.GetIdentitiesContractKeysResponse.GetIdentitiesContractKeysResponseV0.IdentitiesKeysH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1aY\n\x0bPurposeKeys\x12\x36\n\x07purpose\x18\x01 \x01(\x0e\x32%.org.dash.platform.dapi.v0.KeyPurpose\x12\x12\n\nkeys_bytes\x18\x02 \x03(\x0c\x1a\x9f\x01\n\x0cIdentityKeys\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12z\n\x04keys\x18\x02 \x03(\x0b\x32l.org.dash.platform.dapi.v0.GetIdentitiesContractKeysResponse.GetIdentitiesContractKeysResponseV0.PurposeKeys\x1a\x90\x01\n\x0eIdentitiesKeys\x12~\n\x07\x65ntries\x18\x01 \x03(\x0b\x32m.org.dash.platform.dapi.v0.GetIdentitiesContractKeysResponse.GetIdentitiesContractKeysResponseV0.IdentityKeysB\x08\n\x06resultB\t\n\x07version\"\xcb\x0b\n\x10GetProofsRequest\x12L\n\x02v0\x18\x01 \x01(\x0b\x32>.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0H\x00\x1a\xdd\n\n\x12GetProofsRequestV0\x12\x62\n\nidentities\x18\x01 \x03(\x0b\x32N.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest\x12\x61\n\tcontracts\x18\x02 \x03(\x0b\x32N.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest\x12\x61\n\tdocuments\x18\x03 \x03(\x0b\x32N.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest\x12_\n\x05votes\x18\x04 \x03(\x0b\x32P.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.VoteStatusRequest\x1a\xd5\x02\n\x0f\x44ocumentRequest\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x15\n\rdocument_type\x18\x02 \x01(\t\x12#\n\x1b\x64ocument_type_keeps_history\x18\x03 \x01(\x08\x12\x13\n\x0b\x64ocument_id\x18\x04 \x01(\x0c\x12\x89\x01\n\x19\x64ocument_contested_status\x18\x05 \x01(\x0e\x32\x66.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.DocumentContestedStatus\"P\n\x17\x44ocumentContestedStatus\x12\x11\n\rNOT_CONTESTED\x10\x00\x12\x13\n\x0fMAYBE_CONTESTED\x10\x01\x12\r\n\tCONTESTED\x10\x02\x1a\xd1\x01\n\x0fIdentityRequest\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12i\n\x0crequest_type\x18\x02 \x01(\x0e\x32S.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type\">\n\x04Type\x12\x11\n\rFULL_IDENTITY\x10\x00\x12\x0b\n\x07\x42\x41LANCE\x10\x01\x12\x08\n\x04KEYS\x10\x02\x12\x0c\n\x08REVISION\x10\x03\x1a&\n\x0f\x43ontractRequest\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x1a\xe7\x02\n\x11VoteStatusRequest\x12\xa5\x01\n&contested_resource_vote_status_request\x18\x01 \x01(\x0b\x32s.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.VoteStatusRequest.ContestedResourceVoteStatusRequestH\x00\x1a\x99\x01\n\"ContestedResourceVoteStatusRequest\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\x12\n\nindex_name\x18\x03 \x01(\t\x12\x14\n\x0cindex_values\x18\x04 \x03(\x0c\x12\x18\n\x10voter_identifier\x18\x05 \x01(\x0c\x42\x0e\n\x0crequest_typeB\t\n\x07version\"\x82\x02\n\x11GetProofsResponse\x12N\n\x02v0\x18\x01 \x01(\x0b\x32@.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0H\x00\x1a\x91\x01\n\x13GetProofsResponseV0\x12\x31\n\x05proof\x18\x01 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x02 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb4\x01\n\x16GetDataContractRequest\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0H\x00\x1a\x35\n\x18GetDataContractRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xb3\x02\n\x17GetDataContractResponse\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0H\x00\x1a\xb0\x01\n\x19GetDataContractResponseV0\x12\x17\n\rdata_contract\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb9\x01\n\x17GetDataContractsRequest\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0H\x00\x1a\x37\n\x19GetDataContractsRequestV0\x12\x0b\n\x03ids\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xcf\x04\n\x18GetDataContractsResponse\x12\\\n\x02v0\x18\x01 \x01(\x0b\x32N.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0H\x00\x1a[\n\x11\x44\x61taContractEntry\x12\x12\n\nidentifier\x18\x01 \x01(\x0c\x12\x32\n\rdata_contract\x18\x02 \x01(\x0b\x32\x1b.google.protobuf.BytesValue\x1au\n\rDataContracts\x12\x64\n\x15\x64\x61ta_contract_entries\x18\x01 \x03(\x0b\x32\x45.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry\x1a\xf5\x01\n\x1aGetDataContractsResponseV0\x12[\n\x0e\x64\x61ta_contracts\x18\x01 \x01(\x0b\x32\x41.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc1\x02\n\x1dGetDataContractHistoryRequest\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0H\x00\x1a\xac\x01\n\x1fGetDataContractHistoryRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12+\n\x05limit\x18\x02 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12,\n\x06offset\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\x13\n\x0bstart_at_ms\x18\x04 \x01(\x04\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\t\n\x07version\"\xae\x05\n\x1eGetDataContractHistoryResponse\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0H\x00\x1a\x96\x04\n GetDataContractHistoryResponseV0\x12\x8f\x01\n\x15\x64\x61ta_contract_history\x18\x01 \x01(\x0b\x32n.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x37\n\x18\x44\x61taContractHistoryEntry\x12\x0c\n\x04\x64\x61te\x18\x01 \x01(\x04\x12\r\n\x05value\x18\x02 \x01(\x0c\x1a\xaa\x01\n\x13\x44\x61taContractHistory\x12\x92\x01\n\x15\x64\x61ta_contract_entries\x18\x01 \x03(\x0b\x32s.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntryB\x08\n\x06resultB\t\n\x07version\"\xb2\x02\n\x13GetDocumentsRequest\x12R\n\x02v0\x18\x01 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0H\x00\x1a\xbb\x01\n\x15GetDocumentsRequestV0\x12\x18\n\x10\x64\x61ta_contract_id\x18\x01 \x01(\x0c\x12\x15\n\rdocument_type\x18\x02 \x01(\t\x12\r\n\x05where\x18\x03 \x01(\x0c\x12\x10\n\x08order_by\x18\x04 \x01(\x0c\x12\r\n\x05limit\x18\x05 \x01(\r\x12\x15\n\x0bstart_after\x18\x06 \x01(\x0cH\x00\x12\x12\n\x08start_at\x18\x07 \x01(\x0cH\x00\x12\r\n\x05prove\x18\x08 \x01(\x08\x42\x07\n\x05startB\t\n\x07version\"\x95\x03\n\x14GetDocumentsResponse\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0H\x00\x1a\x9b\x02\n\x16GetDocumentsResponseV0\x12\x65\n\tdocuments\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.DocumentsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1e\n\tDocuments\x12\x11\n\tdocuments\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version\"\xed\x01\n!GetIdentityByPublicKeyHashRequest\x12n\n\x02v0\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0H\x00\x1aM\n#GetIdentityByPublicKeyHashRequestV0\x12\x17\n\x0fpublic_key_hash\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xda\x02\n\"GetIdentityByPublicKeyHashResponse\x12p\n\x02v0\x18\x01 \x01(\x0b\x32\x62.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0H\x00\x1a\xb6\x01\n$GetIdentityByPublicKeyHashResponseV0\x12\x12\n\x08identity\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xfb\x01\n#WaitForStateTransitionResultRequest\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0H\x00\x1aU\n%WaitForStateTransitionResultRequestV0\x12\x1d\n\x15state_transition_hash\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x99\x03\n$WaitForStateTransitionResultResponse\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0H\x00\x1a\xef\x01\n&WaitForStateTransitionResultResponseV0\x12I\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x38.org.dash.platform.dapi.v0.StateTransitionBroadcastErrorH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc4\x01\n\x19GetConsensusParamsRequest\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0H\x00\x1a<\n\x1bGetConsensusParamsRequestV0\x12\x0e\n\x06height\x18\x01 \x01(\x05\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x9c\x04\n\x1aGetConsensusParamsResponse\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0H\x00\x1aP\n\x14\x43onsensusParamsBlock\x12\x11\n\tmax_bytes\x18\x01 \x01(\t\x12\x0f\n\x07max_gas\x18\x02 \x01(\t\x12\x14\n\x0ctime_iota_ms\x18\x03 \x01(\t\x1a\x62\n\x17\x43onsensusParamsEvidence\x12\x1a\n\x12max_age_num_blocks\x18\x01 \x01(\t\x12\x18\n\x10max_age_duration\x18\x02 \x01(\t\x12\x11\n\tmax_bytes\x18\x03 \x01(\t\x1a\xda\x01\n\x1cGetConsensusParamsResponseV0\x12Y\n\x05\x62lock\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock\x12_\n\x08\x65vidence\x18\x02 \x01(\x0b\x32M.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidenceB\t\n\x07version\"\xe4\x01\n%GetProtocolVersionUpgradeStateRequest\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0H\x00\x1a\x38\n\'GetProtocolVersionUpgradeStateRequestV0\x12\r\n\x05prove\x18\x01 \x01(\x08\x42\t\n\x07version\"\xb5\x05\n&GetProtocolVersionUpgradeStateResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0H\x00\x1a\x85\x04\n(GetProtocolVersionUpgradeStateResponseV0\x12\x87\x01\n\x08versions\x18\x01 \x01(\x0b\x32s.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x96\x01\n\x08Versions\x12\x89\x01\n\x08versions\x18\x01 \x03(\x0b\x32w.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry\x1a:\n\x0cVersionEntry\x12\x16\n\x0eversion_number\x18\x01 \x01(\r\x12\x12\n\nvote_count\x18\x02 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xa3\x02\n*GetProtocolVersionUpgradeVoteStatusRequest\x12\x80\x01\n\x02v0\x18\x01 \x01(\x0b\x32r.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0H\x00\x1ag\n,GetProtocolVersionUpgradeVoteStatusRequestV0\x12\x19\n\x11start_pro_tx_hash\x18\x01 \x01(\x0c\x12\r\n\x05\x63ount\x18\x02 \x01(\r\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xef\x05\n+GetProtocolVersionUpgradeVoteStatusResponse\x12\x82\x01\n\x02v0\x18\x01 \x01(\x0b\x32t.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0H\x00\x1a\xaf\x04\n-GetProtocolVersionUpgradeVoteStatusResponseV0\x12\x98\x01\n\x08versions\x18\x01 \x01(\x0b\x32\x83\x01.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignalsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\xaf\x01\n\x0eVersionSignals\x12\x9c\x01\n\x0fversion_signals\x18\x01 \x03(\x0b\x32\x82\x01.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal\x1a\x35\n\rVersionSignal\x12\x13\n\x0bpro_tx_hash\x18\x01 \x01(\x0c\x12\x0f\n\x07version\x18\x02 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xf5\x01\n\x14GetEpochsInfoRequest\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0H\x00\x1a|\n\x16GetEpochsInfoRequestV0\x12\x31\n\x0bstart_epoch\x18\x01 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\r\n\x05\x63ount\x18\x02 \x01(\r\x12\x11\n\tascending\x18\x03 \x01(\x08\x12\r\n\x05prove\x18\x04 \x01(\x08\x42\t\n\x07version\"\x91\x05\n\x15GetEpochsInfoResponse\x12V\n\x02v0\x18\x01 \x01(\x0b\x32H.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0H\x00\x1a\x94\x04\n\x17GetEpochsInfoResponseV0\x12\x65\n\x06\x65pochs\x18\x01 \x01(\x0b\x32S.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfosH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1au\n\nEpochInfos\x12g\n\x0b\x65poch_infos\x18\x01 \x03(\x0b\x32R.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo\x1a\x9e\x01\n\tEpochInfo\x12\x0e\n\x06number\x18\x01 \x01(\r\x12\x1a\n\x12\x66irst_block_height\x18\x02 \x01(\x04\x12\x1f\n\x17\x66irst_core_block_height\x18\x03 \x01(\r\x12\x12\n\nstart_time\x18\x04 \x01(\x04\x12\x16\n\x0e\x66\x65\x65_multiplier\x18\x05 \x01(\x01\x12\x18\n\x10protocol_version\x18\x06 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xde\x04\n\x1cGetContestedResourcesRequest\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0H\x00\x1a\xcc\x03\n\x1eGetContestedResourcesRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\x12\n\nindex_name\x18\x03 \x01(\t\x12\x1a\n\x12start_index_values\x18\x04 \x03(\x0c\x12\x18\n\x10\x65nd_index_values\x18\x05 \x03(\x0c\x12\x89\x01\n\x13start_at_value_info\x18\x06 \x01(\x0b\x32g.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.StartAtValueInfoH\x00\x88\x01\x01\x12\x12\n\x05\x63ount\x18\x07 \x01(\rH\x01\x88\x01\x01\x12\x17\n\x0forder_ascending\x18\x08 \x01(\x08\x12\r\n\x05prove\x18\t \x01(\x08\x1a\x45\n\x10StartAtValueInfo\x12\x13\n\x0bstart_value\x18\x01 \x01(\x0c\x12\x1c\n\x14start_value_included\x18\x02 \x01(\x08\x42\x16\n\x14_start_at_value_infoB\x08\n\x06_countB\t\n\x07version\"\x88\x04\n\x1dGetContestedResourcesResponse\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0H\x00\x1a\xf3\x02\n\x1fGetContestedResourcesResponseV0\x12\x95\x01\n\x19\x63ontested_resource_values\x18\x01 \x01(\x0b\x32p.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResourceValuesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a<\n\x17\x43ontestedResourceValues\x12!\n\x19\x63ontested_resource_values\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version\"\xca\x05\n\x1cGetVotePollsByEndDateRequest\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetVotePollsByEndDateRequest.GetVotePollsByEndDateRequestV0H\x00\x1a\xb8\x04\n\x1eGetVotePollsByEndDateRequestV0\x12\x84\x01\n\x0fstart_time_info\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetVotePollsByEndDateRequest.GetVotePollsByEndDateRequestV0.StartAtTimeInfoH\x00\x88\x01\x01\x12\x80\x01\n\rend_time_info\x18\x02 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.GetVotePollsByEndDateRequest.GetVotePollsByEndDateRequestV0.EndAtTimeInfoH\x01\x88\x01\x01\x12\x12\n\x05limit\x18\x03 \x01(\rH\x02\x88\x01\x01\x12\x13\n\x06offset\x18\x04 \x01(\rH\x03\x88\x01\x01\x12\x11\n\tascending\x18\x05 \x01(\x08\x12\r\n\x05prove\x18\x06 \x01(\x08\x1a\x45\n\x0fStartAtTimeInfo\x12\x15\n\rstart_time_ms\x18\x01 \x01(\x04\x12\x1b\n\x13start_time_included\x18\x02 \x01(\x08\x1a?\n\rEndAtTimeInfo\x12\x13\n\x0b\x65nd_time_ms\x18\x01 \x01(\x04\x12\x19\n\x11\x65nd_time_included\x18\x02 \x01(\x08\x42\x12\n\x10_start_time_infoB\x10\n\x0e_end_time_infoB\x08\n\x06_limitB\t\n\x07_offsetB\t\n\x07version\"\xff\x05\n\x1dGetVotePollsByEndDateResponse\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetVotePollsByEndDateResponse.GetVotePollsByEndDateResponseV0H\x00\x1a\xea\x04\n\x1fGetVotePollsByEndDateResponseV0\x12\x9c\x01\n\x18vote_polls_by_timestamps\x18\x01 \x01(\x0b\x32x.org.dash.platform.dapi.v0.GetVotePollsByEndDateResponse.GetVotePollsByEndDateResponseV0.SerializedVotePollsByTimestampsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1aR\n\x1eSerializedVotePollsByTimestamp\x12\x11\n\ttimestamp\x18\x01 \x01(\x04\x12\x1d\n\x15serialized_vote_polls\x18\x02 \x03(\x0c\x1a\xd7\x01\n\x1fSerializedVotePollsByTimestamps\x12\x99\x01\n\x18vote_polls_by_timestamps\x18\x01 \x03(\x0b\x32w.org.dash.platform.dapi.v0.GetVotePollsByEndDateResponse.GetVotePollsByEndDateResponseV0.SerializedVotePollsByTimestamp\x12\x18\n\x10\x66inished_results\x18\x02 \x01(\x08\x42\x08\n\x06resultB\t\n\x07version\"\xff\x06\n$GetContestedResourceVoteStateRequest\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0H\x00\x1a\xd5\x05\n&GetContestedResourceVoteStateRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\x12\n\nindex_name\x18\x03 \x01(\t\x12\x14\n\x0cindex_values\x18\x04 \x03(\x0c\x12\x86\x01\n\x0bresult_type\x18\x05 \x01(\x0e\x32q.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.ResultType\x12\x36\n.allow_include_locked_and_abstaining_vote_tally\x18\x06 \x01(\x08\x12\xa3\x01\n\x18start_at_identifier_info\x18\x07 \x01(\x0b\x32|.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.StartAtIdentifierInfoH\x00\x88\x01\x01\x12\x12\n\x05\x63ount\x18\x08 \x01(\rH\x01\x88\x01\x01\x12\r\n\x05prove\x18\t \x01(\x08\x1aT\n\x15StartAtIdentifierInfo\x12\x18\n\x10start_identifier\x18\x01 \x01(\x0c\x12!\n\x19start_identifier_included\x18\x02 \x01(\x08\"I\n\nResultType\x12\r\n\tDOCUMENTS\x10\x00\x12\x0e\n\nVOTE_TALLY\x10\x01\x12\x1c\n\x18\x44OCUMENTS_AND_VOTE_TALLY\x10\x02\x42\x1b\n\x19_start_at_identifier_infoB\x08\n\x06_countB\t\n\x07version\"\x8c\x0c\n%GetContestedResourceVoteStateResponse\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0H\x00\x1a\xdf\n\n\'GetContestedResourceVoteStateResponseV0\x12\xae\x01\n\x1d\x63ontested_resource_contenders\x18\x01 \x01(\x0b\x32\x84\x01.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContendersH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\xd2\x03\n\x10\x46inishedVoteInfo\x12\xad\x01\n\x15\x66inished_vote_outcome\x18\x01 \x01(\x0e\x32\x8d\x01.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.FinishedVoteInfo.FinishedVoteOutcome\x12\x1f\n\x12won_by_identity_id\x18\x02 \x01(\x0cH\x00\x88\x01\x01\x12 \n\x18\x66inished_at_block_height\x18\x03 \x01(\x04\x12%\n\x1d\x66inished_at_core_block_height\x18\x04 \x01(\r\x12!\n\x19\x66inished_at_block_time_ms\x18\x05 \x01(\x04\x12\x19\n\x11\x66inished_at_epoch\x18\x06 \x01(\r\"O\n\x13\x46inishedVoteOutcome\x12\x14\n\x10TOWARDS_IDENTITY\x10\x00\x12\n\n\x06LOCKED\x10\x01\x12\x16\n\x12NO_PREVIOUS_WINNER\x10\x02\x42\x15\n\x13_won_by_identity_id\x1a\xc4\x03\n\x1b\x43ontestedResourceContenders\x12\x86\x01\n\ncontenders\x18\x01 \x03(\x0b\x32r.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender\x12\x1f\n\x12\x61\x62stain_vote_tally\x18\x02 \x01(\rH\x00\x88\x01\x01\x12\x1c\n\x0flock_vote_tally\x18\x03 \x01(\rH\x01\x88\x01\x01\x12\x9a\x01\n\x12\x66inished_vote_info\x18\x04 \x01(\x0b\x32y.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.FinishedVoteInfoH\x02\x88\x01\x01\x42\x15\n\x13_abstain_vote_tallyB\x12\n\x10_lock_vote_tallyB\x15\n\x13_finished_vote_info\x1ak\n\tContender\x12\x12\n\nidentifier\x18\x01 \x01(\x0c\x12\x17\n\nvote_count\x18\x02 \x01(\rH\x00\x88\x01\x01\x12\x15\n\x08\x64ocument\x18\x03 \x01(\x0cH\x01\x88\x01\x01\x42\r\n\x0b_vote_countB\x0b\n\t_documentB\x08\n\x06resultB\t\n\x07version\"\xd5\x05\n,GetContestedResourceVotersForIdentityRequest\x12\x84\x01\n\x02v0\x18\x01 \x01(\x0b\x32v.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityRequest.GetContestedResourceVotersForIdentityRequestV0H\x00\x1a\x92\x04\n.GetContestedResourceVotersForIdentityRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\x12\n\nindex_name\x18\x03 \x01(\t\x12\x14\n\x0cindex_values\x18\x04 \x03(\x0c\x12\x15\n\rcontestant_id\x18\x05 \x01(\x0c\x12\xb4\x01\n\x18start_at_identifier_info\x18\x06 \x01(\x0b\x32\x8c\x01.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityRequest.GetContestedResourceVotersForIdentityRequestV0.StartAtIdentifierInfoH\x00\x88\x01\x01\x12\x12\n\x05\x63ount\x18\x07 \x01(\rH\x01\x88\x01\x01\x12\x17\n\x0forder_ascending\x18\x08 \x01(\x08\x12\r\n\x05prove\x18\t \x01(\x08\x1aT\n\x15StartAtIdentifierInfo\x12\x18\n\x10start_identifier\x18\x01 \x01(\x0c\x12!\n\x19start_identifier_included\x18\x02 \x01(\x08\x42\x1b\n\x19_start_at_identifier_infoB\x08\n\x06_countB\t\n\x07version\"\xf1\x04\n-GetContestedResourceVotersForIdentityResponse\x12\x86\x01\n\x02v0\x18\x01 \x01(\x0b\x32x.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityResponse.GetContestedResourceVotersForIdentityResponseV0H\x00\x1a\xab\x03\n/GetContestedResourceVotersForIdentityResponseV0\x12\xb6\x01\n\x19\x63ontested_resource_voters\x18\x01 \x01(\x0b\x32\x90\x01.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityResponse.GetContestedResourceVotersForIdentityResponseV0.ContestedResourceVotersH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x43\n\x17\x43ontestedResourceVoters\x12\x0e\n\x06voters\x18\x01 \x03(\x0c\x12\x18\n\x10\x66inished_results\x18\x02 \x01(\x08\x42\x08\n\x06resultB\t\n\x07version\"\xad\x05\n(GetContestedResourceIdentityVotesRequest\x12|\n\x02v0\x18\x01 \x01(\x0b\x32n.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesRequest.GetContestedResourceIdentityVotesRequestV0H\x00\x1a\xf7\x03\n*GetContestedResourceIdentityVotesRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12+\n\x05limit\x18\x02 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12,\n\x06offset\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\x17\n\x0forder_ascending\x18\x04 \x01(\x08\x12\xae\x01\n\x1astart_at_vote_poll_id_info\x18\x05 \x01(\x0b\x32\x84\x01.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesRequest.GetContestedResourceIdentityVotesRequestV0.StartAtVotePollIdInfoH\x00\x88\x01\x01\x12\r\n\x05prove\x18\x06 \x01(\x08\x1a\x61\n\x15StartAtVotePollIdInfo\x12 \n\x18start_at_poll_identifier\x18\x01 \x01(\x0c\x12&\n\x1estart_poll_identifier_included\x18\x02 \x01(\x08\x42\x1d\n\x1b_start_at_vote_poll_id_infoB\t\n\x07version\"\xc8\n\n)GetContestedResourceIdentityVotesResponse\x12~\n\x02v0\x18\x01 \x01(\x0b\x32p.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse.GetContestedResourceIdentityVotesResponseV0H\x00\x1a\x8f\t\n+GetContestedResourceIdentityVotesResponseV0\x12\xa1\x01\n\x05votes\x18\x01 \x01(\x0b\x32\x8f\x01.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse.GetContestedResourceIdentityVotesResponseV0.ContestedResourceIdentityVotesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\xf7\x01\n\x1e\x43ontestedResourceIdentityVotes\x12\xba\x01\n!contested_resource_identity_votes\x18\x01 \x03(\x0b\x32\x8e\x01.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse.GetContestedResourceIdentityVotesResponseV0.ContestedResourceIdentityVote\x12\x18\n\x10\x66inished_results\x18\x02 \x01(\x08\x1a\xad\x02\n\x12ResourceVoteChoice\x12\xad\x01\n\x10vote_choice_type\x18\x01 \x01(\x0e\x32\x92\x01.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse.GetContestedResourceIdentityVotesResponseV0.ResourceVoteChoice.VoteChoiceType\x12\x18\n\x0bidentity_id\x18\x02 \x01(\x0cH\x00\x88\x01\x01\"=\n\x0eVoteChoiceType\x12\x14\n\x10TOWARDS_IDENTITY\x10\x00\x12\x0b\n\x07\x41\x42STAIN\x10\x01\x12\x08\n\x04LOCK\x10\x02\x42\x0e\n\x0c_identity_id\x1a\x95\x02\n\x1d\x43ontestedResourceIdentityVote\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\'\n\x1fserialized_index_storage_values\x18\x03 \x03(\x0c\x12\x99\x01\n\x0bvote_choice\x18\x04 \x01(\x0b\x32\x83\x01.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse.GetContestedResourceIdentityVotesResponseV0.ResourceVoteChoiceB\x08\n\x06resultB\t\n\x07version\"\xf0\x01\n%GetPrefundedSpecializedBalanceRequest\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetPrefundedSpecializedBalanceRequest.GetPrefundedSpecializedBalanceRequestV0H\x00\x1a\x44\n\'GetPrefundedSpecializedBalanceRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xe9\x02\n&GetPrefundedSpecializedBalanceResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetPrefundedSpecializedBalanceResponse.GetPrefundedSpecializedBalanceResponseV0H\x00\x1a\xb9\x01\n(GetPrefundedSpecializedBalanceResponseV0\x12\x11\n\x07\x62\x61lance\x18\x01 \x01(\x04H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc4\x01\n\x16GetPathElementsRequest\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetPathElementsRequest.GetPathElementsRequestV0H\x00\x1a\x45\n\x18GetPathElementsRequestV0\x12\x0c\n\x04path\x18\x01 \x03(\x0c\x12\x0c\n\x04keys\x18\x02 \x03(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xa3\x03\n\x17GetPathElementsResponse\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetPathElementsResponse.GetPathElementsResponseV0H\x00\x1a\xa0\x02\n\x19GetPathElementsResponseV0\x12i\n\x08\x65lements\x18\x01 \x01(\x0b\x32U.org.dash.platform.dapi.v0.GetPathElementsResponse.GetPathElementsResponseV0.ElementsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1c\n\x08\x45lements\x12\x10\n\x08\x65lements\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version*Z\n\nKeyPurpose\x12\x12\n\x0e\x41UTHENTICATION\x10\x00\x12\x0e\n\nENCRYPTION\x10\x01\x12\x0e\n\nDECRYPTION\x10\x02\x12\x0c\n\x08TRANSFER\x10\x03\x12\n\n\x06VOTING\x10\x05\x32\xa1\x1d\n\x08Platform\x12\x93\x01\n\x18\x62roadcastStateTransition\x12:.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest\x1a;.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse\x12l\n\x0bgetIdentity\x12-.org.dash.platform.dapi.v0.GetIdentityRequest\x1a..org.dash.platform.dapi.v0.GetIdentityResponse\x12x\n\x0fgetIdentityKeys\x12\x31.org.dash.platform.dapi.v0.GetIdentityKeysRequest\x1a\x32.org.dash.platform.dapi.v0.GetIdentityKeysResponse\x12\x96\x01\n\x19getIdentitiesContractKeys\x12;.org.dash.platform.dapi.v0.GetIdentitiesContractKeysRequest\x1a<.org.dash.platform.dapi.v0.GetIdentitiesContractKeysResponse\x12{\n\x10getIdentityNonce\x12\x32.org.dash.platform.dapi.v0.GetIdentityNonceRequest\x1a\x33.org.dash.platform.dapi.v0.GetIdentityNonceResponse\x12\x93\x01\n\x18getIdentityContractNonce\x12:.org.dash.platform.dapi.v0.GetIdentityContractNonceRequest\x1a;.org.dash.platform.dapi.v0.GetIdentityContractNonceResponse\x12\x81\x01\n\x12getIdentityBalance\x12\x34.org.dash.platform.dapi.v0.GetIdentityBalanceRequest\x1a\x35.org.dash.platform.dapi.v0.GetIdentityBalanceResponse\x12\xa2\x01\n\x1dgetIdentityBalanceAndRevision\x12?.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest\x1a@.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse\x12\x66\n\tgetProofs\x12+.org.dash.platform.dapi.v0.GetProofsRequest\x1a,.org.dash.platform.dapi.v0.GetProofsResponse\x12x\n\x0fgetDataContract\x12\x31.org.dash.platform.dapi.v0.GetDataContractRequest\x1a\x32.org.dash.platform.dapi.v0.GetDataContractResponse\x12\x8d\x01\n\x16getDataContractHistory\x12\x38.org.dash.platform.dapi.v0.GetDataContractHistoryRequest\x1a\x39.org.dash.platform.dapi.v0.GetDataContractHistoryResponse\x12{\n\x10getDataContracts\x12\x32.org.dash.platform.dapi.v0.GetDataContractsRequest\x1a\x33.org.dash.platform.dapi.v0.GetDataContractsResponse\x12o\n\x0cgetDocuments\x12..org.dash.platform.dapi.v0.GetDocumentsRequest\x1a/.org.dash.platform.dapi.v0.GetDocumentsResponse\x12\x99\x01\n\x1agetIdentityByPublicKeyHash\x12<.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest\x1a=.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse\x12\x9f\x01\n\x1cwaitForStateTransitionResult\x12>.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest\x1a?.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse\x12\x81\x01\n\x12getConsensusParams\x12\x34.org.dash.platform.dapi.v0.GetConsensusParamsRequest\x1a\x35.org.dash.platform.dapi.v0.GetConsensusParamsResponse\x12\xa5\x01\n\x1egetProtocolVersionUpgradeState\x12@.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest\x1a\x41.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse\x12\xb4\x01\n#getProtocolVersionUpgradeVoteStatus\x12\x45.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest\x1a\x46.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse\x12r\n\rgetEpochsInfo\x12/.org.dash.platform.dapi.v0.GetEpochsInfoRequest\x1a\x30.org.dash.platform.dapi.v0.GetEpochsInfoResponse\x12\x8a\x01\n\x15getContestedResources\x12\x37.org.dash.platform.dapi.v0.GetContestedResourcesRequest\x1a\x38.org.dash.platform.dapi.v0.GetContestedResourcesResponse\x12\xa2\x01\n\x1dgetContestedResourceVoteState\x12?.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest\x1a@.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse\x12\xba\x01\n%getContestedResourceVotersForIdentity\x12G.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityRequest\x1aH.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityResponse\x12\xae\x01\n!getContestedResourceIdentityVotes\x12\x43.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesRequest\x1a\x44.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse\x12\x8a\x01\n\x15getVotePollsByEndDate\x12\x37.org.dash.platform.dapi.v0.GetVotePollsByEndDateRequest\x1a\x38.org.dash.platform.dapi.v0.GetVotePollsByEndDateResponse\x12\xa5\x01\n\x1egetPrefundedSpecializedBalance\x12@.org.dash.platform.dapi.v0.GetPrefundedSpecializedBalanceRequest\x1a\x41.org.dash.platform.dapi.v0.GetPrefundedSpecializedBalanceResponse\x12x\n\x0fgetPathElements\x12\x31.org.dash.platform.dapi.v0.GetPathElementsRequest\x1a\x32.org.dash.platform.dapi.v0.GetPathElementsResponseb\x06proto3' + serialized_pb=b'\n\x0eplatform.proto\x12\x19org.dash.platform.dapi.v0\x1a\x1egoogle/protobuf/wrappers.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\x81\x01\n\x05Proof\x12\x15\n\rgrovedb_proof\x18\x01 \x01(\x0c\x12\x13\n\x0bquorum_hash\x18\x02 \x01(\x0c\x12\x11\n\tsignature\x18\x03 \x01(\x0c\x12\r\n\x05round\x18\x04 \x01(\r\x12\x15\n\rblock_id_hash\x18\x05 \x01(\x0c\x12\x13\n\x0bquorum_type\x18\x06 \x01(\r\"\x90\x01\n\x10ResponseMetadata\x12\x0e\n\x06height\x18\x01 \x01(\x04\x12 \n\x18\x63ore_chain_locked_height\x18\x02 \x01(\r\x12\r\n\x05\x65poch\x18\x03 \x01(\r\x12\x0f\n\x07time_ms\x18\x04 \x01(\x04\x12\x18\n\x10protocol_version\x18\x05 \x01(\r\x12\x10\n\x08\x63hain_id\x18\x06 \x01(\t\"L\n\x1dStateTransitionBroadcastError\x12\x0c\n\x04\x63ode\x18\x01 \x01(\r\x12\x0f\n\x07message\x18\x02 \x01(\t\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\x0c\";\n\x1f\x42roadcastStateTransitionRequest\x12\x18\n\x10state_transition\x18\x01 \x01(\x0c\"\"\n BroadcastStateTransitionResponse\"\xa4\x01\n\x12GetIdentityRequest\x12P\n\x02v0\x18\x01 \x01(\x0b\x32\x42.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0H\x00\x1a\x31\n\x14GetIdentityRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xc1\x01\n\x17GetIdentityNonceRequest\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetIdentityNonceRequest.GetIdentityNonceRequestV0H\x00\x1a?\n\x19GetIdentityNonceRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xf6\x01\n\x1fGetIdentityContractNonceRequest\x12j\n\x02v0\x18\x01 \x01(\x0b\x32\\.org.dash.platform.dapi.v0.GetIdentityContractNonceRequest.GetIdentityContractNonceRequestV0H\x00\x1a\\\n!GetIdentityContractNonceRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12\x13\n\x0b\x63ontract_id\x18\x02 \x01(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xc0\x01\n\x19GetIdentityBalanceRequest\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0H\x00\x1a\x38\n\x1bGetIdentityBalanceRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xec\x01\n$GetIdentityBalanceAndRevisionRequest\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0H\x00\x1a\x43\n&GetIdentityBalanceAndRevisionRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x9e\x02\n\x13GetIdentityResponse\x12R\n\x02v0\x18\x01 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0H\x00\x1a\xa7\x01\n\x15GetIdentityResponseV0\x12\x12\n\x08identity\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb8\x02\n\x18GetIdentityNonceResponse\x12\\\n\x02v0\x18\x01 \x01(\x0b\x32N.org.dash.platform.dapi.v0.GetIdentityNonceResponse.GetIdentityNonceResponseV0H\x00\x1a\xb2\x01\n\x1aGetIdentityNonceResponseV0\x12\x18\n\x0eidentity_nonce\x18\x01 \x01(\x04H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xe1\x02\n GetIdentityContractNonceResponse\x12l\n\x02v0\x18\x01 \x01(\x0b\x32^.org.dash.platform.dapi.v0.GetIdentityContractNonceResponse.GetIdentityContractNonceResponseV0H\x00\x1a\xc3\x01\n\"GetIdentityContractNonceResponseV0\x12!\n\x17identity_contract_nonce\x18\x01 \x01(\x04H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb9\x02\n\x1aGetIdentityBalanceResponse\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0H\x00\x1a\xad\x01\n\x1cGetIdentityBalanceResponseV0\x12\x11\n\x07\x62\x61lance\x18\x01 \x01(\x04H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xa9\x04\n%GetIdentityBalanceAndRevisionResponse\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0H\x00\x1a\xfc\x02\n\'GetIdentityBalanceAndRevisionResponseV0\x12\x9b\x01\n\x14\x62\x61lance_and_revision\x18\x01 \x01(\x0b\x32{.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevisionH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x37\n\x12\x42\x61lanceAndRevision\x12\x0f\n\x07\x62\x61lance\x18\x01 \x01(\x04\x12\x10\n\x08revision\x18\x02 \x01(\x04\x42\x08\n\x06resultB\t\n\x07version\"\xd1\x01\n\x0eKeyRequestType\x12\x36\n\x08\x61ll_keys\x18\x01 \x01(\x0b\x32\".org.dash.platform.dapi.v0.AllKeysH\x00\x12@\n\rspecific_keys\x18\x02 \x01(\x0b\x32\'.org.dash.platform.dapi.v0.SpecificKeysH\x00\x12:\n\nsearch_key\x18\x03 \x01(\x0b\x32$.org.dash.platform.dapi.v0.SearchKeyH\x00\x42\t\n\x07request\"\t\n\x07\x41llKeys\"\x1f\n\x0cSpecificKeys\x12\x0f\n\x07key_ids\x18\x01 \x03(\r\"\xb6\x01\n\tSearchKey\x12I\n\x0bpurpose_map\x18\x01 \x03(\x0b\x32\x34.org.dash.platform.dapi.v0.SearchKey.PurposeMapEntry\x1a^\n\x0fPurposeMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\r\x12:\n\x05value\x18\x02 \x01(\x0b\x32+.org.dash.platform.dapi.v0.SecurityLevelMap:\x02\x38\x01\"\xbf\x02\n\x10SecurityLevelMap\x12]\n\x12security_level_map\x18\x01 \x03(\x0b\x32\x41.org.dash.platform.dapi.v0.SecurityLevelMap.SecurityLevelMapEntry\x1aw\n\x15SecurityLevelMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\r\x12M\n\x05value\x18\x02 \x01(\x0e\x32>.org.dash.platform.dapi.v0.SecurityLevelMap.KeyKindRequestType:\x02\x38\x01\"S\n\x12KeyKindRequestType\x12\x1f\n\x1b\x43URRENT_KEY_OF_KIND_REQUEST\x10\x00\x12\x1c\n\x18\x41LL_KEYS_OF_KIND_REQUEST\x10\x01\"\xda\x02\n\x16GetIdentityKeysRequest\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0H\x00\x1a\xda\x01\n\x18GetIdentityKeysRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12?\n\x0crequest_type\x18\x02 \x01(\x0b\x32).org.dash.platform.dapi.v0.KeyRequestType\x12+\n\x05limit\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12,\n\x06offset\x18\x04 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\t\n\x07version\"\x99\x03\n\x17GetIdentityKeysResponse\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0H\x00\x1a\x96\x02\n\x19GetIdentityKeysResponseV0\x12\x61\n\x04keys\x18\x01 \x01(\x0b\x32Q.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.KeysH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1a\n\x04Keys\x12\x12\n\nkeys_bytes\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version\"\xef\x02\n GetIdentitiesContractKeysRequest\x12l\n\x02v0\x18\x01 \x01(\x0b\x32^.org.dash.platform.dapi.v0.GetIdentitiesContractKeysRequest.GetIdentitiesContractKeysRequestV0H\x00\x1a\xd1\x01\n\"GetIdentitiesContractKeysRequestV0\x12\x16\n\x0eidentities_ids\x18\x01 \x03(\x0c\x12\x13\n\x0b\x63ontract_id\x18\x02 \x01(\x0c\x12\x1f\n\x12\x64ocument_type_name\x18\x03 \x01(\tH\x00\x88\x01\x01\x12\x37\n\x08purposes\x18\x04 \x03(\x0e\x32%.org.dash.platform.dapi.v0.KeyPurpose\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\x15\n\x13_document_type_nameB\t\n\x07version\"\xdf\x06\n!GetIdentitiesContractKeysResponse\x12n\n\x02v0\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetIdentitiesContractKeysResponse.GetIdentitiesContractKeysResponseV0H\x00\x1a\xbe\x05\n#GetIdentitiesContractKeysResponseV0\x12\x8a\x01\n\x0fidentities_keys\x18\x01 \x01(\x0b\x32o.org.dash.platform.dapi.v0.GetIdentitiesContractKeysResponse.GetIdentitiesContractKeysResponseV0.IdentitiesKeysH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1aY\n\x0bPurposeKeys\x12\x36\n\x07purpose\x18\x01 \x01(\x0e\x32%.org.dash.platform.dapi.v0.KeyPurpose\x12\x12\n\nkeys_bytes\x18\x02 \x03(\x0c\x1a\x9f\x01\n\x0cIdentityKeys\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12z\n\x04keys\x18\x02 \x03(\x0b\x32l.org.dash.platform.dapi.v0.GetIdentitiesContractKeysResponse.GetIdentitiesContractKeysResponseV0.PurposeKeys\x1a\x90\x01\n\x0eIdentitiesKeys\x12~\n\x07\x65ntries\x18\x01 \x03(\x0b\x32m.org.dash.platform.dapi.v0.GetIdentitiesContractKeysResponse.GetIdentitiesContractKeysResponseV0.IdentityKeysB\x08\n\x06resultB\t\n\x07version\"\xcb\x0b\n\x10GetProofsRequest\x12L\n\x02v0\x18\x01 \x01(\x0b\x32>.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0H\x00\x1a\xdd\n\n\x12GetProofsRequestV0\x12\x62\n\nidentities\x18\x01 \x03(\x0b\x32N.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest\x12\x61\n\tcontracts\x18\x02 \x03(\x0b\x32N.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest\x12\x61\n\tdocuments\x18\x03 \x03(\x0b\x32N.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest\x12_\n\x05votes\x18\x04 \x03(\x0b\x32P.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.VoteStatusRequest\x1a\xd5\x02\n\x0f\x44ocumentRequest\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x15\n\rdocument_type\x18\x02 \x01(\t\x12#\n\x1b\x64ocument_type_keeps_history\x18\x03 \x01(\x08\x12\x13\n\x0b\x64ocument_id\x18\x04 \x01(\x0c\x12\x89\x01\n\x19\x64ocument_contested_status\x18\x05 \x01(\x0e\x32\x66.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.DocumentContestedStatus\"P\n\x17\x44ocumentContestedStatus\x12\x11\n\rNOT_CONTESTED\x10\x00\x12\x13\n\x0fMAYBE_CONTESTED\x10\x01\x12\r\n\tCONTESTED\x10\x02\x1a\xd1\x01\n\x0fIdentityRequest\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12i\n\x0crequest_type\x18\x02 \x01(\x0e\x32S.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type\">\n\x04Type\x12\x11\n\rFULL_IDENTITY\x10\x00\x12\x0b\n\x07\x42\x41LANCE\x10\x01\x12\x08\n\x04KEYS\x10\x02\x12\x0c\n\x08REVISION\x10\x03\x1a&\n\x0f\x43ontractRequest\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x1a\xe7\x02\n\x11VoteStatusRequest\x12\xa5\x01\n&contested_resource_vote_status_request\x18\x01 \x01(\x0b\x32s.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.VoteStatusRequest.ContestedResourceVoteStatusRequestH\x00\x1a\x99\x01\n\"ContestedResourceVoteStatusRequest\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\x12\n\nindex_name\x18\x03 \x01(\t\x12\x14\n\x0cindex_values\x18\x04 \x03(\x0c\x12\x18\n\x10voter_identifier\x18\x05 \x01(\x0c\x42\x0e\n\x0crequest_typeB\t\n\x07version\"\x82\x02\n\x11GetProofsResponse\x12N\n\x02v0\x18\x01 \x01(\x0b\x32@.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0H\x00\x1a\x91\x01\n\x13GetProofsResponseV0\x12\x31\n\x05proof\x18\x01 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x02 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb4\x01\n\x16GetDataContractRequest\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0H\x00\x1a\x35\n\x18GetDataContractRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xb3\x02\n\x17GetDataContractResponse\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0H\x00\x1a\xb0\x01\n\x19GetDataContractResponseV0\x12\x17\n\rdata_contract\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb9\x01\n\x17GetDataContractsRequest\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0H\x00\x1a\x37\n\x19GetDataContractsRequestV0\x12\x0b\n\x03ids\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xcf\x04\n\x18GetDataContractsResponse\x12\\\n\x02v0\x18\x01 \x01(\x0b\x32N.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0H\x00\x1a[\n\x11\x44\x61taContractEntry\x12\x12\n\nidentifier\x18\x01 \x01(\x0c\x12\x32\n\rdata_contract\x18\x02 \x01(\x0b\x32\x1b.google.protobuf.BytesValue\x1au\n\rDataContracts\x12\x64\n\x15\x64\x61ta_contract_entries\x18\x01 \x03(\x0b\x32\x45.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry\x1a\xf5\x01\n\x1aGetDataContractsResponseV0\x12[\n\x0e\x64\x61ta_contracts\x18\x01 \x01(\x0b\x32\x41.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc1\x02\n\x1dGetDataContractHistoryRequest\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0H\x00\x1a\xac\x01\n\x1fGetDataContractHistoryRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12+\n\x05limit\x18\x02 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12,\n\x06offset\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\x13\n\x0bstart_at_ms\x18\x04 \x01(\x04\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\t\n\x07version\"\xae\x05\n\x1eGetDataContractHistoryResponse\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0H\x00\x1a\x96\x04\n GetDataContractHistoryResponseV0\x12\x8f\x01\n\x15\x64\x61ta_contract_history\x18\x01 \x01(\x0b\x32n.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x37\n\x18\x44\x61taContractHistoryEntry\x12\x0c\n\x04\x64\x61te\x18\x01 \x01(\x04\x12\r\n\x05value\x18\x02 \x01(\x0c\x1a\xaa\x01\n\x13\x44\x61taContractHistory\x12\x92\x01\n\x15\x64\x61ta_contract_entries\x18\x01 \x03(\x0b\x32s.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntryB\x08\n\x06resultB\t\n\x07version\"\xb2\x02\n\x13GetDocumentsRequest\x12R\n\x02v0\x18\x01 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0H\x00\x1a\xbb\x01\n\x15GetDocumentsRequestV0\x12\x18\n\x10\x64\x61ta_contract_id\x18\x01 \x01(\x0c\x12\x15\n\rdocument_type\x18\x02 \x01(\t\x12\r\n\x05where\x18\x03 \x01(\x0c\x12\x10\n\x08order_by\x18\x04 \x01(\x0c\x12\r\n\x05limit\x18\x05 \x01(\r\x12\x15\n\x0bstart_after\x18\x06 \x01(\x0cH\x00\x12\x12\n\x08start_at\x18\x07 \x01(\x0cH\x00\x12\r\n\x05prove\x18\x08 \x01(\x08\x42\x07\n\x05startB\t\n\x07version\"\x95\x03\n\x14GetDocumentsResponse\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0H\x00\x1a\x9b\x02\n\x16GetDocumentsResponseV0\x12\x65\n\tdocuments\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.DocumentsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1e\n\tDocuments\x12\x11\n\tdocuments\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version\"\xed\x01\n!GetIdentityByPublicKeyHashRequest\x12n\n\x02v0\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0H\x00\x1aM\n#GetIdentityByPublicKeyHashRequestV0\x12\x17\n\x0fpublic_key_hash\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xda\x02\n\"GetIdentityByPublicKeyHashResponse\x12p\n\x02v0\x18\x01 \x01(\x0b\x32\x62.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0H\x00\x1a\xb6\x01\n$GetIdentityByPublicKeyHashResponseV0\x12\x12\n\x08identity\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xfb\x01\n#WaitForStateTransitionResultRequest\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0H\x00\x1aU\n%WaitForStateTransitionResultRequestV0\x12\x1d\n\x15state_transition_hash\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x99\x03\n$WaitForStateTransitionResultResponse\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0H\x00\x1a\xef\x01\n&WaitForStateTransitionResultResponseV0\x12I\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x38.org.dash.platform.dapi.v0.StateTransitionBroadcastErrorH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc4\x01\n\x19GetConsensusParamsRequest\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0H\x00\x1a<\n\x1bGetConsensusParamsRequestV0\x12\x0e\n\x06height\x18\x01 \x01(\x05\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x9c\x04\n\x1aGetConsensusParamsResponse\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0H\x00\x1aP\n\x14\x43onsensusParamsBlock\x12\x11\n\tmax_bytes\x18\x01 \x01(\t\x12\x0f\n\x07max_gas\x18\x02 \x01(\t\x12\x14\n\x0ctime_iota_ms\x18\x03 \x01(\t\x1a\x62\n\x17\x43onsensusParamsEvidence\x12\x1a\n\x12max_age_num_blocks\x18\x01 \x01(\t\x12\x18\n\x10max_age_duration\x18\x02 \x01(\t\x12\x11\n\tmax_bytes\x18\x03 \x01(\t\x1a\xda\x01\n\x1cGetConsensusParamsResponseV0\x12Y\n\x05\x62lock\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock\x12_\n\x08\x65vidence\x18\x02 \x01(\x0b\x32M.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidenceB\t\n\x07version\"\xe4\x01\n%GetProtocolVersionUpgradeStateRequest\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0H\x00\x1a\x38\n\'GetProtocolVersionUpgradeStateRequestV0\x12\r\n\x05prove\x18\x01 \x01(\x08\x42\t\n\x07version\"\xb5\x05\n&GetProtocolVersionUpgradeStateResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0H\x00\x1a\x85\x04\n(GetProtocolVersionUpgradeStateResponseV0\x12\x87\x01\n\x08versions\x18\x01 \x01(\x0b\x32s.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x96\x01\n\x08Versions\x12\x89\x01\n\x08versions\x18\x01 \x03(\x0b\x32w.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry\x1a:\n\x0cVersionEntry\x12\x16\n\x0eversion_number\x18\x01 \x01(\r\x12\x12\n\nvote_count\x18\x02 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xa3\x02\n*GetProtocolVersionUpgradeVoteStatusRequest\x12\x80\x01\n\x02v0\x18\x01 \x01(\x0b\x32r.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0H\x00\x1ag\n,GetProtocolVersionUpgradeVoteStatusRequestV0\x12\x19\n\x11start_pro_tx_hash\x18\x01 \x01(\x0c\x12\r\n\x05\x63ount\x18\x02 \x01(\r\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xef\x05\n+GetProtocolVersionUpgradeVoteStatusResponse\x12\x82\x01\n\x02v0\x18\x01 \x01(\x0b\x32t.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0H\x00\x1a\xaf\x04\n-GetProtocolVersionUpgradeVoteStatusResponseV0\x12\x98\x01\n\x08versions\x18\x01 \x01(\x0b\x32\x83\x01.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignalsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\xaf\x01\n\x0eVersionSignals\x12\x9c\x01\n\x0fversion_signals\x18\x01 \x03(\x0b\x32\x82\x01.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal\x1a\x35\n\rVersionSignal\x12\x13\n\x0bpro_tx_hash\x18\x01 \x01(\x0c\x12\x0f\n\x07version\x18\x02 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xf5\x01\n\x14GetEpochsInfoRequest\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0H\x00\x1a|\n\x16GetEpochsInfoRequestV0\x12\x31\n\x0bstart_epoch\x18\x01 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\r\n\x05\x63ount\x18\x02 \x01(\r\x12\x11\n\tascending\x18\x03 \x01(\x08\x12\r\n\x05prove\x18\x04 \x01(\x08\x42\t\n\x07version\"\x91\x05\n\x15GetEpochsInfoResponse\x12V\n\x02v0\x18\x01 \x01(\x0b\x32H.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0H\x00\x1a\x94\x04\n\x17GetEpochsInfoResponseV0\x12\x65\n\x06\x65pochs\x18\x01 \x01(\x0b\x32S.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfosH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1au\n\nEpochInfos\x12g\n\x0b\x65poch_infos\x18\x01 \x03(\x0b\x32R.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo\x1a\x9e\x01\n\tEpochInfo\x12\x0e\n\x06number\x18\x01 \x01(\r\x12\x1a\n\x12\x66irst_block_height\x18\x02 \x01(\x04\x12\x1f\n\x17\x66irst_core_block_height\x18\x03 \x01(\r\x12\x12\n\nstart_time\x18\x04 \x01(\x04\x12\x16\n\x0e\x66\x65\x65_multiplier\x18\x05 \x01(\x01\x12\x18\n\x10protocol_version\x18\x06 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xde\x04\n\x1cGetContestedResourcesRequest\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0H\x00\x1a\xcc\x03\n\x1eGetContestedResourcesRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\x12\n\nindex_name\x18\x03 \x01(\t\x12\x1a\n\x12start_index_values\x18\x04 \x03(\x0c\x12\x18\n\x10\x65nd_index_values\x18\x05 \x03(\x0c\x12\x89\x01\n\x13start_at_value_info\x18\x06 \x01(\x0b\x32g.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.StartAtValueInfoH\x00\x88\x01\x01\x12\x12\n\x05\x63ount\x18\x07 \x01(\rH\x01\x88\x01\x01\x12\x17\n\x0forder_ascending\x18\x08 \x01(\x08\x12\r\n\x05prove\x18\t \x01(\x08\x1a\x45\n\x10StartAtValueInfo\x12\x13\n\x0bstart_value\x18\x01 \x01(\x0c\x12\x1c\n\x14start_value_included\x18\x02 \x01(\x08\x42\x16\n\x14_start_at_value_infoB\x08\n\x06_countB\t\n\x07version\"\x88\x04\n\x1dGetContestedResourcesResponse\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0H\x00\x1a\xf3\x02\n\x1fGetContestedResourcesResponseV0\x12\x95\x01\n\x19\x63ontested_resource_values\x18\x01 \x01(\x0b\x32p.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResourceValuesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a<\n\x17\x43ontestedResourceValues\x12!\n\x19\x63ontested_resource_values\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version\"\xca\x05\n\x1cGetVotePollsByEndDateRequest\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetVotePollsByEndDateRequest.GetVotePollsByEndDateRequestV0H\x00\x1a\xb8\x04\n\x1eGetVotePollsByEndDateRequestV0\x12\x84\x01\n\x0fstart_time_info\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetVotePollsByEndDateRequest.GetVotePollsByEndDateRequestV0.StartAtTimeInfoH\x00\x88\x01\x01\x12\x80\x01\n\rend_time_info\x18\x02 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.GetVotePollsByEndDateRequest.GetVotePollsByEndDateRequestV0.EndAtTimeInfoH\x01\x88\x01\x01\x12\x12\n\x05limit\x18\x03 \x01(\rH\x02\x88\x01\x01\x12\x13\n\x06offset\x18\x04 \x01(\rH\x03\x88\x01\x01\x12\x11\n\tascending\x18\x05 \x01(\x08\x12\r\n\x05prove\x18\x06 \x01(\x08\x1a\x45\n\x0fStartAtTimeInfo\x12\x15\n\rstart_time_ms\x18\x01 \x01(\x04\x12\x1b\n\x13start_time_included\x18\x02 \x01(\x08\x1a?\n\rEndAtTimeInfo\x12\x13\n\x0b\x65nd_time_ms\x18\x01 \x01(\x04\x12\x19\n\x11\x65nd_time_included\x18\x02 \x01(\x08\x42\x12\n\x10_start_time_infoB\x10\n\x0e_end_time_infoB\x08\n\x06_limitB\t\n\x07_offsetB\t\n\x07version\"\xff\x05\n\x1dGetVotePollsByEndDateResponse\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetVotePollsByEndDateResponse.GetVotePollsByEndDateResponseV0H\x00\x1a\xea\x04\n\x1fGetVotePollsByEndDateResponseV0\x12\x9c\x01\n\x18vote_polls_by_timestamps\x18\x01 \x01(\x0b\x32x.org.dash.platform.dapi.v0.GetVotePollsByEndDateResponse.GetVotePollsByEndDateResponseV0.SerializedVotePollsByTimestampsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1aR\n\x1eSerializedVotePollsByTimestamp\x12\x11\n\ttimestamp\x18\x01 \x01(\x04\x12\x1d\n\x15serialized_vote_polls\x18\x02 \x03(\x0c\x1a\xd7\x01\n\x1fSerializedVotePollsByTimestamps\x12\x99\x01\n\x18vote_polls_by_timestamps\x18\x01 \x03(\x0b\x32w.org.dash.platform.dapi.v0.GetVotePollsByEndDateResponse.GetVotePollsByEndDateResponseV0.SerializedVotePollsByTimestamp\x12\x18\n\x10\x66inished_results\x18\x02 \x01(\x08\x42\x08\n\x06resultB\t\n\x07version\"\xff\x06\n$GetContestedResourceVoteStateRequest\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0H\x00\x1a\xd5\x05\n&GetContestedResourceVoteStateRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\x12\n\nindex_name\x18\x03 \x01(\t\x12\x14\n\x0cindex_values\x18\x04 \x03(\x0c\x12\x86\x01\n\x0bresult_type\x18\x05 \x01(\x0e\x32q.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.ResultType\x12\x36\n.allow_include_locked_and_abstaining_vote_tally\x18\x06 \x01(\x08\x12\xa3\x01\n\x18start_at_identifier_info\x18\x07 \x01(\x0b\x32|.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.StartAtIdentifierInfoH\x00\x88\x01\x01\x12\x12\n\x05\x63ount\x18\x08 \x01(\rH\x01\x88\x01\x01\x12\r\n\x05prove\x18\t \x01(\x08\x1aT\n\x15StartAtIdentifierInfo\x12\x18\n\x10start_identifier\x18\x01 \x01(\x0c\x12!\n\x19start_identifier_included\x18\x02 \x01(\x08\"I\n\nResultType\x12\r\n\tDOCUMENTS\x10\x00\x12\x0e\n\nVOTE_TALLY\x10\x01\x12\x1c\n\x18\x44OCUMENTS_AND_VOTE_TALLY\x10\x02\x42\x1b\n\x19_start_at_identifier_infoB\x08\n\x06_countB\t\n\x07version\"\x8c\x0c\n%GetContestedResourceVoteStateResponse\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0H\x00\x1a\xdf\n\n\'GetContestedResourceVoteStateResponseV0\x12\xae\x01\n\x1d\x63ontested_resource_contenders\x18\x01 \x01(\x0b\x32\x84\x01.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContendersH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\xd2\x03\n\x10\x46inishedVoteInfo\x12\xad\x01\n\x15\x66inished_vote_outcome\x18\x01 \x01(\x0e\x32\x8d\x01.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.FinishedVoteInfo.FinishedVoteOutcome\x12\x1f\n\x12won_by_identity_id\x18\x02 \x01(\x0cH\x00\x88\x01\x01\x12 \n\x18\x66inished_at_block_height\x18\x03 \x01(\x04\x12%\n\x1d\x66inished_at_core_block_height\x18\x04 \x01(\r\x12!\n\x19\x66inished_at_block_time_ms\x18\x05 \x01(\x04\x12\x19\n\x11\x66inished_at_epoch\x18\x06 \x01(\r\"O\n\x13\x46inishedVoteOutcome\x12\x14\n\x10TOWARDS_IDENTITY\x10\x00\x12\n\n\x06LOCKED\x10\x01\x12\x16\n\x12NO_PREVIOUS_WINNER\x10\x02\x42\x15\n\x13_won_by_identity_id\x1a\xc4\x03\n\x1b\x43ontestedResourceContenders\x12\x86\x01\n\ncontenders\x18\x01 \x03(\x0b\x32r.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender\x12\x1f\n\x12\x61\x62stain_vote_tally\x18\x02 \x01(\rH\x00\x88\x01\x01\x12\x1c\n\x0flock_vote_tally\x18\x03 \x01(\rH\x01\x88\x01\x01\x12\x9a\x01\n\x12\x66inished_vote_info\x18\x04 \x01(\x0b\x32y.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.FinishedVoteInfoH\x02\x88\x01\x01\x42\x15\n\x13_abstain_vote_tallyB\x12\n\x10_lock_vote_tallyB\x15\n\x13_finished_vote_info\x1ak\n\tContender\x12\x12\n\nidentifier\x18\x01 \x01(\x0c\x12\x17\n\nvote_count\x18\x02 \x01(\rH\x00\x88\x01\x01\x12\x15\n\x08\x64ocument\x18\x03 \x01(\x0cH\x01\x88\x01\x01\x42\r\n\x0b_vote_countB\x0b\n\t_documentB\x08\n\x06resultB\t\n\x07version\"\xd5\x05\n,GetContestedResourceVotersForIdentityRequest\x12\x84\x01\n\x02v0\x18\x01 \x01(\x0b\x32v.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityRequest.GetContestedResourceVotersForIdentityRequestV0H\x00\x1a\x92\x04\n.GetContestedResourceVotersForIdentityRequestV0\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\x12\n\nindex_name\x18\x03 \x01(\t\x12\x14\n\x0cindex_values\x18\x04 \x03(\x0c\x12\x15\n\rcontestant_id\x18\x05 \x01(\x0c\x12\xb4\x01\n\x18start_at_identifier_info\x18\x06 \x01(\x0b\x32\x8c\x01.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityRequest.GetContestedResourceVotersForIdentityRequestV0.StartAtIdentifierInfoH\x00\x88\x01\x01\x12\x12\n\x05\x63ount\x18\x07 \x01(\rH\x01\x88\x01\x01\x12\x17\n\x0forder_ascending\x18\x08 \x01(\x08\x12\r\n\x05prove\x18\t \x01(\x08\x1aT\n\x15StartAtIdentifierInfo\x12\x18\n\x10start_identifier\x18\x01 \x01(\x0c\x12!\n\x19start_identifier_included\x18\x02 \x01(\x08\x42\x1b\n\x19_start_at_identifier_infoB\x08\n\x06_countB\t\n\x07version\"\xf1\x04\n-GetContestedResourceVotersForIdentityResponse\x12\x86\x01\n\x02v0\x18\x01 \x01(\x0b\x32x.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityResponse.GetContestedResourceVotersForIdentityResponseV0H\x00\x1a\xab\x03\n/GetContestedResourceVotersForIdentityResponseV0\x12\xb6\x01\n\x19\x63ontested_resource_voters\x18\x01 \x01(\x0b\x32\x90\x01.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityResponse.GetContestedResourceVotersForIdentityResponseV0.ContestedResourceVotersH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x43\n\x17\x43ontestedResourceVoters\x12\x0e\n\x06voters\x18\x01 \x03(\x0c\x12\x18\n\x10\x66inished_results\x18\x02 \x01(\x08\x42\x08\n\x06resultB\t\n\x07version\"\xad\x05\n(GetContestedResourceIdentityVotesRequest\x12|\n\x02v0\x18\x01 \x01(\x0b\x32n.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesRequest.GetContestedResourceIdentityVotesRequestV0H\x00\x1a\xf7\x03\n*GetContestedResourceIdentityVotesRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12+\n\x05limit\x18\x02 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12,\n\x06offset\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\x17\n\x0forder_ascending\x18\x04 \x01(\x08\x12\xae\x01\n\x1astart_at_vote_poll_id_info\x18\x05 \x01(\x0b\x32\x84\x01.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesRequest.GetContestedResourceIdentityVotesRequestV0.StartAtVotePollIdInfoH\x00\x88\x01\x01\x12\r\n\x05prove\x18\x06 \x01(\x08\x1a\x61\n\x15StartAtVotePollIdInfo\x12 \n\x18start_at_poll_identifier\x18\x01 \x01(\x0c\x12&\n\x1estart_poll_identifier_included\x18\x02 \x01(\x08\x42\x1d\n\x1b_start_at_vote_poll_id_infoB\t\n\x07version\"\xc8\n\n)GetContestedResourceIdentityVotesResponse\x12~\n\x02v0\x18\x01 \x01(\x0b\x32p.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse.GetContestedResourceIdentityVotesResponseV0H\x00\x1a\x8f\t\n+GetContestedResourceIdentityVotesResponseV0\x12\xa1\x01\n\x05votes\x18\x01 \x01(\x0b\x32\x8f\x01.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse.GetContestedResourceIdentityVotesResponseV0.ContestedResourceIdentityVotesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\xf7\x01\n\x1e\x43ontestedResourceIdentityVotes\x12\xba\x01\n!contested_resource_identity_votes\x18\x01 \x03(\x0b\x32\x8e\x01.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse.GetContestedResourceIdentityVotesResponseV0.ContestedResourceIdentityVote\x12\x18\n\x10\x66inished_results\x18\x02 \x01(\x08\x1a\xad\x02\n\x12ResourceVoteChoice\x12\xad\x01\n\x10vote_choice_type\x18\x01 \x01(\x0e\x32\x92\x01.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse.GetContestedResourceIdentityVotesResponseV0.ResourceVoteChoice.VoteChoiceType\x12\x18\n\x0bidentity_id\x18\x02 \x01(\x0cH\x00\x88\x01\x01\"=\n\x0eVoteChoiceType\x12\x14\n\x10TOWARDS_IDENTITY\x10\x00\x12\x0b\n\x07\x41\x42STAIN\x10\x01\x12\x08\n\x04LOCK\x10\x02\x42\x0e\n\x0c_identity_id\x1a\x95\x02\n\x1d\x43ontestedResourceIdentityVote\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x1a\n\x12\x64ocument_type_name\x18\x02 \x01(\t\x12\'\n\x1fserialized_index_storage_values\x18\x03 \x03(\x0c\x12\x99\x01\n\x0bvote_choice\x18\x04 \x01(\x0b\x32\x83\x01.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse.GetContestedResourceIdentityVotesResponseV0.ResourceVoteChoiceB\x08\n\x06resultB\t\n\x07version\"\xf0\x01\n%GetPrefundedSpecializedBalanceRequest\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetPrefundedSpecializedBalanceRequest.GetPrefundedSpecializedBalanceRequestV0H\x00\x1a\x44\n\'GetPrefundedSpecializedBalanceRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xe9\x02\n&GetPrefundedSpecializedBalanceResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetPrefundedSpecializedBalanceResponse.GetPrefundedSpecializedBalanceResponseV0H\x00\x1a\xb9\x01\n(GetPrefundedSpecializedBalanceResponseV0\x12\x11\n\x07\x62\x61lance\x18\x01 \x01(\x04H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xd0\x01\n GetTotalCreditsInPlatformRequest\x12l\n\x02v0\x18\x01 \x01(\x0b\x32^.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0H\x00\x1a\x33\n\"GetTotalCreditsInPlatformRequestV0\x12\r\n\x05prove\x18\x01 \x01(\x08\x42\t\n\x07version\"\xd5\x02\n!GetTotalCreditsInPlatformResponse\x12n\n\x02v0\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0H\x00\x1a\xb4\x01\n#GetTotalCreditsInPlatformResponseV0\x12\x11\n\x07\x63redits\x18\x01 \x01(\x04H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc4\x01\n\x16GetPathElementsRequest\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetPathElementsRequest.GetPathElementsRequestV0H\x00\x1a\x45\n\x18GetPathElementsRequestV0\x12\x0c\n\x04path\x18\x01 \x03(\x0c\x12\x0c\n\x04keys\x18\x02 \x03(\x0c\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xa3\x03\n\x17GetPathElementsResponse\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetPathElementsResponse.GetPathElementsResponseV0H\x00\x1a\xa0\x02\n\x19GetPathElementsResponseV0\x12i\n\x08\x65lements\x18\x01 \x01(\x0b\x32U.org.dash.platform.dapi.v0.GetPathElementsResponse.GetPathElementsResponseV0.ElementsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1c\n\x08\x45lements\x12\x10\n\x08\x65lements\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version*Z\n\nKeyPurpose\x12\x12\n\x0e\x41UTHENTICATION\x10\x00\x12\x0e\n\nENCRYPTION\x10\x01\x12\x0e\n\nDECRYPTION\x10\x02\x12\x0c\n\x08TRANSFER\x10\x03\x12\n\n\x06VOTING\x10\x05\x32\xba\x1e\n\x08Platform\x12\x93\x01\n\x18\x62roadcastStateTransition\x12:.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest\x1a;.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse\x12l\n\x0bgetIdentity\x12-.org.dash.platform.dapi.v0.GetIdentityRequest\x1a..org.dash.platform.dapi.v0.GetIdentityResponse\x12x\n\x0fgetIdentityKeys\x12\x31.org.dash.platform.dapi.v0.GetIdentityKeysRequest\x1a\x32.org.dash.platform.dapi.v0.GetIdentityKeysResponse\x12\x96\x01\n\x19getIdentitiesContractKeys\x12;.org.dash.platform.dapi.v0.GetIdentitiesContractKeysRequest\x1a<.org.dash.platform.dapi.v0.GetIdentitiesContractKeysResponse\x12{\n\x10getIdentityNonce\x12\x32.org.dash.platform.dapi.v0.GetIdentityNonceRequest\x1a\x33.org.dash.platform.dapi.v0.GetIdentityNonceResponse\x12\x93\x01\n\x18getIdentityContractNonce\x12:.org.dash.platform.dapi.v0.GetIdentityContractNonceRequest\x1a;.org.dash.platform.dapi.v0.GetIdentityContractNonceResponse\x12\x81\x01\n\x12getIdentityBalance\x12\x34.org.dash.platform.dapi.v0.GetIdentityBalanceRequest\x1a\x35.org.dash.platform.dapi.v0.GetIdentityBalanceResponse\x12\xa2\x01\n\x1dgetIdentityBalanceAndRevision\x12?.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest\x1a@.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse\x12\x66\n\tgetProofs\x12+.org.dash.platform.dapi.v0.GetProofsRequest\x1a,.org.dash.platform.dapi.v0.GetProofsResponse\x12x\n\x0fgetDataContract\x12\x31.org.dash.platform.dapi.v0.GetDataContractRequest\x1a\x32.org.dash.platform.dapi.v0.GetDataContractResponse\x12\x8d\x01\n\x16getDataContractHistory\x12\x38.org.dash.platform.dapi.v0.GetDataContractHistoryRequest\x1a\x39.org.dash.platform.dapi.v0.GetDataContractHistoryResponse\x12{\n\x10getDataContracts\x12\x32.org.dash.platform.dapi.v0.GetDataContractsRequest\x1a\x33.org.dash.platform.dapi.v0.GetDataContractsResponse\x12o\n\x0cgetDocuments\x12..org.dash.platform.dapi.v0.GetDocumentsRequest\x1a/.org.dash.platform.dapi.v0.GetDocumentsResponse\x12\x99\x01\n\x1agetIdentityByPublicKeyHash\x12<.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest\x1a=.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse\x12\x9f\x01\n\x1cwaitForStateTransitionResult\x12>.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest\x1a?.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse\x12\x81\x01\n\x12getConsensusParams\x12\x34.org.dash.platform.dapi.v0.GetConsensusParamsRequest\x1a\x35.org.dash.platform.dapi.v0.GetConsensusParamsResponse\x12\xa5\x01\n\x1egetProtocolVersionUpgradeState\x12@.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest\x1a\x41.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse\x12\xb4\x01\n#getProtocolVersionUpgradeVoteStatus\x12\x45.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest\x1a\x46.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse\x12r\n\rgetEpochsInfo\x12/.org.dash.platform.dapi.v0.GetEpochsInfoRequest\x1a\x30.org.dash.platform.dapi.v0.GetEpochsInfoResponse\x12\x8a\x01\n\x15getContestedResources\x12\x37.org.dash.platform.dapi.v0.GetContestedResourcesRequest\x1a\x38.org.dash.platform.dapi.v0.GetContestedResourcesResponse\x12\xa2\x01\n\x1dgetContestedResourceVoteState\x12?.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest\x1a@.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse\x12\xba\x01\n%getContestedResourceVotersForIdentity\x12G.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityRequest\x1aH.org.dash.platform.dapi.v0.GetContestedResourceVotersForIdentityResponse\x12\xae\x01\n!getContestedResourceIdentityVotes\x12\x43.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesRequest\x1a\x44.org.dash.platform.dapi.v0.GetContestedResourceIdentityVotesResponse\x12\x8a\x01\n\x15getVotePollsByEndDate\x12\x37.org.dash.platform.dapi.v0.GetVotePollsByEndDateRequest\x1a\x38.org.dash.platform.dapi.v0.GetVotePollsByEndDateResponse\x12\xa5\x01\n\x1egetPrefundedSpecializedBalance\x12@.org.dash.platform.dapi.v0.GetPrefundedSpecializedBalanceRequest\x1a\x41.org.dash.platform.dapi.v0.GetPrefundedSpecializedBalanceResponse\x12\x96\x01\n\x19getTotalCreditsInPlatform\x12;.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest\x1a<.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse\x12x\n\x0fgetPathElements\x12\x31.org.dash.platform.dapi.v0.GetPathElementsRequest\x1a\x32.org.dash.platform.dapi.v0.GetPathElementsResponseb\x06proto3' , dependencies=[google_dot_protobuf_dot_wrappers__pb2.DESCRIPTOR,google_dot_protobuf_dot_struct__pb2.DESCRIPTOR,google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,]) @@ -62,8 +62,8 @@ ], containing_type=None, serialized_options=None, - serialized_start=25559, - serialized_end=25649, + serialized_start=26114, + serialized_end=26204, ) _sym_db.RegisterEnumDescriptor(_KEYPURPOSE) @@ -6616,6 +6616,161 @@ ) +_GETTOTALCREDITSINPLATFORMREQUEST_GETTOTALCREDITSINPLATFORMREQUESTV0 = _descriptor.Descriptor( + name='GetTotalCreditsInPlatformRequestV0', + full_name='org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='prove', full_name='org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.prove', index=0, + number=1, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=25085, + serialized_end=25136, +) + +_GETTOTALCREDITSINPLATFORMREQUEST = _descriptor.Descriptor( + name='GetTotalCreditsInPlatformRequest', + full_name='org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='v0', full_name='org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.v0', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[_GETTOTALCREDITSINPLATFORMREQUEST_GETTOTALCREDITSINPLATFORMREQUESTV0, ], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='version', full_name='org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.version', + index=0, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), + ], + serialized_start=24939, + serialized_end=25147, +) + + +_GETTOTALCREDITSINPLATFORMRESPONSE_GETTOTALCREDITSINPLATFORMRESPONSEV0 = _descriptor.Descriptor( + name='GetTotalCreditsInPlatformResponseV0', + full_name='org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='credits', full_name='org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.credits', index=0, + number=1, type=4, cpp_type=4, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='proof', full_name='org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.proof', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='metadata', full_name='org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.metadata', index=2, + number=3, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='result', full_name='org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.result', + index=0, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), + ], + serialized_start=25300, + serialized_end=25480, +) + +_GETTOTALCREDITSINPLATFORMRESPONSE = _descriptor.Descriptor( + name='GetTotalCreditsInPlatformResponse', + full_name='org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='v0', full_name='org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.v0', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[_GETTOTALCREDITSINPLATFORMRESPONSE_GETTOTALCREDITSINPLATFORMRESPONSEV0, ], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='version', full_name='org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.version', + index=0, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), + ], + serialized_start=25150, + serialized_end=25491, +) + + _GETPATHELEMENTSREQUEST_GETPATHELEMENTSREQUESTV0 = _descriptor.Descriptor( name='GetPathElementsRequestV0', full_name='org.dash.platform.dapi.v0.GetPathElementsRequest.GetPathElementsRequestV0', @@ -6657,8 +6812,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=25055, - serialized_end=25124, + serialized_start=25610, + serialized_end=25679, ) _GETPATHELEMENTSREQUEST = _descriptor.Descriptor( @@ -6693,8 +6848,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=24939, - serialized_end=25135, + serialized_start=25494, + serialized_end=25690, ) @@ -6725,8 +6880,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=25508, - serialized_end=25536, + serialized_start=26063, + serialized_end=26091, ) _GETPATHELEMENTSRESPONSE_GETPATHELEMENTSRESPONSEV0 = _descriptor.Descriptor( @@ -6775,8 +6930,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=25258, - serialized_end=25546, + serialized_start=25813, + serialized_end=26101, ) _GETPATHELEMENTSRESPONSE = _descriptor.Descriptor( @@ -6811,8 +6966,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=25138, - serialized_end=25557, + serialized_start=25693, + serialized_end=26112, ) _GETIDENTITYREQUEST_GETIDENTITYREQUESTV0.containing_type = _GETIDENTITYREQUEST @@ -7421,6 +7576,24 @@ _GETPREFUNDEDSPECIALIZEDBALANCERESPONSE.oneofs_by_name['version'].fields.append( _GETPREFUNDEDSPECIALIZEDBALANCERESPONSE.fields_by_name['v0']) _GETPREFUNDEDSPECIALIZEDBALANCERESPONSE.fields_by_name['v0'].containing_oneof = _GETPREFUNDEDSPECIALIZEDBALANCERESPONSE.oneofs_by_name['version'] +_GETTOTALCREDITSINPLATFORMREQUEST_GETTOTALCREDITSINPLATFORMREQUESTV0.containing_type = _GETTOTALCREDITSINPLATFORMREQUEST +_GETTOTALCREDITSINPLATFORMREQUEST.fields_by_name['v0'].message_type = _GETTOTALCREDITSINPLATFORMREQUEST_GETTOTALCREDITSINPLATFORMREQUESTV0 +_GETTOTALCREDITSINPLATFORMREQUEST.oneofs_by_name['version'].fields.append( + _GETTOTALCREDITSINPLATFORMREQUEST.fields_by_name['v0']) +_GETTOTALCREDITSINPLATFORMREQUEST.fields_by_name['v0'].containing_oneof = _GETTOTALCREDITSINPLATFORMREQUEST.oneofs_by_name['version'] +_GETTOTALCREDITSINPLATFORMRESPONSE_GETTOTALCREDITSINPLATFORMRESPONSEV0.fields_by_name['proof'].message_type = _PROOF +_GETTOTALCREDITSINPLATFORMRESPONSE_GETTOTALCREDITSINPLATFORMRESPONSEV0.fields_by_name['metadata'].message_type = _RESPONSEMETADATA +_GETTOTALCREDITSINPLATFORMRESPONSE_GETTOTALCREDITSINPLATFORMRESPONSEV0.containing_type = _GETTOTALCREDITSINPLATFORMRESPONSE +_GETTOTALCREDITSINPLATFORMRESPONSE_GETTOTALCREDITSINPLATFORMRESPONSEV0.oneofs_by_name['result'].fields.append( + _GETTOTALCREDITSINPLATFORMRESPONSE_GETTOTALCREDITSINPLATFORMRESPONSEV0.fields_by_name['credits']) +_GETTOTALCREDITSINPLATFORMRESPONSE_GETTOTALCREDITSINPLATFORMRESPONSEV0.fields_by_name['credits'].containing_oneof = _GETTOTALCREDITSINPLATFORMRESPONSE_GETTOTALCREDITSINPLATFORMRESPONSEV0.oneofs_by_name['result'] +_GETTOTALCREDITSINPLATFORMRESPONSE_GETTOTALCREDITSINPLATFORMRESPONSEV0.oneofs_by_name['result'].fields.append( + _GETTOTALCREDITSINPLATFORMRESPONSE_GETTOTALCREDITSINPLATFORMRESPONSEV0.fields_by_name['proof']) +_GETTOTALCREDITSINPLATFORMRESPONSE_GETTOTALCREDITSINPLATFORMRESPONSEV0.fields_by_name['proof'].containing_oneof = _GETTOTALCREDITSINPLATFORMRESPONSE_GETTOTALCREDITSINPLATFORMRESPONSEV0.oneofs_by_name['result'] +_GETTOTALCREDITSINPLATFORMRESPONSE.fields_by_name['v0'].message_type = _GETTOTALCREDITSINPLATFORMRESPONSE_GETTOTALCREDITSINPLATFORMRESPONSEV0 +_GETTOTALCREDITSINPLATFORMRESPONSE.oneofs_by_name['version'].fields.append( + _GETTOTALCREDITSINPLATFORMRESPONSE.fields_by_name['v0']) +_GETTOTALCREDITSINPLATFORMRESPONSE.fields_by_name['v0'].containing_oneof = _GETTOTALCREDITSINPLATFORMRESPONSE.oneofs_by_name['version'] _GETPATHELEMENTSREQUEST_GETPATHELEMENTSREQUESTV0.containing_type = _GETPATHELEMENTSREQUEST _GETPATHELEMENTSREQUEST.fields_by_name['v0'].message_type = _GETPATHELEMENTSREQUEST_GETPATHELEMENTSREQUESTV0 _GETPATHELEMENTSREQUEST.oneofs_by_name['version'].fields.append( @@ -7499,6 +7672,8 @@ DESCRIPTOR.message_types_by_name['GetContestedResourceIdentityVotesResponse'] = _GETCONTESTEDRESOURCEIDENTITYVOTESRESPONSE DESCRIPTOR.message_types_by_name['GetPrefundedSpecializedBalanceRequest'] = _GETPREFUNDEDSPECIALIZEDBALANCEREQUEST DESCRIPTOR.message_types_by_name['GetPrefundedSpecializedBalanceResponse'] = _GETPREFUNDEDSPECIALIZEDBALANCERESPONSE +DESCRIPTOR.message_types_by_name['GetTotalCreditsInPlatformRequest'] = _GETTOTALCREDITSINPLATFORMREQUEST +DESCRIPTOR.message_types_by_name['GetTotalCreditsInPlatformResponse'] = _GETTOTALCREDITSINPLATFORMRESPONSE DESCRIPTOR.message_types_by_name['GetPathElementsRequest'] = _GETPATHELEMENTSREQUEST DESCRIPTOR.message_types_by_name['GetPathElementsResponse'] = _GETPATHELEMENTSRESPONSE DESCRIPTOR.enum_types_by_name['KeyPurpose'] = _KEYPURPOSE @@ -8622,6 +8797,36 @@ _sym_db.RegisterMessage(GetPrefundedSpecializedBalanceResponse) _sym_db.RegisterMessage(GetPrefundedSpecializedBalanceResponse.GetPrefundedSpecializedBalanceResponseV0) +GetTotalCreditsInPlatformRequest = _reflection.GeneratedProtocolMessageType('GetTotalCreditsInPlatformRequest', (_message.Message,), { + + 'GetTotalCreditsInPlatformRequestV0' : _reflection.GeneratedProtocolMessageType('GetTotalCreditsInPlatformRequestV0', (_message.Message,), { + 'DESCRIPTOR' : _GETTOTALCREDITSINPLATFORMREQUEST_GETTOTALCREDITSINPLATFORMREQUESTV0, + '__module__' : 'platform_pb2' + # @@protoc_insertion_point(class_scope:org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0) + }) + , + 'DESCRIPTOR' : _GETTOTALCREDITSINPLATFORMREQUEST, + '__module__' : 'platform_pb2' + # @@protoc_insertion_point(class_scope:org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest) + }) +_sym_db.RegisterMessage(GetTotalCreditsInPlatformRequest) +_sym_db.RegisterMessage(GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0) + +GetTotalCreditsInPlatformResponse = _reflection.GeneratedProtocolMessageType('GetTotalCreditsInPlatformResponse', (_message.Message,), { + + 'GetTotalCreditsInPlatformResponseV0' : _reflection.GeneratedProtocolMessageType('GetTotalCreditsInPlatformResponseV0', (_message.Message,), { + 'DESCRIPTOR' : _GETTOTALCREDITSINPLATFORMRESPONSE_GETTOTALCREDITSINPLATFORMRESPONSEV0, + '__module__' : 'platform_pb2' + # @@protoc_insertion_point(class_scope:org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0) + }) + , + 'DESCRIPTOR' : _GETTOTALCREDITSINPLATFORMRESPONSE, + '__module__' : 'platform_pb2' + # @@protoc_insertion_point(class_scope:org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse) + }) +_sym_db.RegisterMessage(GetTotalCreditsInPlatformResponse) +_sym_db.RegisterMessage(GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0) + GetPathElementsRequest = _reflection.GeneratedProtocolMessageType('GetPathElementsRequest', (_message.Message,), { 'GetPathElementsRequestV0' : _reflection.GeneratedProtocolMessageType('GetPathElementsRequestV0', (_message.Message,), { @@ -8671,8 +8876,8 @@ index=0, serialized_options=None, create_key=_descriptor._internal_create_key, - serialized_start=25652, - serialized_end=29397, + serialized_start=26207, + serialized_end=30105, methods=[ _descriptor.MethodDescriptor( name='broadcastStateTransition', @@ -8924,10 +9129,20 @@ serialized_options=None, create_key=_descriptor._internal_create_key, ), + _descriptor.MethodDescriptor( + name='getTotalCreditsInPlatform', + full_name='org.dash.platform.dapi.v0.Platform.getTotalCreditsInPlatform', + index=25, + containing_service=None, + input_type=_GETTOTALCREDITSINPLATFORMREQUEST, + output_type=_GETTOTALCREDITSINPLATFORMRESPONSE, + serialized_options=None, + create_key=_descriptor._internal_create_key, + ), _descriptor.MethodDescriptor( name='getPathElements', full_name='org.dash.platform.dapi.v0.Platform.getPathElements', - index=25, + index=26, containing_service=None, input_type=_GETPATHELEMENTSREQUEST, output_type=_GETPATHELEMENTSRESPONSE, diff --git a/packages/dapi-grpc/clients/platform/v0/python/platform_pb2_grpc.py b/packages/dapi-grpc/clients/platform/v0/python/platform_pb2_grpc.py index 35666c1928..83189ff09f 100644 --- a/packages/dapi-grpc/clients/platform/v0/python/platform_pb2_grpc.py +++ b/packages/dapi-grpc/clients/platform/v0/python/platform_pb2_grpc.py @@ -139,6 +139,11 @@ def __init__(self, channel): request_serializer=platform__pb2.GetPrefundedSpecializedBalanceRequest.SerializeToString, response_deserializer=platform__pb2.GetPrefundedSpecializedBalanceResponse.FromString, ) + self.getTotalCreditsInPlatform = channel.unary_unary( + '/org.dash.platform.dapi.v0.Platform/getTotalCreditsInPlatform', + request_serializer=platform__pb2.GetTotalCreditsInPlatformRequest.SerializeToString, + response_deserializer=platform__pb2.GetTotalCreditsInPlatformResponse.FromString, + ) self.getPathElements = channel.unary_unary( '/org.dash.platform.dapi.v0.Platform/getPathElements', request_serializer=platform__pb2.GetPathElementsRequest.SerializeToString, @@ -304,6 +309,12 @@ def getPrefundedSpecializedBalance(self, request, context): context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') + def getTotalCreditsInPlatform(self, request, context): + """Missing associated documentation comment in .proto file.""" + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + def getPathElements(self, request, context): """Missing associated documentation comment in .proto file.""" context.set_code(grpc.StatusCode.UNIMPLEMENTED) @@ -438,6 +449,11 @@ def add_PlatformServicer_to_server(servicer, server): request_deserializer=platform__pb2.GetPrefundedSpecializedBalanceRequest.FromString, response_serializer=platform__pb2.GetPrefundedSpecializedBalanceResponse.SerializeToString, ), + 'getTotalCreditsInPlatform': grpc.unary_unary_rpc_method_handler( + servicer.getTotalCreditsInPlatform, + request_deserializer=platform__pb2.GetTotalCreditsInPlatformRequest.FromString, + response_serializer=platform__pb2.GetTotalCreditsInPlatformResponse.SerializeToString, + ), 'getPathElements': grpc.unary_unary_rpc_method_handler( servicer.getPathElements, request_deserializer=platform__pb2.GetPathElementsRequest.FromString, @@ -878,6 +894,23 @@ def getPrefundedSpecializedBalance(request, options, channel_credentials, insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + @staticmethod + def getTotalCreditsInPlatform(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/org.dash.platform.dapi.v0.Platform/getTotalCreditsInPlatform', + platform__pb2.GetTotalCreditsInPlatformRequest.SerializeToString, + platform__pb2.GetTotalCreditsInPlatformResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + @staticmethod def getPathElements(request, target, diff --git a/packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts b/packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts index 9614ea37c3..e4c266bee1 100644 --- a/packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts +++ b/packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts @@ -4639,6 +4639,123 @@ export namespace GetPrefundedSpecializedBalanceResponse { } } +export class GetTotalCreditsInPlatformRequest extends jspb.Message { + hasV0(): boolean; + clearV0(): void; + getV0(): GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0 | undefined; + setV0(value?: GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0): void; + + getVersionCase(): GetTotalCreditsInPlatformRequest.VersionCase; + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetTotalCreditsInPlatformRequest.AsObject; + static toObject(includeInstance: boolean, msg: GetTotalCreditsInPlatformRequest): GetTotalCreditsInPlatformRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetTotalCreditsInPlatformRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetTotalCreditsInPlatformRequest; + static deserializeBinaryFromReader(message: GetTotalCreditsInPlatformRequest, reader: jspb.BinaryReader): GetTotalCreditsInPlatformRequest; +} + +export namespace GetTotalCreditsInPlatformRequest { + export type AsObject = { + v0?: GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.AsObject, + } + + export class GetTotalCreditsInPlatformRequestV0 extends jspb.Message { + getProve(): boolean; + setProve(value: boolean): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetTotalCreditsInPlatformRequestV0.AsObject; + static toObject(includeInstance: boolean, msg: GetTotalCreditsInPlatformRequestV0): GetTotalCreditsInPlatformRequestV0.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetTotalCreditsInPlatformRequestV0, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetTotalCreditsInPlatformRequestV0; + static deserializeBinaryFromReader(message: GetTotalCreditsInPlatformRequestV0, reader: jspb.BinaryReader): GetTotalCreditsInPlatformRequestV0; + } + + export namespace GetTotalCreditsInPlatformRequestV0 { + export type AsObject = { + prove: boolean, + } + } + + export enum VersionCase { + VERSION_NOT_SET = 0, + V0 = 1, + } +} + +export class GetTotalCreditsInPlatformResponse extends jspb.Message { + hasV0(): boolean; + clearV0(): void; + getV0(): GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0 | undefined; + setV0(value?: GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0): void; + + getVersionCase(): GetTotalCreditsInPlatformResponse.VersionCase; + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetTotalCreditsInPlatformResponse.AsObject; + static toObject(includeInstance: boolean, msg: GetTotalCreditsInPlatformResponse): GetTotalCreditsInPlatformResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetTotalCreditsInPlatformResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetTotalCreditsInPlatformResponse; + static deserializeBinaryFromReader(message: GetTotalCreditsInPlatformResponse, reader: jspb.BinaryReader): GetTotalCreditsInPlatformResponse; +} + +export namespace GetTotalCreditsInPlatformResponse { + export type AsObject = { + v0?: GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.AsObject, + } + + export class GetTotalCreditsInPlatformResponseV0 extends jspb.Message { + hasCredits(): boolean; + clearCredits(): void; + getCredits(): number; + setCredits(value: number): void; + + hasProof(): boolean; + clearProof(): void; + getProof(): Proof | undefined; + setProof(value?: Proof): void; + + hasMetadata(): boolean; + clearMetadata(): void; + getMetadata(): ResponseMetadata | undefined; + setMetadata(value?: ResponseMetadata): void; + + getResultCase(): GetTotalCreditsInPlatformResponseV0.ResultCase; + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetTotalCreditsInPlatformResponseV0.AsObject; + static toObject(includeInstance: boolean, msg: GetTotalCreditsInPlatformResponseV0): GetTotalCreditsInPlatformResponseV0.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetTotalCreditsInPlatformResponseV0, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetTotalCreditsInPlatformResponseV0; + static deserializeBinaryFromReader(message: GetTotalCreditsInPlatformResponseV0, reader: jspb.BinaryReader): GetTotalCreditsInPlatformResponseV0; + } + + export namespace GetTotalCreditsInPlatformResponseV0 { + export type AsObject = { + credits: number, + proof?: Proof.AsObject, + metadata?: ResponseMetadata.AsObject, + } + + export enum ResultCase { + RESULT_NOT_SET = 0, + CREDITS = 1, + PROOF = 2, + } + } + + export enum VersionCase { + VERSION_NOT_SET = 0, + V0 = 1, + } +} + export class GetPathElementsRequest extends jspb.Message { hasV0(): boolean; clearV0(): void; diff --git a/packages/dapi-grpc/clients/platform/v0/web/platform_pb.js b/packages/dapi-grpc/clients/platform/v0/web/platform_pb.js index 8d995602b9..be474b049e 100644 --- a/packages/dapi-grpc/clients/platform/v0/web/platform_pb.js +++ b/packages/dapi-grpc/clients/platform/v0/web/platform_pb.js @@ -227,6 +227,13 @@ goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVote goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.VersionCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.VersionCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.ResultCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.VersionCase', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetVotePollsByEndDateRequest', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetVotePollsByEndDateRequest.GetVotePollsByEndDateRequestV0', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetVotePollsByEndDateRequest.GetVotePollsByEndDateRequestV0.EndAtTimeInfo', null, { proto }); @@ -3300,6 +3307,90 @@ if (goog.DEBUG && !COMPILED) { */ proto.org.dash.platform.dapi.v0.GetPrefundedSpecializedBalanceResponse.GetPrefundedSpecializedBalanceResponseV0.displayName = 'proto.org.dash.platform.dapi.v0.GetPrefundedSpecializedBalanceResponse.GetPrefundedSpecializedBalanceResponseV0'; } +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.displayName = 'proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.displayName = 'proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.displayName = 'proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.displayName = 'proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0'; +} /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -35132,6 +35223,764 @@ proto.org.dash.platform.dapi.v0.GetPrefundedSpecializedBalanceResponse.prototype +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest; + return proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.serializeBinaryToWriter + ); + } +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.toObject = function(includeInstance, msg) { + var f, obj = { + prove: jspb.Message.getBooleanFieldWithDefault(msg, 1, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0; + return proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getProve(); + if (f) { + writer.writeBool( + 1, + f + ); + } +}; + + +/** + * optional bool prove = 1; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 1, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 1, value); +}; + + +/** + * optional GetTotalCreditsInPlatformRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.GetTotalCreditsInPlatformRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest} returns this +*/ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest} returns this + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.prototype.clearV0 = function() { + return this.setV0(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformRequest.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse; + return proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.serializeBinaryToWriter + ); + } +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.oneofGroups_ = [[1,2]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + CREDITS: 1, + PROOF: 2 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.ResultCase} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.toObject = function(includeInstance, msg) { + var f, obj = { + credits: jspb.Message.getFieldWithDefault(msg, 1, 0), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0; + return proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readUint64()); + msg.setCredits(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); + break; + case 3: + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeUint64( + 1, + f + ); + } + f = message.getProof(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter + ); + } + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter + ); + } +}; + + +/** + * optional uint64 credits = 1; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.getCredits = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.setCredits = function(value) { + return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.clearCredits = function() { + return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.oneofGroups_[0], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.hasCredits = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * optional GetTotalCreditsInPlatformResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.GetTotalCreditsInPlatformResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse} returns this +*/ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse} returns this + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.prototype.clearV0 = function() { + return this.setV0(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetTotalCreditsInPlatformResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + /** * Oneof group definitions for this message. Each group defines the field * numbers belonging to that group. When of these fields' value is set, all diff --git a/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.d.ts b/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.d.ts index 09de0d560b..5b55cb4a71 100644 --- a/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.d.ts +++ b/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.d.ts @@ -229,6 +229,15 @@ type PlatformgetPrefundedSpecializedBalance = { readonly responseType: typeof platform_pb.GetPrefundedSpecializedBalanceResponse; }; +type PlatformgetTotalCreditsInPlatform = { + readonly methodName: string; + readonly service: typeof Platform; + readonly requestStream: false; + readonly responseStream: false; + readonly requestType: typeof platform_pb.GetTotalCreditsInPlatformRequest; + readonly responseType: typeof platform_pb.GetTotalCreditsInPlatformResponse; +}; + type PlatformgetPathElements = { readonly methodName: string; readonly service: typeof Platform; @@ -265,6 +274,7 @@ export class Platform { static readonly getContestedResourceIdentityVotes: PlatformgetContestedResourceIdentityVotes; static readonly getVotePollsByEndDate: PlatformgetVotePollsByEndDate; static readonly getPrefundedSpecializedBalance: PlatformgetPrefundedSpecializedBalance; + static readonly getTotalCreditsInPlatform: PlatformgetTotalCreditsInPlatform; static readonly getPathElements: PlatformgetPathElements; } @@ -525,6 +535,15 @@ export class PlatformClient { requestMessage: platform_pb.GetPrefundedSpecializedBalanceRequest, callback: (error: ServiceError|null, responseMessage: platform_pb.GetPrefundedSpecializedBalanceResponse|null) => void ): UnaryResponse; + getTotalCreditsInPlatform( + requestMessage: platform_pb.GetTotalCreditsInPlatformRequest, + metadata: grpc.Metadata, + callback: (error: ServiceError|null, responseMessage: platform_pb.GetTotalCreditsInPlatformResponse|null) => void + ): UnaryResponse; + getTotalCreditsInPlatform( + requestMessage: platform_pb.GetTotalCreditsInPlatformRequest, + callback: (error: ServiceError|null, responseMessage: platform_pb.GetTotalCreditsInPlatformResponse|null) => void + ): UnaryResponse; getPathElements( requestMessage: platform_pb.GetPathElementsRequest, metadata: grpc.Metadata, diff --git a/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.js b/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.js index c8e21b94b0..a6774546d2 100644 --- a/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.js +++ b/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.js @@ -235,6 +235,15 @@ Platform.getPrefundedSpecializedBalance = { responseType: platform_pb.GetPrefundedSpecializedBalanceResponse }; +Platform.getTotalCreditsInPlatform = { + methodName: "getTotalCreditsInPlatform", + service: Platform, + requestStream: false, + responseStream: false, + requestType: platform_pb.GetTotalCreditsInPlatformRequest, + responseType: platform_pb.GetTotalCreditsInPlatformResponse +}; + Platform.getPathElements = { methodName: "getPathElements", service: Platform, @@ -1026,6 +1035,37 @@ PlatformClient.prototype.getPrefundedSpecializedBalance = function getPrefundedS }; }; +PlatformClient.prototype.getTotalCreditsInPlatform = function getTotalCreditsInPlatform(requestMessage, metadata, callback) { + if (arguments.length === 2) { + callback = arguments[1]; + } + var client = grpc.unary(Platform.getTotalCreditsInPlatform, { + request: requestMessage, + host: this.serviceHost, + metadata: metadata, + transport: this.options.transport, + debug: this.options.debug, + onEnd: function (response) { + if (callback) { + if (response.status !== grpc.Code.OK) { + var err = new Error(response.statusMessage); + err.code = response.status; + err.metadata = response.trailers; + callback(err, null); + } else { + callback(null, response.message); + } + } + } + }); + return { + cancel: function () { + callback = null; + client.close(); + } + }; +}; + PlatformClient.prototype.getPathElements = function getPathElements(requestMessage, metadata, callback) { if (arguments.length === 2) { callback = arguments[1]; diff --git a/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/GetTotalCreditsOnPlatformResponse.js b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/GetTotalCreditsOnPlatformResponse.js new file mode 100644 index 0000000000..5f4a8f71c3 --- /dev/null +++ b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/GetTotalCreditsOnPlatformResponse.js @@ -0,0 +1,46 @@ +const AbstractResponse = require('../response/AbstractResponse'); +const InvalidResponseError = require('../response/errors/InvalidResponseError'); + +class GetTotalCreditsOnPlatformResponse extends AbstractResponse { + /** + * @param {number} totalCreditsOnPlatform + * @param {Metadata} metadata + * @param {Proof} [proof] + */ + constructor(totalCreditsOnPlatform, metadata, proof = undefined) { + super(metadata, proof); + + this.totalCreditsOnPlatform = totalCreditsOnPlatform; + } + + /** + * @returns {number} + */ + getTotalCreditsOnPlatform() { + return this.totalCreditsOnPlatform; + } + + /** + * @param proto + * @returns {GetTotalCreditsOnPlatformResponse} + */ + static createFromProto(proto) { + // eslint-disable-next-line + const totalCreditsOnPlatform = proto.getV0().getTotalCreditsOnPlatform(); + const { metadata, proof } = AbstractResponse.createMetadataAndProofFromProto( + proto, + ); + + if ((typeof totalCreditsOnPlatform === 'undefined' || totalCreditsOnPlatform === null) && !proof) { + throw new InvalidResponseError('Total Credits on Platform data is not defined'); + } + + return new GetTotalCreditsOnPlatformResponse( + totalCreditsOnPlatform, + metadata, + proof, + ); + } +} + +module.exports = GetTotalCreditsOnPlatformResponse; diff --git a/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/getTotalCreditsOnPlatformFactory.js b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/getTotalCreditsOnPlatformFactory.js new file mode 100644 index 0000000000..fdd7a00f84 --- /dev/null +++ b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/getTotalCreditsOnPlatformFactory.js @@ -0,0 +1,67 @@ +const { + v0: { + PlatformPromiseClient, + GetTotalCreditsOnPlatformRequest, + }, +} = require('@dashevo/dapi-grpc'); + +const GetTotalCreditsOnPlatformResponse = require('./GetTotalCreditsOnPlatformResponse'); +const InvalidResponseError = require('../response/errors/InvalidResponseError'); + +/** + * @param {GrpcTransport} grpcTransport + * @returns {getTotalCreditsOnPlatform} + */ +function getTotalCreditsOnPlatformFactory(grpcTransport) { + /** + * Fetch the version upgrade votes status + * @typedef {getTotalCreditsOnPlatform} + * @param {DAPIClientOptions & {prove: boolean}} [options] + * @returns {Promise} + */ + async function getTotalCreditsOnPlatform(options = {}) { + const { + GetTotalCreditsOnPlatformRequestV0, + } = GetTotalCreditsOnPlatformRequest; + + // eslint-disable-next-line max-len + const getTotalCreditsOnPlatformRequest = new GetTotalCreditsOnPlatformRequest(); + + getTotalCreditsOnPlatformRequest.setV0( + new GetTotalCreditsOnPlatformRequestV0() + .setProve(!!options.prove), + ); + + let lastError; + + // TODO: simple retry before the dapi versioning is properly implemented + for (let i = 0; i < 3; i += 1) { + try { + // eslint-disable-next-line no-await-in-loop + const getTotalCreditsOnPlatformResponse = await grpcTransport.request( + PlatformPromiseClient, + 'getTotalCreditsOnPlatform', + getTotalCreditsOnPlatformRequest, + options, + ); + + return GetTotalCreditsOnPlatformResponse + .createFromProto(getTotalCreditsOnPlatformResponse); + } catch (e) { + if (e instanceof InvalidResponseError) { + lastError = e; + } else { + throw e; + } + } + } + + // If we made it past the cycle it means that the retry didn't work, + // and we're throwing the last error encountered + throw lastError; + } + + return getTotalCreditsOnPlatform; +} + +module.exports = getTotalCreditsOnPlatformFactory; From 276e75fc0152334faf97fa318372633b88283c1e Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 4 Aug 2024 07:49:35 +0700 Subject: [PATCH 06/33] dealth with core subsidy issue --- .../mod.rs | 8 +-- .../v0/mod.rs | 19 ++---- packages/rs-dpp/src/core_subsidy/mod.rs | 24 +++++-- packages/rs-drive-abci/src/config.rs | 12 ++-- .../v0/mod.rs | 3 +- .../total_credits_in_platform/v0/mod.rs | 10 ++- packages/rs-drive-proof-verifier/src/proof.rs | 66 ++++++++++++++----- .../verify_total_credits_in_system/mod.rs | 4 +- .../verify_total_credits_in_system/v0/mod.rs | 4 +- packages/rs-sdk/src/mock/sdk.rs | 4 +- packages/rs-sdk/src/platform/delegate.rs | 5 +- .../rs-sdk/src/platform/document_query.rs | 20 ++++-- packages/rs-sdk/src/sdk.rs | 20 +++++- 13 files changed, 134 insertions(+), 65 deletions(-) diff --git a/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/mod.rs b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/mod.rs index 3aa676b633..f7106bd22d 100644 --- a/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/mod.rs +++ b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/mod.rs @@ -18,7 +18,7 @@ use platform_version::version::PlatformVersion; pub fn epoch_core_reward_credits_for_distribution( epoch_start_block_core_height: u32, next_epoch_start_block_core_height: u32, - distribution_multiplier: u16, + core_subsidy_halving_interval: u32, platform_version: &PlatformVersion, ) -> Result { match platform_version @@ -26,11 +26,11 @@ pub fn epoch_core_reward_credits_for_distribution( .methods .epoch_core_reward_credits_for_distribution { - 0 => epoch_core_reward_credits_for_distribution_v0( + 0 => Ok(epoch_core_reward_credits_for_distribution_v0( epoch_start_block_core_height, next_epoch_start_block_core_height, - distribution_multiplier, - ), + core_subsidy_halving_interval, + )), version => Err(ProtocolError::UnknownVersionMismatch { method: "epoch_core_reward_credits_for_distribution".to_string(), known_versions: vec![0], diff --git a/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs index cf74263d4f..b1ee09cfb3 100644 --- a/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs +++ b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs @@ -1,8 +1,7 @@ use crate::block::epoch::EpochIndex; use crate::fee::Credits; -use crate::core_subsidy::{CORE_GENESIS_BLOCK_SUBSIDY, CORE_SUBSIDY_HALVING_INTERVAL}; -use crate::ProtocolError; +use crate::core_subsidy::CORE_GENESIS_BLOCK_SUBSIDY; use lazy_static::lazy_static; use std::collections::HashMap; @@ -23,8 +22,8 @@ lazy_static! { pub(super) fn epoch_core_reward_credits_for_distribution_v0( epoch_start_block_core_height: u32, next_epoch_start_block_core_height: u32, - distribution_multiplier: u16, -) -> Result { + core_subsidy_halving_interval: u32, +) -> Credits { // Core is halving block rewards every year so we need to pay // core block rewards according to halving ratio for the all years during // the platform epoch payout period (unpaid epoch) @@ -32,9 +31,9 @@ pub(super) fn epoch_core_reward_credits_for_distribution_v0( // Calculate start and end years for the platform epoch payout period // according to start and end core block heights let start_core_reward_year = - (epoch_start_block_core_height / CORE_SUBSIDY_HALVING_INTERVAL) as EpochIndex; + (epoch_start_block_core_height / core_subsidy_halving_interval) as EpochIndex; let end_core_reward_year = - (next_epoch_start_block_core_height / CORE_SUBSIDY_HALVING_INTERVAL) as EpochIndex; + (next_epoch_start_block_core_height / core_subsidy_halving_interval) as EpochIndex; let mut total_core_rewards = 0; @@ -45,13 +44,13 @@ pub(super) fn epoch_core_reward_credits_for_distribution_v0( let core_reward_year_start_block = if core_reward_year == end_core_reward_year { next_epoch_start_block_core_height } else { - (core_reward_year + 1) as u32 * CORE_SUBSIDY_HALVING_INTERVAL + (core_reward_year + 1) as u32 * core_subsidy_halving_interval }; let core_reward_year_end_block = if core_reward_year == start_core_reward_year { epoch_start_block_core_height } else { - core_reward_year as u32 * CORE_SUBSIDY_HALVING_INTERVAL + core_reward_year as u32 * core_subsidy_halving_interval }; let block_count = core_reward_year_start_block - core_reward_year_end_block; @@ -67,8 +66,4 @@ pub(super) fn epoch_core_reward_credits_for_distribution_v0( } total_core_rewards - .checked_mul(distribution_multiplier as u64) - .ok_or(ProtocolError::Overflow( - "overflow in total core reward calculation", - )) } diff --git a/packages/rs-dpp/src/core_subsidy/mod.rs b/packages/rs-dpp/src/core_subsidy/mod.rs index c26e920840..0db38969cb 100644 --- a/packages/rs-dpp/src/core_subsidy/mod.rs +++ b/packages/rs-dpp/src/core_subsidy/mod.rs @@ -1,12 +1,26 @@ pub mod epoch_core_reward_credits_for_distribution; +use dashcore::Network; use crate::fee::Credits; -/// Actual number of core blocks per calendar year with DGW v3 is ~200700 (for example 449750 - 249050) -pub const CORE_SUBSIDY_HALVING_INTERVAL: u32 = 210240; - /// ORIGINAL CORE BLOCK DISTRIBUTION -/// STARTS AT 25 Dash +/// STARTS AT 5 Dash /// Take 60% for Masternodes /// Take 37.5% of that for Platform -const CORE_GENESIS_BLOCK_SUBSIDY: Credits = 585000000000; +const CORE_GENESIS_BLOCK_SUBSIDY: Credits = 117000000000; + +pub trait NetworkCoreSubsidy { + fn core_subsidy_halving_interval(&self) -> u32; +} + +impl NetworkCoreSubsidy for Network { + fn core_subsidy_halving_interval(&self) -> u32 { + match self { + Network::Dash => 210240, + Network::Testnet => 210240, + Network::Devnet => 210240, + Network::Regtest => 150, + _ => 210240, + } + } +} \ No newline at end of file diff --git a/packages/rs-drive-abci/src/config.rs b/packages/rs-drive-abci/src/config.rs index 4d0365ffda..5bf823529c 100644 --- a/packages/rs-drive-abci/src/config.rs +++ b/packages/rs-drive-abci/src/config.rs @@ -36,6 +36,7 @@ use dpp::util::deserializer::ProtocolVersion; use dpp::version::INITIAL_PROTOCOL_VERSION; use drive::config::DriveConfig; use serde::{de::DeserializeOwned, Deserialize, Serialize}; +use dpp::dashcore::Network; /// Configuration for Dash Core RPC client used in consensus logic #[derive(Clone, Debug, Serialize, Deserialize, Default)] @@ -107,17 +108,11 @@ pub struct CoreConfig { /// Core RPC config for check tx #[serde(flatten)] pub check_tx_rpc: CheckTxCoreRpcConfig, - - /// The reward multiplier of core - /// This is 1 for mainnet - /// This is often 10 for other networks - pub reward_multiplier: u16, } impl Default for CoreConfig { fn default() -> Self { Self { - reward_multiplier: 1, consensus_rpc: Default::default(), check_tx_rpc: Default::default(), } @@ -177,6 +172,8 @@ where // NOTE: in renames, we use lower_snake_case, because uppercase does not work; see // https://github.com/softprops/envy/issues/61 and https://github.com/softprops/envy/pull/69 pub struct PlatformConfig { + /// The network type + pub network: Network, /// Drive configuration #[serde(flatten)] pub drive: DriveConfig, @@ -636,6 +633,7 @@ impl Default for PlatformConfig { impl PlatformConfig { pub fn default_local() -> Self { Self { + network: Network::Regtest, validator_set: ValidatorSetConfig { quorum_type: QuorumType::LlmqTestPlatform, quorum_size: 3, @@ -677,6 +675,7 @@ impl PlatformConfig { pub fn default_testnet() -> Self { Self { + network: Network::Testnet, validator_set: ValidatorSetConfig { quorum_type: QuorumType::Llmq25_67, quorum_size: 25, @@ -718,6 +717,7 @@ impl PlatformConfig { pub fn default_mainnet() -> Self { Self { + network: Network::Dash, validator_set: ValidatorSetConfig { quorum_type: QuorumType::Llmq100_67, quorum_size: 100, diff --git a/packages/rs-drive-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations/v0/mod.rs index f0e763cc9c..49973cbd1f 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations/v0/mod.rs @@ -3,6 +3,7 @@ use crate::execution::types::proposer_payouts; use crate::platform_types::platform::Platform; use dpp::block::epoch::Epoch; use dpp::core_subsidy::epoch_core_reward_credits_for_distribution::epoch_core_reward_credits_for_distribution; +use dpp::core_subsidy::NetworkCoreSubsidy; use dpp::version::PlatformVersion; use drive::drive::credit_pools::epochs::operations_factory::EpochOperations; use drive::drive::credit_pools::operations::update_unpaid_epoch_index_operation; @@ -43,7 +44,7 @@ impl Platform { let core_block_rewards = epoch_core_reward_credits_for_distribution( unpaid_epoch.start_block_core_height, unpaid_epoch.next_epoch_start_block_core_height, - self.config.core.reward_multiplier, + self.config.network.core_subsidy_halving_interval(), platform_version, )?; diff --git a/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs b/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs index 0f40f3c4ec..7932abe9c5 100644 --- a/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs @@ -10,6 +10,7 @@ use dapi_grpc::platform::v0::get_total_credits_in_platform_response::{ use dpp::block::epoch::Epoch; use dpp::check_validation_result_with_data; use dpp::core_subsidy::epoch_core_reward_credits_for_distribution::epoch_core_reward_credits_for_distribution; +use dpp::core_subsidy::NetworkCoreSubsidy; use dpp::validation::ValidationResult; use dpp::version::PlatformVersion; use drive::drive::balances::{ @@ -109,7 +110,7 @@ impl Platform { epoch_core_reward_credits_for_distribution( start_block_core_height, platform_state.last_committed_core_height(), - self.config.core.reward_multiplier, + self.config.network.core_subsidy_halving_interval(), platform_version, )?; @@ -129,6 +130,7 @@ impl Platform { #[cfg(test)] mod tests { + use dashcore_rpc::dashcore::Network; use super::*; use crate::query::tests::setup_platform; use crate::test::helpers::fast_forward_to_block::fast_forward_to_block; @@ -250,10 +252,14 @@ mod tests { else { panic!("expected proof") }; + + let network = Network::Testnet; + + let core_subsidy_halving_interval = network.core_subsidy_halving_interval(); let (_, credits) = Drive::verify_total_credits_in_system( &proof.grovedb_proof, - 1, //todo: we need to set this based on network + core_subsidy_halving_interval, current_core_height, platform_version, ) diff --git a/packages/rs-drive-proof-verifier/src/proof.rs b/packages/rs-drive-proof-verifier/src/proof.rs index 0cb276f4f0..d484b94cf5 100644 --- a/packages/rs-drive-proof-verifier/src/proof.rs +++ b/packages/rs-drive-proof-verifier/src/proof.rs @@ -28,7 +28,7 @@ use dpp::block::block_info::BlockInfo; use dpp::block::epoch::{EpochIndex, MAX_EPOCH}; use dpp::block::extended_epoch_info::ExtendedEpochInfo; use dpp::dashcore::hashes::Hash; -use dpp::dashcore::ProTxHash; +use dpp::dashcore::{Network, ProTxHash}; use dpp::document::{Document, DocumentV0Getters}; use dpp::identity::identities_contract_keys::IdentitiesContractKeys; use dpp::identity::Purpose; @@ -52,6 +52,7 @@ use drive::query::{DriveDocumentQuery, VotePollsByEndDateDriveQuery}; use std::array::TryFromSliceError; use std::collections::BTreeMap; use std::num::TryFromIntError; +use dpp::core_subsidy::NetworkCoreSubsidy; /// Parse and verify the received proof and retrieve the requested object, if any. /// @@ -78,6 +79,7 @@ pub trait FromProof { /// /// * `request`: The request sent to the server. /// * `response`: The response received from the server. + /// * `network`: The network we are using, Mainnet/Testnet/Devnet or Regtest /// * `platform_version`: The platform version that should be used. /// * `provider`: A callback implementing [ContextProvider] that provides quorum details required to verify the proof. /// @@ -90,13 +92,14 @@ pub trait FromProof { fn maybe_from_proof<'a, I: Into, O: Into>( request: I, response: O, + network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result, Error> where Self: Sized + 'a, { - Self::maybe_from_proof_with_metadata(request, response, platform_version, provider) + Self::maybe_from_proof_with_metadata(request, response, network, platform_version, provider) .map(|maybe_result| maybe_result.0) } @@ -106,6 +109,7 @@ pub trait FromProof { /// /// * `request`: The request sent to the server. /// * `response`: The response received from the server. + /// * `network`: The network we are using, Mainnet/Testnet/Devnet or Regtest /// * `platform_version`: The platform version that should be used. /// * `provider`: A callback implementing [ContextProvider] that provides quorum details required to verify the proof. /// @@ -118,6 +122,7 @@ pub trait FromProof { fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> @@ -135,6 +140,7 @@ pub trait FromProof { /// /// * `request`: The request sent to the server. /// * `response`: The response received from the server. + /// * `network`: The network we are using, Mainnet/Testnet/Devnet or Regtest /// * `platform_version`: The platform version that should be used. /// * `provider`: A callback implementing [ContextProvider] that provides quorum details required to verify the proof. /// @@ -146,13 +152,14 @@ pub trait FromProof { fn from_proof<'a, I: Into, O: Into>( request: I, response: O, + network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result where Self: Sized + 'a, { - Self::maybe_from_proof(request, response, platform_version, provider)? + Self::maybe_from_proof(request, response, network, platform_version, provider)? .ok_or(Error::NotFound) } @@ -167,6 +174,7 @@ pub trait FromProof { /// /// * `request`: The request sent to the server. /// * `response`: The response received from the server. + /// * `network`: The network we are using, Mainnet/Testnet/Devnet or Regtest /// * `platform_version`: The platform version that should be used. /// * `provider`: A callback implementing [ContextProvider] that provides quorum details required to verify the proof. /// @@ -178,6 +186,7 @@ pub trait FromProof { fn from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Self, ResponseMetadata), Error> @@ -185,7 +194,7 @@ pub trait FromProof { Self: Sized + 'a, { let (main_item, response_metadata, _) = - Self::maybe_from_proof_with_metadata(request, response, platform_version, provider)?; + Self::maybe_from_proof_with_metadata(request, response, network, platform_version, provider)?; Ok((main_item.ok_or(Error::NotFound)?, response_metadata)) } @@ -200,6 +209,7 @@ pub trait FromProof { /// /// * `request`: The request sent to the server. /// * `response`: The response received from the server. + /// * `network`: The network we are using, Mainnet/Testnet/Devnet or Regtest /// * `platform_version`: The platform version that should be used. /// * `provider`: A callback implementing [ContextProvider] that provides quorum details required to verify the proof. /// @@ -211,6 +221,7 @@ pub trait FromProof { fn from_proof_with_metadata_and_proof<'a, I: Into, O: Into>( request: I, response: O, + network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Self, ResponseMetadata, Proof), Error> @@ -218,7 +229,7 @@ pub trait FromProof { Self: Sized + 'a, { let (main_item, response_metadata, proof) = - Self::maybe_from_proof_with_metadata(request, response, platform_version, provider)?; + Self::maybe_from_proof_with_metadata(request, response, network, platform_version, provider)?; Ok((main_item.ok_or(Error::NotFound)?, response_metadata, proof)) } } @@ -230,6 +241,7 @@ impl FromProof for Identity { fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> @@ -276,8 +288,8 @@ impl FromProof for Identity { fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + _network: Network, platform_version: &PlatformVersion, - provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> where @@ -325,8 +337,8 @@ impl FromProof for IdentityPublicKeys { fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + _network: Network, platform_version: &PlatformVersion, - provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> where @@ -492,8 +504,8 @@ impl FromProof for IdentityNonceFetcher { fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + _network: Network, platform_version: &PlatformVersion, - provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> where @@ -545,8 +557,8 @@ impl FromProof for IdentityContractNo fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + _network: Network, platform_version: &PlatformVersion, - provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> where @@ -602,8 +614,8 @@ impl FromProof for IdentityBalance { fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + _network: Network, platform_version: &PlatformVersion, - provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> where @@ -648,8 +660,8 @@ impl FromProof for IdentityBalan fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + _network: Network, platform_version: &PlatformVersion, - provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> where @@ -696,8 +708,8 @@ impl FromProof for DataContract { fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + _network: Network, platform_version: &PlatformVersion, - provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> where @@ -745,8 +757,8 @@ impl FromProof for DataContracts { fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + _network: Network, platform_version: &PlatformVersion, - provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> where @@ -816,8 +828,8 @@ impl FromProof for DataContractHistory fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + _network: Network, platform_version: &PlatformVersion, - provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> where @@ -869,6 +881,7 @@ impl FromProof for StateTransitionPro fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> @@ -925,6 +938,7 @@ impl FromProof for ExtendedEpochInfo { fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> @@ -934,6 +948,7 @@ impl FromProof for ExtendedEpochInfo { let epochs = ExtendedEpochInfos::maybe_from_proof_with_metadata( request, response, + network, platform_version, provider, )?; @@ -959,6 +974,7 @@ impl FromProof for ExtendedEpochInfos { fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> @@ -1028,6 +1044,7 @@ impl FromProof for ProtocolVersionUpgrade fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( _request: I, response: O, + _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> @@ -1058,6 +1075,7 @@ impl FromProof for MasternodeProtoco fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> @@ -1128,6 +1146,7 @@ impl FromProof for Elements { fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> @@ -1169,8 +1188,8 @@ where fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + _network: Network, platform_version: &PlatformVersion, - provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> where @@ -1215,8 +1234,8 @@ impl FromProof for IdentitiesContrac fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + _network: Network, platform_version: &PlatformVersion, - provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> where @@ -1298,6 +1317,7 @@ impl FromProof for ContestedResources { fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> @@ -1339,6 +1359,7 @@ impl FromProof for Contenders { fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> @@ -1390,6 +1411,7 @@ impl FromProof for Voters { fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> @@ -1436,6 +1458,7 @@ impl FromProof for ResourceV fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> @@ -1481,6 +1504,7 @@ impl FromProof for VotePollsGroupedByTim fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> @@ -1521,6 +1545,7 @@ impl FromProof for PrefundedSpe fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + _network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> @@ -1562,6 +1587,7 @@ impl FromProof for Vote { fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), Error> @@ -1581,6 +1607,7 @@ impl FromProof for Vote { ResourceVotesByIdentity::maybe_from_proof_with_metadata( request, response, + network, platform_version, provider, )?; @@ -1616,9 +1643,10 @@ impl FromProof for TotalCreditsOnPla fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( _request: I, response: O, + network: Network, platform_version: &PlatformVersion, provider: &'a dyn ContextProvider, - ) -> Result<(Option, ResponseMetadata, Proof), Error> + ) -> Result<(Option, ResponseMetadata, Proof), Error> where Self: Sized + 'a, { @@ -1627,9 +1655,11 @@ impl FromProof for TotalCreditsOnPla let proof = response.proof().or(Err(Error::NoProofInResult))?; let mtd = response.metadata().or(Err(Error::EmptyResponseMetadata))?; + let core_subsidy_halving_interval = network.core_subsidy_halving_interval(); + let (root_hash, credits) = Drive::verify_total_credits_in_system( &proof.grovedb_proof, - 1, //todo: we need to set this based on network + core_subsidy_halving_interval, mtd.core_chain_locked_height, platform_version, ) diff --git a/packages/rs-drive/src/verify/system/verify_total_credits_in_system/mod.rs b/packages/rs-drive/src/verify/system/verify_total_credits_in_system/mod.rs index a6f18a50db..0a57d34ba3 100644 --- a/packages/rs-drive/src/verify/system/verify_total_credits_in_system/mod.rs +++ b/packages/rs-drive/src/verify/system/verify_total_credits_in_system/mod.rs @@ -31,7 +31,7 @@ impl Drive { /// - The platform version is unknown. pub fn verify_total_credits_in_system( proof: &[u8], - core_distribution_multiplier: u16, + core_subsidy_halving_interval: u32, current_core_height: CoreBlockHeight, platform_version: &PlatformVersion, ) -> Result<(RootHash, Credits), Error> { @@ -44,7 +44,7 @@ impl Drive { { 0 => Drive::verify_total_credits_in_system_v0( proof, - core_distribution_multiplier, + core_subsidy_halving_interval, current_core_height, platform_version, ), diff --git a/packages/rs-drive/src/verify/system/verify_total_credits_in_system/v0/mod.rs b/packages/rs-drive/src/verify/system/verify_total_credits_in_system/v0/mod.rs index 5a02026bec..fce4bd6d43 100644 --- a/packages/rs-drive/src/verify/system/verify_total_credits_in_system/v0/mod.rs +++ b/packages/rs-drive/src/verify/system/verify_total_credits_in_system/v0/mod.rs @@ -40,7 +40,7 @@ impl Drive { #[inline(always)] pub(crate) fn verify_total_credits_in_system_v0( proof: &[u8], - core_distribution_multiplier: u16, + core_subsidy_halving_interval: u32, current_core_height: CoreBlockHeight, platform_version: &PlatformVersion, ) -> Result<(RootHash, Credits), Error> { @@ -183,7 +183,7 @@ impl Drive { epoch_core_reward_credits_for_distribution( start_core_height, current_core_height, - core_distribution_multiplier, + core_subsidy_halving_interval, platform_version, )?; diff --git a/packages/rs-sdk/src/mock/sdk.rs b/packages/rs-sdk/src/mock/sdk.rs index cdc9d3a617..f282822e9c 100644 --- a/packages/rs-sdk/src/mock/sdk.rs +++ b/packages/rs-sdk/src/mock/sdk.rs @@ -16,7 +16,7 @@ use rs_dapi_client::{ }; use std::{collections::BTreeMap, path::PathBuf, sync::Arc}; use tokio::sync::Mutex; - +use dpp::dashcore::Network; use crate::{ platform::{types::identity::IdentityRequest, DocumentQuery, Fetch, FetchMany, Query}, Error, @@ -397,7 +397,7 @@ impl MockDashPlatformSdk { .ok_or(ContextProviderError::InvalidQuorum( "expectation not found and quorum info provider not initialized with sdk.mock().quorum_info_dir()".to_string() ))?; - O::maybe_from_proof_with_metadata(request, response, version, provider)? + O::maybe_from_proof_with_metadata(request, response, Network::Regtest, version, provider)? } }; diff --git a/packages/rs-sdk/src/platform/delegate.rs b/packages/rs-sdk/src/platform/delegate.rs index 37b5e47bc8..9b77b751e6 100644 --- a/packages/rs-sdk/src/platform/delegate.rs +++ b/packages/rs-sdk/src/platform/delegate.rs @@ -81,6 +81,7 @@ macro_rules! delegate_from_proof_variant { fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, + network: dpp::dashcore::Network, version: &dpp::version::PlatformVersion, provider: &'a dyn drive_proof_verifier::ContextProvider, ) -> Result<(Option, ResponseMetadata, dapi_grpc::platform::v0::Proof), drive_proof_verifier::Error> @@ -97,7 +98,7 @@ macro_rules! delegate_from_proof_variant { req::$variant(request) => { if let resp::$variant(response) = response { >::maybe_from_proof_with_metadata( - request, response, version, provider, + request, response, network, version, provider, ) } else { Err(drive_proof_verifier::Error::ResponseDecodeError { @@ -108,7 +109,7 @@ macro_rules! delegate_from_proof_variant { ), }) } - }, + } )* } } diff --git a/packages/rs-sdk/src/platform/document_query.rs b/packages/rs-sdk/src/platform/document_query.rs index 7beb977643..fade673466 100644 --- a/packages/rs-sdk/src/platform/document_query.rs +++ b/packages/rs-sdk/src/platform/document_query.rs @@ -19,8 +19,10 @@ use dpp::{ prelude::{DataContract, Identifier}, ProtocolError, }; +use dpp::dashcore::Network; +use dpp::version::PlatformVersion; use drive::query::{DriveDocumentQuery, InternalClauses, OrderClause, WhereClause, WhereOperator}; -use drive_proof_verifier::{types::Documents, FromProof}; +use drive_proof_verifier::{types::Documents, FromProof, ContextProvider}; use rs_dapi_client::transport::{ AppliedRequestSettings, BoxFuture, TransportClient, TransportRequest, }; @@ -160,8 +162,9 @@ impl FromProof for Document { fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, - version: &dpp::version::PlatformVersion, - provider: &'a dyn drive_proof_verifier::ContextProvider, + network: Network, + platform_version: &PlatformVersion, + provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), drive_proof_verifier::Error> where Self: Sized + 'a, @@ -170,7 +173,8 @@ impl FromProof for Document { let (documents, metadata, proof): (Option, ResponseMetadata, Proof) = >::maybe_from_proof_with_metadata( - request, response, version, provider, + request, response, + network, platform_version, provider, )?; match documents { @@ -195,8 +199,9 @@ impl FromProof for drive_proof_verifier::types::Documents { fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( request: I, response: O, - version: &dpp::version::PlatformVersion, - provider: &'a dyn drive_proof_verifier::ContextProvider, + network: Network, + platform_version: &PlatformVersion, + provider: &'a dyn ContextProvider, ) -> Result<(Option, ResponseMetadata, Proof), drive_proof_verifier::Error> where Self: Sized + 'a, @@ -212,7 +217,8 @@ impl FromProof for drive_proof_verifier::types::Documents { >::maybe_from_proof_with_metadata( drive_query, response, - version, + network, + platform_version, provider, ) } diff --git a/packages/rs-sdk/src/sdk.rs b/packages/rs-sdk/src/sdk.rs index 8d7c3abcdc..e224953cc2 100644 --- a/packages/rs-sdk/src/sdk.rs +++ b/packages/rs-sdk/src/sdk.rs @@ -39,6 +39,7 @@ use std::time::{SystemTime, UNIX_EPOCH}; #[cfg(feature = "mocks")] use tokio::sync::{Mutex, MutexGuard}; use tokio_util::sync::{CancellationToken, WaitForCancellationFuture}; +use dpp::dashcore::Network; /// How many data contracts fit in the cache. pub const DEFAULT_CONTRACT_CACHE_SIZE: usize = 100; @@ -80,6 +81,8 @@ pub type LastQueryTimestamp = u64; /// See tests/ for examples of using the SDK. #[derive(Clone)] pub struct Sdk { + /// The network that the sdk is configured for (Dash (mainnet), Testnet, Devnet, Regtest) + pub network: Network, inner: SdkInstance, /// Use proofs when retrieving data from Platform. /// @@ -206,7 +209,7 @@ impl Sdk { match self.inner { SdkInstance::Dapi { .. } => { - O::maybe_from_proof_with_metadata(request, response, self.version(), &provider) + O::maybe_from_proof_with_metadata(request, response, self.network, self.version(), &provider) .map(|(a, b, _)| (a, b)) } #[cfg(feature = "mocks")] @@ -242,7 +245,7 @@ impl Sdk { match self.inner { SdkInstance::Dapi { .. } => { - O::maybe_from_proof_with_metadata(request, response, self.version(), &provider) + O::maybe_from_proof_with_metadata(request, response, self.network, self.version(), &provider) } #[cfg(feature = "mocks")] SdkInstance::Mock { ref mock, .. } => { @@ -545,6 +548,8 @@ pub struct SdkBuilder { /// If `None`, a mock client will be created. addresses: Option, settings: RequestSettings, + + network: Network, core_ip: String, core_port: u16, @@ -582,6 +587,7 @@ impl Default for SdkBuilder { Self { addresses: None, settings: RequestSettings::default(), + network: Network::Dash, core_ip: "".to_string(), core_port: 0, core_password: "".to_string(), @@ -643,6 +649,14 @@ impl SdkBuilder { ) } + /// Configure network type. + /// + /// Defaults to Network::Dash which is mainnet. + pub fn with_network(mut self, network: Network) -> Self { + self.network = network; + self + } + /// Configure request settings. /// /// Tune request settings used to connect to the Dash Platform. @@ -741,6 +755,7 @@ impl SdkBuilder { #[allow(unused_mut)] // needs to be mutable for #[cfg(feature = "mocks")] let mut sdk= Sdk{ + network: self.network, inner:SdkInstance::Dapi { dapi, version:self.version }, proofs:self.proofs, context_provider: self.context_provider.map(Arc::new), @@ -787,6 +802,7 @@ impl SdkBuilder { let context_provider = self.context_provider.unwrap_or(Box::new(MockContextProvider::new())); Sdk { + network: self.network, inner:SdkInstance::Mock { mock:Arc::new(Mutex::new( MockDashPlatformSdk::new(self.version, Arc::clone(&dapi), self.proofs))), dapi, From c16685e4f8936b3f7bbd8f66461fd99f943ac3fd Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 4 Aug 2024 07:49:48 +0700 Subject: [PATCH 07/33] fmt --- packages/rs-dpp/src/core_subsidy/mod.rs | 4 +-- packages/rs-drive-abci/src/config.rs | 2 +- .../total_credits_in_platform/v0/mod.rs | 4 +-- packages/rs-drive-proof-verifier/src/proof.rs | 20 ++++++++++---- packages/rs-sdk/src/mock/sdk.rs | 18 ++++++++----- .../rs-sdk/src/platform/document_query.rs | 13 ++++++---- packages/rs-sdk/src/sdk.rs | 26 ++++++++++++------- 7 files changed, 57 insertions(+), 30 deletions(-) diff --git a/packages/rs-dpp/src/core_subsidy/mod.rs b/packages/rs-dpp/src/core_subsidy/mod.rs index 0db38969cb..ad8a56fc84 100644 --- a/packages/rs-dpp/src/core_subsidy/mod.rs +++ b/packages/rs-dpp/src/core_subsidy/mod.rs @@ -1,7 +1,7 @@ pub mod epoch_core_reward_credits_for_distribution; -use dashcore::Network; use crate::fee::Credits; +use dashcore::Network; /// ORIGINAL CORE BLOCK DISTRIBUTION /// STARTS AT 5 Dash @@ -23,4 +23,4 @@ impl NetworkCoreSubsidy for Network { _ => 210240, } } -} \ No newline at end of file +} diff --git a/packages/rs-drive-abci/src/config.rs b/packages/rs-drive-abci/src/config.rs index 5bf823529c..56600a83c8 100644 --- a/packages/rs-drive-abci/src/config.rs +++ b/packages/rs-drive-abci/src/config.rs @@ -32,11 +32,11 @@ use std::path::PathBuf; use crate::logging::LogConfigs; use crate::{abci::config::AbciConfig, error::Error}; +use dpp::dashcore::Network; use dpp::util::deserializer::ProtocolVersion; use dpp::version::INITIAL_PROTOCOL_VERSION; use drive::config::DriveConfig; use serde::{de::DeserializeOwned, Deserialize, Serialize}; -use dpp::dashcore::Network; /// Configuration for Dash Core RPC client used in consensus logic #[derive(Clone, Debug, Serialize, Deserialize, Default)] diff --git a/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs b/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs index 7932abe9c5..8bd8ee6122 100644 --- a/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs @@ -130,10 +130,10 @@ impl Platform { #[cfg(test)] mod tests { - use dashcore_rpc::dashcore::Network; use super::*; use crate::query::tests::setup_platform; use crate::test::helpers::fast_forward_to_block::fast_forward_to_block; + use dashcore_rpc::dashcore::Network; use dpp::block::epoch::EpochIndex; use dpp::prelude::CoreBlockHeight; use drive::drive::Drive; @@ -252,7 +252,7 @@ mod tests { else { panic!("expected proof") }; - + let network = Network::Testnet; let core_subsidy_halving_interval = network.core_subsidy_halving_interval(); diff --git a/packages/rs-drive-proof-verifier/src/proof.rs b/packages/rs-drive-proof-verifier/src/proof.rs index d484b94cf5..2f071e5adf 100644 --- a/packages/rs-drive-proof-verifier/src/proof.rs +++ b/packages/rs-drive-proof-verifier/src/proof.rs @@ -27,6 +27,7 @@ use dapi_grpc::platform::{ use dpp::block::block_info::BlockInfo; use dpp::block::epoch::{EpochIndex, MAX_EPOCH}; use dpp::block::extended_epoch_info::ExtendedEpochInfo; +use dpp::core_subsidy::NetworkCoreSubsidy; use dpp::dashcore::hashes::Hash; use dpp::dashcore::{Network, ProTxHash}; use dpp::document::{Document, DocumentV0Getters}; @@ -52,7 +53,6 @@ use drive::query::{DriveDocumentQuery, VotePollsByEndDateDriveQuery}; use std::array::TryFromSliceError; use std::collections::BTreeMap; use std::num::TryFromIntError; -use dpp::core_subsidy::NetworkCoreSubsidy; /// Parse and verify the received proof and retrieve the requested object, if any. /// @@ -193,8 +193,13 @@ pub trait FromProof { where Self: Sized + 'a, { - let (main_item, response_metadata, _) = - Self::maybe_from_proof_with_metadata(request, response, network, platform_version, provider)?; + let (main_item, response_metadata, _) = Self::maybe_from_proof_with_metadata( + request, + response, + network, + platform_version, + provider, + )?; Ok((main_item.ok_or(Error::NotFound)?, response_metadata)) } @@ -228,8 +233,13 @@ pub trait FromProof { where Self: Sized + 'a, { - let (main_item, response_metadata, proof) = - Self::maybe_from_proof_with_metadata(request, response, network, platform_version, provider)?; + let (main_item, response_metadata, proof) = Self::maybe_from_proof_with_metadata( + request, + response, + network, + platform_version, + provider, + )?; Ok((main_item.ok_or(Error::NotFound)?, response_metadata, proof)) } } diff --git a/packages/rs-sdk/src/mock/sdk.rs b/packages/rs-sdk/src/mock/sdk.rs index f282822e9c..6b658abf1c 100644 --- a/packages/rs-sdk/src/mock/sdk.rs +++ b/packages/rs-sdk/src/mock/sdk.rs @@ -1,11 +1,16 @@ //! Mocking mechanisms for Dash Platform SDK. //! //! See [MockDashPlatformSdk] for more details. +use crate::{ + platform::{types::identity::IdentityRequest, DocumentQuery, Fetch, FetchMany, Query}, + Error, +}; use dapi_grpc::platform::v0::{Proof, ResponseMetadata}; use dapi_grpc::{ mock::Mockable, platform::v0::{self as proto}, }; +use dpp::dashcore::Network; use dpp::version::PlatformVersion; use drive_proof_verifier::{error::ContextProviderError, FromProof, MockContextProvider}; use rs_dapi_client::mock::MockError; @@ -16,11 +21,6 @@ use rs_dapi_client::{ }; use std::{collections::BTreeMap, path::PathBuf, sync::Arc}; use tokio::sync::Mutex; -use dpp::dashcore::Network; -use crate::{ - platform::{types::identity::IdentityRequest, DocumentQuery, Fetch, FetchMany, Query}, - Error, -}; use super::MockResponse; @@ -397,7 +397,13 @@ impl MockDashPlatformSdk { .ok_or(ContextProviderError::InvalidQuorum( "expectation not found and quorum info provider not initialized with sdk.mock().quorum_info_dir()".to_string() ))?; - O::maybe_from_proof_with_metadata(request, response, Network::Regtest, version, provider)? + O::maybe_from_proof_with_metadata( + request, + response, + Network::Regtest, + version, + provider, + )? } }; diff --git a/packages/rs-sdk/src/platform/document_query.rs b/packages/rs-sdk/src/platform/document_query.rs index fade673466..9c61f94376 100644 --- a/packages/rs-sdk/src/platform/document_query.rs +++ b/packages/rs-sdk/src/platform/document_query.rs @@ -10,6 +10,8 @@ use dapi_grpc::platform::v0::{ get_documents_request::{get_documents_request_v0::Start, GetDocumentsRequestV0}, GetDocumentsRequest, Proof, ResponseMetadata, }; +use dpp::dashcore::Network; +use dpp::version::PlatformVersion; use dpp::{ data_contract::{ accessors::v0::DataContractV0Getters, document_type::accessors::DocumentTypeV0Getters, @@ -19,10 +21,8 @@ use dpp::{ prelude::{DataContract, Identifier}, ProtocolError, }; -use dpp::dashcore::Network; -use dpp::version::PlatformVersion; use drive::query::{DriveDocumentQuery, InternalClauses, OrderClause, WhereClause, WhereOperator}; -use drive_proof_verifier::{types::Documents, FromProof, ContextProvider}; +use drive_proof_verifier::{types::Documents, ContextProvider, FromProof}; use rs_dapi_client::transport::{ AppliedRequestSettings, BoxFuture, TransportClient, TransportRequest, }; @@ -173,8 +173,11 @@ impl FromProof for Document { let (documents, metadata, proof): (Option, ResponseMetadata, Proof) = >::maybe_from_proof_with_metadata( - request, response, - network, platform_version, provider, + request, + response, + network, + platform_version, + provider, )?; match documents { diff --git a/packages/rs-sdk/src/sdk.rs b/packages/rs-sdk/src/sdk.rs index e224953cc2..79f53edb36 100644 --- a/packages/rs-sdk/src/sdk.rs +++ b/packages/rs-sdk/src/sdk.rs @@ -11,6 +11,7 @@ use dapi_grpc::mock::Mockable; use dapi_grpc::platform::v0::{Proof, ResponseMetadata}; use dpp::bincode; use dpp::bincode::error::DecodeError; +use dpp::dashcore::Network; use dpp::identity::identity_nonce::IDENTITY_NONCE_VALUE_FILTER; use dpp::prelude::IdentityNonce; use dpp::version::{PlatformVersion, PlatformVersionCurrentVersion}; @@ -39,7 +40,6 @@ use std::time::{SystemTime, UNIX_EPOCH}; #[cfg(feature = "mocks")] use tokio::sync::{Mutex, MutexGuard}; use tokio_util::sync::{CancellationToken, WaitForCancellationFuture}; -use dpp::dashcore::Network; /// How many data contracts fit in the cache. pub const DEFAULT_CONTRACT_CACHE_SIZE: usize = 100; @@ -208,10 +208,14 @@ impl Sdk { .ok_or(drive_proof_verifier::Error::ContextProviderNotSet)?; match self.inner { - SdkInstance::Dapi { .. } => { - O::maybe_from_proof_with_metadata(request, response, self.network, self.version(), &provider) - .map(|(a, b, _)| (a, b)) - } + SdkInstance::Dapi { .. } => O::maybe_from_proof_with_metadata( + request, + response, + self.network, + self.version(), + &provider, + ) + .map(|(a, b, _)| (a, b)), #[cfg(feature = "mocks")] SdkInstance::Mock { ref mock, .. } => { let guard = mock.lock().await; @@ -244,9 +248,13 @@ impl Sdk { .ok_or(drive_proof_verifier::Error::ContextProviderNotSet)?; match self.inner { - SdkInstance::Dapi { .. } => { - O::maybe_from_proof_with_metadata(request, response, self.network, self.version(), &provider) - } + SdkInstance::Dapi { .. } => O::maybe_from_proof_with_metadata( + request, + response, + self.network, + self.version(), + &provider, + ), #[cfg(feature = "mocks")] SdkInstance::Mock { ref mock, .. } => { let guard = mock.lock().await; @@ -548,7 +556,7 @@ pub struct SdkBuilder { /// If `None`, a mock client will be created. addresses: Option, settings: RequestSettings, - + network: Network, core_ip: String, From 1f10ed585f2201e4398e692acd7ce2d73bccd324 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 4 Aug 2024 10:40:23 +0700 Subject: [PATCH 08/33] fixes --- packages/rs-drive-abci/src/config.rs | 33 +++++----------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/packages/rs-drive-abci/src/config.rs b/packages/rs-drive-abci/src/config.rs index 56600a83c8..e8e111400d 100644 --- a/packages/rs-drive-abci/src/config.rs +++ b/packages/rs-drive-abci/src/config.rs @@ -1,31 +1,3 @@ -// MIT LICENSE -// -// Copyright (c) 2021 Dash Core Group -// -// Permission is hereby granted, free of charge, to any -// person obtaining a copy of this software and associated -// documentation files (the "Software"), to deal in the -// Software without restriction, including without -// limitation the rights to use, copy, modify, merge, -// publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software -// is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice -// shall be included in all copies or substantial portions -// of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF -// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - use bincode::{Decode, Encode}; use dashcore_rpc::json::QuorumType; use std::path::PathBuf; @@ -173,6 +145,7 @@ where // https://github.com/softprops/envy/issues/61 and https://github.com/softprops/envy/pull/69 pub struct PlatformConfig { /// The network type + #[serde(default = "PlatformConfig::default_network")] pub network: Network, /// Drive configuration #[serde(flatten)] @@ -581,6 +554,10 @@ impl PlatformConfig { INITIAL_PROTOCOL_VERSION } + fn default_network() -> Network { + Network::Regtest //todo: Do not leave this as regtest + } + fn default_tokio_console_address() -> String { String::from("127.0.0.1:6669") } From 461bc1b53ab90bbbac9f4e5bef68e936d2eb9bda Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 5 Aug 2024 06:45:27 +0700 Subject: [PATCH 09/33] work on subsidy --- .../v0/mod.rs | 127 ++++++++++++++++-- 1 file changed, 115 insertions(+), 12 deletions(-) diff --git a/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs index b1ee09cfb3..341050c5bb 100644 --- a/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs +++ b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs @@ -10,7 +10,7 @@ lazy_static! { /// Yearly decline of production by ~7.1% per year, projected ~18M coins max by year 2050+. pub static ref CORE_HALVING_DISTRIBUTION: HashMap = { let mut distribution = CORE_GENESIS_BLOCK_SUBSIDY; - (0..100).map(|i| { + (0..200).map(|i| { let old_distribution = distribution; distribution -= distribution / 14; (i, old_distribution) @@ -20,20 +20,30 @@ lazy_static! { /// Gets the amount of core reward fees to be distributed for the Epoch. pub(super) fn epoch_core_reward_credits_for_distribution_v0( - epoch_start_block_core_height: u32, - next_epoch_start_block_core_height: u32, + from_start_block_core_height: u32, + to_end_block_core_height_included: u32, core_subsidy_halving_interval: u32, ) -> Credits { // Core is halving block rewards every year so we need to pay // core block rewards according to halving ratio for the all years during // the platform epoch payout period (unpaid epoch) + // In Core there is an off by 1 compared to what we would expect, for if the halving interval is 1000 + // We would see a new reward year on block 1001. + + let previous_from_start_block_core_height = from_start_block_core_height.saturating_sub(1); + + let previous_to_end_block_core_height = to_end_block_core_height_included.saturating_sub(1); + // Calculate start and end years for the platform epoch payout period // according to start and end core block heights + + // 1000 would be on core year 0, as we would have 1000 - 1/1000 => 0, this is correct let start_core_reward_year = - (epoch_start_block_core_height / core_subsidy_halving_interval) as EpochIndex; + (previous_from_start_block_core_height / core_subsidy_halving_interval) as EpochIndex; + // 2000 would be on core year 1, as we would have 2000 - 1/1000 => 1, this is correct let end_core_reward_year = - (next_epoch_start_block_core_height / core_subsidy_halving_interval) as EpochIndex; + (previous_to_end_block_core_height / core_subsidy_halving_interval) as EpochIndex; let mut total_core_rewards = 0; @@ -41,19 +51,23 @@ pub(super) fn epoch_core_reward_credits_for_distribution_v0( for core_reward_year in start_core_reward_year..=end_core_reward_year { // Calculate the block count per core reward year - let core_reward_year_start_block = if core_reward_year == end_core_reward_year { - next_epoch_start_block_core_height + // If we are on the end core reward year + // We use the previous_from_start_block_core_height + // For example if we are calculating 2000 to 2001 + // We should have one block on start core year and one block on end core year + let core_reward_year_start_block = if core_reward_year == start_core_reward_year { + previous_from_start_block_core_height } else { - (core_reward_year + 1) as u32 * core_subsidy_halving_interval + core_reward_year as u32 * core_subsidy_halving_interval }; - let core_reward_year_end_block = if core_reward_year == start_core_reward_year { - epoch_start_block_core_height + let core_reward_year_end_block = if core_reward_year == end_core_reward_year { + to_end_block_core_height_included } else { - core_reward_year as u32 * core_subsidy_halving_interval + (core_reward_year + 1) as u32 * core_subsidy_halving_interval }; - let block_count = core_reward_year_start_block - core_reward_year_end_block; + let block_count = core_reward_year_end_block - core_reward_year_start_block; // Fetch the core block distribution for the corresponding epoch from the distribution table // Default to 0 if the core reward year is more than 100 years in the future @@ -67,3 +81,92 @@ pub(super) fn epoch_core_reward_credits_for_distribution_v0( total_core_rewards } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_epoch_core_reward_credits_for_distribution_simple_case_at_first_core_epoch() { + let core_subsidy_halving_interval = 150; + let from_start_block_core_height = 1; + let to_end_block_core_height_included = 150; + let expected_reward = 117000000000 * 150; // Since all blocks are in the first epoch + + let result = epoch_core_reward_credits_for_distribution_v0( + from_start_block_core_height, + to_end_block_core_height_included, + core_subsidy_halving_interval, + ); + + assert_eq!(result, expected_reward); + } + + #[test] + fn test_epoch_core_reward_credits_for_distribution_simple_case_at_eighth_core_epoch() { + let core_subsidy_halving_interval = 150; + let from_start_block_core_height = 1201; + let to_end_block_core_height_included = 1350; + let expected_reward = CORE_HALVING_DISTRIBUTION[&8] * 150; // 1200 / 150 = 8 + + let result = epoch_core_reward_credits_for_distribution_v0( + from_start_block_core_height, + to_end_block_core_height_included, + core_subsidy_halving_interval, + ); + + assert_eq!(result, expected_reward); + } + + #[test] + fn test_epoch_core_reward_credits_for_distribution_across_two_epochs() { + let core_subsidy_halving_interval = 150; + let from_start_block_core_height = 149; + let to_end_block_core_height_included = 151; + let halved_subsidy = CORE_GENESIS_BLOCK_SUBSIDY - CORE_GENESIS_BLOCK_SUBSIDY / 14; + let expected_reward = (CORE_GENESIS_BLOCK_SUBSIDY * 2) + halved_subsidy; + + let result = epoch_core_reward_credits_for_distribution_v0( + from_start_block_core_height, + to_end_block_core_height_included, + core_subsidy_halving_interval, + ); + + assert_eq!(result, expected_reward); + } + + #[test] + fn test_epoch_core_reward_credits_for_distribution_across_three_epochs() { + let core_subsidy_halving_interval = 150; + let from_start_block_core_height = 149; + let to_end_block_core_height_included = 301; + let halved_subsidy = CORE_GENESIS_BLOCK_SUBSIDY - CORE_GENESIS_BLOCK_SUBSIDY / 14; + let next_halved_subsidy = halved_subsidy - halved_subsidy / 14; + let expected_reward = + (CORE_GENESIS_BLOCK_SUBSIDY * 2) + halved_subsidy * 150 + next_halved_subsidy; + + let result = epoch_core_reward_credits_for_distribution_v0( + from_start_block_core_height, + to_end_block_core_height_included, + core_subsidy_halving_interval, + ); + + assert_eq!(result, expected_reward); + } + + #[test] + fn test_epoch_core_reward_credits_for_distribution_inner_epoch() { + let core_subsidy_halving_interval = 150; + let from_start_block_core_height = 1303; + let to_end_block_core_height_included = 1305; + let expected_reward = CORE_HALVING_DISTRIBUTION[&8] * 3; // 1200 / 150 = 8 + + let result = epoch_core_reward_credits_for_distribution_v0( + from_start_block_core_height, + to_end_block_core_height_included, + core_subsidy_halving_interval, + ); + + assert_eq!(result, expected_reward); + } +} From 2ffb6d7a5a4cbac10e7655b3823ffaadfd7b5e8b Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 5 Aug 2024 06:53:08 +0700 Subject: [PATCH 10/33] more work --- packages/rs-dpp/src/core_subsidy/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rs-dpp/src/core_subsidy/mod.rs b/packages/rs-dpp/src/core_subsidy/mod.rs index ad8a56fc84..10370ae134 100644 --- a/packages/rs-dpp/src/core_subsidy/mod.rs +++ b/packages/rs-dpp/src/core_subsidy/mod.rs @@ -7,7 +7,7 @@ use dashcore::Network; /// STARTS AT 5 Dash /// Take 60% for Masternodes /// Take 37.5% of that for Platform -const CORE_GENESIS_BLOCK_SUBSIDY: Credits = 117000000000; +const CORE_GENESIS_BLOCK_SUBSIDY: Credits = 112500000000; pub trait NetworkCoreSubsidy { fn core_subsidy_halving_interval(&self) -> u32; From 7db6c309650092e2e24ea5568ee66956acd3c6ae Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 5 Aug 2024 07:59:35 +0700 Subject: [PATCH 11/33] small fix --- .../epoch_core_reward_credits_for_distribution/v0/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs index 341050c5bb..d79709d205 100644 --- a/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs +++ b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs @@ -91,7 +91,7 @@ mod tests { let core_subsidy_halving_interval = 150; let from_start_block_core_height = 1; let to_end_block_core_height_included = 150; - let expected_reward = 117000000000 * 150; // Since all blocks are in the first epoch + let expected_reward = CORE_GENESIS_BLOCK_SUBSIDY * 150; // Since all blocks are in the first epoch let result = epoch_core_reward_credits_for_distribution_v0( from_start_block_core_height, From 3c41e7e1406856f46b5d97b57ee4774b5267bd54 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Mon, 5 Aug 2024 10:43:23 +0700 Subject: [PATCH 12/33] chore: pass network option to Drive ABCI (#2037) --- packages/dashmate/docker-compose.yml | 1 + packages/rs-drive-abci/.env.local | 2 ++ packages/rs-drive-abci/.env.mainnet | 2 ++ packages/rs-drive-abci/.env.testnet | 2 ++ packages/rs-drive-abci/src/config.rs | 22 +++++++++++++++++----- 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/packages/dashmate/docker-compose.yml b/packages/dashmate/docker-compose.yml index 53a3c835b9..5088e5bd8d 100644 --- a/packages/dashmate/docker-compose.yml +++ b/packages/dashmate/docker-compose.yml @@ -80,6 +80,7 @@ services: - TOKIO_CONSOLE_RETENTION_SECS=${PLATFORM_DRIVE_ABCI_TOKIO_CONSOLE_RETENTION:?err} - GROVEDB_VISUALIZER_ENABLED=${PLATFORM_DRIVE_ABCI_GROVEDB_VISUALIZER_ENABLED:?err} - GROVEDB_VISUALIZER_ADDRESS=0.0.0.0:${PLATFORM_DRIVE_ABCI_GROVEDB_VISUALIZER_PORT:?err} + - NETWORK=${NETWORK:?err} stop_grace_period: 30s expose: - 26658 diff --git a/packages/rs-drive-abci/.env.local b/packages/rs-drive-abci/.env.local index ebfdf12149..c0e3ac3347 100644 --- a/packages/rs-drive-abci/.env.local +++ b/packages/rs-drive-abci/.env.local @@ -88,3 +88,5 @@ TOKIO_CONSOLE_RETENTION_SECS=180 GROVEDB_VISUALIZER_ENABLED=false GROVEDB_VISUALIZER_ADDRESS=127.0.0.1:8083 + +NETWORK=regtest diff --git a/packages/rs-drive-abci/.env.mainnet b/packages/rs-drive-abci/.env.mainnet index ea1b3915ae..4cf80e1820 100644 --- a/packages/rs-drive-abci/.env.mainnet +++ b/packages/rs-drive-abci/.env.mainnet @@ -88,3 +88,5 @@ TOKIO_CONSOLE_RETENTION_SECS=180 GROVEDB_VISUALIZER_ENABLED=false GROVEDB_VISUALIZER_ADDRESS=127.0.0.1:8083 + +NETWORK=mainnet diff --git a/packages/rs-drive-abci/.env.testnet b/packages/rs-drive-abci/.env.testnet index 11d9a92cdd..ed6de0a52e 100644 --- a/packages/rs-drive-abci/.env.testnet +++ b/packages/rs-drive-abci/.env.testnet @@ -88,3 +88,5 @@ TOKIO_CONSOLE_RETENTION_SECS=180 GROVEDB_VISUALIZER_ENABLED=false GROVEDB_VISUALIZER_ADDRESS=127.0.0.1:8083 + +NETWORK=testnet diff --git a/packages/rs-drive-abci/src/config.rs b/packages/rs-drive-abci/src/config.rs index e8e111400d..733efe45a2 100644 --- a/packages/rs-drive-abci/src/config.rs +++ b/packages/rs-drive-abci/src/config.rs @@ -1,14 +1,14 @@ -use bincode::{Decode, Encode}; -use dashcore_rpc::json::QuorumType; -use std::path::PathBuf; - use crate::logging::LogConfigs; use crate::{abci::config::AbciConfig, error::Error}; +use bincode::{Decode, Encode}; +use dashcore_rpc::json::QuorumType; use dpp::dashcore::Network; use dpp::util::deserializer::ProtocolVersion; use dpp::version::INITIAL_PROTOCOL_VERSION; use drive::config::DriveConfig; use serde::{de::DeserializeOwned, Deserialize, Serialize}; +use std::path::PathBuf; +use std::str::FromStr; /// Configuration for Dash Core RPC client used in consensus logic #[derive(Clone, Debug, Serialize, Deserialize, Default)] @@ -145,7 +145,10 @@ where // https://github.com/softprops/envy/issues/61 and https://github.com/softprops/envy/pull/69 pub struct PlatformConfig { /// The network type - #[serde(default = "PlatformConfig::default_network")] + #[serde( + default = "PlatformConfig::default_network", + deserialize_with = "from_str_to_network_with_aliases" + )] pub network: Network, /// Drive configuration #[serde(flatten)] @@ -224,6 +227,14 @@ pub struct PlatformConfig { pub tokio_console_retention_secs: u64, } +fn from_str_to_network_with_aliases(network_name: &str) -> Network { + match network_name { + "mainnet" => Network::Dash, + "local" => Network::Regtest, + _ => Network::from_str(network_name).expect("failed to parse network name"), + } +} + /// A config suitable for a quorum configuration pub trait QuorumLikeConfig: Sized { /// Quorum type @@ -556,6 +567,7 @@ impl PlatformConfig { fn default_network() -> Network { Network::Regtest //todo: Do not leave this as regtest + // TODO: Yes, must be mainnet } fn default_tokio_console_address() -> String { From edde35164ab6bcc0fb8d13c7b6bd98df8fe28598 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Mon, 5 Aug 2024 10:57:28 +0700 Subject: [PATCH 13/33] fix: invalid network alias deserializer --- packages/rs-drive-abci/src/config.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/rs-drive-abci/src/config.rs b/packages/rs-drive-abci/src/config.rs index 733efe45a2..79523316b0 100644 --- a/packages/rs-drive-abci/src/config.rs +++ b/packages/rs-drive-abci/src/config.rs @@ -227,11 +227,17 @@ pub struct PlatformConfig { pub tokio_console_retention_secs: u64, } -fn from_str_to_network_with_aliases(network_name: &str) -> Network { - match network_name { - "mainnet" => Network::Dash, - "local" => Network::Regtest, - _ => Network::from_str(network_name).expect("failed to parse network name"), +fn from_str_to_network_with_aliases<'de, D>(deserializer: D) -> Result +where + D: serde::Deserializer<'de>, +{ + let network_name = String::deserialize(deserializer)?; + + match network_name.as_str() { + "mainnet" => Ok(Network::Dash), + "local" => Ok(Network::Regtest), + _ => Network::from_str(network_name.as_str()) + .map_err(|e| serde::de::Error::custom(format!("can't parse network name: {e}"))), } } From 6a28efde2668a84f5e3c32014969bfbf2de8cd38 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Mon, 5 Aug 2024 12:01:34 +0700 Subject: [PATCH 14/33] chore(dashmate): set epoch time 20 mins for local --- .../dashmate/configs/defaults/getLocalConfigFactory.js | 1 + .../dashmate/configs/getConfigFileMigrationsFactory.js | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/packages/dashmate/configs/defaults/getLocalConfigFactory.js b/packages/dashmate/configs/defaults/getLocalConfigFactory.js index ebc4e014ae..42254deb5d 100644 --- a/packages/dashmate/configs/defaults/getLocalConfigFactory.js +++ b/packages/dashmate/configs/defaults/getLocalConfigFactory.js @@ -65,6 +65,7 @@ export default function getLocalConfigFactory(getBaseConfig) { }, }, abci: { + epochTime: 1200, validatorSet: { quorum: { llmqType: 106, diff --git a/packages/dashmate/configs/getConfigFileMigrationsFactory.js b/packages/dashmate/configs/getConfigFileMigrationsFactory.js index aeca8274d8..a78f61df84 100644 --- a/packages/dashmate/configs/getConfigFileMigrationsFactory.js +++ b/packages/dashmate/configs/getConfigFileMigrationsFactory.js @@ -765,6 +765,15 @@ export default function getConfigFileMigrationsFactory(homeDir, defaultConfigs) }); return configFile; }, + '1.0.3': (configFile) => { + Object.entries(configFile.configs) + .forEach(([name, options]) => { + if (name === 'local') { + options.platform.drive.abci.epochTime = 1200; + } + }); + return configFile; + }, }; } From 345d1f0e65b7b0114b5a172d3844716c395c5d09 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 5 Aug 2024 12:18:14 +0700 Subject: [PATCH 15/33] more fixes --- .../mod.rs | 14 ++++++----- packages/rs-drive-proof-verifier/src/error.rs | 4 +++ .../rs-drive-proof-verifier/src/provider.rs | 23 ++++++++++++++++- packages/rs-sdk/src/core_client.rs | 25 ++++++++++++++++--- packages/rs-sdk/src/mock/provider.rs | 6 ++++- 5 files changed, 61 insertions(+), 11 deletions(-) diff --git a/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/mod.rs b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/mod.rs index f7106bd22d..597fccf806 100644 --- a/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/mod.rs +++ b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/mod.rs @@ -9,15 +9,17 @@ use platform_version::version::PlatformVersion; /// /// # Arguments /// -/// * `epoch_start_block_core_height` - The height of the core block at the start of the epoch. -/// * `next_epoch_start_block_core_height` - The height of the core block at the start of the next epoch. +/// * `from_start_block_core_height` - The height of the core block at the start of the epoch. +/// * `to_end_block_core_height_included` - The height of the core block at the start of the next epoch. +/// * `core_subsidy_halving_interval` - The halving interval set by the Core network. +/// * `platform_version` - The platform version. /// /// # Returns /// /// * `Result` - If the operation is successful, it returns `Ok(Credits)`. If there is an error, it returns `Error`. pub fn epoch_core_reward_credits_for_distribution( - epoch_start_block_core_height: u32, - next_epoch_start_block_core_height: u32, + from_start_block_core_height: u32, + to_end_block_core_height_included: u32, core_subsidy_halving_interval: u32, platform_version: &PlatformVersion, ) -> Result { @@ -27,8 +29,8 @@ pub fn epoch_core_reward_credits_for_distribution( .epoch_core_reward_credits_for_distribution { 0 => Ok(epoch_core_reward_credits_for_distribution_v0( - epoch_start_block_core_height, - next_epoch_start_block_core_height, + from_start_block_core_height, + to_end_block_core_height_included, core_subsidy_halving_interval, )), version => Err(ProtocolError::UnknownVersionMismatch { diff --git a/packages/rs-drive-proof-verifier/src/error.rs b/packages/rs-drive-proof-verifier/src/error.rs index 7b7848f1db..02752a4b12 100644 --- a/packages/rs-drive-proof-verifier/src/error.rs +++ b/packages/rs-drive-proof-verifier/src/error.rs @@ -102,6 +102,10 @@ pub enum ContextProviderError { /// Provided quorum is invalid #[error("invalid quorum: {0}")] InvalidQuorum(String), + + /// Core Fork Error + #[error("activation fork error: {0}")] + ActivationForkError(String), } impl From for Error { diff --git a/packages/rs-drive-proof-verifier/src/provider.rs b/packages/rs-drive-proof-verifier/src/provider.rs index bc60cfed2b..ecead85994 100644 --- a/packages/rs-drive-proof-verifier/src/provider.rs +++ b/packages/rs-drive-proof-verifier/src/provider.rs @@ -1,5 +1,5 @@ use crate::error::ContextProviderError; -use dpp::prelude::{DataContract, Identifier}; +use dpp::prelude::{CoreBlockHeight, DataContract, Identifier}; use drive::{error::proof::ProofError, query::ContractLookupFn}; #[cfg(feature = "mocks")] use hex::ToHex; @@ -53,6 +53,14 @@ pub trait ContextProvider: Send + Sync { &self, id: &Identifier, ) -> Result>, ContextProviderError>; + + /// Gets the platform activation height from core. Once this has happened this can be hardcoded. + /// + /// # Returns + /// + /// * `Ok(CoreBlockHeight)`: On success, returns the platform activation height as defined by mn_rr + /// * `Err(Error)`: On failure, returns an error indicating why the operation failed. + fn get_platform_activation_height(&self) -> Result; } impl + Send + Sync> ContextProvider for C { @@ -72,6 +80,10 @@ impl + Send + Sync> ContextProvider for C { ) -> Result>, ContextProviderError> { self.as_ref().get_data_contract(id) } + + fn get_platform_activation_height(&self) -> Result { + self.as_ref().get_platform_activation_height() + } } impl<'a, T: ContextProvider + 'a> ContextProvider for std::sync::Mutex @@ -94,6 +106,11 @@ where let lock = self.lock().expect("lock poisoned"); lock.get_quorum_public_key(quorum_type, quorum_hash, core_chain_locked_height) } + + fn get_platform_activation_height(&self) -> Result { + let lock = self.lock().expect("lock poisoned"); + lock.get_platform_activation_height() + } } /// A trait that provides a function that can be used to look up a [DataContract] by its [Identifier]. @@ -226,6 +243,10 @@ impl ContextProvider for MockContextProvider { Ok(Some(Arc::new(dc))) } + + fn get_platform_activation_height(&self) -> Result { + Ok(1320) // This is the default activation height for a Regtest network + } } // the trait `std::convert::AsRef<(dyn drive_proof_verifier::ContextProvider + 'static)>` diff --git a/packages/rs-sdk/src/core_client.rs b/packages/rs-sdk/src/core_client.rs index 656fff61b1..e68bb6166d 100644 --- a/packages/rs-sdk/src/core_client.rs +++ b/packages/rs-sdk/src/core_client.rs @@ -3,6 +3,7 @@ //! TODO: This is a temporary implementation, effective until we integrate SPV //! into dash-platform-sdk. +use crate::error::Error; use dashcore_rpc::{ dashcore::{hashes::Hash, Amount, QuorumHash}, dashcore_rpc_json as json, @@ -10,11 +11,10 @@ use dashcore_rpc::{ Auth, Client, RpcApi, }; use dpp::dashcore::ProTxHash; +use dpp::prelude::CoreBlockHeight; use drive_proof_verifier::error::ContextProviderError; use std::{fmt::Debug, sync::Mutex}; -use crate::error::Error; - /// Core RPC client that can be used to retrieve quorum keys from core. /// /// Implements [`ContextProvider`] trait. @@ -120,7 +120,7 @@ impl CoreClient { let core = self.core.lock().expect("Core lock poisoned"); let quorum_info = core .get_quorum_info(json::QuorumType::from(quorum_type), &quorum_hash, None) - .map_err(|e: dashcore_rpc::Error| ContextProviderError::InvalidQuorum(e.to_string()))?; + .map_err(|e: dashcore_rpc::Error| ContextProviderError::Generic(e.to_string()))?; let key = quorum_info.quorum_public_key; let pubkey = as TryInto<[u8; 48]>>::try_into(key).map_err(|_e| { ContextProviderError::InvalidQuorum( @@ -130,6 +130,25 @@ impl CoreClient { Ok(pubkey) } + /// Retrieve platform activation height from core. + pub fn get_platform_activation_height(&self) -> Result { + let core = self.core.lock().expect("Core lock poisoned"); + + let fork_info = core + .get_blockchain_info() + .map(|blockchain_info| blockchain_info.softforks.get("mn_rr").cloned()) + .map_err(|e: dashcore_rpc::Error| ContextProviderError::Generic(e.to_string()))? + .ok_or(ContextProviderError::ActivationForkError( + "no fork info for mn_rr".to_string(), + ))?; + + fork_info + .height + .ok_or(ContextProviderError::ActivationForkError( + "unknown fork height".to_string(), + )) + } + /// Require list of validators from Core. /// /// See also [Dash Core documentation](https://docs.dash.org/projects/core/en/stable/docs/api/remote-procedure-calls-evo.html#protx-list) diff --git a/packages/rs-sdk/src/mock/provider.rs b/packages/rs-sdk/src/mock/provider.rs index 67aadfdb01..8c0297bf47 100644 --- a/packages/rs-sdk/src/mock/provider.rs +++ b/packages/rs-sdk/src/mock/provider.rs @@ -4,7 +4,7 @@ use crate::core_client::CoreClient; use crate::platform::Fetch; use crate::{Error, Sdk}; use arc_swap::ArcSwapAny; -use dpp::prelude::{DataContract, Identifier}; +use dpp::prelude::{CoreBlockHeight, DataContract, Identifier}; use drive_proof_verifier::error::ContextProviderError; use drive_proof_verifier::ContextProvider; use pollster::FutureExt; @@ -212,6 +212,10 @@ impl ContextProvider for GrpcContextProvider { Ok(data_contract.map(Arc::new)) } + + fn get_platform_activation_height(&self) -> Result { + self.core.get_platform_activation_height() + } } /// Thread-safe cache of various objects inside the SDK. From 845550ad2c5e664b10137c3b75e04fd0475cd4f6 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 5 Aug 2024 12:57:38 +0700 Subject: [PATCH 16/33] updated sdk --- .../total_credits_in_platform/v0/mod.rs | 1 + packages/rs-drive-proof-verifier/src/proof.rs | 5 + packages/rs-drive/src/error/proof.rs | 5 + .../verify_total_credits_in_system/mod.rs | 2 + .../verify_total_credits_in_system/v0/mod.rs | 107 +++++++++--------- 5 files changed, 69 insertions(+), 51 deletions(-) diff --git a/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs b/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs index 8bd8ee6122..5b53120243 100644 --- a/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs @@ -260,6 +260,7 @@ mod tests { let (_, credits) = Drive::verify_total_credits_in_system( &proof.grovedb_proof, core_subsidy_halving_interval, + || Ok(0), current_core_height, platform_version, ) diff --git a/packages/rs-drive-proof-verifier/src/proof.rs b/packages/rs-drive-proof-verifier/src/proof.rs index 2f071e5adf..141b2769c2 100644 --- a/packages/rs-drive-proof-verifier/src/proof.rs +++ b/packages/rs-drive-proof-verifier/src/proof.rs @@ -1670,6 +1670,11 @@ impl FromProof for TotalCreditsOnPla let (root_hash, credits) = Drive::verify_total_credits_in_system( &proof.grovedb_proof, core_subsidy_halving_interval, + || { + provider.get_platform_activation_height().map_err(|e| { + drive::error::Error::Proof(ProofError::MissingContextRequirement(e.to_string())) + }) + }, mtd.core_chain_locked_height, platform_version, ) diff --git a/packages/rs-drive/src/error/proof.rs b/packages/rs-drive/src/error/proof.rs index f482f95bff..504aa11f55 100644 --- a/packages/rs-drive/src/error/proof.rs +++ b/packages/rs-drive/src/error/proof.rs @@ -46,6 +46,10 @@ pub enum ProofError { #[error("the contract could not be retrieved during verification: {0}")] ErrorRetrievingContract(String), + /// We are missing a context requirement + #[error("missing context requirement error: {0}")] + MissingContextRequirement(String), + /// Incomplete proof error #[error("incomplete proof error: {0}")] IncompleteProof(&'static str), @@ -80,5 +84,6 @@ fn get_error_code(error: &ProofError) -> u32 { ProofError::UnknownContract(_) => 6009, ProofError::ErrorRetrievingContract(_) => 6010, ProofError::InvalidMetadata(_) => 6011, + ProofError::MissingContextRequirement(_) => 6012, } } diff --git a/packages/rs-drive/src/verify/system/verify_total_credits_in_system/mod.rs b/packages/rs-drive/src/verify/system/verify_total_credits_in_system/mod.rs index 0a57d34ba3..337cf53629 100644 --- a/packages/rs-drive/src/verify/system/verify_total_credits_in_system/mod.rs +++ b/packages/rs-drive/src/verify/system/verify_total_credits_in_system/mod.rs @@ -32,6 +32,7 @@ impl Drive { pub fn verify_total_credits_in_system( proof: &[u8], core_subsidy_halving_interval: u32, + request_activation_core_height: impl Fn() -> Result, current_core_height: CoreBlockHeight, platform_version: &PlatformVersion, ) -> Result<(RootHash, Credits), Error> { @@ -45,6 +46,7 @@ impl Drive { 0 => Drive::verify_total_credits_in_system_v0( proof, core_subsidy_halving_interval, + request_activation_core_height, current_core_height, platform_version, ), diff --git a/packages/rs-drive/src/verify/system/verify_total_credits_in_system/v0/mod.rs b/packages/rs-drive/src/verify/system/verify_total_credits_in_system/v0/mod.rs index fce4bd6d43..79e9c69ae1 100644 --- a/packages/rs-drive/src/verify/system/verify_total_credits_in_system/v0/mod.rs +++ b/packages/rs-drive/src/verify/system/verify_total_credits_in_system/v0/mod.rs @@ -41,6 +41,7 @@ impl Drive { pub(crate) fn verify_total_credits_in_system_v0( proof: &[u8], core_subsidy_halving_interval: u32, + request_activation_core_height: impl Fn() -> Result, current_core_height: CoreBlockHeight, platform_version: &PlatformVersion, ) -> Result<(RootHash, Credits), Error> { @@ -125,60 +126,64 @@ impl Drive { )) })?); - let epoch = Epoch::new(epoch_index).map_err(|_| { - Error::Proof(ProofError::CorruptedProof( - "Epoch index out of bounds".to_string(), - )) - })?; - - let start_core_height_query = PathQuery { - path: epoch.get_path_vec(), - query: SizedQuery { - query: Query::new_single_key(KEY_START_BLOCK_CORE_HEIGHT.to_vec()), - limit: None, - offset: None, - }, - }; - - let (_, mut proved_path_key_values) = GroveDb::verify_subset_query( - proof, - &start_core_height_query, - &platform_version.drive.grove_version, - )?; - - let Some(proved_path_key_value) = proved_path_key_values.pop() else { - return Err(Error::Proof(ProofError::IncorrectProof( - "We can not find the start core height of the unpaid epoch".to_string(), - ))); - }; - - if proved_path_key_value.0 != start_core_height_query.path { - return Err(Error::Proof(ProofError::CorruptedProof( - "The result of this proof is not what we asked for (start core height path)" - .to_string(), - ))); - } - - if proved_path_key_value.1 != KEY_START_BLOCK_CORE_HEIGHT.to_vec() { - return Err(Error::Proof(ProofError::CorruptedProof( - "The result of this proof is not what we asked for (start core height key)" - .to_string(), - ))); - } + let start_core_height = if epoch_index == 0 { + request_activation_core_height()? + } else { + let epoch = Epoch::new(epoch_index).map_err(|_| { + Error::Proof(ProofError::CorruptedProof( + "Epoch index out of bounds".to_string(), + )) + })?; + + let start_core_height_query = PathQuery { + path: epoch.get_path_vec(), + query: SizedQuery { + query: Query::new_single_key(KEY_START_BLOCK_CORE_HEIGHT.to_vec()), + limit: None, + offset: None, + }, + }; + + let (_, mut proved_path_key_values) = GroveDb::verify_subset_query( + proof, + &start_core_height_query, + &platform_version.drive.grove_version, + )?; - let Some(Element::Item(bytes, _)) = proved_path_key_value.2 else { - return Err(Error::Proof(ProofError::CorruptedProof( - "We are expecting an item for the start core height of the unpaid epoch" - .to_string(), - ))); + let Some(proved_path_key_value) = proved_path_key_values.pop() else { + return Err(Error::Proof(ProofError::IncorrectProof( + "We can not find the start core height of the unpaid epoch".to_string(), + ))); + }; + + if proved_path_key_value.0 != start_core_height_query.path { + return Err(Error::Proof(ProofError::CorruptedProof( + "The result of this proof is not what we asked for (start core height path)" + .to_string(), + ))); + } + + if proved_path_key_value.1 != KEY_START_BLOCK_CORE_HEIGHT.to_vec() { + return Err(Error::Proof(ProofError::CorruptedProof( + "The result of this proof is not what we asked for (start core height key)" + .to_string(), + ))); + } + + let Some(Element::Item(bytes, _)) = proved_path_key_value.2 else { + return Err(Error::Proof(ProofError::CorruptedProof( + "We are expecting an item for the start core height of the unpaid epoch" + .to_string(), + ))); + }; + + u32::from_be_bytes(bytes.as_slice().try_into().map_err(|_| { + Error::Proof(ProofError::CorruptedProof( + "start core height invalid length".to_string(), + )) + })?) }; - let start_core_height = u32::from_be_bytes(bytes.as_slice().try_into().map_err(|_| { - Error::Proof(ProofError::CorruptedProof( - "start core height invalid length".to_string(), - )) - })?); - let reward_credits_accumulated_during_current_epoch = epoch_core_reward_credits_for_distribution( start_core_height, From 5b5ebe8e935134ca16c9e380f851d7c3466b7824 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 5 Aug 2024 15:53:04 +0700 Subject: [PATCH 17/33] fixes --- .../v0/mod.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs index d79709d205..07789ef3fc 100644 --- a/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs +++ b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs @@ -169,4 +169,19 @@ mod tests { assert_eq!(result, expected_reward); } + + #[test] + fn test_epoch_core_reward_credits_for_distribution_long_test() { + let core_subsidy_halving_interval = 150; + let from_start_block_core_height = 1320; + let to_end_block_core_height_included = 1320; + + let result = epoch_core_reward_credits_for_distribution_v0( + from_start_block_core_height, + to_end_block_core_height_included, + core_subsidy_halving_interval, + ); + + assert_eq!(result, 22566703215); + } } From 0c709ab8fb2cbeb5a0719150d3f50fb777e3c135 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 5 Aug 2024 15:55:05 +0700 Subject: [PATCH 18/33] fixes --- .../epoch_core_reward_credits_for_distribution/v0/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs index 07789ef3fc..9b07f0c667 100644 --- a/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs +++ b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs @@ -182,6 +182,6 @@ mod tests { core_subsidy_halving_interval, ); - assert_eq!(result, 22566703215); + assert_eq!(result, 62183484655); } } From bc606d75e68257849ce35fe9ed91bb1e482e6823 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 7 Aug 2024 07:14:12 +0700 Subject: [PATCH 19/33] more work --- packages/rs-drive-abci/src/config.rs | 59 ++++++++++++++++++- .../data_contract/v0/mod.rs | 7 ++- .../data_contract_history/v0/mod.rs | 11 ++-- .../data_contracts/v0/mod.rs | 7 ++- .../src/query/document_query/v0/mod.rs | 21 +++---- .../identity_based_queries/balance/v0/mod.rs | 7 ++- .../balance_and_revision/v0/mod.rs | 7 ++- .../identities_contract_keys/v0/mod.rs | 25 ++++---- .../identity_based_queries/identity/v0/mod.rs | 7 ++- .../identity_by_public_key_hash/v0/mod.rs | 7 ++- .../identity_contract_nonce/v0/mod.rs | 17 +++--- .../identity_nonce/v0/mod.rs | 13 ++-- .../identity_based_queries/keys/v0/mod.rs | 19 +++--- packages/rs-drive-abci/src/query/mod.rs | 12 +++- .../balance/v0/mod.rs | 7 ++- .../rs-drive-abci/src/query/proofs/v0/mod.rs | 17 +++--- .../src/query/system/epoch_infos/v0/mod.rs | 5 +- .../src/query/system/path_elements/v0/mod.rs | 3 +- .../total_credits_in_platform/v0/mod.rs | 51 ++++++++++------ .../system/version_upgrade_state/v0/mod.rs | 9 +-- .../version_upgrade_vote_status/v0/mod.rs | 9 +-- .../rs-drive-abci/src/test/helpers/setup.rs | 11 +++- 22 files changed, 219 insertions(+), 112 deletions(-) diff --git a/packages/rs-drive-abci/src/config.rs b/packages/rs-drive-abci/src/config.rs index 79523316b0..9da4937e47 100644 --- a/packages/rs-drive-abci/src/config.rs +++ b/packages/rs-drive-abci/src/config.rs @@ -624,8 +624,20 @@ impl Default for PlatformConfig { } } -#[allow(missing_docs)] +/// The platform config impl PlatformConfig { + /// The default depending on the network + pub fn default_for_network(network: Network) -> Self { + match network { + Network::Dash => Self::default_mainnet(), + Network::Testnet => Self::default_testnet(), + Network::Devnet => Self::default_devnet(), + Network::Regtest => Self::default_local(), + _ => Self::default_testnet() + } + } + + /// The default local config pub fn default_local() -> Self { Self { network: Network::Regtest, @@ -668,6 +680,50 @@ impl PlatformConfig { } } + /// The default devnet config + pub fn default_devnet() -> Self { + Self { + network: Network::Regtest, + validator_set: ValidatorSetConfig { + quorum_type: QuorumType::LlmqDevnetPlatform, + quorum_size: 12, + quorum_window: 24, + quorum_active_signers: 8, + quorum_rotation: false, + }, + chain_lock: ChainLockConfig { + quorum_type: QuorumType::LlmqDevnetPlatform, + quorum_size: 12, + quorum_window: 24, + quorum_active_signers: 8, + quorum_rotation: false, + }, + instant_lock: InstantLockConfig { + quorum_type: QuorumType::LlmqDevnetDip0024, + quorum_active_signers: 4, + quorum_size: 8, + quorum_window: 48, + quorum_rotation: true, + }, + block_spacing_ms: 5000, + drive: Default::default(), + abci: Default::default(), + core: Default::default(), + execution: Default::default(), + db_path: PathBuf::from("/var/lib/dash-platform/data"), + rejections_path: Some(PathBuf::from("/var/log/dash/rejected")), + #[cfg(feature = "testing-config")] + testing_configs: PlatformTestConfig::default(), + tokio_console_enabled: false, + tokio_console_address: PlatformConfig::default_tokio_console_address(), + tokio_console_retention_secs: PlatformConfig::default_tokio_console_retention_secs(), + initial_protocol_version: Self::default_initial_protocol_version(), + prometheus_bind_address: None, + grpc_bind_address: "127.0.0.1:26670".to_string(), + } + } + + /// The default testnet config pub fn default_testnet() -> Self { Self { network: Network::Testnet, @@ -710,6 +766,7 @@ impl PlatformConfig { } } + /// The default mainnet config pub fn default_mainnet() -> Self { Self { network: Network::Dash, diff --git a/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract/v0/mod.rs b/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract/v0/mod.rs index dbc404f84f..04049a0435 100644 --- a/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract/v0/mod.rs @@ -74,12 +74,13 @@ impl Platform { #[cfg(test)] mod tests { + use dpp::dashcore::Network; use super::*; use crate::query::tests::{assert_invalid_identifier, setup_platform}; #[test] fn test_invalid_data_contract_id() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetDataContractRequestV0 { id: vec![0; 8], @@ -93,7 +94,7 @@ mod tests { #[test] fn test_data_contract_not_found() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let id = vec![0; 32]; let request = GetDataContractRequestV0 { @@ -113,7 +114,7 @@ mod tests { #[test] fn test_data_contract_absence_proof() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let id = vec![0; 32]; let request = GetDataContractRequestV0 { diff --git a/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract_history/v0/mod.rs b/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract_history/v0/mod.rs index 6e7ceb62a1..e9821fc761 100644 --- a/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract_history/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract_history/v0/mod.rs @@ -123,6 +123,7 @@ mod tests { use dpp::tests::fixtures::get_data_contract_fixture; use drive::drive::Drive; use std::sync::Arc; + use dpp::dashcore::Network; fn default_request_v0() -> GetDataContractHistoryRequestV0 { GetDataContractHistoryRequestV0 { @@ -242,7 +243,7 @@ mod tests { #[test] fn test_invalid_data_contract_id() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetDataContractHistoryRequestV0 { id: vec![0; 8], @@ -261,7 +262,7 @@ mod tests { #[test] fn test_invalid_limit_overflow() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetDataContractHistoryRequestV0 { id: vec![0; 32], @@ -283,7 +284,7 @@ mod tests { #[test] fn test_invalid_offset_overflow() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetDataContractHistoryRequestV0 { id: vec![0; 32], @@ -304,7 +305,7 @@ mod tests { #[test] fn test_data_contract_not_found() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let id = vec![0; 32]; @@ -469,7 +470,7 @@ mod tests { #[test] fn test_data_contract_history_absence_proof() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetDataContractHistoryRequestV0 { id: vec![0; 32], diff --git a/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contracts/v0/mod.rs b/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contracts/v0/mod.rs index f7ca5e71ed..f92c06e021 100644 --- a/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contracts/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contracts/v0/mod.rs @@ -86,12 +86,13 @@ impl Platform { #[cfg(test)] mod tests { + use dpp::dashcore::Network; use super::*; use crate::query::tests::{assert_invalid_identifier, setup_platform}; #[test] fn test_invalid_data_contract_id() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetDataContractsRequestV0 { ids: vec![vec![0; 8]], @@ -107,7 +108,7 @@ mod tests { #[test] fn test_data_contracts_not_found() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let id = vec![0; 32]; let request = GetDataContractsRequestV0 { @@ -130,7 +131,7 @@ mod tests { #[test] fn test_data_contracts_absence_proof() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let id = vec![0; 32]; let request = GetDataContractsRequestV0 { diff --git a/packages/rs-drive-abci/src/query/document_query/v0/mod.rs b/packages/rs-drive-abci/src/query/document_query/v0/mod.rs index 0c043af2c9..7dc8694635 100644 --- a/packages/rs-drive-abci/src/query/document_query/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/document_query/v0/mod.rs @@ -179,13 +179,14 @@ impl Platform { #[cfg(test)] mod tests { + use dpp::dashcore::Network; use super::*; use crate::query::tests::{assert_invalid_identifier, setup_platform, store_data_contract}; use dpp::tests::fixtures::get_data_contract_fixture; #[test] fn test_invalid_document_id() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetDocumentsRequestV0 { data_contract_id: vec![0; 8], @@ -206,7 +207,7 @@ mod tests { #[test] fn test_data_contract_not_found_in_documents_request() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let data_contract_id = vec![0; 32]; @@ -232,7 +233,7 @@ mod tests { #[test] fn test_absent_document_type() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let created_data_contract = get_data_contract_fixture(None, 0, version.protocol_version); store_data_contract(&platform, created_data_contract.data_contract(), version); @@ -264,7 +265,7 @@ mod tests { #[test] fn test_invalid_where_clause() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let created_data_contract = get_data_contract_fixture(None, 0, version.protocol_version); store_data_contract(&platform, created_data_contract.data_contract(), version); @@ -294,7 +295,7 @@ mod tests { #[test] fn test_invalid_order_by_clause() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let created_data_contract = get_data_contract_fixture(None, 0, version.protocol_version); store_data_contract(&platform, created_data_contract.data_contract(), version); @@ -324,7 +325,7 @@ mod tests { #[test] fn test_invalid_start_at_clause() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let created_data_contract = get_data_contract_fixture(None, 0, version.protocol_version); store_data_contract(&platform, created_data_contract.data_contract(), version); @@ -354,7 +355,7 @@ mod tests { #[test] fn test_invalid_start_after_clause() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let created_data_contract = get_data_contract_fixture(None, 0, version.protocol_version); store_data_contract(&platform, created_data_contract.data_contract(), version); @@ -384,7 +385,7 @@ mod tests { #[test] fn test_invalid_limit() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let created_data_contract = get_data_contract_fixture(None, 0, version.protocol_version); store_data_contract(&platform, created_data_contract.data_contract(), version); @@ -415,7 +416,7 @@ mod tests { #[test] fn test_documents_not_found() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let created_data_contract = get_data_contract_fixture(None, 0, version.protocol_version); store_data_contract(&platform, created_data_contract.data_contract(), version); @@ -448,7 +449,7 @@ mod tests { #[test] fn test_documents_absence_proof() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let created_data_contract = get_data_contract_fixture(None, 0, version.protocol_version); store_data_contract(&platform, created_data_contract.data_contract(), version); diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/balance/v0/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/balance/v0/mod.rs index 3abbaec601..1c6330a3c7 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/balance/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/balance/v0/mod.rs @@ -63,12 +63,13 @@ impl Platform { #[cfg(test)] mod tests { + use dpp::dashcore::Network; use super::*; use crate::query::tests::{assert_invalid_identifier, setup_platform}; #[test] fn test_invalid_identity_id() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetIdentityBalanceRequestV0 { id: vec![0; 8], @@ -84,7 +85,7 @@ mod tests { #[test] fn test_identity_not_found() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let id = vec![0; 32]; @@ -105,7 +106,7 @@ mod tests { #[test] fn test_identity_balance_absence_proof() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let id = vec![0; 32]; diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/balance_and_revision/v0/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/balance_and_revision/v0/mod.rs index 6d3bc39c68..c0e58644ce 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/balance_and_revision/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/balance_and_revision/v0/mod.rs @@ -82,12 +82,13 @@ impl Platform { #[cfg(test)] mod tests { + use dpp::dashcore::Network; use super::*; use crate::query::tests::{assert_invalid_identifier, setup_platform}; #[test] fn test_invalid_identity_id() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetIdentityBalanceAndRevisionRequestV0 { id: vec![0; 8], @@ -103,7 +104,7 @@ mod tests { #[test] fn test_identity_not_found_when_querying_balance_and_revision() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let id = vec![0; 32]; @@ -124,7 +125,7 @@ mod tests { #[test] fn test_identity_balance_and_revision_absence_proof() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let id = vec![0; 32]; diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/identities_contract_keys/v0/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/identities_contract_keys/v0/mod.rs index 8b37d35071..f58d802723 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/identities_contract_keys/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/identities_contract_keys/v0/mod.rs @@ -144,12 +144,13 @@ mod tests { use rand::{Rng, SeedableRng}; use itertools::Itertools; use dapi_grpc::platform::v0::get_identities_contract_keys_response::get_identities_contract_keys_response_v0::{IdentitiesKeys, IdentityKeys, Result}; + use dpp::dashcore::Network; use dpp::identity::identity_public_key::accessors::v0::IdentityPublicKeyGettersV0; use drive::drive::Drive; #[test] fn test_identities_contract_keys_missing_identity() { - let (platform, state, platform_version) = setup_platform(true); + let (platform, state, platform_version) = setup_platform(true, Network::Testnet); let dashpay = platform.drive.cache.system_data_contracts.load_dashpay(); @@ -179,7 +180,7 @@ mod tests { #[test] fn test_identities_contract_keys_missing_identity_proved() { - let (platform, state, platform_version) = setup_platform(true); + let (platform, state, platform_version) = setup_platform(true, Network::Testnet); let dashpay = platform.drive.cache.system_data_contracts.load_dashpay(); @@ -230,7 +231,7 @@ mod tests { #[test] fn test_identities_contract_keys_missing_identity_absent_contract() { - let (platform, state, platform_version) = setup_platform(false); + let (platform, state, platform_version) = setup_platform(false, Network::Testnet); let request = GetIdentitiesContractKeysRequestV0 { identities_ids: vec![vec![1; 32]], @@ -258,7 +259,7 @@ mod tests { #[test] fn test_identities_contract_keys_missing_identity_absent_contract_proved() { - let (platform, state, platform_version) = setup_platform(false); + let (platform, state, platform_version) = setup_platform(false, Network::Testnet); let request = GetIdentitiesContractKeysRequestV0 { identities_ids: vec![vec![1; 32]], @@ -305,7 +306,7 @@ mod tests { #[test] fn test_identities_contract_keys_with_identity_absent_contract() { - let (platform, state, platform_version) = setup_platform(false); + let (platform, state, platform_version) = setup_platform(false, Network::Testnet); let mut rng = StdRng::seed_from_u64(10); @@ -347,7 +348,7 @@ mod tests { #[test] fn test_identities_contract_keys_with_identity_absent_contract_proved() { - let (platform, state, platform_version) = setup_platform(false); + let (platform, state, platform_version) = setup_platform(false, Network::Testnet); let mut rng = StdRng::seed_from_u64(10); @@ -408,7 +409,7 @@ mod tests { #[test] fn test_identities_contract_keys_missing_identity_keys() { - let (platform, state, platform_version) = setup_platform(true); + let (platform, state, platform_version) = setup_platform(true, Network::Testnet); let dashpay = platform.drive.cache.system_data_contracts.load_dashpay(); @@ -452,7 +453,7 @@ mod tests { #[test] fn test_identities_contract_keys_missing_identity_keys_proved() { - let (platform, state, platform_version) = setup_platform(true); + let (platform, state, platform_version) = setup_platform(true, Network::Testnet); let dashpay = platform.drive.cache.system_data_contracts.load_dashpay(); @@ -515,7 +516,7 @@ mod tests { #[test] fn test_identities_contract_keys() { - let (platform, state, platform_version) = setup_platform(true); + let (platform, state, platform_version) = setup_platform(true, Network::Testnet); let dashpay = platform.drive.cache.system_data_contracts.load_dashpay(); @@ -673,7 +674,7 @@ mod tests { #[test] fn test_identities_contract_keys_proof() { - let (platform, state, platform_version) = setup_platform(true); + let (platform, state, platform_version) = setup_platform(true, Network::Testnet); let dashpay = platform.drive.cache.system_data_contracts.load_dashpay(); @@ -768,7 +769,7 @@ mod tests { #[test] fn test_multiple_identities_contract_keys() { - let (platform, state, platform_version) = setup_platform(true); + let (platform, state, platform_version) = setup_platform(true, Network::Testnet); let dashpay = platform.drive.cache.system_data_contracts.load_dashpay(); @@ -968,7 +969,7 @@ mod tests { #[test] fn test_multiple_identities_contract_keys_proof() { - let (platform, state, platform_version) = setup_platform(true); + let (platform, state, platform_version) = setup_platform(true, Network::Testnet); let dashpay = platform.drive.cache.system_data_contracts.load_dashpay(); diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/identity/v0/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/identity/v0/mod.rs index fa1b9002bc..b3a9d32150 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/identity/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/identity/v0/mod.rs @@ -69,12 +69,13 @@ impl Platform { #[cfg(test)] mod tests { + use dpp::dashcore::Network; use super::*; use crate::query::tests::{assert_invalid_identifier, setup_platform}; #[test] fn test_invalid_identity_id() { - let (platform, state, _unused_version) = setup_platform(false); + let (platform, state, _unused_version) = setup_platform(false, Network::Testnet); let version = PlatformVersion::latest(); @@ -92,7 +93,7 @@ mod tests { #[test] fn test_identity_not_found() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let id = vec![0; 32]; let request = GetIdentityRequestV0 { @@ -114,7 +115,7 @@ mod tests { #[test] fn test_identity_absence_proof() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let id = vec![0; 32]; let request = GetIdentityRequestV0 { diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_public_key_hash/v0/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_public_key_hash/v0/mod.rs index 38e4b50a91..efa283ffdd 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_public_key_hash/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_public_key_hash/v0/mod.rs @@ -77,12 +77,13 @@ impl Platform { #[cfg(test)] mod tests { + use dpp::dashcore::Network; use super::*; use crate::query::tests::setup_platform; #[test] fn test_invalid_public_key_hash() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetIdentityByPublicKeyHashRequestV0 { public_key_hash: vec![0; 8], @@ -101,7 +102,7 @@ mod tests { #[test] fn test_identity_not_found() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let public_key_hash = vec![0; 20]; let request = GetIdentityByPublicKeyHashRequestV0 { @@ -121,7 +122,7 @@ mod tests { #[test] fn test_identity_absence_proof() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let public_key_hash = vec![0; 20]; let request = GetIdentityByPublicKeyHashRequestV0 { diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/identity_contract_nonce/v0/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/identity_contract_nonce/v0/mod.rs index ba4e81643c..b23249d430 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/identity_contract_nonce/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/identity_contract_nonce/v0/mod.rs @@ -88,10 +88,11 @@ mod tests { use drive::util::test_helpers::test_utils::identities::create_test_identity_with_rng; use rand::rngs::StdRng; use rand::{Rng, SeedableRng}; + use dpp::dashcore::Network; #[test] fn test_invalid_identity_id() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetIdentityContractNonceRequestV0 { identity_id: vec![0; 8], @@ -110,7 +111,7 @@ mod tests { #[test] fn test_invalid_contract_id() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetIdentityContractNonceRequestV0 { identity_id: vec![0; 32], @@ -129,7 +130,7 @@ mod tests { #[test] fn test_identity_not_found_when_querying_identity_nonce() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetIdentityContractNonceRequestV0 { identity_id: vec![0; 32], @@ -156,7 +157,7 @@ mod tests { #[test] fn test_contract_info_not_found_when_querying_identity_nonce_with_known_identity() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let mut rng = StdRng::seed_from_u64(45); let id = rng.gen::<[u8; 32]>(); let _unused_identity = @@ -188,7 +189,7 @@ mod tests { #[test] fn test_identity_is_found_when_querying_identity_nonce() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let mut rng = StdRng::seed_from_u64(10); let id = rng.gen::<[u8; 32]>(); let identity = create_test_identity_with_rng(&platform.drive, id, &mut rng, None, version) @@ -235,7 +236,7 @@ mod tests { #[test] fn test_identity_is_found_when_querying_identity_nonce_after_update() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let mut rng = StdRng::seed_from_u64(10); let id = rng.gen::<[u8; 32]>(); let identity = create_test_identity_with_rng(&platform.drive, id, &mut rng, None, version) @@ -296,7 +297,7 @@ mod tests { #[test] fn test_identity_is_found_when_querying_identity_nonce_after_update_for_past() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let mut rng = StdRng::seed_from_u64(10); let id = rng.gen::<[u8; 32]>(); let identity = create_test_identity_with_rng(&platform.drive, id, &mut rng, None, version) @@ -372,7 +373,7 @@ mod tests { #[test] fn test_identity_contract_nonce_absence_proof() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetIdentityContractNonceRequestV0 { identity_id: vec![0; 32], diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/identity_nonce/v0/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/identity_nonce/v0/mod.rs index 855fae69b0..4047c071b2 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/identity_nonce/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/identity_nonce/v0/mod.rs @@ -68,10 +68,11 @@ mod tests { use drive::util::test_helpers::test_utils::identities::create_test_identity_with_rng; use rand::prelude::StdRng; use rand::{Rng, SeedableRng}; + use dpp::dashcore::Network; #[test] fn test_invalid_identity_id() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetIdentityNonceRequestV0 { identity_id: vec![0; 8], @@ -89,7 +90,7 @@ mod tests { #[test] fn test_identity_not_found_when_querying_identity_nonce() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetIdentityNonceRequestV0 { identity_id: vec![0; 32], @@ -113,7 +114,7 @@ mod tests { #[test] fn test_identity_is_found_when_querying_identity_nonce() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let mut rng = StdRng::seed_from_u64(10); let id = rng.gen::<[u8; 32]>(); let _unused_identity = @@ -142,7 +143,7 @@ mod tests { #[test] fn test_identity_is_found_when_querying_identity_nonce_after_update() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let mut rng = StdRng::seed_from_u64(10); let id = rng.gen::<[u8; 32]>(); let identity = create_test_identity_with_rng(&platform.drive, id, &mut rng, None, version) @@ -194,7 +195,7 @@ mod tests { #[test] fn test_identity_is_found_when_querying_identity_nonce_after_update_for_past() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let mut rng = StdRng::seed_from_u64(10); let id = rng.gen::<[u8; 32]>(); let identity = create_test_identity_with_rng(&platform.drive, id, &mut rng, None, version) @@ -259,7 +260,7 @@ mod tests { #[test] fn test_identity_contract_nonce_absence_proof() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetIdentityNonceRequestV0 { identity_id: vec![0; 32], diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/keys/v0/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/keys/v0/mod.rs index a8e8510b24..fb3c50545c 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/keys/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/keys/v0/mod.rs @@ -169,10 +169,11 @@ mod tests { use crate::query::tests::{assert_invalid_identifier, setup_platform}; use dapi_grpc::platform::v0::key_request_type::Request; use dapi_grpc::platform::v0::{AllKeys, KeyRequestType, SearchKey, SecurityLevelMap}; + use dpp::dashcore::Network; #[test] fn test_invalid_identity_id() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetIdentityKeysRequestV0 { identity_id: vec![0; 8], @@ -191,7 +192,7 @@ mod tests { #[test] fn test_invalid_limit_u16_overflow() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetIdentityKeysRequestV0 { identity_id: vec![0; 32], @@ -213,7 +214,7 @@ mod tests { #[test] fn test_invalid_limit_max() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetIdentityKeysRequestV0 { identity_id: vec![0; 32], @@ -240,7 +241,7 @@ mod tests { #[test] fn test_invalid_offset_u16_overflow() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetIdentityKeysRequestV0 { identity_id: vec![0; 32], @@ -262,7 +263,7 @@ mod tests { #[test] fn test_missing_request_type() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetIdentityKeysRequestV0 { identity_id: vec![0; 32], @@ -284,7 +285,7 @@ mod tests { #[test] fn test_missing_request() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetIdentityKeysRequestV0 { identity_id: vec![0; 32], @@ -306,7 +307,7 @@ mod tests { #[test] fn test_invalid_key_request_type() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetIdentityKeysRequestV0 { identity_id: vec![0; 32], @@ -339,7 +340,7 @@ mod tests { #[test] fn test_absent_keys() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetIdentityKeysRequestV0 { identity_id: vec![0; 32], @@ -366,7 +367,7 @@ mod tests { #[test] fn test_absent_keys_proof() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetIdentityKeysRequestV0 { identity_id: vec![0; 32], diff --git a/packages/rs-drive-abci/src/query/mod.rs b/packages/rs-drive-abci/src/query/mod.rs index 19e2ce1097..8aa5b9f673 100644 --- a/packages/rs-drive-abci/src/query/mod.rs +++ b/packages/rs-drive-abci/src/query/mod.rs @@ -34,20 +34,26 @@ mod tests { use platform_version::version::PlatformVersion; use std::borrow::Cow; use std::sync::Arc; + use dpp::dashcore::Network; + use dpp::prelude::{CoreBlockHeight, TimestampMillis}; + use crate::config::PlatformConfig; pub fn setup_platform<'a>( - with_genesis_state: bool, + with_genesis_state: Option<(TimestampMillis, CoreBlockHeight)>, + network: Network, ) -> ( TempPlatform, Arc, &'a PlatformVersion, ) { - let platform = if with_genesis_state { + let platform = if let Some((timestamp, activation_core_block_height)) = with_genesis_state { TestPlatformBuilder::new() + .with_config(PlatformConfig::default_for_network(network)) .build_with_mock_rpc() - .set_genesis_state() + .set_genesis_state_with_activation_info(timestamp, activation_core_block_height) } else { TestPlatformBuilder::new() + .with_config(PlatformConfig::default_for_network(network)) .build_with_mock_rpc() .set_initial_state_structure() }; diff --git a/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/v0/mod.rs b/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/v0/mod.rs index b4a21fd97b..83ed091521 100644 --- a/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/v0/mod.rs @@ -68,12 +68,13 @@ impl Platform { #[cfg(test)] mod tests { + use dpp::dashcore::Network; use super::*; use crate::query::tests::{assert_invalid_identifier, setup_platform}; #[test] fn test_invalid_identity_id() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetPrefundedSpecializedBalanceRequestV0 { id: vec![0; 8], @@ -89,7 +90,7 @@ mod tests { #[test] fn test_identity_not_found() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let id = vec![0; 32]; @@ -110,7 +111,7 @@ mod tests { #[test] fn test_identity_balance_absence_proof() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let id = vec![0; 32]; diff --git a/packages/rs-drive-abci/src/query/proofs/v0/mod.rs b/packages/rs-drive-abci/src/query/proofs/v0/mod.rs index e82980bdf3..6b7e2201c3 100644 --- a/packages/rs-drive-abci/src/query/proofs/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/proofs/v0/mod.rs @@ -173,13 +173,14 @@ mod tests { use dapi_grpc::platform::v0::get_proofs_request::get_proofs_request_v0::{ ContractRequest, DocumentRequest, IdentityRequest, VoteStatusRequest, }; + use dpp::dashcore::Network; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::platform_value::Value; use dpp::util::strings::convert_to_homograph_safe_chars; #[test] fn test_invalid_identity_ids() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetProofsRequestV0 { identities: vec![IdentityRequest { @@ -200,7 +201,7 @@ mod tests { #[test] fn test_invalid_identity_prove_request_type() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request_type = 10; @@ -229,7 +230,7 @@ mod tests { #[test] fn test_invalid_contract_ids() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetProofsRequestV0 { identities: vec![], @@ -249,7 +250,7 @@ mod tests { #[test] fn test_invalid_contract_id_for_documents_proof() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetProofsRequestV0 { identities: vec![], @@ -273,7 +274,7 @@ mod tests { #[test] fn test_invalid_document_id() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetProofsRequestV0 { identities: vec![], @@ -297,7 +298,7 @@ mod tests { #[test] fn test_proof_of_absence() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetProofsRequestV0 { identities: vec![], @@ -324,7 +325,7 @@ mod tests { #[test] fn test_proof_of_absence_of_vote() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let dpns_contract = platform .drive @@ -376,7 +377,7 @@ mod tests { #[test] fn test_prove_all() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetProofsRequestV0 { identities: vec![IdentityRequest { diff --git a/packages/rs-drive-abci/src/query/system/epoch_infos/v0/mod.rs b/packages/rs-drive-abci/src/query/system/epoch_infos/v0/mod.rs index 4684008a2b..408f179f54 100644 --- a/packages/rs-drive-abci/src/query/system/epoch_infos/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/system/epoch_infos/v0/mod.rs @@ -100,12 +100,13 @@ impl Platform { #[cfg(test)] mod tests { + use dpp::dashcore::Network; use super::*; use crate::query::tests::setup_platform; #[test] fn test_query_empty_epoch_infos() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetEpochsInfoRequestV0 { start_epoch: None, // 0 @@ -129,7 +130,7 @@ mod tests { #[test] fn test_query_empty_epoch_infos_descending() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetEpochsInfoRequestV0 { start_epoch: None, // 0 diff --git a/packages/rs-drive-abci/src/query/system/path_elements/v0/mod.rs b/packages/rs-drive-abci/src/query/system/path_elements/v0/mod.rs index dec93e5b92..c38656441e 100644 --- a/packages/rs-drive-abci/src/query/system/path_elements/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/system/path_elements/v0/mod.rs @@ -81,10 +81,11 @@ mod tests { use drive::drive::RootTree; use drive::grovedb::Element; use integer_encoding::VarInt; + use dpp::dashcore::Network; #[test] fn test_query_total_system_credits_from_path_elements_query() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let platform_version = PlatformVersion::latest(); diff --git a/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs b/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs index 5b53120243..e7f639115a 100644 --- a/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs @@ -140,10 +140,11 @@ mod tests { fn test_query_total_system_credits( epoch_index: EpochIndex, + activation_core_height: CoreBlockHeight, epoch_core_start_height: CoreBlockHeight, current_core_height: CoreBlockHeight, ) { - let (platform, _state, platform_version) = setup_platform(true); + let (platform, _state, platform_version) = setup_platform(true, Network::Regtest); platform .drive @@ -193,7 +194,7 @@ mod tests { let rewards = epoch_core_reward_credits_for_distribution( epoch_core_start_height, current_core_height, - 1, + Network::Regtest.core_subsidy_halving_interval(), platform_version, ) .expect("expected to get rewards"); @@ -203,10 +204,11 @@ mod tests { fn test_proved_query_total_system_credits( epoch_index: EpochIndex, + activation_core_height: CoreBlockHeight, epoch_core_start_height: CoreBlockHeight, current_core_height: CoreBlockHeight, ) { - let (platform, _state, platform_version) = setup_platform(true); + let (platform, _state, platform_version) = setup_platform(true, Network::Regtest); platform .drive @@ -253,14 +255,14 @@ mod tests { panic!("expected proof") }; - let network = Network::Testnet; + let network = Network::Regtest; let core_subsidy_halving_interval = network.core_subsidy_halving_interval(); let (_, credits) = Drive::verify_total_credits_in_system( &proof.grovedb_proof, core_subsidy_halving_interval, - || Ok(0), + || Ok(activation_core_height), current_core_height, platform_version, ) @@ -269,7 +271,7 @@ mod tests { let rewards = epoch_core_reward_credits_for_distribution( epoch_core_start_height, current_core_height, - 1, + core_subsidy_halving_interval, platform_version, ) .expect("expected to get rewards"); @@ -278,23 +280,38 @@ mod tests { } #[test] - fn test_query_total_system_credits_at_genesis() { - // let's say the genesis is 1500 - test_query_total_system_credits(0, 1500, 1500); - test_proved_query_total_system_credits(0, 1500, 1500); + fn test_query_total_system_credits_at_genesis_platform_immediate_start() { + // the fork height is 1500, the genesis core height is 1500 and we are asking for credits after this first block was committed + test_query_total_system_credits(0, 1500, 1500, 1500); + test_proved_query_total_system_credits(0, 1500, 1500,1500); + } + + #[test] + fn test_query_total_system_credits_at_genesis_platform_later_start() { + // the fork height was 1320, the genesis core height is 1500 and we are asking for credits after this first block was committed + test_query_total_system_credits(0, 1320, 1500, 1500); + test_proved_query_total_system_credits(0, 1320, 1500,1500); + } + + + #[test] + fn test_query_total_system_credits_on_first_epoch_not_genesis_immediate_start() { + // the fork height is 1500, the genesis core height is 1500 and we are at height 1550 + test_query_total_system_credits(0, 1500, 1500, 1550); + test_proved_query_total_system_credits(0, 1500, 1500, 1550); } #[test] - fn test_query_total_system_credits_on_first_epoch_not_genesis() { - // let's say the genesis is 1500, we are height 1550 - test_query_total_system_credits(0, 1500, 1550); - test_proved_query_total_system_credits(0, 1500, 1550); + fn test_query_total_system_credits_on_first_epoch_not_genesis_later_start() { + // the fork height was 1320, the genesis core height is 1500 and we are at height 1550 + test_query_total_system_credits(0, 1320, 1500, 1550); + test_proved_query_total_system_credits(0, 1320, 1500, 1550); } #[test] fn test_query_total_system_credits_not_genesis_epoch() { - // let's say the genesis is 1500, we are height 2500 - test_query_total_system_credits(1, 2000, 2500); - test_proved_query_total_system_credits(1, 2000, 2500); + // the fork height was 1500, the genesis core height is 1500 and we are at height 1550 + test_query_total_system_credits(1, 1500, 2000, 2500); + test_proved_query_total_system_credits(1, 1500, 2000, 2000, 2500); } } diff --git a/packages/rs-drive-abci/src/query/system/version_upgrade_state/v0/mod.rs b/packages/rs-drive-abci/src/query/system/version_upgrade_state/v0/mod.rs index d4647bc90e..63a687add3 100644 --- a/packages/rs-drive-abci/src/query/system/version_upgrade_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/system/version_upgrade_state/v0/mod.rs @@ -74,10 +74,11 @@ mod tests { use rand::rngs::StdRng; use rand::{Rng, SeedableRng}; use std::ops::RangeFull; + use dpp::dashcore::Network; #[test] fn test_query_empty_upgrade_state() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetProtocolVersionUpgradeStateRequestV0 { prove: false }; @@ -96,7 +97,7 @@ mod tests { #[test] fn test_query_upgrade_state() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let mut rand = StdRng::seed_from_u64(10); @@ -188,7 +189,7 @@ mod tests { #[test] fn test_prove_empty_upgrade_state() { let platform_version = PlatformVersion::latest(); - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let request = GetProtocolVersionUpgradeStateRequestV0 { prove: true }; @@ -225,7 +226,7 @@ mod tests { #[test] fn test_prove_upgrade_state() { let platform_version = PlatformVersion::latest(); - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let mut rand = StdRng::seed_from_u64(10); diff --git a/packages/rs-drive-abci/src/query/system/version_upgrade_vote_status/v0/mod.rs b/packages/rs-drive-abci/src/query/system/version_upgrade_vote_status/v0/mod.rs index 813810a2d5..2b77f71f3a 100644 --- a/packages/rs-drive-abci/src/query/system/version_upgrade_vote_status/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/system/version_upgrade_vote_status/v0/mod.rs @@ -110,10 +110,11 @@ mod tests { use integer_encoding::VarInt; use rand::rngs::StdRng; use rand::{Rng, SeedableRng}; + use dpp::dashcore::Network; #[test] fn test_query_empty_upgrade_vote_status() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let mut rand = StdRng::seed_from_u64(10); @@ -139,7 +140,7 @@ mod tests { #[test] fn test_query_upgrade_vote_status() { - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let mut rand = StdRng::seed_from_u64(10); @@ -232,7 +233,7 @@ mod tests { #[test] fn test_prove_empty_upgrade_vote_status() { let platform_version = PlatformVersion::latest(); - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let mut rand = StdRng::seed_from_u64(10); @@ -281,7 +282,7 @@ mod tests { #[test] fn test_prove_upgrade_vote_status() { let platform_version = PlatformVersion::latest(); - let (platform, state, version) = setup_platform(false); + let (platform, state, version) = setup_platform(false, Network::Testnet); let mut rand = StdRng::seed_from_u64(10); diff --git a/packages/rs-drive-abci/src/test/helpers/setup.rs b/packages/rs-drive-abci/src/test/helpers/setup.rs index b4e0c5a4df..da127eed6f 100644 --- a/packages/rs-drive-abci/src/test/helpers/setup.rs +++ b/packages/rs-drive-abci/src/test/helpers/setup.rs @@ -42,7 +42,7 @@ use crate::{config::PlatformConfig, rpc::core::DefaultCoreRPC}; use dpp::block::block_info::BlockInfo; use dpp::document::transfer::Transferable; use dpp::nft::TradeMode; -use dpp::prelude::DataContract; +use dpp::prelude::{CoreBlockHeight, DataContract, TimestampMillis}; use dpp::tests::json_document::json_document_to_contract; use dpp::version::PlatformVersion; use drive::util::storage_flags::StorageFlags; @@ -199,6 +199,15 @@ impl TempPlatform { self } + /// Sets Platform to genesis state with information that came at activation. + pub fn set_genesis_state_with_activation_info(self, genesis_time: TimestampMillis, start_core_block_height: CoreBlockHeight) -> Self { + self.platform + .create_genesis_state(genesis_time, None, PlatformVersion::latest()) + .expect("should create root tree successfully"); + + self + } + /// Rebuilds Platform from the tempdir as if it was destroyed and restarted pub fn open_with_tempdir(tempdir: TempDir, config: PlatformConfig) -> Self { let platform = Platform::::open(tempdir.path(), Some(config)) From c9a8857915df12e511d6b98f5b92802a46a6ef7b Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 7 Aug 2024 18:20:16 +0700 Subject: [PATCH 20/33] more fixes --- packages/rs-drive-abci/src/config.rs | 4 +- .../v0/mod.rs | 10 +- .../data_contract/v0/mod.rs | 8 +- .../data_contract_history/v0/mod.rs | 12 +- .../data_contracts/v0/mod.rs | 8 +- .../src/query/document_query/v0/mod.rs | 22 ++-- .../identity_based_queries/balance/v0/mod.rs | 8 +- .../balance_and_revision/v0/mod.rs | 8 +- .../identities_contract_keys/v0/mod.rs | 24 ++-- .../identity_based_queries/identity/v0/mod.rs | 8 +- .../identity_by_public_key_hash/v0/mod.rs | 8 +- .../identity_contract_nonce/v0/mod.rs | 18 +-- .../identity_nonce/v0/mod.rs | 14 +-- .../identity_based_queries/keys/v0/mod.rs | 18 +-- packages/rs-drive-abci/src/query/mod.rs | 6 +- .../balance/v0/mod.rs | 8 +- .../rs-drive-abci/src/query/proofs/v0/mod.rs | 16 +-- .../src/query/system/epoch_infos/v0/mod.rs | 6 +- .../src/query/system/path_elements/v0/mod.rs | 4 +- .../total_credits_in_platform/v0/mod.rs | 118 ++++++++++-------- .../system/version_upgrade_state/v0/mod.rs | 10 +- .../version_upgrade_vote_status/v0/mod.rs | 10 +- .../src/test/helpers/fast_forward_to_block.rs | 5 + .../rs-drive-abci/src/test/helpers/setup.rs | 13 +- .../initialization/genesis_core_height/mod.rs | 1 - 25 files changed, 202 insertions(+), 165 deletions(-) diff --git a/packages/rs-drive-abci/src/config.rs b/packages/rs-drive-abci/src/config.rs index 9da4937e47..9513f93dc4 100644 --- a/packages/rs-drive-abci/src/config.rs +++ b/packages/rs-drive-abci/src/config.rs @@ -633,10 +633,10 @@ impl PlatformConfig { Network::Testnet => Self::default_testnet(), Network::Devnet => Self::default_devnet(), Network::Regtest => Self::default_local(), - _ => Self::default_testnet() + _ => Self::default_testnet(), } } - + /// The default local config pub fn default_local() -> Self { Self { diff --git a/packages/rs-drive-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations/v0/mod.rs index 49973cbd1f..71a3ae0120 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations/v0/mod.rs @@ -40,9 +40,17 @@ impl Platform { return Ok(None); }; + let start_block_core_height = if unpaid_epoch.epoch_index == 0 { + //On epoch 0 we need to use the activation height instead of the start of the block + self.drive + .fetch_genesis_core_height(Some(transaction), platform_version)? + } else { + unpaid_epoch.start_block_core_height + }; + // Calculate core block reward for the unpaid epoch let core_block_rewards = epoch_core_reward_credits_for_distribution( - unpaid_epoch.start_block_core_height, + start_block_core_height, unpaid_epoch.next_epoch_start_block_core_height, self.config.network.core_subsidy_halving_interval(), platform_version, diff --git a/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract/v0/mod.rs b/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract/v0/mod.rs index 04049a0435..83b8fea5f7 100644 --- a/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract/v0/mod.rs @@ -74,13 +74,13 @@ impl Platform { #[cfg(test)] mod tests { - use dpp::dashcore::Network; use super::*; use crate::query::tests::{assert_invalid_identifier, setup_platform}; + use dpp::dashcore::Network; #[test] fn test_invalid_data_contract_id() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetDataContractRequestV0 { id: vec![0; 8], @@ -94,7 +94,7 @@ mod tests { #[test] fn test_data_contract_not_found() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let id = vec![0; 32]; let request = GetDataContractRequestV0 { @@ -114,7 +114,7 @@ mod tests { #[test] fn test_data_contract_absence_proof() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let id = vec![0; 32]; let request = GetDataContractRequestV0 { diff --git a/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract_history/v0/mod.rs b/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract_history/v0/mod.rs index e9821fc761..0611a3ccc1 100644 --- a/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract_history/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract_history/v0/mod.rs @@ -113,6 +113,7 @@ mod tests { use crate::rpc::core::MockCoreRPCLike; use crate::test::helpers::setup::{TempPlatform, TestPlatformBuilder}; use dpp::block::block_info::BlockInfo; + use dpp::dashcore::Network; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::config::v0::DataContractConfigSettersV0; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; @@ -123,7 +124,6 @@ mod tests { use dpp::tests::fixtures::get_data_contract_fixture; use drive::drive::Drive; use std::sync::Arc; - use dpp::dashcore::Network; fn default_request_v0() -> GetDataContractHistoryRequestV0 { GetDataContractHistoryRequestV0 { @@ -243,7 +243,7 @@ mod tests { #[test] fn test_invalid_data_contract_id() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetDataContractHistoryRequestV0 { id: vec![0; 8], @@ -262,7 +262,7 @@ mod tests { #[test] fn test_invalid_limit_overflow() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetDataContractHistoryRequestV0 { id: vec![0; 32], @@ -284,7 +284,7 @@ mod tests { #[test] fn test_invalid_offset_overflow() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetDataContractHistoryRequestV0 { id: vec![0; 32], @@ -305,7 +305,7 @@ mod tests { #[test] fn test_data_contract_not_found() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let id = vec![0; 32]; @@ -470,7 +470,7 @@ mod tests { #[test] fn test_data_contract_history_absence_proof() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetDataContractHistoryRequestV0 { id: vec![0; 32], diff --git a/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contracts/v0/mod.rs b/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contracts/v0/mod.rs index f92c06e021..f1533b2473 100644 --- a/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contracts/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/data_contract_based_queries/data_contracts/v0/mod.rs @@ -86,13 +86,13 @@ impl Platform { #[cfg(test)] mod tests { - use dpp::dashcore::Network; use super::*; use crate::query::tests::{assert_invalid_identifier, setup_platform}; + use dpp::dashcore::Network; #[test] fn test_invalid_data_contract_id() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetDataContractsRequestV0 { ids: vec![vec![0; 8]], @@ -108,7 +108,7 @@ mod tests { #[test] fn test_data_contracts_not_found() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let id = vec![0; 32]; let request = GetDataContractsRequestV0 { @@ -131,7 +131,7 @@ mod tests { #[test] fn test_data_contracts_absence_proof() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let id = vec![0; 32]; let request = GetDataContractsRequestV0 { diff --git a/packages/rs-drive-abci/src/query/document_query/v0/mod.rs b/packages/rs-drive-abci/src/query/document_query/v0/mod.rs index 7dc8694635..307919493c 100644 --- a/packages/rs-drive-abci/src/query/document_query/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/document_query/v0/mod.rs @@ -179,14 +179,14 @@ impl Platform { #[cfg(test)] mod tests { - use dpp::dashcore::Network; use super::*; use crate::query::tests::{assert_invalid_identifier, setup_platform, store_data_contract}; + use dpp::dashcore::Network; use dpp::tests::fixtures::get_data_contract_fixture; #[test] fn test_invalid_document_id() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetDocumentsRequestV0 { data_contract_id: vec![0; 8], @@ -207,7 +207,7 @@ mod tests { #[test] fn test_data_contract_not_found_in_documents_request() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let data_contract_id = vec![0; 32]; @@ -233,7 +233,7 @@ mod tests { #[test] fn test_absent_document_type() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let created_data_contract = get_data_contract_fixture(None, 0, version.protocol_version); store_data_contract(&platform, created_data_contract.data_contract(), version); @@ -265,7 +265,7 @@ mod tests { #[test] fn test_invalid_where_clause() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let created_data_contract = get_data_contract_fixture(None, 0, version.protocol_version); store_data_contract(&platform, created_data_contract.data_contract(), version); @@ -295,7 +295,7 @@ mod tests { #[test] fn test_invalid_order_by_clause() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let created_data_contract = get_data_contract_fixture(None, 0, version.protocol_version); store_data_contract(&platform, created_data_contract.data_contract(), version); @@ -325,7 +325,7 @@ mod tests { #[test] fn test_invalid_start_at_clause() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let created_data_contract = get_data_contract_fixture(None, 0, version.protocol_version); store_data_contract(&platform, created_data_contract.data_contract(), version); @@ -355,7 +355,7 @@ mod tests { #[test] fn test_invalid_start_after_clause() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let created_data_contract = get_data_contract_fixture(None, 0, version.protocol_version); store_data_contract(&platform, created_data_contract.data_contract(), version); @@ -385,7 +385,7 @@ mod tests { #[test] fn test_invalid_limit() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let created_data_contract = get_data_contract_fixture(None, 0, version.protocol_version); store_data_contract(&platform, created_data_contract.data_contract(), version); @@ -416,7 +416,7 @@ mod tests { #[test] fn test_documents_not_found() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let created_data_contract = get_data_contract_fixture(None, 0, version.protocol_version); store_data_contract(&platform, created_data_contract.data_contract(), version); @@ -449,7 +449,7 @@ mod tests { #[test] fn test_documents_absence_proof() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let created_data_contract = get_data_contract_fixture(None, 0, version.protocol_version); store_data_contract(&platform, created_data_contract.data_contract(), version); diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/balance/v0/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/balance/v0/mod.rs index 1c6330a3c7..5f6718eb13 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/balance/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/balance/v0/mod.rs @@ -63,13 +63,13 @@ impl Platform { #[cfg(test)] mod tests { - use dpp::dashcore::Network; use super::*; use crate::query::tests::{assert_invalid_identifier, setup_platform}; + use dpp::dashcore::Network; #[test] fn test_invalid_identity_id() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetIdentityBalanceRequestV0 { id: vec![0; 8], @@ -85,7 +85,7 @@ mod tests { #[test] fn test_identity_not_found() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let id = vec![0; 32]; @@ -106,7 +106,7 @@ mod tests { #[test] fn test_identity_balance_absence_proof() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let id = vec![0; 32]; diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/balance_and_revision/v0/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/balance_and_revision/v0/mod.rs index c0e58644ce..d4f8233e21 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/balance_and_revision/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/balance_and_revision/v0/mod.rs @@ -82,13 +82,13 @@ impl Platform { #[cfg(test)] mod tests { - use dpp::dashcore::Network; use super::*; use crate::query::tests::{assert_invalid_identifier, setup_platform}; + use dpp::dashcore::Network; #[test] fn test_invalid_identity_id() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetIdentityBalanceAndRevisionRequestV0 { id: vec![0; 8], @@ -104,7 +104,7 @@ mod tests { #[test] fn test_identity_not_found_when_querying_balance_and_revision() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let id = vec![0; 32]; @@ -125,7 +125,7 @@ mod tests { #[test] fn test_identity_balance_and_revision_absence_proof() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let id = vec![0; 32]; diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/identities_contract_keys/v0/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/identities_contract_keys/v0/mod.rs index f58d802723..12f840d9d9 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/identities_contract_keys/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/identities_contract_keys/v0/mod.rs @@ -150,7 +150,7 @@ mod tests { #[test] fn test_identities_contract_keys_missing_identity() { - let (platform, state, platform_version) = setup_platform(true, Network::Testnet); + let (platform, state, platform_version) = setup_platform(Some((1, 1)), Network::Testnet); let dashpay = platform.drive.cache.system_data_contracts.load_dashpay(); @@ -180,7 +180,7 @@ mod tests { #[test] fn test_identities_contract_keys_missing_identity_proved() { - let (platform, state, platform_version) = setup_platform(true, Network::Testnet); + let (platform, state, platform_version) = setup_platform(Some((1, 1)), Network::Testnet); let dashpay = platform.drive.cache.system_data_contracts.load_dashpay(); @@ -231,7 +231,7 @@ mod tests { #[test] fn test_identities_contract_keys_missing_identity_absent_contract() { - let (platform, state, platform_version) = setup_platform(false, Network::Testnet); + let (platform, state, platform_version) = setup_platform(None, Network::Testnet); let request = GetIdentitiesContractKeysRequestV0 { identities_ids: vec![vec![1; 32]], @@ -259,7 +259,7 @@ mod tests { #[test] fn test_identities_contract_keys_missing_identity_absent_contract_proved() { - let (platform, state, platform_version) = setup_platform(false, Network::Testnet); + let (platform, state, platform_version) = setup_platform(None, Network::Testnet); let request = GetIdentitiesContractKeysRequestV0 { identities_ids: vec![vec![1; 32]], @@ -306,7 +306,7 @@ mod tests { #[test] fn test_identities_contract_keys_with_identity_absent_contract() { - let (platform, state, platform_version) = setup_platform(false, Network::Testnet); + let (platform, state, platform_version) = setup_platform(None, Network::Testnet); let mut rng = StdRng::seed_from_u64(10); @@ -348,7 +348,7 @@ mod tests { #[test] fn test_identities_contract_keys_with_identity_absent_contract_proved() { - let (platform, state, platform_version) = setup_platform(false, Network::Testnet); + let (platform, state, platform_version) = setup_platform(None, Network::Testnet); let mut rng = StdRng::seed_from_u64(10); @@ -409,7 +409,7 @@ mod tests { #[test] fn test_identities_contract_keys_missing_identity_keys() { - let (platform, state, platform_version) = setup_platform(true, Network::Testnet); + let (platform, state, platform_version) = setup_platform(Some((1, 1)), Network::Testnet); let dashpay = platform.drive.cache.system_data_contracts.load_dashpay(); @@ -453,7 +453,7 @@ mod tests { #[test] fn test_identities_contract_keys_missing_identity_keys_proved() { - let (platform, state, platform_version) = setup_platform(true, Network::Testnet); + let (platform, state, platform_version) = setup_platform(Some((1, 1)), Network::Testnet); let dashpay = platform.drive.cache.system_data_contracts.load_dashpay(); @@ -516,7 +516,7 @@ mod tests { #[test] fn test_identities_contract_keys() { - let (platform, state, platform_version) = setup_platform(true, Network::Testnet); + let (platform, state, platform_version) = setup_platform(Some((1, 1)), Network::Testnet); let dashpay = platform.drive.cache.system_data_contracts.load_dashpay(); @@ -674,7 +674,7 @@ mod tests { #[test] fn test_identities_contract_keys_proof() { - let (platform, state, platform_version) = setup_platform(true, Network::Testnet); + let (platform, state, platform_version) = setup_platform(Some((1, 1)), Network::Testnet); let dashpay = platform.drive.cache.system_data_contracts.load_dashpay(); @@ -769,7 +769,7 @@ mod tests { #[test] fn test_multiple_identities_contract_keys() { - let (platform, state, platform_version) = setup_platform(true, Network::Testnet); + let (platform, state, platform_version) = setup_platform(Some((1, 1)), Network::Testnet); let dashpay = platform.drive.cache.system_data_contracts.load_dashpay(); @@ -969,7 +969,7 @@ mod tests { #[test] fn test_multiple_identities_contract_keys_proof() { - let (platform, state, platform_version) = setup_platform(true, Network::Testnet); + let (platform, state, platform_version) = setup_platform(Some((1, 1)), Network::Testnet); let dashpay = platform.drive.cache.system_data_contracts.load_dashpay(); diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/identity/v0/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/identity/v0/mod.rs index b3a9d32150..9ead1303bf 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/identity/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/identity/v0/mod.rs @@ -69,13 +69,13 @@ impl Platform { #[cfg(test)] mod tests { - use dpp::dashcore::Network; use super::*; use crate::query::tests::{assert_invalid_identifier, setup_platform}; + use dpp::dashcore::Network; #[test] fn test_invalid_identity_id() { - let (platform, state, _unused_version) = setup_platform(false, Network::Testnet); + let (platform, state, _unused_version) = setup_platform(None, Network::Testnet); let version = PlatformVersion::latest(); @@ -93,7 +93,7 @@ mod tests { #[test] fn test_identity_not_found() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let id = vec![0; 32]; let request = GetIdentityRequestV0 { @@ -115,7 +115,7 @@ mod tests { #[test] fn test_identity_absence_proof() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let id = vec![0; 32]; let request = GetIdentityRequestV0 { diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_public_key_hash/v0/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_public_key_hash/v0/mod.rs index efa283ffdd..e3249f2537 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_public_key_hash/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/identity_by_public_key_hash/v0/mod.rs @@ -77,13 +77,13 @@ impl Platform { #[cfg(test)] mod tests { - use dpp::dashcore::Network; use super::*; use crate::query::tests::setup_platform; + use dpp::dashcore::Network; #[test] fn test_invalid_public_key_hash() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetIdentityByPublicKeyHashRequestV0 { public_key_hash: vec![0; 8], @@ -102,7 +102,7 @@ mod tests { #[test] fn test_identity_not_found() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let public_key_hash = vec![0; 20]; let request = GetIdentityByPublicKeyHashRequestV0 { @@ -122,7 +122,7 @@ mod tests { #[test] fn test_identity_absence_proof() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let public_key_hash = vec![0; 20]; let request = GetIdentityByPublicKeyHashRequestV0 { diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/identity_contract_nonce/v0/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/identity_contract_nonce/v0/mod.rs index b23249d430..6db26c62f8 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/identity_contract_nonce/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/identity_contract_nonce/v0/mod.rs @@ -80,6 +80,7 @@ mod tests { use super::*; use crate::query::tests::setup_platform; use dpp::block::block_info::BlockInfo; + use dpp::dashcore::Network; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::identity::accessors::IdentityGettersV0; use dpp::identity::identity_nonce::{ @@ -88,11 +89,10 @@ mod tests { use drive::util::test_helpers::test_utils::identities::create_test_identity_with_rng; use rand::rngs::StdRng; use rand::{Rng, SeedableRng}; - use dpp::dashcore::Network; #[test] fn test_invalid_identity_id() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetIdentityContractNonceRequestV0 { identity_id: vec![0; 8], @@ -111,7 +111,7 @@ mod tests { #[test] fn test_invalid_contract_id() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetIdentityContractNonceRequestV0 { identity_id: vec![0; 32], @@ -130,7 +130,7 @@ mod tests { #[test] fn test_identity_not_found_when_querying_identity_nonce() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetIdentityContractNonceRequestV0 { identity_id: vec![0; 32], @@ -157,7 +157,7 @@ mod tests { #[test] fn test_contract_info_not_found_when_querying_identity_nonce_with_known_identity() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let mut rng = StdRng::seed_from_u64(45); let id = rng.gen::<[u8; 32]>(); let _unused_identity = @@ -189,7 +189,7 @@ mod tests { #[test] fn test_identity_is_found_when_querying_identity_nonce() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let mut rng = StdRng::seed_from_u64(10); let id = rng.gen::<[u8; 32]>(); let identity = create_test_identity_with_rng(&platform.drive, id, &mut rng, None, version) @@ -236,7 +236,7 @@ mod tests { #[test] fn test_identity_is_found_when_querying_identity_nonce_after_update() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let mut rng = StdRng::seed_from_u64(10); let id = rng.gen::<[u8; 32]>(); let identity = create_test_identity_with_rng(&platform.drive, id, &mut rng, None, version) @@ -297,7 +297,7 @@ mod tests { #[test] fn test_identity_is_found_when_querying_identity_nonce_after_update_for_past() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let mut rng = StdRng::seed_from_u64(10); let id = rng.gen::<[u8; 32]>(); let identity = create_test_identity_with_rng(&platform.drive, id, &mut rng, None, version) @@ -373,7 +373,7 @@ mod tests { #[test] fn test_identity_contract_nonce_absence_proof() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetIdentityContractNonceRequestV0 { identity_id: vec![0; 32], diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/identity_nonce/v0/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/identity_nonce/v0/mod.rs index 4047c071b2..4c6874cf27 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/identity_nonce/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/identity_nonce/v0/mod.rs @@ -61,6 +61,7 @@ mod tests { use super::*; use crate::query::tests::setup_platform; use dpp::block::block_info::BlockInfo; + use dpp::dashcore::Network; use dpp::identity::accessors::IdentityGettersV0; use dpp::identity::identity_nonce::{ IDENTITY_NONCE_VALUE_FILTER, IDENTITY_NONCE_VALUE_FILTER_MAX_BYTES, @@ -68,11 +69,10 @@ mod tests { use drive::util::test_helpers::test_utils::identities::create_test_identity_with_rng; use rand::prelude::StdRng; use rand::{Rng, SeedableRng}; - use dpp::dashcore::Network; #[test] fn test_invalid_identity_id() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetIdentityNonceRequestV0 { identity_id: vec![0; 8], @@ -90,7 +90,7 @@ mod tests { #[test] fn test_identity_not_found_when_querying_identity_nonce() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetIdentityNonceRequestV0 { identity_id: vec![0; 32], @@ -114,7 +114,7 @@ mod tests { #[test] fn test_identity_is_found_when_querying_identity_nonce() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let mut rng = StdRng::seed_from_u64(10); let id = rng.gen::<[u8; 32]>(); let _unused_identity = @@ -143,7 +143,7 @@ mod tests { #[test] fn test_identity_is_found_when_querying_identity_nonce_after_update() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let mut rng = StdRng::seed_from_u64(10); let id = rng.gen::<[u8; 32]>(); let identity = create_test_identity_with_rng(&platform.drive, id, &mut rng, None, version) @@ -195,7 +195,7 @@ mod tests { #[test] fn test_identity_is_found_when_querying_identity_nonce_after_update_for_past() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let mut rng = StdRng::seed_from_u64(10); let id = rng.gen::<[u8; 32]>(); let identity = create_test_identity_with_rng(&platform.drive, id, &mut rng, None, version) @@ -260,7 +260,7 @@ mod tests { #[test] fn test_identity_contract_nonce_absence_proof() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetIdentityNonceRequestV0 { identity_id: vec![0; 32], diff --git a/packages/rs-drive-abci/src/query/identity_based_queries/keys/v0/mod.rs b/packages/rs-drive-abci/src/query/identity_based_queries/keys/v0/mod.rs index fb3c50545c..7079dacf09 100644 --- a/packages/rs-drive-abci/src/query/identity_based_queries/keys/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/identity_based_queries/keys/v0/mod.rs @@ -173,7 +173,7 @@ mod tests { #[test] fn test_invalid_identity_id() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetIdentityKeysRequestV0 { identity_id: vec![0; 8], @@ -192,7 +192,7 @@ mod tests { #[test] fn test_invalid_limit_u16_overflow() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetIdentityKeysRequestV0 { identity_id: vec![0; 32], @@ -214,7 +214,7 @@ mod tests { #[test] fn test_invalid_limit_max() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetIdentityKeysRequestV0 { identity_id: vec![0; 32], @@ -241,7 +241,7 @@ mod tests { #[test] fn test_invalid_offset_u16_overflow() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetIdentityKeysRequestV0 { identity_id: vec![0; 32], @@ -263,7 +263,7 @@ mod tests { #[test] fn test_missing_request_type() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetIdentityKeysRequestV0 { identity_id: vec![0; 32], @@ -285,7 +285,7 @@ mod tests { #[test] fn test_missing_request() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetIdentityKeysRequestV0 { identity_id: vec![0; 32], @@ -307,7 +307,7 @@ mod tests { #[test] fn test_invalid_key_request_type() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetIdentityKeysRequestV0 { identity_id: vec![0; 32], @@ -340,7 +340,7 @@ mod tests { #[test] fn test_absent_keys() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetIdentityKeysRequestV0 { identity_id: vec![0; 32], @@ -367,7 +367,7 @@ mod tests { #[test] fn test_absent_keys_proof() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetIdentityKeysRequestV0 { identity_id: vec![0; 32], diff --git a/packages/rs-drive-abci/src/query/mod.rs b/packages/rs-drive-abci/src/query/mod.rs index 8aa5b9f673..197cb4dd26 100644 --- a/packages/rs-drive-abci/src/query/mod.rs +++ b/packages/rs-drive-abci/src/query/mod.rs @@ -29,14 +29,14 @@ mod tests { use dpp::block::block_info::BlockInfo; use dpp::data_contract::DataContract; + use crate::config::PlatformConfig; + use dpp::dashcore::Network; + use dpp::prelude::{CoreBlockHeight, TimestampMillis}; use drive::util::batch::DataContractOperationType; use drive::util::batch::DriveOperation::DataContractOperation; use platform_version::version::PlatformVersion; use std::borrow::Cow; use std::sync::Arc; - use dpp::dashcore::Network; - use dpp::prelude::{CoreBlockHeight, TimestampMillis}; - use crate::config::PlatformConfig; pub fn setup_platform<'a>( with_genesis_state: Option<(TimestampMillis, CoreBlockHeight)>, diff --git a/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/v0/mod.rs b/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/v0/mod.rs index 83ed091521..4684c64658 100644 --- a/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/v0/mod.rs @@ -68,13 +68,13 @@ impl Platform { #[cfg(test)] mod tests { - use dpp::dashcore::Network; use super::*; use crate::query::tests::{assert_invalid_identifier, setup_platform}; + use dpp::dashcore::Network; #[test] fn test_invalid_identity_id() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetPrefundedSpecializedBalanceRequestV0 { id: vec![0; 8], @@ -90,7 +90,7 @@ mod tests { #[test] fn test_identity_not_found() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let id = vec![0; 32]; @@ -111,7 +111,7 @@ mod tests { #[test] fn test_identity_balance_absence_proof() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let id = vec![0; 32]; diff --git a/packages/rs-drive-abci/src/query/proofs/v0/mod.rs b/packages/rs-drive-abci/src/query/proofs/v0/mod.rs index 6b7e2201c3..3152ecf4c8 100644 --- a/packages/rs-drive-abci/src/query/proofs/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/proofs/v0/mod.rs @@ -180,7 +180,7 @@ mod tests { #[test] fn test_invalid_identity_ids() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetProofsRequestV0 { identities: vec![IdentityRequest { @@ -201,7 +201,7 @@ mod tests { #[test] fn test_invalid_identity_prove_request_type() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request_type = 10; @@ -230,7 +230,7 @@ mod tests { #[test] fn test_invalid_contract_ids() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetProofsRequestV0 { identities: vec![], @@ -250,7 +250,7 @@ mod tests { #[test] fn test_invalid_contract_id_for_documents_proof() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetProofsRequestV0 { identities: vec![], @@ -274,7 +274,7 @@ mod tests { #[test] fn test_invalid_document_id() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetProofsRequestV0 { identities: vec![], @@ -298,7 +298,7 @@ mod tests { #[test] fn test_proof_of_absence() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetProofsRequestV0 { identities: vec![], @@ -325,7 +325,7 @@ mod tests { #[test] fn test_proof_of_absence_of_vote() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let dpns_contract = platform .drive @@ -377,7 +377,7 @@ mod tests { #[test] fn test_prove_all() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetProofsRequestV0 { identities: vec![IdentityRequest { diff --git a/packages/rs-drive-abci/src/query/system/epoch_infos/v0/mod.rs b/packages/rs-drive-abci/src/query/system/epoch_infos/v0/mod.rs index 408f179f54..48f32c8847 100644 --- a/packages/rs-drive-abci/src/query/system/epoch_infos/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/system/epoch_infos/v0/mod.rs @@ -100,13 +100,13 @@ impl Platform { #[cfg(test)] mod tests { - use dpp::dashcore::Network; use super::*; use crate::query::tests::setup_platform; + use dpp::dashcore::Network; #[test] fn test_query_empty_epoch_infos() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetEpochsInfoRequestV0 { start_epoch: None, // 0 @@ -130,7 +130,7 @@ mod tests { #[test] fn test_query_empty_epoch_infos_descending() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetEpochsInfoRequestV0 { start_epoch: None, // 0 diff --git a/packages/rs-drive-abci/src/query/system/path_elements/v0/mod.rs b/packages/rs-drive-abci/src/query/system/path_elements/v0/mod.rs index c38656441e..f3d63cb6e5 100644 --- a/packages/rs-drive-abci/src/query/system/path_elements/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/system/path_elements/v0/mod.rs @@ -77,15 +77,15 @@ impl Platform { mod tests { use super::*; use crate::query::tests::setup_platform; + use dpp::dashcore::Network; use drive::drive::balances::TOTAL_SYSTEM_CREDITS_STORAGE_KEY; use drive::drive::RootTree; use drive::grovedb::Element; use integer_encoding::VarInt; - use dpp::dashcore::Network; #[test] fn test_query_total_system_credits_from_path_elements_query() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let platform_version = PlatformVersion::latest(); diff --git a/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs b/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs index e7f639115a..2aa391f3cd 100644 --- a/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs @@ -100,11 +100,16 @@ impl Platform { let unpaid_epoch = Epoch::new(unpaid_epoch_index)?; - let start_block_core_height = self.drive.get_epoch_start_block_core_height( - &unpaid_epoch, - None, - platform_version, - )?; + let start_block_core_height = if unpaid_epoch.index == 0 { + self.drive + .fetch_genesis_core_height(None, platform_version)? + } else { + self.drive.get_epoch_start_block_core_height( + &unpaid_epoch, + None, + platform_version, + )? + }; let reward_credits_accumulated_during_current_epoch = epoch_core_reward_credits_for_distribution( @@ -135,6 +140,7 @@ mod tests { use crate::test::helpers::fast_forward_to_block::fast_forward_to_block; use dashcore_rpc::dashcore::Network; use dpp::block::epoch::EpochIndex; + use dpp::fee::Credits; use dpp::prelude::CoreBlockHeight; use drive::drive::Drive; @@ -143,32 +149,29 @@ mod tests { activation_core_height: CoreBlockHeight, epoch_core_start_height: CoreBlockHeight, current_core_height: CoreBlockHeight, - ) { - let (platform, _state, platform_version) = setup_platform(true, Network::Regtest); + ) -> Credits { + let (platform, _state, platform_version) = + setup_platform(Some((1, activation_core_height)), Network::Regtest); platform .drive .add_to_system_credits(100, None, platform_version) .expect("expected to insert identity"); - if epoch_index > 0 { - fast_forward_to_block( - &platform, - 5000, - 100, - epoch_core_start_height, - epoch_index - 1, - true, - ); - } else { - fast_forward_to_block(&platform, 0, 1, epoch_core_start_height, 0, true); - } + fast_forward_to_block( + &platform, + 5000 * epoch_index as u64, + 100 * epoch_index as u64, + epoch_core_start_height, + epoch_index, + true, + ); if current_core_height > epoch_core_start_height { fast_forward_to_block( &platform, - 15000, - 200, + 5000 * epoch_index as u64 + 10000, + 100 * epoch_index as u64 + 50, current_core_height, epoch_index, false, @@ -192,7 +195,11 @@ mod tests { }; let rewards = epoch_core_reward_credits_for_distribution( - epoch_core_start_height, + if epoch_index == 0 { + activation_core_height + } else { + epoch_core_start_height + }, current_core_height, Network::Regtest.core_subsidy_halving_interval(), platform_version, @@ -200,6 +207,8 @@ mod tests { .expect("expected to get rewards"); assert_eq!(credits, 100 + rewards); + + credits } fn test_proved_query_total_system_credits( @@ -207,32 +216,29 @@ mod tests { activation_core_height: CoreBlockHeight, epoch_core_start_height: CoreBlockHeight, current_core_height: CoreBlockHeight, - ) { - let (platform, _state, platform_version) = setup_platform(true, Network::Regtest); + ) -> Credits { + let (platform, _state, platform_version) = + setup_platform(Some((1, activation_core_height)), Network::Regtest); platform .drive .add_to_system_credits(100, None, platform_version) .expect("expected to insert identity"); - if epoch_index > 0 { - fast_forward_to_block( - &platform, - 5000, - 100, - epoch_core_start_height, - epoch_index - 1, - true, - ); - } else { - fast_forward_to_block(&platform, 0, 1, epoch_core_start_height, 0, true); - } + fast_forward_to_block( + &platform, + 5000 * epoch_index as u64, + 100 * epoch_index as u64, + epoch_core_start_height, + epoch_index, + true, + ); if current_core_height > epoch_core_start_height { fast_forward_to_block( &platform, - 15000, - 200, + 5000 * epoch_index as u64 + 10000, + 100 * epoch_index as u64 + 50, current_core_height, epoch_index, false, @@ -269,7 +275,11 @@ mod tests { .expect("expected to verify total credits in platform"); let rewards = epoch_core_reward_credits_for_distribution( - epoch_core_start_height, + if epoch_index == 0 { + activation_core_height + } else { + epoch_core_start_height + }, current_core_height, core_subsidy_halving_interval, platform_version, @@ -277,41 +287,47 @@ mod tests { .expect("expected to get rewards"); assert_eq!(credits, 100 + rewards); + + credits } #[test] fn test_query_total_system_credits_at_genesis_platform_immediate_start() { // the fork height is 1500, the genesis core height is 1500 and we are asking for credits after this first block was committed - test_query_total_system_credits(0, 1500, 1500, 1500); - test_proved_query_total_system_credits(0, 1500, 1500,1500); + let non_proved = test_query_total_system_credits(0, 1500, 1500, 1500); + let proved = test_proved_query_total_system_credits(0, 1500, 1500, 1500); + assert_eq!(non_proved, proved); } #[test] fn test_query_total_system_credits_at_genesis_platform_later_start() { // the fork height was 1320, the genesis core height is 1500 and we are asking for credits after this first block was committed - test_query_total_system_credits(0, 1320, 1500, 1500); - test_proved_query_total_system_credits(0, 1320, 1500,1500); + let non_proved = test_query_total_system_credits(0, 1320, 1500, 1500); + let proved = test_proved_query_total_system_credits(0, 1320, 1500, 1500); + assert_eq!(non_proved, proved); } - #[test] fn test_query_total_system_credits_on_first_epoch_not_genesis_immediate_start() { // the fork height is 1500, the genesis core height is 1500 and we are at height 1550 - test_query_total_system_credits(0, 1500, 1500, 1550); - test_proved_query_total_system_credits(0, 1500, 1500, 1550); + let non_proved = test_query_total_system_credits(0, 1500, 1500, 1550); + let proved = test_proved_query_total_system_credits(0, 1500, 1500, 1550); + assert_eq!(non_proved, proved); } #[test] fn test_query_total_system_credits_on_first_epoch_not_genesis_later_start() { // the fork height was 1320, the genesis core height is 1500 and we are at height 1550 - test_query_total_system_credits(0, 1320, 1500, 1550); - test_proved_query_total_system_credits(0, 1320, 1500, 1550); + let non_proved = test_query_total_system_credits(0, 1320, 1500, 1550); + let proved = test_proved_query_total_system_credits(0, 1320, 1500, 1550); + assert_eq!(non_proved, proved); } #[test] fn test_query_total_system_credits_not_genesis_epoch() { - // the fork height was 1500, the genesis core height is 1500 and we are at height 1550 - test_query_total_system_credits(1, 1500, 2000, 2500); - test_proved_query_total_system_credits(1, 1500, 2000, 2000, 2500); + // the fork height was 1500, the genesis core height is 1500 and we are at height 2500 + let non_proved = test_query_total_system_credits(1, 1500, 2000, 2500); + let proved = test_proved_query_total_system_credits(1, 1500, 2000, 2500); + assert_eq!(non_proved, proved); } } diff --git a/packages/rs-drive-abci/src/query/system/version_upgrade_state/v0/mod.rs b/packages/rs-drive-abci/src/query/system/version_upgrade_state/v0/mod.rs index 63a687add3..44e6f7a685 100644 --- a/packages/rs-drive-abci/src/query/system/version_upgrade_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/system/version_upgrade_state/v0/mod.rs @@ -62,6 +62,7 @@ impl Platform { mod tests { use super::*; use crate::query::tests::setup_platform; + use dpp::dashcore::Network; use drive::drive::protocol_upgrade::{ desired_version_for_validators_path, versions_counter_path, versions_counter_path_vec, }; @@ -74,11 +75,10 @@ mod tests { use rand::rngs::StdRng; use rand::{Rng, SeedableRng}; use std::ops::RangeFull; - use dpp::dashcore::Network; #[test] fn test_query_empty_upgrade_state() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetProtocolVersionUpgradeStateRequestV0 { prove: false }; @@ -97,7 +97,7 @@ mod tests { #[test] fn test_query_upgrade_state() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let mut rand = StdRng::seed_from_u64(10); @@ -189,7 +189,7 @@ mod tests { #[test] fn test_prove_empty_upgrade_state() { let platform_version = PlatformVersion::latest(); - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let request = GetProtocolVersionUpgradeStateRequestV0 { prove: true }; @@ -226,7 +226,7 @@ mod tests { #[test] fn test_prove_upgrade_state() { let platform_version = PlatformVersion::latest(); - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let mut rand = StdRng::seed_from_u64(10); diff --git a/packages/rs-drive-abci/src/query/system/version_upgrade_vote_status/v0/mod.rs b/packages/rs-drive-abci/src/query/system/version_upgrade_vote_status/v0/mod.rs index 2b77f71f3a..08b598fb31 100644 --- a/packages/rs-drive-abci/src/query/system/version_upgrade_vote_status/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/system/version_upgrade_vote_status/v0/mod.rs @@ -98,6 +98,7 @@ impl Platform { mod tests { use super::*; use crate::query::tests::setup_platform; + use dpp::dashcore::Network; use drive::drive::protocol_upgrade::{ desired_version_for_validators_path, desired_version_for_validators_path_vec, versions_counter_path, @@ -110,11 +111,10 @@ mod tests { use integer_encoding::VarInt; use rand::rngs::StdRng; use rand::{Rng, SeedableRng}; - use dpp::dashcore::Network; #[test] fn test_query_empty_upgrade_vote_status() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let mut rand = StdRng::seed_from_u64(10); @@ -140,7 +140,7 @@ mod tests { #[test] fn test_query_upgrade_vote_status() { - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let mut rand = StdRng::seed_from_u64(10); @@ -233,7 +233,7 @@ mod tests { #[test] fn test_prove_empty_upgrade_vote_status() { let platform_version = PlatformVersion::latest(); - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let mut rand = StdRng::seed_from_u64(10); @@ -282,7 +282,7 @@ mod tests { #[test] fn test_prove_upgrade_vote_status() { let platform_version = PlatformVersion::latest(); - let (platform, state, version) = setup_platform(false, Network::Testnet); + let (platform, state, version) = setup_platform(None, Network::Testnet); let mut rand = StdRng::seed_from_u64(10); diff --git a/packages/rs-drive-abci/src/test/helpers/fast_forward_to_block.rs b/packages/rs-drive-abci/src/test/helpers/fast_forward_to_block.rs index ff7dc8c7bd..9cbc8bec21 100644 --- a/packages/rs-drive-abci/src/test/helpers/fast_forward_to_block.rs +++ b/packages/rs-drive-abci/src/test/helpers/fast_forward_to_block.rs @@ -13,6 +13,7 @@ use crate::test::helpers::setup::TempPlatform; use dpp::block::block_info::BlockInfo; use dpp::block::epoch::Epoch; use dpp::block::extended_block_info::v0::ExtendedBlockInfoV0; +use drive::drive::credit_pools::operations::update_unpaid_epoch_index_operation; use platform_version::version::PlatformVersion; use std::sync::Arc; @@ -127,6 +128,10 @@ pub(crate) fn process_epoch_change( ) .expect("expected to process change operations"); + operations.push(drive::util::batch::DriveOperation::GroveDBOperation( + update_unpaid_epoch_index_operation(epoch_index), + )); + platform .drive .apply_drive_operations( diff --git a/packages/rs-drive-abci/src/test/helpers/setup.rs b/packages/rs-drive-abci/src/test/helpers/setup.rs index fec82c9a33..a557c2e915 100644 --- a/packages/rs-drive-abci/src/test/helpers/setup.rs +++ b/packages/rs-drive-abci/src/test/helpers/setup.rs @@ -200,9 +200,18 @@ impl TempPlatform { } /// Sets Platform to genesis state with information that came at activation. - pub fn set_genesis_state_with_activation_info(self, genesis_time: TimestampMillis, start_core_block_height: CoreBlockHeight) -> Self { + pub fn set_genesis_state_with_activation_info( + self, + genesis_time: TimestampMillis, + start_core_block_height: CoreBlockHeight, + ) -> Self { self.platform - .create_genesis_state(genesis_time, None, PlatformVersion::latest()) + .create_genesis_state( + start_core_block_height, + genesis_time, + None, + PlatformVersion::latest(), + ) .expect("should create root tree successfully"); self diff --git a/packages/rs-drive/src/drive/initialization/genesis_core_height/mod.rs b/packages/rs-drive/src/drive/initialization/genesis_core_height/mod.rs index 57a175611d..5e8f21d95e 100644 --- a/packages/rs-drive/src/drive/initialization/genesis_core_height/mod.rs +++ b/packages/rs-drive/src/drive/initialization/genesis_core_height/mod.rs @@ -86,7 +86,6 @@ mod tests { let db_transaction = drive.grove.start_transaction(); let platform_version = PlatformVersion::latest(); - let drive_version = &platform_version.drive; let core_genesis_height: CoreBlockHeight = 1320; drive From 8f00f99aa488ebd5369459a61f4d854d3ba29384 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 7 Aug 2024 18:49:32 +0700 Subject: [PATCH 21/33] version working --- .../mod.rs | 4 +-- .../v0/mod.rs | 29 ++++++++++++++----- .../process_block_fees/v0/mod.rs | 2 +- .../v0/mod.rs | 2 +- .../tests/strategy_tests/main.rs | 6 ++-- .../v0/mod.rs | 1 + .../v0/mod.rs | 17 ++++++----- 7 files changed, 39 insertions(+), 22 deletions(-) diff --git a/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/mod.rs b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/mod.rs index 597fccf806..ddefad34d6 100644 --- a/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/mod.rs +++ b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/mod.rs @@ -28,11 +28,11 @@ pub fn epoch_core_reward_credits_for_distribution( .methods .epoch_core_reward_credits_for_distribution { - 0 => Ok(epoch_core_reward_credits_for_distribution_v0( + 0 => epoch_core_reward_credits_for_distribution_v0( from_start_block_core_height, to_end_block_core_height_included, core_subsidy_halving_interval, - )), + ), version => Err(ProtocolError::UnknownVersionMismatch { method: "epoch_core_reward_credits_for_distribution".to_string(), known_versions: vec![0], diff --git a/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs index 9b07f0c667..7115b89e38 100644 --- a/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs +++ b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs @@ -2,6 +2,7 @@ use crate::block::epoch::EpochIndex; use crate::fee::Credits; use crate::core_subsidy::CORE_GENESIS_BLOCK_SUBSIDY; +use crate::ProtocolError; use lazy_static::lazy_static; use std::collections::HashMap; @@ -23,7 +24,13 @@ pub(super) fn epoch_core_reward_credits_for_distribution_v0( from_start_block_core_height: u32, to_end_block_core_height_included: u32, core_subsidy_halving_interval: u32, -) -> Credits { +) -> Result { + if from_start_block_core_height > to_end_block_core_height_included { + return Err(ProtocolError::CorruptedCodeExecution(format!( + "from start block {} must be before or equal to end block core height {}", + from_start_block_core_height, to_end_block_core_height_included + ))); + } // Core is halving block rewards every year so we need to pay // core block rewards according to halving ratio for the all years during // the platform epoch payout period (unpaid epoch) @@ -79,7 +86,7 @@ pub(super) fn epoch_core_reward_credits_for_distribution_v0( total_core_rewards += block_count as Credits * *core_block_distribution_ratio; } - total_core_rewards + Ok(total_core_rewards) } #[cfg(test)] @@ -97,7 +104,8 @@ mod tests { from_start_block_core_height, to_end_block_core_height_included, core_subsidy_halving_interval, - ); + ) + .unwrap(); assert_eq!(result, expected_reward); } @@ -113,7 +121,8 @@ mod tests { from_start_block_core_height, to_end_block_core_height_included, core_subsidy_halving_interval, - ); + ) + .unwrap(); assert_eq!(result, expected_reward); } @@ -130,7 +139,8 @@ mod tests { from_start_block_core_height, to_end_block_core_height_included, core_subsidy_halving_interval, - ); + ) + .unwrap(); assert_eq!(result, expected_reward); } @@ -149,7 +159,8 @@ mod tests { from_start_block_core_height, to_end_block_core_height_included, core_subsidy_halving_interval, - ); + ) + .unwrap(); assert_eq!(result, expected_reward); } @@ -165,7 +176,8 @@ mod tests { from_start_block_core_height, to_end_block_core_height_included, core_subsidy_halving_interval, - ); + ) + .unwrap(); assert_eq!(result, expected_reward); } @@ -180,7 +192,8 @@ mod tests { from_start_block_core_height, to_end_block_core_height_included, core_subsidy_halving_interval, - ); + ) + .unwrap(); assert_eq!(result, 62183484655); } diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/v0/mod.rs index 731579b379..d73b86e7a2 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_fee_processing/process_block_fees/v0/mod.rs @@ -363,7 +363,7 @@ mod tests { ..Default::default() }) .build_with_mock_rpc() - .set_initial_state_structure(); + .set_genesis_state_with_activation_info(0, 1); let transaction = platform.drive.grove.start_transaction(); diff --git a/packages/rs-drive-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations/v0/mod.rs index 71a3ae0120..90d14aaa23 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations/v0/mod.rs @@ -151,7 +151,7 @@ mod tests { let platform_version = PlatformVersion::latest(); let platform = TestPlatformBuilder::new() .build_with_mock_rpc() - .set_initial_state_structure(); + .set_genesis_state_with_activation_info(0, 1); let transaction = platform.drive.grove.start_transaction(); // Create masternode reward shares contract diff --git a/packages/rs-drive-abci/tests/strategy_tests/main.rs b/packages/rs-drive-abci/tests/strategy_tests/main.rs index b9d19a2b35..897f1b4bcc 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/main.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/main.rs @@ -1194,7 +1194,7 @@ mod tests { .unwrap() .unwrap() ), - "ab195045304053357267bd2044ccfcf5773b8f9a2724a767559f915d49cecc1d".to_string() + "3391a28d8a7fed61516eee99c3df8878f9788085f1dc5b3882230de32bdce112".to_string() ) } @@ -1915,7 +1915,7 @@ mod tests { .unwrap() .unwrap() ), - "7d28354353e8a0e300a09f52820934d8aff376cd5b4b8c00321776396faa3df0".to_string() + "3d1a0cc92c1ee52ce0f4f2be6fea8a3e4e05f4a6dfda77e923a85fec282e3924".to_string() ) } @@ -2050,7 +2050,7 @@ mod tests { .unwrap() .unwrap() ), - "afb99810fec251dfb76fcd5fe82f19eb9b9938076a12b5e7db7bef48ef5f69fc".to_string() + "1350389e5ad6f9b79f8219a169fbb5d70651d1f4760ae8a5afcb6c119fb56c4e".to_string() ) } diff --git a/packages/rs-drive/src/drive/contract/apply/apply_contract_with_serialization/v0/mod.rs b/packages/rs-drive/src/drive/contract/apply/apply_contract_with_serialization/v0/mod.rs index e3566f5fb8..2346fce2a1 100644 --- a/packages/rs-drive/src/drive/contract/apply/apply_contract_with_serialization/v0/mod.rs +++ b/packages/rs-drive/src/drive/contract/apply/apply_contract_with_serialization/v0/mod.rs @@ -52,6 +52,7 @@ impl Drive { platform_version, )?; let fetch_cost = LowLevelDriveOperation::combine_cost_operations(&batch_operations); + println!("operations are {:?}", batch_operations); self.apply_batch_low_level_drive_operations( estimated_costs_only_with_layer_info, transaction, diff --git a/packages/rs-drive/src/util/operations/apply_batch_low_level_drive_operations/v0/mod.rs b/packages/rs-drive/src/util/operations/apply_batch_low_level_drive_operations/v0/mod.rs index 4932c00031..74c318ee83 100644 --- a/packages/rs-drive/src/util/operations/apply_batch_low_level_drive_operations/v0/mod.rs +++ b/packages/rs-drive/src/util/operations/apply_batch_low_level_drive_operations/v0/mod.rs @@ -1,6 +1,7 @@ use crate::drive::Drive; use crate::error::Error; use crate::fees::op::LowLevelDriveOperation; +use crate::util::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; use dpp::version::drive_versions::DriveVersion; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; @@ -22,13 +23,15 @@ impl Drive { LowLevelDriveOperation::grovedb_operations_batch_consume_with_leftovers( batch_operations, ); - self.apply_batch_grovedb_operations( - estimated_costs_only_with_layer_info, - transaction, - grove_db_operations, - drive_operations, - drive_version, - )?; + if !grove_db_operations.is_empty() { + self.apply_batch_grovedb_operations( + estimated_costs_only_with_layer_info, + transaction, + grove_db_operations, + drive_operations, + drive_version, + )?; + } drive_operations.append(&mut other_operations); Ok(()) } From 6742e55aacd0739ca765809252276f16ec401b1b Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Thu, 8 Aug 2024 17:40:25 +0700 Subject: [PATCH 22/33] set to mainnet --- packages/rs-drive-abci/src/config.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/rs-drive-abci/src/config.rs b/packages/rs-drive-abci/src/config.rs index 9513f93dc4..ca2128de5d 100644 --- a/packages/rs-drive-abci/src/config.rs +++ b/packages/rs-drive-abci/src/config.rs @@ -572,8 +572,7 @@ impl PlatformConfig { } fn default_network() -> Network { - Network::Regtest //todo: Do not leave this as regtest - // TODO: Yes, must be mainnet + Network::Dash } fn default_tokio_console_address() -> String { From a25cdb8bc3afd556d781268c401caaf5ec45894d Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 12 Aug 2024 11:44:01 +0700 Subject: [PATCH 23/33] another fix --- .../v0/mod.rs | 19 ++++++++----------- .../v0/mod.rs | 3 ++- .../tests/strategy_tests/main.rs | 6 +++--- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs index 7115b89e38..f1f826028e 100644 --- a/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs +++ b/packages/rs-dpp/src/core_subsidy/epoch_core_reward_credits_for_distribution/v0/mod.rs @@ -26,10 +26,7 @@ pub(super) fn epoch_core_reward_credits_for_distribution_v0( core_subsidy_halving_interval: u32, ) -> Result { if from_start_block_core_height > to_end_block_core_height_included { - return Err(ProtocolError::CorruptedCodeExecution(format!( - "from start block {} must be before or equal to end block core height {}", - from_start_block_core_height, to_end_block_core_height_included - ))); + return Ok(0) } // Core is halving block rewards every year so we need to pay // core block rewards according to halving ratio for the all years during @@ -55,23 +52,23 @@ pub(super) fn epoch_core_reward_credits_for_distribution_v0( let mut total_core_rewards = 0; // Calculate block rewards for each core reward year during the platform epoch payout period - for core_reward_year in start_core_reward_year..=end_core_reward_year { + for core_reward_epoch in start_core_reward_year..=end_core_reward_year { // Calculate the block count per core reward year // If we are on the end core reward year // We use the previous_from_start_block_core_height // For example if we are calculating 2000 to 2001 // We should have one block on start core year and one block on end core year - let core_reward_year_start_block = if core_reward_year == start_core_reward_year { + let core_reward_year_start_block = if core_reward_epoch == start_core_reward_year { previous_from_start_block_core_height } else { - core_reward_year as u32 * core_subsidy_halving_interval + core_reward_epoch as u32 * core_subsidy_halving_interval }; - let core_reward_year_end_block = if core_reward_year == end_core_reward_year { + let core_reward_year_end_block = if core_reward_epoch == end_core_reward_year { to_end_block_core_height_included } else { - (core_reward_year + 1) as u32 * core_subsidy_halving_interval + (core_reward_epoch + 1) as u32 * core_subsidy_halving_interval }; let block_count = core_reward_year_end_block - core_reward_year_start_block; @@ -79,8 +76,8 @@ pub(super) fn epoch_core_reward_credits_for_distribution_v0( // Fetch the core block distribution for the corresponding epoch from the distribution table // Default to 0 if the core reward year is more than 100 years in the future let core_block_distribution_ratio = CORE_HALVING_DISTRIBUTION - .get(&core_reward_year) - .unwrap_or(&0); + .get(&core_reward_epoch) + .ok_or(ProtocolError::NotSupported(format!("having distribution not supported for core reward epoch {}", core_reward_epoch)))?; // Calculate the core rewards for this epoch and add to the total total_core_rewards += block_count as Credits * *core_block_distribution_ratio; diff --git a/packages/rs-drive-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations/v0/mod.rs index 90d14aaa23..dbc0ddb09b 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_distribute_fees_from_oldest_unpaid_epoch_pool_to_proposers_operations/v0/mod.rs @@ -49,8 +49,9 @@ impl Platform { }; // Calculate core block reward for the unpaid epoch + // The unpdaid epochs start block has had it's credits distributed, so we must do a + 1 let core_block_rewards = epoch_core_reward_credits_for_distribution( - start_block_core_height, + start_block_core_height + 1, unpaid_epoch.next_epoch_start_block_core_height, self.config.network.core_subsidy_halving_interval(), platform_version, diff --git a/packages/rs-drive-abci/tests/strategy_tests/main.rs b/packages/rs-drive-abci/tests/strategy_tests/main.rs index 897f1b4bcc..b9d19a2b35 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/main.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/main.rs @@ -1194,7 +1194,7 @@ mod tests { .unwrap() .unwrap() ), - "3391a28d8a7fed61516eee99c3df8878f9788085f1dc5b3882230de32bdce112".to_string() + "ab195045304053357267bd2044ccfcf5773b8f9a2724a767559f915d49cecc1d".to_string() ) } @@ -1915,7 +1915,7 @@ mod tests { .unwrap() .unwrap() ), - "3d1a0cc92c1ee52ce0f4f2be6fea8a3e4e05f4a6dfda77e923a85fec282e3924".to_string() + "7d28354353e8a0e300a09f52820934d8aff376cd5b4b8c00321776396faa3df0".to_string() ) } @@ -2050,7 +2050,7 @@ mod tests { .unwrap() .unwrap() ), - "1350389e5ad6f9b79f8219a169fbb5d70651d1f4760ae8a5afcb6c119fb56c4e".to_string() + "afb99810fec251dfb76fcd5fe82f19eb9b9938076a12b5e7db7bef48ef5f69fc".to_string() ) } From b70c5bd53159ee9c1266345c9095da0ed73de3d1 Mon Sep 17 00:00:00 2001 From: owl352 Date: Mon, 12 Aug 2024 14:06:13 +0500 Subject: [PATCH 24/33] initial commit --- .../v0/nodejs/PlatformPromiseClient.js | 39 +++++++++++++++++++ .../methods/platform/PlatformMethodsFacade.js | 2 + .../GetTotalCreditsOnPlatformResponse.js | 3 +- .../getTotalCreditsOnPlatformFactory.js | 12 +++--- 4 files changed, 49 insertions(+), 7 deletions(-) diff --git a/packages/dapi-grpc/clients/platform/v0/nodejs/PlatformPromiseClient.js b/packages/dapi-grpc/clients/platform/v0/nodejs/PlatformPromiseClient.js index d56eaf8f30..2356da8e04 100644 --- a/packages/dapi-grpc/clients/platform/v0/nodejs/PlatformPromiseClient.js +++ b/packages/dapi-grpc/clients/platform/v0/nodejs/PlatformPromiseClient.js @@ -58,6 +58,8 @@ const { GetIdentityNonceResponse: PBJSGetIdentityNonceResponse, GetIdentityKeysRequest: PBJSGetIdentityKeysRequest, GetIdentityKeysResponse: PBJSGetIdentityKeysResponse, + GetTotalCreditsInPlatformRequest: PBJSGetTotalCreditsInPlatformRequest, + GetTotalCreditsInPlatformResponse: PBJSGetTotalCreditsInPlatformResponse }, }, }, @@ -82,6 +84,7 @@ const { GetIdentityContractNonceResponse: ProtocGetIdentityContractNonceResponse, GetIdentityNonceResponse: ProtocGetIdentityNonceResponse, GetIdentityKeysResponse: ProtocGetIdentityKeysResponse, + GetTotalCreditsInPlatformResponse: ProtocGetTotalCreditsInPlatformResponse } = require('./platform_protoc'); const getPlatformDefinition = require('../../../../lib/getPlatformDefinition'); @@ -172,6 +175,10 @@ class PlatformPromiseClient { this.client.getIdentityKeys.bind(this.client), ); + this.client.getTotalCreditsInPlatform = promisify( + this.client.getTotalCreditsInPlatform.bind(this.client), + ); + this.protocolVersion = undefined; } @@ -690,6 +697,38 @@ class PlatformPromiseClient { ); } + // getTotalCreditsInPlatform + + getTotalCreditsInPlatform( + getTotalCreditsInPlatformRequest, + metadata = {}, + options = {}, + ) { + if (!isObject(metadata)) { + throw new Error('metadata must be an object'); + } + + return this.client.getTotalCreditsInPlatform( + getTotalCreditsInPlatformRequest, + convertObjectToMetadata(metadata), + { + interceptors: [ + jsonToProtobufInterceptorFactory( + jsonToProtobufFactory( + ProtocGetTotalCreditsInPlatformResponse, + PBJSGetTotalCreditsInPlatformResponse, + ), + protobufToJsonFactory( + PBJSGetTotalCreditsInPlatformRequest, + ), + ), + ], + ...options, + }, + ); + } + + /** * @param {string} protocolVersion */ diff --git a/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js b/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js index e82f776cbb..9530005411 100644 --- a/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js +++ b/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js @@ -13,6 +13,7 @@ const getProtocolVersionUpgradeStateFactory = require('./getProtocolVersionUpgra const getIdentityContractNonceFactory = require('./getIdentityContractNonce/getIdentityContractNonceFactory'); const getIdentityNonceFactory = require('./getIdentityNonce/getIdentityNonceFactory'); const getIdentityKeysFactory = require('./getIdentityKeys/getIdentityKeysFactory'); +const getTotalCreditsFactory = require('./getTotalCreditsOnPlatform/getTotalCreditsOnPlatformFactory') class PlatformMethodsFacade { /** @@ -36,6 +37,7 @@ class PlatformMethodsFacade { this.getIdentityContractNonce = getIdentityContractNonceFactory(grpcTransport); this.getIdentityNonce = getIdentityNonceFactory(grpcTransport); this.getIdentityKeys = getIdentityKeysFactory(grpcTransport); + this.getTotalCredits = getTotalCreditsFactory(grpcTransport) } } diff --git a/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/GetTotalCreditsOnPlatformResponse.js b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/GetTotalCreditsOnPlatformResponse.js index 5f4a8f71c3..2f40101613 100644 --- a/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/GetTotalCreditsOnPlatformResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/GetTotalCreditsOnPlatformResponse.js @@ -26,7 +26,8 @@ class GetTotalCreditsOnPlatformResponse extends AbstractResponse { */ static createFromProto(proto) { // eslint-disable-next-line - const totalCreditsOnPlatform = proto.getV0().getTotalCreditsOnPlatform(); + const totalCreditsOnPlatform = proto.getV0().getCredits(); + const { metadata, proof } = AbstractResponse.createMetadataAndProofFromProto( proto, ); diff --git a/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/getTotalCreditsOnPlatformFactory.js b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/getTotalCreditsOnPlatformFactory.js index fdd7a00f84..07c51eeca2 100644 --- a/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/getTotalCreditsOnPlatformFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/getTotalCreditsOnPlatformFactory.js @@ -1,7 +1,7 @@ const { v0: { PlatformPromiseClient, - GetTotalCreditsOnPlatformRequest, + GetTotalCreditsInPlatformRequest, }, } = require('@dashevo/dapi-grpc'); @@ -21,14 +21,14 @@ function getTotalCreditsOnPlatformFactory(grpcTransport) { */ async function getTotalCreditsOnPlatform(options = {}) { const { - GetTotalCreditsOnPlatformRequestV0, - } = GetTotalCreditsOnPlatformRequest; + GetTotalCreditsInPlatformRequestV0, + } = GetTotalCreditsInPlatformRequest; // eslint-disable-next-line max-len - const getTotalCreditsOnPlatformRequest = new GetTotalCreditsOnPlatformRequest(); + const getTotalCreditsOnPlatformRequest = new GetTotalCreditsInPlatformRequest(); getTotalCreditsOnPlatformRequest.setV0( - new GetTotalCreditsOnPlatformRequestV0() + new GetTotalCreditsInPlatformRequestV0() .setProve(!!options.prove), ); @@ -40,7 +40,7 @@ function getTotalCreditsOnPlatformFactory(grpcTransport) { // eslint-disable-next-line no-await-in-loop const getTotalCreditsOnPlatformResponse = await grpcTransport.request( PlatformPromiseClient, - 'getTotalCreditsOnPlatform', + 'getTotalCreditsInPlatform', getTotalCreditsOnPlatformRequest, options, ); From f1d12090fb72255dfe83aefc0be97b603004b4a2 Mon Sep 17 00:00:00 2001 From: owl352 Date: Mon, 12 Aug 2024 14:19:50 +0500 Subject: [PATCH 25/33] names fix --- .../getTotalCreditsOnPlatformFactory.js | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/getTotalCreditsOnPlatformFactory.js b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/getTotalCreditsOnPlatformFactory.js index 07c51eeca2..e53c6034f7 100644 --- a/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/getTotalCreditsOnPlatformFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/getTotalCreditsOnPlatformFactory.js @@ -5,29 +5,29 @@ const { }, } = require('@dashevo/dapi-grpc'); -const GetTotalCreditsOnPlatformResponse = require('./GetTotalCreditsOnPlatformResponse'); +const GetTotalCreditsInPlatformResponse = require('./GetTotalCreditsOnPlatformResponse'); const InvalidResponseError = require('../response/errors/InvalidResponseError'); /** * @param {GrpcTransport} grpcTransport - * @returns {getTotalCreditsOnPlatform} + * @returns {getTotalCreditsInPlatform} */ -function getTotalCreditsOnPlatformFactory(grpcTransport) { +function getTotalCreditsInPlatformFactory(grpcTransport) { /** * Fetch the version upgrade votes status - * @typedef {getTotalCreditsOnPlatform} + * @typedef {getTotalCreditsInPlatform} * @param {DAPIClientOptions & {prove: boolean}} [options] - * @returns {Promise} + * @returns {Promise} */ - async function getTotalCreditsOnPlatform(options = {}) { + async function getTotalCreditsInPlatform(options = {}) { const { GetTotalCreditsInPlatformRequestV0, } = GetTotalCreditsInPlatformRequest; // eslint-disable-next-line max-len - const getTotalCreditsOnPlatformRequest = new GetTotalCreditsInPlatformRequest(); + const getTotalCreditsInPlatformRequest = new GetTotalCreditsInPlatformRequest(); - getTotalCreditsOnPlatformRequest.setV0( + getTotalCreditsInPlatformRequest.setV0( new GetTotalCreditsInPlatformRequestV0() .setProve(!!options.prove), ); @@ -38,15 +38,15 @@ function getTotalCreditsOnPlatformFactory(grpcTransport) { for (let i = 0; i < 3; i += 1) { try { // eslint-disable-next-line no-await-in-loop - const getTotalCreditsOnPlatformResponse = await grpcTransport.request( + const getTotalCreditsInPlatformResponse = await grpcTransport.request( PlatformPromiseClient, 'getTotalCreditsInPlatform', - getTotalCreditsOnPlatformRequest, + getTotalCreditsInPlatformRequest, options, ); - return GetTotalCreditsOnPlatformResponse - .createFromProto(getTotalCreditsOnPlatformResponse); + return GetTotalCreditsInPlatformResponse + .createFromProto(getTotalCreditsInPlatformResponse); } catch (e) { if (e instanceof InvalidResponseError) { lastError = e; @@ -61,7 +61,7 @@ function getTotalCreditsOnPlatformFactory(grpcTransport) { throw lastError; } - return getTotalCreditsOnPlatform; + return getTotalCreditsInPlatform; } -module.exports = getTotalCreditsOnPlatformFactory; +module.exports = getTotalCreditsInPlatformFactory; From 9371b87b4cecfe1c9cfdebcd7821fb8c051cdd8a Mon Sep 17 00:00:00 2001 From: owl352 Date: Wed, 14 Aug 2024 13:29:44 +0500 Subject: [PATCH 26/33] fix response --- .../GetTotalCreditsOnPlatformResponse.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/GetTotalCreditsOnPlatformResponse.js b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/GetTotalCreditsOnPlatformResponse.js index 5f4a8f71c3..2f40101613 100644 --- a/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/GetTotalCreditsOnPlatformResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/GetTotalCreditsOnPlatformResponse.js @@ -26,7 +26,8 @@ class GetTotalCreditsOnPlatformResponse extends AbstractResponse { */ static createFromProto(proto) { // eslint-disable-next-line - const totalCreditsOnPlatform = proto.getV0().getTotalCreditsOnPlatform(); + const totalCreditsOnPlatform = proto.getV0().getCredits(); + const { metadata, proof } = AbstractResponse.createMetadataAndProofFromProto( proto, ); From 14a8ea70c67ee366f673201b95a93b19931641dc Mon Sep 17 00:00:00 2001 From: owl352 Date: Wed, 14 Aug 2024 13:42:27 +0500 Subject: [PATCH 27/33] names fix --- .../v0/nodejs/PlatformPromiseClient.js | 2 -- .../methods/platform/PlatformMethodsFacade.js | 2 +- .../GetTotalCreditsInPlatformResponse.js} | 10 +++--- .../getTotalCreditsInPlatformFactory.js} | 36 +++++++++---------- 4 files changed, 24 insertions(+), 26 deletions(-) rename packages/js-dapi-client/lib/methods/platform/{getTotalCreditsOnPlatform/GetTotalCreditsOnPlatformResponse.js => getTotalCreditsInPlatform/GetTotalCreditsInPlatformResponse.js} (80%) rename packages/js-dapi-client/lib/methods/platform/{getTotalCreditsOnPlatform/getTotalCreditsOnPlatformFactory.js => getTotalCreditsInPlatform/getTotalCreditsInPlatformFactory.js} (52%) diff --git a/packages/dapi-grpc/clients/platform/v0/nodejs/PlatformPromiseClient.js b/packages/dapi-grpc/clients/platform/v0/nodejs/PlatformPromiseClient.js index 2356da8e04..7e8429dbfa 100644 --- a/packages/dapi-grpc/clients/platform/v0/nodejs/PlatformPromiseClient.js +++ b/packages/dapi-grpc/clients/platform/v0/nodejs/PlatformPromiseClient.js @@ -697,8 +697,6 @@ class PlatformPromiseClient { ); } - // getTotalCreditsInPlatform - getTotalCreditsInPlatform( getTotalCreditsInPlatformRequest, metadata = {}, diff --git a/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js b/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js index 9530005411..80cdd0226c 100644 --- a/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js +++ b/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js @@ -13,7 +13,7 @@ const getProtocolVersionUpgradeStateFactory = require('./getProtocolVersionUpgra const getIdentityContractNonceFactory = require('./getIdentityContractNonce/getIdentityContractNonceFactory'); const getIdentityNonceFactory = require('./getIdentityNonce/getIdentityNonceFactory'); const getIdentityKeysFactory = require('./getIdentityKeys/getIdentityKeysFactory'); -const getTotalCreditsFactory = require('./getTotalCreditsOnPlatform/getTotalCreditsOnPlatformFactory') +const getTotalCreditsFactory = require('./getTotalCreditsInPlatform/getTotalCreditsInPlatformFactory') class PlatformMethodsFacade { /** diff --git a/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/GetTotalCreditsOnPlatformResponse.js b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsInPlatform/GetTotalCreditsInPlatformResponse.js similarity index 80% rename from packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/GetTotalCreditsOnPlatformResponse.js rename to packages/js-dapi-client/lib/methods/platform/getTotalCreditsInPlatform/GetTotalCreditsInPlatformResponse.js index 2f40101613..4c01644d09 100644 --- a/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/GetTotalCreditsOnPlatformResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsInPlatform/GetTotalCreditsInPlatformResponse.js @@ -1,7 +1,7 @@ const AbstractResponse = require('../response/AbstractResponse'); const InvalidResponseError = require('../response/errors/InvalidResponseError'); -class GetTotalCreditsOnPlatformResponse extends AbstractResponse { +class GetTotalCreditsInPlatformResponse extends AbstractResponse { /** * @param {number} totalCreditsOnPlatform * @param {Metadata} metadata @@ -16,13 +16,13 @@ class GetTotalCreditsOnPlatformResponse extends AbstractResponse { /** * @returns {number} */ - getTotalCreditsOnPlatform() { + getTotalCreditsInPlatform() { return this.totalCreditsOnPlatform; } /** * @param proto - * @returns {GetTotalCreditsOnPlatformResponse} + * @returns {GetTotalCreditsInPlatformResponse} */ static createFromProto(proto) { // eslint-disable-next-line @@ -36,7 +36,7 @@ class GetTotalCreditsOnPlatformResponse extends AbstractResponse { throw new InvalidResponseError('Total Credits on Platform data is not defined'); } - return new GetTotalCreditsOnPlatformResponse( + return new GetTotalCreditsInPlatformResponse( totalCreditsOnPlatform, metadata, proof, @@ -44,4 +44,4 @@ class GetTotalCreditsOnPlatformResponse extends AbstractResponse { } } -module.exports = GetTotalCreditsOnPlatformResponse; +module.exports = GetTotalCreditsInPlatformResponse; diff --git a/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/getTotalCreditsOnPlatformFactory.js b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsInPlatform/getTotalCreditsInPlatformFactory.js similarity index 52% rename from packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/getTotalCreditsOnPlatformFactory.js rename to packages/js-dapi-client/lib/methods/platform/getTotalCreditsInPlatform/getTotalCreditsInPlatformFactory.js index 0807223965..1bbbd3f022 100644 --- a/packages/js-dapi-client/lib/methods/platform/getTotalCreditsOnPlatform/getTotalCreditsOnPlatformFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsInPlatform/getTotalCreditsInPlatformFactory.js @@ -1,34 +1,34 @@ const { v0: { PlatformPromiseClient, - GetTotalCreditsOnPlatformRequest, + GetTotalCreditsInPlatformRequest, }, } = require('@dashevo/dapi-grpc'); -const GetTotalCreditsOnPlatformResponse = require('./GetTotalCreditsOnPlatformResponse'); +const GetTotalCreditsInPlatformResponse = require('./GetTotalCreditsInPlatformResponse'); const InvalidResponseError = require('../response/errors/InvalidResponseError'); /** * @param {GrpcTransport} grpcTransport - * @returns {getTotalCreditsOnPlatform} + * @returns {getTotalCreditsInPlatform} */ -function getTotalCreditsOnPlatformFactory(grpcTransport) { +function getTotalCreditsInPlatformFactory(grpcTransport) { /** * Fetch the version upgrade votes status - * @typedef {getTotalCreditsOnPlatform} + * @typedef {getTotalCreditsInPlatform} * @param {DAPIClientOptions & {prove: boolean}} [options] - * @returns {Promise} + * @returns {Promise} */ - async function getTotalCreditsOnPlatform(options = {}) { + async function getTotalCreditsInPlatform(options = {}) { const { - GetTotalCreditsOnPlatformRequestV0, - } = GetTotalCreditsOnPlatformRequest; + GetTotalCreditsInPlatformRequestV0, + } = GetTotalCreditsInPlatformRequest; // eslint-disable-next-line max-len - const getTotalCreditsOnPlatformRequest = new GetTotalCreditsOnPlatformRequest(); + const getTotalCreditsInPlatformRequest = new GetTotalCreditsInPlatformRequest(); - getTotalCreditsOnPlatformRequest.setV0( - new GetTotalCreditsOnPlatformRequestV0() + getTotalCreditsInPlatformRequest.setV0( + new GetTotalCreditsInPlatformRequestV0() .setProve(!!options.prove), ); @@ -38,15 +38,15 @@ function getTotalCreditsOnPlatformFactory(grpcTransport) { for (let i = 0; i < 3; i += 1) { try { // eslint-disable-next-line no-await-in-loop - const getTotalCreditsOnPlatformResponse = await grpcTransport.request( + const getTotalCreditsInPlatformResponse = await grpcTransport.request( PlatformPromiseClient, - 'getTotalCreditsOnPlatform', - getTotalCreditsOnPlatformRequest, + 'getTotalCreditsInPlatform', + getTotalCreditsInPlatformRequest, options, ); - return GetTotalCreditsOnPlatformResponse - .createFromProto(getTotalCreditsOnPlatformResponse); + return GetTotalCreditsInPlatformResponse + .createFromProto(getTotalCreditsInPlatformResponse); } catch (e) { if (e instanceof InvalidResponseError) { lastError = e; @@ -64,4 +64,4 @@ function getTotalCreditsOnPlatformFactory(grpcTransport) { return getTotalCreditsInPlatform; } -module.exports = getTotalCreditsOnPlatformFactory; +module.exports = getTotalCreditsInPlatformFactory; From 27ea677cacb10fb533193c1b41b4f67c5958ca01 Mon Sep 17 00:00:00 2001 From: owl352 Date: Wed, 14 Aug 2024 13:46:11 +0500 Subject: [PATCH 28/33] name fix --- .../lib/methods/platform/PlatformMethodsFacade.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js b/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js index 80cdd0226c..2ca4630029 100644 --- a/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js +++ b/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js @@ -13,7 +13,7 @@ const getProtocolVersionUpgradeStateFactory = require('./getProtocolVersionUpgra const getIdentityContractNonceFactory = require('./getIdentityContractNonce/getIdentityContractNonceFactory'); const getIdentityNonceFactory = require('./getIdentityNonce/getIdentityNonceFactory'); const getIdentityKeysFactory = require('./getIdentityKeys/getIdentityKeysFactory'); -const getTotalCreditsFactory = require('./getTotalCreditsInPlatform/getTotalCreditsInPlatformFactory') +const getTotalCreditsInPlatformFactory = require('./getTotalCreditsInPlatform/getTotalCreditsInPlatformFactory') class PlatformMethodsFacade { /** @@ -37,7 +37,7 @@ class PlatformMethodsFacade { this.getIdentityContractNonce = getIdentityContractNonceFactory(grpcTransport); this.getIdentityNonce = getIdentityNonceFactory(grpcTransport); this.getIdentityKeys = getIdentityKeysFactory(grpcTransport); - this.getTotalCredits = getTotalCreditsFactory(grpcTransport) + this.getTotalCreditsInPlatform = getTotalCreditsInPlatform(grpcTransport) } } From 36ad576b79462a1e076247a2c15173e6b12f93bf Mon Sep 17 00:00:00 2001 From: owl352 Date: Wed, 14 Aug 2024 13:54:48 +0500 Subject: [PATCH 29/33] names fix --- .../GetTotalCreditsInPlatformResponse.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/js-dapi-client/lib/methods/platform/getTotalCreditsInPlatform/GetTotalCreditsInPlatformResponse.js b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsInPlatform/GetTotalCreditsInPlatformResponse.js index 4c01644d09..ce6f1ae07e 100644 --- a/packages/js-dapi-client/lib/methods/platform/getTotalCreditsInPlatform/GetTotalCreditsInPlatformResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsInPlatform/GetTotalCreditsInPlatformResponse.js @@ -3,21 +3,21 @@ const InvalidResponseError = require('../response/errors/InvalidResponseError'); class GetTotalCreditsInPlatformResponse extends AbstractResponse { /** - * @param {number} totalCreditsOnPlatform + * @param {number} totalCreditsInPlatform * @param {Metadata} metadata * @param {Proof} [proof] */ - constructor(totalCreditsOnPlatform, metadata, proof = undefined) { + constructor(totalCreditsInPlatform, metadata, proof = undefined) { super(metadata, proof); - this.totalCreditsOnPlatform = totalCreditsOnPlatform; + this.totalCreditsInPlatform = totalCreditsInPlatform; } /** * @returns {number} */ getTotalCreditsInPlatform() { - return this.totalCreditsOnPlatform; + return this.totalCreditsInPlatform; } /** @@ -26,18 +26,18 @@ class GetTotalCreditsInPlatformResponse extends AbstractResponse { */ static createFromProto(proto) { // eslint-disable-next-line - const totalCreditsOnPlatform = proto.getV0().getCredits(); + const totalCreditsInPlatform = proto.getV0().getCredits(); const { metadata, proof } = AbstractResponse.createMetadataAndProofFromProto( proto, ); - if ((typeof totalCreditsOnPlatform === 'undefined' || totalCreditsOnPlatform === null) && !proof) { + if ((typeof totalCreditsInPlatform === 'undefined' || totalCreditsInPlatform === null) && !proof) { throw new InvalidResponseError('Total Credits on Platform data is not defined'); } return new GetTotalCreditsInPlatformResponse( - totalCreditsOnPlatform, + totalCreditsInPlatform, metadata, proof, ); From f7a40631f56232b837994e172c1c98bea8ab5088 Mon Sep 17 00:00:00 2001 From: owl352 Date: Wed, 14 Aug 2024 14:46:52 +0500 Subject: [PATCH 30/33] facade fix --- .../lib/methods/platform/PlatformMethodsFacade.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js b/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js index 2ca4630029..5e9cbfaa2d 100644 --- a/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js +++ b/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js @@ -37,7 +37,7 @@ class PlatformMethodsFacade { this.getIdentityContractNonce = getIdentityContractNonceFactory(grpcTransport); this.getIdentityNonce = getIdentityNonceFactory(grpcTransport); this.getIdentityKeys = getIdentityKeysFactory(grpcTransport); - this.getTotalCreditsInPlatform = getTotalCreditsInPlatform(grpcTransport) + this.getTotalCreditsInPlatform = getTotalCreditsInPlatformFactory(grpcTransport) } } From 258cfb20854bcfe708fbeab84587b00b6ffb2c37 Mon Sep 17 00:00:00 2001 From: owl352 Date: Wed, 14 Aug 2024 16:30:34 +0500 Subject: [PATCH 31/33] fix response --- .../GetTotalCreditsInPlatformResponse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/js-dapi-client/lib/methods/platform/getTotalCreditsInPlatform/GetTotalCreditsInPlatformResponse.js b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsInPlatform/GetTotalCreditsInPlatformResponse.js index bf197cf373..a682d646d3 100644 --- a/packages/js-dapi-client/lib/methods/platform/getTotalCreditsInPlatform/GetTotalCreditsInPlatformResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsInPlatform/GetTotalCreditsInPlatformResponse.js @@ -26,7 +26,7 @@ class GetTotalCreditsInPlatformResponse extends AbstractResponse { */ static createFromProto(proto) { // eslint-disable-next-line - const totalCreditsInPlatform = proto.getV0().getTotalCreditsInPlatform(); + const totalCreditsInPlatform = proto.getV0().getCredits(); const { metadata, proof } = AbstractResponse.createMetadataAndProofFromProto( proto, ); From 727f40501ecde1e5012e999b995bdeadb8b6a410 Mon Sep 17 00:00:00 2001 From: pshenmic Date: Wed, 14 Aug 2024 19:00:01 +0700 Subject: [PATCH 32/33] chore(dapi): lint fix --- .../lib/methods/platform/PlatformMethodsFacade.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js b/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js index 5e9cbfaa2d..b9659142ec 100644 --- a/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js +++ b/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js @@ -13,7 +13,7 @@ const getProtocolVersionUpgradeStateFactory = require('./getProtocolVersionUpgra const getIdentityContractNonceFactory = require('./getIdentityContractNonce/getIdentityContractNonceFactory'); const getIdentityNonceFactory = require('./getIdentityNonce/getIdentityNonceFactory'); const getIdentityKeysFactory = require('./getIdentityKeys/getIdentityKeysFactory'); -const getTotalCreditsInPlatformFactory = require('./getTotalCreditsInPlatform/getTotalCreditsInPlatformFactory') +const getTotalCreditsInPlatformFactory = require('./getTotalCreditsInPlatform/getTotalCreditsInPlatformFactory'); class PlatformMethodsFacade { /** @@ -37,7 +37,7 @@ class PlatformMethodsFacade { this.getIdentityContractNonce = getIdentityContractNonceFactory(grpcTransport); this.getIdentityNonce = getIdentityNonceFactory(grpcTransport); this.getIdentityKeys = getIdentityKeysFactory(grpcTransport); - this.getTotalCreditsInPlatform = getTotalCreditsInPlatformFactory(grpcTransport) + this.getTotalCreditsInPlatform = getTotalCreditsInPlatformFactory(grpcTransport); } } From 047783c0f0edde778e5aad2eb38c66041779b8dc Mon Sep 17 00:00:00 2001 From: pshenmic Date: Wed, 14 Aug 2024 19:00:24 +0700 Subject: [PATCH 33/33] chore(dapi): lint fix --- .../clients/platform/v0/nodejs/PlatformPromiseClient.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/dapi-grpc/clients/platform/v0/nodejs/PlatformPromiseClient.js b/packages/dapi-grpc/clients/platform/v0/nodejs/PlatformPromiseClient.js index 7e8429dbfa..e7606a52bc 100644 --- a/packages/dapi-grpc/clients/platform/v0/nodejs/PlatformPromiseClient.js +++ b/packages/dapi-grpc/clients/platform/v0/nodejs/PlatformPromiseClient.js @@ -59,7 +59,7 @@ const { GetIdentityKeysRequest: PBJSGetIdentityKeysRequest, GetIdentityKeysResponse: PBJSGetIdentityKeysResponse, GetTotalCreditsInPlatformRequest: PBJSGetTotalCreditsInPlatformRequest, - GetTotalCreditsInPlatformResponse: PBJSGetTotalCreditsInPlatformResponse + GetTotalCreditsInPlatformResponse: PBJSGetTotalCreditsInPlatformResponse, }, }, }, @@ -84,7 +84,7 @@ const { GetIdentityContractNonceResponse: ProtocGetIdentityContractNonceResponse, GetIdentityNonceResponse: ProtocGetIdentityNonceResponse, GetIdentityKeysResponse: ProtocGetIdentityKeysResponse, - GetTotalCreditsInPlatformResponse: ProtocGetTotalCreditsInPlatformResponse + GetTotalCreditsInPlatformResponse: ProtocGetTotalCreditsInPlatformResponse, } = require('./platform_protoc'); const getPlatformDefinition = require('../../../../lib/getPlatformDefinition'); @@ -726,7 +726,6 @@ class PlatformPromiseClient { ); } - /** * @param {string} protocolVersion */