Skip to content

Commit

Permalink
Merge of #3779
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Sep 8, 2024
2 parents d297b09 + 46eb69b commit 0517731
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Check the string length of the validator name in provided metadata.
([\#3779](https://github.com/anoma/namada/pull/3779))
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 0517731

Please sign in to comment.