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

Made geyser interface repr(c) to improve interface stability #33703

Merged
merged 2 commits into from
Oct 23, 2023

Conversation

lijunwangs
Copy link
Contributor

Problem

Spurious validator crashes due to rust version mismatch for validator and plugins.

Summary of Changes

Made geyser interface repr(c) to improve interface stability

Fixes #

@codecov
Copy link

codecov bot commented Oct 16, 2023

Codecov Report

Merging #33703 (9ea6ebd) into master (4751199) will increase coverage by 0.0%.
Report is 51 commits behind head on master.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master   #33703   +/-   ##
=======================================
  Coverage    81.8%    81.8%           
=======================================
  Files         806      806           
  Lines      217676   217676           
=======================================
+ Hits       178197   178208   +11     
+ Misses      39479    39468   -11     

@CriesofCarrots
Copy link
Contributor

Do we expect users to have to do much to accommodate this change in their plugins?

@t-nelson
Copy link
Contributor

Do we expect users to have to do much to accommodate this change in their plugins?

One Last Recompile ™️

@@ -112,6 +115,7 @@ pub struct ReplicaAccountInfoV3<'a> {
/// If there were a change to the structure of ReplicaAccountInfo,
/// there would be new enum entry for the newer version, forcing
/// plugin implementations to handle the change.
#[repr(C)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might consider setting the discriminant width on enums explicitly. they support a syntax like #[repr(C,u{8,16,32,64})] which corresponds to similar annotations in recent C++. afaik there's no such syntax in C though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made them repr(u32). Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they'd need to be repr(C, u32), but repr(C) uses u32 discriminates by default iirc. so just repr(C) would be the same.

fwiw there's some annoying lint around multiple repr in current rust. they're only valid for data-bearing enums. given that these structs are not intended to be persisted or sent over the wire, repr(C) is probably actually the least wrong choice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried repr(C, u32), it does not compile. According to https://doc.rust-lang.org/nomicon/other-reprs.html, it should be repr(u*) format. repr(C), also:

repr(C) is equivalent to one of repr(u*) (see the next section) for fieldless enums. The chosen size is the default enum size for the target platform's C application binary interface (ABI). Note that enum representation in C is implementation defined, so this is really a "best guess". In particular, this may be incorrect when the C code of interest is compiled with certain flags.

So I think repr(u32) is more explicit. https://github.com/rust-lang/rfcs/blob/master/text/2195-really-tagged-unions.md documented more benefits on enum with fields.

@CriesofCarrots
Copy link
Contributor

One Last Recompile ™️

Yeah, that's what I was hoping :)

@lijunwangs
Copy link
Contributor Author

lijunwangs commented Oct 19, 2023

Do we expect users to have to do much to accommodate this change in their plugins?

I have not found it requires any code change needed from the plugin side. Just compile and it works.

@lijunwangs
Copy link
Contributor Author

@t-nelson @CriesofCarrots , a gentle nudge on this PR.

Copy link
Contributor

@CriesofCarrots CriesofCarrots left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wfm if Trent's happy

@lijunwangs lijunwangs merged commit 1e8aa52 into solana-labs:master Oct 23, 2023
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants