Skip to content

Commit

Permalink
add check on metadata name
Browse files Browse the repository at this point in the history
  • Loading branch information
brentstone committed Sep 8, 2024
1 parent 59fdda8 commit d51b59a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions crates/apps_lib/src/config/genesis/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,15 @@ pub fn validate_validator_account(
);
}
}
if let Some(name) = metadata.name.as_ref() {
if name.len() as u64 > MAX_VALIDATOR_METADATA_LEN {
panic!(
"The name metadata of the validator with address {} is too \
long, must be within {MAX_VALIDATOR_METADATA_LEN} characters",
signed_tx.data.address
);
}
}

// Check signature
let mut is_valid = {
Expand Down
12 changes: 12 additions & 0 deletions crates/sdk/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,18 @@ pub async fn build_validator_metadata_change(
}
}
}
if let Some(name) = name.as_ref() {
if name.len() as u64 > MAX_VALIDATOR_METADATA_LEN {
edisplay_line!(
context.io(),
"Name provided is too long, must be within \
{MAX_VALIDATOR_METADATA_LEN} characters"
);
if !tx_args.force {
return Err(Error::from(TxSubmitError::MetadataTooLong));
}
}
}

// If there's a new commission rate, it must be valid
if let Some(rate) = commission_rate.as_ref() {
Expand Down

0 comments on commit d51b59a

Please sign in to comment.