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

staking: length-limit validator definition strings #3619

Merged
merged 1 commit into from
Jan 17, 2024
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
Expand Up @@ -16,7 +16,22 @@ use crate::{
impl ActionHandler for validator::Definition {
type CheckStatelessContext = ();
async fn check_stateless(&self, _context: ()) -> Result<()> {
// First, check the signature:
// First, we check that the validator website/name/description does not
// exceed 70, 140, and 280 characters respectively. We use guard statements
// so that clients can display actionable error messages.
if self.validator.website.len() > 70 {
anyhow::bail!("validator website field must be less than 70 characters")
}

if self.validator.name.len() > 140 {
anyhow::bail!("validator name must be less than 140 characters")
}

if self.validator.description.len() > 280 {
anyhow::bail!("validator description must be less than 280 characters")
}

// Then, we check the signature:
let definition_bytes = self.validator.encode_to_vec();
self.validator
.identity_key
Expand Down
3 changes: 3 additions & 0 deletions crates/core/component/stake/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ pub struct Validator {
pub consensus_key: tendermint::PublicKey,

/// The validator's (human-readable) name.
/// Length: <= 140 characters.
pub name: String,

/// The validator's website URL.
/// Length: <= 70 characters.
pub website: String,

/// The validator's description.
/// Length: <= 280 characters.
pub description: String,

/// Whether the validator is enabled or not.
Expand Down
Loading