From 60844db57b34f994c1560071b4ecf9ef069984cc Mon Sep 17 00:00:00 2001 From: Lijun Wang <83639177+lijunwangs@users.noreply.github.com> Date: Mon, 16 Oct 2023 00:01:56 -0700 Subject: [PATCH 1/2] Made geyser interface repr(c) to improve interface stability --- .../src/geyser_plugin_interface.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/geyser-plugin-interface/src/geyser_plugin_interface.rs b/geyser-plugin-interface/src/geyser_plugin_interface.rs index b2bbb5a4953aed..b9d684797802b1 100644 --- a/geyser-plugin-interface/src/geyser_plugin_interface.rs +++ b/geyser-plugin-interface/src/geyser_plugin_interface.rs @@ -14,6 +14,7 @@ use { }; #[derive(Debug, Clone, PartialEq, Eq)] +#[repr(C)] /// Information about an account being updated pub struct ReplicaAccountInfo<'a> { /// The Pubkey for the account @@ -43,6 +44,7 @@ pub struct ReplicaAccountInfo<'a> { } #[derive(Debug, Clone, PartialEq, Eq)] +#[repr(C)] /// Information about an account being updated /// (extended with transaction signature doing this update) pub struct ReplicaAccountInfoV2<'a> { @@ -76,6 +78,7 @@ pub struct ReplicaAccountInfoV2<'a> { } #[derive(Debug, Clone, PartialEq, Eq)] +#[repr(C)] /// Information about an account being updated /// (extended with reference to transaction doing this update) pub struct ReplicaAccountInfoV3<'a> { @@ -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)] pub enum ReplicaAccountInfoVersions<'a> { V0_0_1(&'a ReplicaAccountInfo<'a>), V0_0_2(&'a ReplicaAccountInfoV2<'a>), @@ -120,6 +124,7 @@ pub enum ReplicaAccountInfoVersions<'a> { /// Information about a transaction #[derive(Clone, Debug)] +#[repr(C)] pub struct ReplicaTransactionInfo<'a> { /// The first signature of the transaction, used for identifying the transaction. pub signature: &'a Signature, @@ -136,6 +141,7 @@ pub struct ReplicaTransactionInfo<'a> { /// Information about a transaction, including index in block #[derive(Clone, Debug)] +#[repr(C)] pub struct ReplicaTransactionInfoV2<'a> { /// The first signature of the transaction, used for identifying the transaction. pub signature: &'a Signature, @@ -157,12 +163,14 @@ pub struct ReplicaTransactionInfoV2<'a> { /// If there were a change to the structure of ReplicaTransactionInfo, /// there would be new enum entry for the newer version, forcing /// plugin implementations to handle the change. +#[repr(C)] pub enum ReplicaTransactionInfoVersions<'a> { V0_0_1(&'a ReplicaTransactionInfo<'a>), V0_0_2(&'a ReplicaTransactionInfoV2<'a>), } #[derive(Clone, Debug)] +#[repr(C)] pub struct ReplicaEntryInfo<'a> { /// The slot number of the block containing this Entry pub slot: Slot, @@ -180,11 +188,13 @@ pub struct ReplicaEntryInfo<'a> { /// A wrapper to future-proof ReplicaEntryInfo handling. To make a change to the structure of /// ReplicaEntryInfo, add an new enum variant wrapping a newer version, which will force plugin /// implementations to handle the change. +#[repr(C)] pub enum ReplicaEntryInfoVersions<'a> { V0_0_1(&'a ReplicaEntryInfo<'a>), } #[derive(Clone, Debug)] +#[repr(C)] pub struct ReplicaBlockInfo<'a> { pub slot: Slot, pub blockhash: &'a str, @@ -195,6 +205,7 @@ pub struct ReplicaBlockInfo<'a> { /// Extending ReplicaBlockInfo by sending the executed_transaction_count. #[derive(Clone, Debug)] +#[repr(C)] pub struct ReplicaBlockInfoV2<'a> { pub parent_slot: Slot, pub parent_blockhash: &'a str, @@ -208,6 +219,7 @@ pub struct ReplicaBlockInfoV2<'a> { /// Extending ReplicaBlockInfo by sending the entries_count. #[derive(Clone, Debug)] +#[repr(C)] pub struct ReplicaBlockInfoV3<'a> { pub parent_slot: Slot, pub parent_blockhash: &'a str, @@ -220,6 +232,7 @@ pub struct ReplicaBlockInfoV3<'a> { pub entry_count: u64, } +#[repr(C)] pub enum ReplicaBlockInfoVersions<'a> { V0_0_1(&'a ReplicaBlockInfo<'a>), V0_0_2(&'a ReplicaBlockInfoV2<'a>), @@ -228,6 +241,7 @@ pub enum ReplicaBlockInfoVersions<'a> { /// Errors returned by plugin calls #[derive(Error, Debug)] +#[repr(C)] pub enum GeyserPluginError { /// Error opening the configuration file; for example, when the file /// is not found or when the validator process has no permission to read it. @@ -258,6 +272,7 @@ pub enum GeyserPluginError { /// The current status of a slot #[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[repr(C)] pub enum SlotStatus { /// The highest slot of the heaviest fork processed by the node. Ledger state at this slot is /// not derived from a confirmed or finalized block, but if multiple forks are present, is from From 9ea6ebd3a896ee1e63483b4316e8e05e491ca923 Mon Sep 17 00:00:00 2001 From: Lijun Wang <83639177+lijunwangs@users.noreply.github.com> Date: Thu, 19 Oct 2023 11:22:48 -0700 Subject: [PATCH 2/2] Made enum repr(u32) --- .../src/geyser_plugin_interface.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/geyser-plugin-interface/src/geyser_plugin_interface.rs b/geyser-plugin-interface/src/geyser_plugin_interface.rs index b9d684797802b1..8b31aba48bc654 100644 --- a/geyser-plugin-interface/src/geyser_plugin_interface.rs +++ b/geyser-plugin-interface/src/geyser_plugin_interface.rs @@ -115,7 +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)] +#[repr(u32)] pub enum ReplicaAccountInfoVersions<'a> { V0_0_1(&'a ReplicaAccountInfo<'a>), V0_0_2(&'a ReplicaAccountInfoV2<'a>), @@ -163,7 +163,7 @@ pub struct ReplicaTransactionInfoV2<'a> { /// If there were a change to the structure of ReplicaTransactionInfo, /// there would be new enum entry for the newer version, forcing /// plugin implementations to handle the change. -#[repr(C)] +#[repr(u32)] pub enum ReplicaTransactionInfoVersions<'a> { V0_0_1(&'a ReplicaTransactionInfo<'a>), V0_0_2(&'a ReplicaTransactionInfoV2<'a>), @@ -188,7 +188,7 @@ pub struct ReplicaEntryInfo<'a> { /// A wrapper to future-proof ReplicaEntryInfo handling. To make a change to the structure of /// ReplicaEntryInfo, add an new enum variant wrapping a newer version, which will force plugin /// implementations to handle the change. -#[repr(C)] +#[repr(u32)] pub enum ReplicaEntryInfoVersions<'a> { V0_0_1(&'a ReplicaEntryInfo<'a>), } @@ -232,7 +232,7 @@ pub struct ReplicaBlockInfoV3<'a> { pub entry_count: u64, } -#[repr(C)] +#[repr(u32)] pub enum ReplicaBlockInfoVersions<'a> { V0_0_1(&'a ReplicaBlockInfo<'a>), V0_0_2(&'a ReplicaBlockInfoV2<'a>), @@ -241,7 +241,7 @@ pub enum ReplicaBlockInfoVersions<'a> { /// Errors returned by plugin calls #[derive(Error, Debug)] -#[repr(C)] +#[repr(u32)] pub enum GeyserPluginError { /// Error opening the configuration file; for example, when the file /// is not found or when the validator process has no permission to read it. @@ -272,7 +272,7 @@ pub enum GeyserPluginError { /// The current status of a slot #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[repr(C)] +#[repr(u32)] pub enum SlotStatus { /// The highest slot of the heaviest fork processed by the node. Ledger state at this slot is /// not derived from a confirmed or finalized block, but if multiple forks are present, is from