Skip to content

Commit d4a47af

Browse files
authored
fix: remove grpc plugin altogether from geyser manager (#400)
<!-- greptile_comment --> ## Greptile Summary Improves stability by removing Geyser gRPC plugin from the plugin manager while maintaining RPC service functionality, eliminating potential segfaults from unsafe memory handling. - Removed unsafe memory transmutation code in `magicblock-api/src/init_geyser_service.rs` that was creating artificial Library handles - Eliminated `libloading::Library` and `LoadedGeyserPlugin` dependencies to prevent memory-related crashes - Preserved core RPC service functionality while removing plugin tracking from manager - Removed potential segfault vector from plugin manager's plugins list management <!-- /greptile_comment -->
1 parent a1d509a commit d4a47af

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

magicblock-api/src/init_geyser_service.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::sync::Arc;
22

3-
use libloading::Library;
43
use log::*;
54
use magicblock_config::GeyserGrpcConfig;
65
use magicblock_geyser_plugin::{
@@ -11,7 +10,7 @@ use magicblock_geyser_plugin::{
1110
rpc::GeyserRpcService,
1211
};
1312
use solana_geyser_plugin_manager::{
14-
geyser_plugin_manager::{GeyserPluginManager, LoadedGeyserPlugin},
13+
geyser_plugin_manager::GeyserPluginManager,
1514
geyser_plugin_service::GeyserPluginServiceError,
1615
};
1716

@@ -66,8 +65,8 @@ pub fn init_geyser_service(
6665
),
6766
..Default::default()
6867
};
69-
let mut manager = GeyserPluginManager::new();
70-
let (grpc_plugin, rpc_service): (_, Arc<GeyserRpcService>) = {
68+
let manager = GeyserPluginManager::new();
69+
let rpc_service = {
7170
let plugin = GrpcGeyserPlugin::create(config)
7271
.map_err(|err| {
7372
error!("Failed to load geyser plugin: {:?}", err);
@@ -83,17 +82,8 @@ pub fn init_geyser_service(
8382
"Launched GRPC Geyser service on '{}'",
8483
geyser_grpc.socket_addr()
8584
);
86-
let rpc_service = plugin.rpc();
87-
// hack: we don't load the geyser plugin from .so file, as such we don't own a handle to Library,
88-
// to bypass this, we just make up one from null pointer and forget about it, this should work as long
89-
// as geyser plugin manager doesn't try to do anything fancy with that handle
90-
let lib = unsafe { std::mem::transmute::<usize, Library>(0_usize) };
91-
(
92-
LoadedGeyserPlugin::new(lib, Box::new(plugin), None),
93-
rpc_service,
94-
)
85+
plugin.rpc()
9586
};
96-
manager.plugins.push(grpc_plugin);
9787

9888
Ok((manager, rpc_service))
9989
}

0 commit comments

Comments
 (0)