Skip to content

Commit

Permalink
fix(platform): add limits to identity balances and proposed block cou…
Browse files Browse the repository at this point in the history
…nts queries (#2148)
  • Loading branch information
QuantumExplorer authored Sep 19, 2024
1 parent a0621de commit b9d3bf7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/rs-drive-abci/src/error/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ pub enum QueryError {
#[error("invalid argument error: {0}")]
InvalidArgument(String),

/// Too many elements Error
#[error("too many elements error: {0}")]
TooManyElements(String),

/// Not found Error
#[error("not found error: {0}")]
NotFound(String),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ impl<C> Platform<C> {
platform_state: &PlatformState,
platform_version: &PlatformVersion,
) -> Result<QueryValidationResult<GetEvonodesProposedEpochBlocksResponseV0>, Error> {
if ids.len() > self.config.drive.max_query_limit as usize {
return Ok(QueryValidationResult::new_with_error(
QueryError::TooManyElements(format!(
"this query only supports up to {} ids at a time",
ids.len()
)),
));
}
let evonode_ids = check_validation_result_with_data!(ids
.into_iter()
.map(|evonode_id_vec| {
Expand Down
2 changes: 1 addition & 1 deletion packages/rs-drive/src/drive/identity/fetch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl Drive {
path: vec![vec![RootTree::Balances as u8]],
query: SizedQuery {
query,
limit: None,
limit: Some(self.config.max_query_limit),
offset: None,
},
};
Expand Down

0 comments on commit b9d3bf7

Please sign in to comment.