From f34b6633df25e5056e732371ddb2775eb783d2cc Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 14 Mar 2024 08:15:25 -0400 Subject: [PATCH] v1.18: [anza migration] Sets client id to Agave (backport of #163) (#206) [anza migration] Sets client id to Agave (#163) (cherry picked from commit 0f1ca20d38a111bb47621aa3108a2f9fc107f998) Co-authored-by: Brooks --- version/src/lib.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/version/src/lib.rs b/version/src/lib.rs index edeca08c960243..7a59406cf0647d 100644 --- a/version/src/lib.rs +++ b/version/src/lib.rs @@ -17,6 +17,7 @@ enum ClientId { SolanaLabs, JitoLabs, Firedancer, + Agave, // If new variants are added, update From and TryFrom. Unknown(u16), } @@ -63,7 +64,7 @@ impl Default for Version { commit: compute_commit(option_env!("CI_COMMIT")).unwrap_or_default(), feature_set, // Other client implementations need to modify this line. - client: u16::try_from(ClientId::SolanaLabs).unwrap(), + client: u16::try_from(ClientId::Agave).unwrap(), } } } @@ -97,6 +98,7 @@ impl From for ClientId { 0u16 => Self::SolanaLabs, 1u16 => Self::JitoLabs, 2u16 => Self::Firedancer, + 3u16 => Self::Agave, _ => Self::Unknown(client), } } @@ -110,7 +112,8 @@ impl TryFrom for u16 { ClientId::SolanaLabs => Ok(0u16), ClientId::JitoLabs => Ok(1u16), ClientId::Firedancer => Ok(2u16), - ClientId::Unknown(client @ 0u16..=2u16) => Err(format!("Invalid client: {client}")), + ClientId::Agave => Ok(3u16), + ClientId::Unknown(client @ 0u16..=3u16) => Err(format!("Invalid client: {client}")), ClientId::Unknown(client) => Ok(client), } } @@ -147,19 +150,21 @@ mod test { assert_eq!(ClientId::from(0u16), ClientId::SolanaLabs); assert_eq!(ClientId::from(1u16), ClientId::JitoLabs); assert_eq!(ClientId::from(2u16), ClientId::Firedancer); - for client in 3u16..=u16::MAX { + assert_eq!(ClientId::from(3u16), ClientId::Agave); + for client in 4u16..=u16::MAX { assert_eq!(ClientId::from(client), ClientId::Unknown(client)); } assert_eq!(u16::try_from(ClientId::SolanaLabs), Ok(0u16)); assert_eq!(u16::try_from(ClientId::JitoLabs), Ok(1u16)); assert_eq!(u16::try_from(ClientId::Firedancer), Ok(2u16)); - for client in 0..=2u16 { + assert_eq!(u16::try_from(ClientId::Agave), Ok(3u16)); + for client in 0..=3u16 { assert_eq!( u16::try_from(ClientId::Unknown(client)), Err(format!("Invalid client: {client}")) ); } - for client in 3u16..=u16::MAX { + for client in 4u16..=u16::MAX { assert_eq!(u16::try_from(ClientId::Unknown(client)), Ok(client)); } }