Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions packages/rs-dpp/src/data_contract/serialized_version/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,37 @@ impl DataContractInSerializationFormat {
DataContractInSerializationFormat::V1(v1) => &v1.tokens,
}
}

pub fn eq_without_auto_fields(&self, other: &Self) -> bool {
match (self, other) {
(
DataContractInSerializationFormat::V0(v0_self),
DataContractInSerializationFormat::V0(v0_other),
) => v0_self == v0_other,
(
DataContractInSerializationFormat::V1(v1_self),
DataContractInSerializationFormat::V1(v1_other),
) => {
v1_self.id == v1_other.id
&& v1_self.config == v1_other.config
&& v1_self.version == v1_other.version
&& v1_self.owner_id == v1_other.owner_id
&& v1_self.schema_defs == v1_other.schema_defs
&& v1_self.document_schemas == v1_other.document_schemas
&& v1_self.groups == v1_other.groups
&& v1_self.tokens == v1_other.tokens
}
// Cross-version comparisons return false
(
DataContractInSerializationFormat::V0(_),
DataContractInSerializationFormat::V1(_),
)
| (
DataContractInSerializationFormat::V1(_),
DataContractInSerializationFormat::V0(_),
) => false,
}
}
}

impl TryFromPlatformVersioned<DataContractV0> for DataContractInSerializationFormat {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@ impl Drive {
let contract_for_serialization: DataContractInSerializationFormat = contract
.clone()
.try_into_platform_versioned(platform_version)?;
if &contract_for_serialization != data_contract_create.data_contract() {

if !contract_for_serialization
.eq_without_auto_fields(data_contract_create.data_contract())
{
return Err(Error::Proof(ProofError::IncorrectProof(format!("proof of state transition execution did not contain exact expected contract after create with id {}", data_contract_create.data_contract().id()))));
}

Ok((root_hash, VerifiedDataContract(contract)))
}
StateTransition::DataContractUpdate(data_contract_update) => {
Expand Down