@@ -162,6 +162,21 @@ pub struct GeyserSubscriber {
162162}
163163
164164impl GeyserSubscriber {
165+ fn is_supported_geyser_version ( version : & Version , required : & VersionReq ) -> bool {
166+ if required. matches ( version) {
167+ return true ;
168+ }
169+
170+ // semver excludes prereleases from broad ranges (e.g. ">=1.14.1").
171+ // Treat prereleases as supported when their stable counterpart matches.
172+ if !version. pre . is_empty ( ) {
173+ let stable = Version :: new ( version. major , version. minor , version. patch ) ;
174+ return required. matches ( & stable) ;
175+ }
176+
177+ false
178+ }
179+
165180 pub fn new (
166181 primary_grpc : ConfigUpstreamGrpc ,
167182 include_transactions : bool ,
@@ -723,7 +738,7 @@ impl GeyserSubscriber {
723738 GeyserError :: VersionParse ( format ! ( "failed to parse required version: {e}" ) )
724739 } ) ?;
725740
726- if !required . matches ( & version) {
741+ if !Self :: is_supported_geyser_version ( & version, & required ) {
727742 return Err ( GeyserError :: VersionValidation ( format ! (
728743 "gRPC version {version} doesn't match required {required}"
729744 ) ) ) ;
@@ -767,7 +782,11 @@ impl GeyserStreams for GeyserSubscriber {
767782#[ cfg( test) ]
768783mod tests {
769784 use {
770- crate :: { grpc_geyser:: SlotTrackingInfo , util:: SlotStatus } ,
785+ crate :: {
786+ grpc_geyser:: { GeyserSubscriber , SlotTrackingInfo } ,
787+ util:: SlotStatus ,
788+ } ,
789+ semver:: { Version , VersionReq } ,
771790 solana_hash:: Hash ,
772791 } ;
773792
@@ -832,4 +851,27 @@ mod tests {
832851 info. mark_status_seen ( SlotStatus :: SlotConfirmed ) ;
833852 assert ! ( !info. has_seen_status( SlotStatus :: SlotFinalized ) ) ;
834853 }
854+
855+ #[ test]
856+ fn it_should_parse_rc_version ( ) {
857+ let version_str = "2.0.0-rc1" ;
858+ let version = Version :: parse ( version_str) . unwrap ( ) ;
859+ let required = VersionReq :: parse ( ">=1.14.1" ) . unwrap ( ) ;
860+
861+ assert ! ( GeyserSubscriber :: is_supported_geyser_version(
862+ & version, & required
863+ ) ) ;
864+
865+ let version_str = "1.14.0-rc1" ;
866+ let version = Version :: parse ( version_str) . unwrap ( ) ;
867+ assert ! ( !GeyserSubscriber :: is_supported_geyser_version(
868+ & version, & required
869+ ) ) ;
870+
871+ let version_str = "1.14.0" ;
872+ let version = Version :: parse ( version_str) . unwrap ( ) ;
873+ assert ! ( !GeyserSubscriber :: is_supported_geyser_version(
874+ & version, & required
875+ ) ) ;
876+ }
835877}
0 commit comments