Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
zbuc committed Jun 10, 2024
1 parent 97cbfd3 commit e6e7940
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/bin/pd/src/migrate/testnet78.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ pub fn floor_char_boundary(s: &str, index: usize) -> usize {
.rposition(|b| is_utf8_char_boundary(*b));

// SAFETY: we know that the character boundary will be within four bytes
unsafe { lower_bound + new_index.unwrap_unchecked() }
lower_bound + new_index.unwrap()
}
}

Expand Down
10 changes: 6 additions & 4 deletions crates/core/component/governance/src/proposal_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use serde::{Deserialize, Serialize};

use penumbra_proto::{penumbra::core::component::governance::v1 as pb, DomainType};

use crate::MAX_VALIDATOR_VOTE_REASON_LENGTH;

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(try_from = "pb::ProposalState", into = "pb::ProposalState")]
pub enum State {
Expand Down Expand Up @@ -293,7 +295,7 @@ impl TryFrom<pb::ProposalOutcome> for Outcome<String> {
}) => Outcome::Failed {
withdrawn: if let Some(pb::proposal_outcome::Withdrawn { reason }) = withdrawn {
// Max reason length is 1kb
if reason.len() > 1024 {
if reason.len() > MAX_VALIDATOR_VOTE_REASON_LENGTH {
anyhow::bail!("withdrawn reason must be smaller than 1kb")
}

Expand All @@ -307,7 +309,7 @@ impl TryFrom<pb::ProposalOutcome> for Outcome<String> {
}) => Outcome::Slashed {
withdrawn: if let Some(pb::proposal_outcome::Withdrawn { reason }) = withdrawn {
// Max reason length is 1kb
if reason.len() > 1024 {
if reason.len() > MAX_VALIDATOR_VOTE_REASON_LENGTH {
anyhow::bail!("withdrawn reason must be smaller than 1kb")
}
Withdrawn::WithReason { reason }
Expand Down Expand Up @@ -373,7 +375,7 @@ impl TryFrom<pb::ProposalOutcome> for Outcome<()> {
// Max reason length is 1kb
if withdrawn.is_some() {
let reason = &withdrawn.as_ref().expect("reason is some").reason;
if reason.len() > 1024 {
if reason.len() > MAX_VALIDATOR_VOTE_REASON_LENGTH {
anyhow::bail!("withdrawn reason must be smaller than 1kb");
}
}
Expand All @@ -388,7 +390,7 @@ impl TryFrom<pb::ProposalOutcome> for Outcome<()> {
// Max reason length is 1kb
if withdrawn.is_some() {
let reason = &withdrawn.as_ref().expect("reason is some").reason;
if reason.len() > 1024 {
if reason.len() > MAX_VALIDATOR_VOTE_REASON_LENGTH {
anyhow::bail!("withdrawn reason must be smaller than 1kb");
}
}
Expand Down

0 comments on commit e6e7940

Please sign in to comment.