Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix(dpp)!: wrapping overflow issue #2430

Merged
merged 2 commits into from
Jan 17, 2025
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
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
use crate::data_contract::document_type::v0::DocumentTypeV0;

use crate::ProtocolError;
use platform_version::version::PlatformVersion;
// If another document type (like V1) ever were to exist we would need to implement estimated_size_v0 again

impl DocumentTypeV0 {
/// The estimated size uses the middle ceil size of all attributes
pub(in crate::data_contract::document_type) fn estimated_size_v0(&self) -> u16 {
let mut iter = self
.flattened_properties
.iter()
.filter_map(|(_, document_property)| {
document_property.property_type.middle_byte_size_ceil()
});
let first = Some(iter.next().unwrap_or_default());
pub(in crate::data_contract::document_type) fn estimated_size_v0(
&self,
platform_version: &PlatformVersion,
) -> Result<u16, ProtocolError> {
let mut total_size = 0u16;

for (_, document_property) in self.flattened_properties.iter() {
// This call now returns a Result<Option<u16>, ProtocolError>.
let maybe_size = document_property
.property_type
.middle_byte_size_ceil(platform_version)?;

if let Some(size) = maybe_size {
total_size = match total_size.checked_add(size) {
Some(new_total) => new_total,
None => {
return Ok(u16::MAX);
}
};
}
}

iter.fold(first, |acc, item| acc.and_then(|acc| acc.checked_add(item)))
.unwrap_or(u16::MAX)
Ok(total_size)
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
use crate::data_contract::document_type::v0::DocumentTypeV0;

use crate::ProtocolError;
use platform_version::version::PlatformVersion;
// If another document type (like V1) ever were to exist we would need to implement max_size_v0 again

impl DocumentTypeV0 {
pub(in crate::data_contract::document_type) fn max_size_v0(&self) -> u16 {
let mut iter = self
.flattened_properties
.iter()
.filter_map(|(_, document_property)| document_property.property_type.max_byte_size());
let first = Some(iter.next().unwrap_or_default());
pub(in crate::data_contract::document_type) fn max_size_v0(
&self,
platform_version: &PlatformVersion,
) -> Result<u16, ProtocolError> {
let mut total_size = 0u16;

for (_, document_property) in self.flattened_properties.iter() {
let maybe_size = document_property
.property_type
.max_byte_size(platform_version)?;

if let Some(size) = maybe_size {
total_size = match total_size.checked_add(size) {
Some(new_total) => new_total,
None => {
return Ok(u16::MAX);
}
};
}
}

iter.fold(first, |acc, item| acc.and_then(|acc| acc.checked_add(item)))
.unwrap_or(u16::MAX)
Ok(total_size)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl DocumentTypeV0Methods for DocumentTypeV0 {
.methods
.max_size
{
0 => Ok(self.max_size_v0()),
0 => self.max_size_v0(platform_version),
version => Err(ProtocolError::UnknownVersionMismatch {
method: "max_size".to_string(),
known_versions: vec![0],
Expand All @@ -239,7 +239,7 @@ impl DocumentTypeV0Methods for DocumentTypeV0 {
.methods
.estimated_size
{
0 => Ok(self.estimated_size_v0()),
0 => self.estimated_size_v0(platform_version),
version => Err(ProtocolError::UnknownVersionMismatch {
method: "estimated_size".to_string(),
known_versions: vec![0],
Expand Down
195 changes: 113 additions & 82 deletions packages/rs-dpp/src/data_contract/document_type/property/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use indexmap::IndexMap;
use integer_encoding::{VarInt, VarIntReader};
use platform_value::{Identifier, Value};
use platform_version::version::PlatformVersion;
use rand::distributions::{Alphanumeric, Standard};
use rand::rngs::StdRng;
use rand::Rng;
Expand Down Expand Up @@ -159,69 +160,93 @@
}
}

pub fn min_byte_size(&self) -> Option<u16> {
pub fn min_byte_size(
&self,
platform_version: &PlatformVersion,
) -> Result<Option<u16>, ProtocolError> {
match self {
DocumentPropertyType::U128 => Some(16),
DocumentPropertyType::I128 => Some(16),
DocumentPropertyType::U64 => Some(8),
DocumentPropertyType::I64 => Some(8),
DocumentPropertyType::U32 => Some(4),
DocumentPropertyType::I32 => Some(4),
DocumentPropertyType::U16 => Some(2),
DocumentPropertyType::I16 => Some(2),
DocumentPropertyType::U8 => Some(1),
DocumentPropertyType::I8 => Some(1),
DocumentPropertyType::F64 => Some(8),
DocumentPropertyType::U128 => Ok(Some(16)),
DocumentPropertyType::I128 => Ok(Some(16)),
DocumentPropertyType::U64 => Ok(Some(8)),
DocumentPropertyType::I64 => Ok(Some(8)),
DocumentPropertyType::U32 => Ok(Some(4)),
DocumentPropertyType::I32 => Ok(Some(4)),
DocumentPropertyType::U16 => Ok(Some(2)),
DocumentPropertyType::I16 => Ok(Some(2)),
DocumentPropertyType::U8 => Ok(Some(1)),
DocumentPropertyType::I8 => Ok(Some(1)),
DocumentPropertyType::F64 => Ok(Some(8)),
DocumentPropertyType::String(sizes) => match sizes.min_length {
None => Some(0),
Some(size) => Some(size * 4),
None => Ok(Some(0)),
Some(size) => {
if platform_version.protocol_version > 8 {
match size.checked_mul(4) {
Some(mul) => Ok(Some(mul)),
None => Err(ProtocolError::Overflow("min_byte_size overflow")),
}
} else {
Ok(Some(size.wrapping_mul(4)))
}
}
},
DocumentPropertyType::ByteArray(sizes) => match sizes.min_size {
None => Some(0),
Some(size) => Some(size),
None => Ok(Some(0)),
Some(size) => Ok(Some(size)),
},
DocumentPropertyType::Boolean => Some(1),
DocumentPropertyType::Date => Some(8),
DocumentPropertyType::Boolean => Ok(Some(1)),
DocumentPropertyType::Date => Ok(Some(8)),
DocumentPropertyType::Object(sub_fields) => sub_fields
.iter()
.map(|(_, sub_field)| sub_field.property_type.min_byte_size())
.map(|(_, sub_field)| sub_field.property_type.min_byte_size(platform_version))
.sum(),
DocumentPropertyType::Array(_) => None,
DocumentPropertyType::VariableTypeArray(_) => None,
DocumentPropertyType::Identifier => Some(32),
DocumentPropertyType::Array(_) => Ok(None),
DocumentPropertyType::VariableTypeArray(_) => Ok(None),
DocumentPropertyType::Identifier => Ok(Some(32)),
}
}

pub fn max_byte_size(&self) -> Option<u16> {
pub fn max_byte_size(
&self,
platform_version: &PlatformVersion,
) -> Result<Option<u16>, ProtocolError> {
match self {
DocumentPropertyType::U128 => Some(16),
DocumentPropertyType::I128 => Some(16),
DocumentPropertyType::U64 => Some(8),
DocumentPropertyType::I64 => Some(8),
DocumentPropertyType::U32 => Some(4),
DocumentPropertyType::I32 => Some(4),
DocumentPropertyType::U16 => Some(2),
DocumentPropertyType::I16 => Some(2),
DocumentPropertyType::U8 => Some(1),
DocumentPropertyType::I8 => Some(1),
DocumentPropertyType::F64 => Some(8),
DocumentPropertyType::U128 => Ok(Some(16)),
DocumentPropertyType::I128 => Ok(Some(16)),
DocumentPropertyType::U64 => Ok(Some(8)),
DocumentPropertyType::I64 => Ok(Some(8)),
DocumentPropertyType::U32 => Ok(Some(4)),
DocumentPropertyType::I32 => Ok(Some(4)),
DocumentPropertyType::U16 => Ok(Some(2)),
DocumentPropertyType::I16 => Ok(Some(2)),
DocumentPropertyType::U8 => Ok(Some(1)),
DocumentPropertyType::I8 => Ok(Some(1)),
DocumentPropertyType::F64 => Ok(Some(8)),
DocumentPropertyType::String(sizes) => match sizes.max_length {
None => Some(u16::MAX),
Some(size) => Some(size * 4),
None => Ok(Some(u16::MAX)),
Some(size) => {
if platform_version.protocol_version > 8 {
match size.checked_mul(4) {
Some(mul) => Ok(Some(mul)),
None => Err(ProtocolError::Overflow("max_byte_size overflow")),
}
} else {
Ok(Some(size.wrapping_mul(4)))
}
}
},
DocumentPropertyType::ByteArray(sizes) => match sizes.max_size {
None => Some(u16::MAX),
Some(size) => Some(size),
None => Ok(Some(u16::MAX)),
Some(size) => Ok(Some(size)),
},
DocumentPropertyType::Boolean => Some(1),
DocumentPropertyType::Date => Some(8),
DocumentPropertyType::Boolean => Ok(Some(1)),
DocumentPropertyType::Date => Ok(Some(8)),
DocumentPropertyType::Object(sub_fields) => sub_fields
.iter()
.map(|(_, sub_field)| sub_field.property_type.max_byte_size())
.map(|(_, sub_field)| sub_field.property_type.max_byte_size(platform_version))
.sum(),
DocumentPropertyType::Array(_) => None,
DocumentPropertyType::VariableTypeArray(_) => None,
DocumentPropertyType::Identifier => Some(32),
DocumentPropertyType::Array(_) => Ok(None),
DocumentPropertyType::VariableTypeArray(_) => Ok(None),
DocumentPropertyType::Identifier => Ok(Some(32)),
}
}

Expand Down Expand Up @@ -259,60 +284,66 @@
}

/// The middle size rounded down halfway between min and max size
pub fn middle_size(&self) -> Option<u16> {
match self {
DocumentPropertyType::Array(_) | DocumentPropertyType::VariableTypeArray(_) => {
return None
}
_ => {}
pub fn middle_size(&self, platform_version: &PlatformVersion) -> Option<u16> {
let min_size = self.min_size()?;
let max_size = self.max_size()?;
if platform_version.protocol_version > 8 {
Some(((min_size as u32 + max_size as u32) / 2) as u16)
} else {
Some(min_size.wrapping_add(max_size) / 2)
}
let min_size = self.min_size().unwrap();
let max_size = self.max_size().unwrap();
Some((min_size + max_size) / 2)
}

/// The middle size rounded up halfway between min and max size
pub fn middle_size_ceil(&self) -> Option<u16> {
match self {
DocumentPropertyType::Array(_) | DocumentPropertyType::VariableTypeArray(_) => {
return None
}
_ => {}
pub fn middle_size_ceil(&self, platform_version: &PlatformVersion) -> Option<u16> {
let min_size = self.min_size()?;
let max_size = self.max_size()?;
if platform_version.protocol_version > 8 {
Some(((min_size as u32 + max_size as u32 + 1) / 2) as u16)
} else {
Some(min_size.wrapping_add(max_size).wrapping_add(1) / 2)
}
let min_size = self.min_size().unwrap();
let max_size = self.max_size().unwrap();
Some((min_size + max_size + 1) / 2)
}

/// The middle size rounded down halfway between min and max byte size
pub fn middle_byte_size(&self) -> Option<u16> {
match self {
DocumentPropertyType::Array(_) | DocumentPropertyType::VariableTypeArray(_) => {
return None
}
_ => {}
pub fn middle_byte_size(
&self,
platform_version: &PlatformVersion,
) -> Result<Option<u16>, ProtocolError> {
let Some(min_size) = self.min_byte_size(platform_version)? else {
return Ok(None);
};
let Some(max_size) = self.max_byte_size(platform_version)? else {
return Ok(None);
};
if platform_version.protocol_version > 8 {
Ok(Some(((min_size as u32 + max_size as u32) / 2) as u16))
} else {
Ok(Some(min_size.wrapping_add(max_size) / 2))
}
let min_size = self.min_byte_size().unwrap();
let max_size = self.max_byte_size().unwrap();
Some((min_size + max_size) / 2)
}

/// The middle size rounded up halfway between min and max byte size
pub fn middle_byte_size_ceil(&self) -> Option<u16> {
match self {
DocumentPropertyType::Array(_) | DocumentPropertyType::VariableTypeArray(_) => {
return None
}
_ => {}
pub fn middle_byte_size_ceil(
&self,
platform_version: &PlatformVersion,
) -> Result<Option<u16>, ProtocolError> {
let Some(min_size) = self.min_byte_size(platform_version)? else {
return Ok(None);
};
let Some(max_size) = self.max_byte_size(platform_version)? else {
return Ok(None);
};
if platform_version.protocol_version > 8 {
Ok(Some(((min_size as u32 + max_size as u32 + 1) / 2) as u16))
} else {
Ok(Some(min_size.wrapping_add(max_size).wrapping_add(1) / 2))
}
let min_size = self.min_byte_size().unwrap() as u32;
let max_size = self.max_byte_size().unwrap() as u32;
Some(((min_size + max_size + 1) / 2) as u16)
}

pub fn random_size(&self, rng: &mut StdRng) -> u16 {
let min_size = self.min_size().unwrap();
let max_size = self.max_size().unwrap();
let min_size = self.min_size().unwrap_or_default();
let max_size = self.max_size().unwrap_or_default();
rng.gen_range(min_size..=max_size)
}

Expand Down Expand Up @@ -952,150 +983,150 @@
if value.is_null() {
return Ok(vec![]);
}
return match self {
DocumentPropertyType::String(_) => {
let value_as_text = value
.as_text()
.ok_or_else(|| get_field_type_matching_error(value))?;
let vec = value_as_text.as_bytes().to_vec();
let mut r_vec = vec.len().encode_var_vec();
r_vec.extend(vec);
Ok(r_vec)
}
// TODO: Make the same as in https://github.com/dashpay/platform/blob/8d2a9e54d62b77581c44a15a09a2c61864af37d3/packages/rs-dpp/src/document/v0/serialize.rs#L161
// it must be u64 BE. Markers are wrong here as well
DocumentPropertyType::Date => {
let value_as_f64 = value.to_float().map_err(ProtocolError::ValueError)?;
let mut value_bytes = value_as_f64.to_be_bytes().to_vec();
if required {
Ok(value_bytes)
} else {
// if the value wasn't required we need to add a byte to prove it existed
let mut r_vec = vec![255u8];
r_vec.append(&mut value_bytes);
Ok(r_vec)
}
}
DocumentPropertyType::U128 => {
let value_as_u128: u128 = value.to_integer().map_err(ProtocolError::ValueError)?;
Ok(value_as_u128.to_be_bytes().to_vec())
}
DocumentPropertyType::I128 => {
let value_as_i128: i128 = value.to_integer().map_err(ProtocolError::ValueError)?;
Ok(value_as_i128.to_be_bytes().to_vec())
}
DocumentPropertyType::U64 => {
let value_as_u64: u64 = value.to_integer().map_err(ProtocolError::ValueError)?;
Ok(value_as_u64.to_be_bytes().to_vec())
}
DocumentPropertyType::I64 => {
let value_as_i64: i64 = value.to_integer().map_err(ProtocolError::ValueError)?;
Ok(value_as_i64.to_be_bytes().to_vec())
}
DocumentPropertyType::U32 => {
let value_as_u32: u32 = value.to_integer().map_err(ProtocolError::ValueError)?;
Ok(value_as_u32.to_be_bytes().to_vec())
}
DocumentPropertyType::I32 => {
let value_as_i32: i32 = value.to_integer().map_err(ProtocolError::ValueError)?;
Ok(value_as_i32.to_be_bytes().to_vec())
}
DocumentPropertyType::U16 => {
let value_as_u16: u16 = value.to_integer().map_err(ProtocolError::ValueError)?;
Ok(value_as_u16.to_be_bytes().to_vec())
}
DocumentPropertyType::I16 => {
let value_as_i16: i16 = value.to_integer().map_err(ProtocolError::ValueError)?;
Ok(value_as_i16.to_be_bytes().to_vec())
}
DocumentPropertyType::U8 => {
let value_as_u8: u8 = value.to_integer().map_err(ProtocolError::ValueError)?;
Ok(value_as_u8.to_be_bytes().to_vec())
}
DocumentPropertyType::I8 => {
let value_as_i8: i8 = value.to_integer().map_err(ProtocolError::ValueError)?;
Ok(value_as_i8.to_be_bytes().to_vec())
}
DocumentPropertyType::F64 => {
let value_as_f64 = value.to_float().map_err(ProtocolError::ValueError)?;
Ok(value_as_f64.to_be_bytes().to_vec())
}
DocumentPropertyType::ByteArray(sizes) => match (sizes.min_size, sizes.max_size) {
(Some(min), Some(max)) if min == max => Ok(value.to_binary_bytes()?),
_ => {
let mut bytes = value.to_binary_bytes()?;

let mut r_vec = bytes.len().encode_var_vec();
r_vec.append(&mut bytes);
Ok(r_vec)
}
},
DocumentPropertyType::Identifier => Ok(value.to_identifier_bytes()?),
DocumentPropertyType::Boolean => {
let value_as_boolean = value
.as_bool()
.ok_or_else(|| get_field_type_matching_error(value))?;
// 0 means does not exist
if value_as_boolean {
Ok(vec![1]) // 1 is true
} else {
Ok(vec![0]) // 0 is false
}
}
DocumentPropertyType::Object(inner_fields) => {
let Some(value_map) = value.as_map() else {
return Err(get_field_type_matching_error(value).into());
};
let value_map = Value::map_ref_into_btree_string_map(value_map)?;
let mut r_vec = vec![];
inner_fields.iter().try_for_each(|(key, field)| {
if let Some(value) = value_map.get(key) {
if !field.required {
r_vec.push(1);
}
let value = field
.property_type
.encode_value_ref_with_size(value, field.required)?;
r_vec.extend(value.as_slice());
Ok(())
} else if field.required {
Err(ProtocolError::DataContractError(
DataContractError::MissingRequiredKey(
"a required field is not present".to_string(),
),
))
} else {
// We don't have something that wasn't required
r_vec.push(0);
Ok(())
}
})?;
let mut len_prepended_vec = r_vec.len().encode_var_vec();
len_prepended_vec.append(&mut r_vec);
Ok(len_prepended_vec)
}
DocumentPropertyType::Array(array_field_type) => {
if let Value::Array(array) = value {
let mut r_vec = array.len().encode_var_vec();

array.iter().try_for_each(|value| {
let mut serialized_value =
array_field_type.encode_value_ref_with_size(value)?;
r_vec.append(&mut serialized_value);
Ok::<(), ProtocolError>(())
})?;
Ok(r_vec)
} else {
Err(get_field_type_matching_error(value).into())
}
}

DocumentPropertyType::VariableTypeArray(_) => Err(ProtocolError::DataContractError(
DataContractError::Unsupported(
"serialization of arrays not yet supported".to_string(),
),
)),
};

Check warning on line 1129 in packages/rs-dpp/src/data_contract/document_type/property/mod.rs

View workflow job for this annotation

GitHub Actions / Rust packages (dpp) / Linting

unneeded `return` statement

warning: unneeded `return` statement --> packages/rs-dpp/src/data_contract/document_type/property/mod.rs:986:9 | 986 | / return match self { 987 | | DocumentPropertyType::String(_) => { 988 | | let value_as_text = value 989 | | .as_text() ... | 1128 | | )), 1129 | | }; | |_________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 986 ~ match self { 987 + DocumentPropertyType::String(_) => { 988 + let value_as_text = value 989 + .as_text() 990 + .ok_or_else(|| get_field_type_matching_error(value))?; 991 + let vec = value_as_text.as_bytes().to_vec(); 992 + let mut r_vec = vec.len().encode_var_vec(); 993 + r_vec.extend(vec); 994 + Ok(r_vec) 995 + } 996 + // TODO: Make the same as in https://github.com/dashpay/platform/blob/8d2a9e54d62b77581c44a15a09a2c61864af37d3/packages/rs-dpp/src/document/v0/serialize.rs#L161 997 + // it must be u64 BE. Markers are wrong here as well 998 + DocumentPropertyType::Date => { 999 + let value_as_f64 = value.to_float().map_err(ProtocolError::ValueError)?; 1000 + let mut value_bytes = value_as_f64.to_be_bytes().to_vec(); 1001 + if required { 1002 + Ok(value_bytes) 1003 + } else { 1004 + // if the value wasn't required we need to add a byte to prove it existed 1005 + let mut r_vec = vec![255u8]; 1006 + r_vec.append(&mut value_bytes); 1007 + Ok(r_vec) 1008 + } 1009 + } 1010 + DocumentPropertyType::U128 => { 1011 + let value_as_u128: u128 = value.to_integer().map_err(ProtocolError::ValueError)?; 1012 + Ok(value_as_u128.to_be_bytes().to_vec()) 1013 + } 1014 + DocumentPropertyType::I128 => { 1015 + let value_as_i128: i128 = value.to_integer().map_err(ProtocolError::ValueError)?; 1016 + Ok(value_as_i128.to_be_bytes().to_vec()) 1017 + } 1018 + DocumentPropertyType::U64 => { 1019 + let value_as_u64: u64 = value.to_integer().map_err(ProtocolError::ValueError)?; 1020 + Ok(value_as_u64.to_be_bytes().to_vec()) 1021 + } 1022 + DocumentPropertyType::I64 => { 1023 + let value_as_i64: i64 = value.to_integer().map_err(ProtocolError::ValueError)?; 1024 + Ok(value_as_i64.to_be_bytes().to_vec()) 1025 + } 1026 + DocumentPropertyType::U32 => { 1027 + let value_as_u32: u32 = value.to_integer().map_err(ProtocolError::ValueError)?; 1028 + Ok(value_as_u32.to_be_bytes().to_vec()) 1029 + } 1030 + DocumentPropertyType::I32 => { 1031 + let value_as_i32: i32 = value.to_integer().map_err(ProtocolError::ValueError)?; 1032 + Ok(value_as_i32.to_be_bytes().to_vec()) 1033 + } 1034 + DocumentPropertyType::U16 => { 1035 + let value_as_u16: u16 = value.to_integer().map_err(ProtocolError::ValueError)?; 1036 + Ok(value_as_u16.to_be_bytes().to_vec()) 1037 + } 1038 + DocumentPropertyType::I16 => { 1039 + let value_as_i16: i16 = value.to_integer().map_err(ProtocolError::ValueError)?; 1040 + Ok(value_as_i16.to_be_bytes().to_vec()) 1041 + } 1042 + DocumentPropertyType::U8 => { 1043 + let value_as_u8: u8 = value.to_integer().map_err(ProtocolError::ValueError)?; 1044 + Ok(value_as_u8.to_be_bytes().to_vec()) 1045 + } 1046 + DocumentPropertyType::I8 => {
}

// Given a field type and a value this function chooses and executes the right encoding method
Expand Down Expand Up @@ -1200,7 +1231,7 @@
}
match self {
DocumentPropertyType::String(_) => {
if value == &vec![0] {

Check warning on line 1234 in packages/rs-dpp/src/data_contract/document_type/property/mod.rs

View workflow job for this annotation

GitHub Actions / Rust packages (dpp) / Linting

taken reference of right operand

warning: taken reference of right operand --> packages/rs-dpp/src/data_contract/document_type/property/mod.rs:1234:20 | 1234 | if value == &vec![0] { | ^^^^^^^^^-------- | | | help: use the right value directly: `...` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#op_ref = note: `#[warn(clippy::op_ref)]` on by default
// we don't want to collide with the definition of an empty string
Ok(Value::Text("".to_string()))
} else {
Expand Down Expand Up @@ -1291,9 +1322,9 @@
Ok(identifier.into())
}
DocumentPropertyType::Boolean => {
if value == &vec![0] {

Check warning on line 1325 in packages/rs-dpp/src/data_contract/document_type/property/mod.rs

View workflow job for this annotation

GitHub Actions / Rust packages (dpp) / Linting

taken reference of right operand

warning: taken reference of right operand --> packages/rs-dpp/src/data_contract/document_type/property/mod.rs:1325:20 | 1325 | if value == &vec![0] { | ^^^^^^^^^-------- | | | help: use the right value directly: `...` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#op_ref
Ok(Value::Bool(false))
} else if value == &vec![1] {

Check warning on line 1327 in packages/rs-dpp/src/data_contract/document_type/property/mod.rs

View workflow job for this annotation

GitHub Actions / Rust packages (dpp) / Linting

taken reference of right operand

warning: taken reference of right operand --> packages/rs-dpp/src/data_contract/document_type/property/mod.rs:1327:27 | 1327 | } else if value == &vec![1] { | ^^^^^^^^^-------- | | | help: use the right value directly: `...` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#op_ref
Ok(Value::Bool(true))
} else {
Err(ProtocolError::DecodingError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl Drive {
let document_top_field_estimated_size = document_and_contract_info
.owned_document_info
.document_info
.get_estimated_size_for_document_type(name, document_type)?;
.get_estimated_size_for_document_type(name, document_type, platform_version)?;

if document_top_field_estimated_size > u8::MAX as u16 {
return Err(Error::Fee(FeeError::Overflow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl Drive {
let document_top_field_estimated_size = document_and_contract_info
.owned_document_info
.document_info
.get_estimated_size_for_document_type(name, document_type)?;
.get_estimated_size_for_document_type(name, document_type, platform_version)?;

if document_top_field_estimated_size > u8::MAX as u16 {
return Err(Error::Fee(FeeError::Overflow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl Drive {
let document_top_field_estimated_size = document_and_contract_info
.owned_document_info
.document_info
.get_estimated_size_for_document_type(name, document_type)?;
.get_estimated_size_for_document_type(name, document_type, platform_version)?;

if document_top_field_estimated_size > u8::MAX as u16 {
return Err(Error::Fee(FeeError::Overflow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl Drive {
let document_top_field_estimated_size = document_and_contract_info
.owned_document_info
.document_info
.get_estimated_size_for_document_type(name, document_type)?;
.get_estimated_size_for_document_type(name, document_type, platform_version)?;

if document_top_field_estimated_size > u8::MAX as u16 {
return Err(Error::Fee(FeeError::Overflow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl Drive {
let document_top_field_estimated_size = document_and_contract_info
.owned_document_info
.document_info
.get_estimated_size_for_document_type(name, document_type)?;
.get_estimated_size_for_document_type(name, document_type, platform_version)?;

if document_top_field_estimated_size > u8::MAX as u16 {
return Err(Error::Fee(FeeError::Overflow(
Expand Down
Loading
Loading