Skip to content

Commit

Permalink
feat(platform)!: contested document resolution with masternode voting (
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumExplorer authored Jul 9, 2024
2 parents 11a7bc7 + 0e29160 commit 72c65b6
Show file tree
Hide file tree
Showing 1,010 changed files with 103,253 additions and 20,749 deletions.
1,135 changes: 667 additions & 468 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ WORKDIR /platform

COPY . .

# Workaround: as we cache dapi-grpc, its build.rs is not rerun, so we need to touch it
RUN touch /platform/packages/dapi-grpc/build.rs

#
# STAGE: BUILD RS-DRIVE-ABCI
#
Expand Down
21 changes: 12 additions & 9 deletions packages/check-features/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ use toml::Value;

fn main() {
let crates = [
"rs-sdk",
"rs-drive-abci",
"rs-dpp",
"rs-drive",
"rs-drive-proof-verifier",
("rs-sdk", vec![]),
("rs-drive-abci", vec![]),
("rs-dpp", vec!["documents-faker"]),
("rs-drive", vec![]),
("rs-drive-proof-verifier", vec![]),
];

for specific_crate in crates {
check_crate(specific_crate)
for (specific_crate, to_ignore) in crates {
check_crate(specific_crate, to_ignore)
}
}

fn check_crate(crate_name: &str) {
fn check_crate(crate_name: &str, to_ignore: Vec<&str>) {
// Construct the path to the Cargo.toml file for each crate
let cargo_toml_path = format!("packages/{}/Cargo.toml", crate_name);

Expand Down Expand Up @@ -77,7 +77,10 @@ fn check_crate(crate_name: &str) {

for (feature, _) in features.as_table().unwrap().iter() {
// Skip special feature groups
if feature == "default" || feature.ends_with("features") {
if feature == "default"
|| feature.ends_with("features")
|| to_ignore.contains(&feature.as_str())
{
continue;
}

Expand Down
4 changes: 3 additions & 1 deletion packages/dapi-grpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ tonic = { version = "0.11", features = [
serde = { version = "1.0.197", optional = true, features = ["derive"] }
serde_bytes = { version = "0.11.12", optional = true }
serde_json = { version = "1.0", optional = true }
tenderdash-proto = { git = "https://github.com/dashpay/rs-tenderdash-abci", version = "1.0.0", tag = "v1.0.0", default-features = false }
tenderdash-proto = { git = "https://github.com/dashpay/rs-tenderdash-abci", version = "1.0.0", tag = "v1.0.0", default-features = false, features = [
"grpc",
] }
dapi-grpc-macros = { path = "../rs-dapi-grpc-macros" }
platform-version = { path = "../rs-platform-version" }

Expand Down
42 changes: 40 additions & 2 deletions packages/dapi-grpc/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{
collections::HashSet,
fs::{create_dir_all, remove_dir_all},
path::PathBuf,
process::exit,
Expand Down Expand Up @@ -46,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; 19] = [
const VERSIONED_REQUESTS: [&str; 25] = [
"GetDataContractHistoryRequest",
"GetDataContractRequest",
"GetDataContractsRequest",
Expand All @@ -66,10 +67,16 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig {
"GetProtocolVersionUpgradeVoteStatusRequest",
"GetPathElementsRequest",
"GetIdentitiesContractKeysRequest",
"GetPrefundedSpecializedBalanceRequest",
"GetContestedResourcesRequest",
"GetContestedResourceVoteStateRequest",
"GetContestedResourceVotersForIdentityRequest",
"GetContestedResourceIdentityVotesRequest",
"GetVotePollsByEndDateRequest",
];

// "GetConsensusParamsResponse" is excluded as this message does not support proofs
const VERSIONED_RESPONSES: [&str; 20] = [
const VERSIONED_RESPONSES: [&str; 26] = [
"GetDataContractHistoryResponse",
"GetDataContractResponse",
"GetDataContractsResponse",
Expand All @@ -90,8 +97,17 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig {
"GetProtocolVersionUpgradeVoteStatusResponse",
"GetPathElementsResponse",
"GetIdentitiesContractKeysResponse",
"GetPrefundedSpecializedBalanceResponse",
"GetContestedResourcesResponse",
"GetContestedResourceVoteStateResponse",
"GetContestedResourceVotersForIdentityResponse",
"GetContestedResourceIdentityVotesResponse",
"GetVotePollsByEndDateResponse",
];

check_unique(&VERSIONED_REQUESTS).expect("VERSIONED_REQUESTS");
check_unique(&VERSIONED_RESPONSES).expect("VERSIONED_RESPONSES");

// Derive VersionedGrpcMessage on requests
for msg in VERSIONED_REQUESTS {
platform = platform
Expand Down Expand Up @@ -146,6 +162,28 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig {
platform
}

/// Check for duplicate messages in the list.
fn check_unique(messages: &[&'static str]) -> Result<(), String> {
let mut hashset: HashSet<&'static str> = HashSet::new();
let mut duplicates = String::new();

for value in messages {
if !hashset.insert(*value) {
duplicates.push_str(value);
duplicates.push_str(", ");
}
}

if duplicates.is_empty() {
Ok(())
} else {
Err(format!(
"Duplicate messages found: {}",
duplicates.trim_end_matches(", ")
))
}
}

fn configure_core(core: MappingConfig) -> MappingConfig {
// All messages can be mocked.
let core = core.message_attribute(".", r#"#[derive(::dapi_grpc_macros::Mockable)]"#);
Expand Down
Loading

0 comments on commit 72c65b6

Please sign in to comment.