-
Notifications
You must be signed in to change notification settings - Fork 270
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
stream crds node updates via geyser #3434
base: master
Are you sure you want to change the base?
Conversation
197d4dd
to
a9c4800
Compare
6b6e493
to
d88db4b
Compare
d88db4b
to
bd9dbe0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM. Just dont like unsafe code that much.
/// Default is true -- if the plugin is not interested in | ||
/// gossip messages, please return false. | ||
fn node_update_notifications_enabled(&self) -> bool { | ||
true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be false by default.
gossip/src/contact_info_ffi.rs
Outdated
#[repr(C)] | ||
#[derive(Clone, Copy, Debug, Default)] | ||
pub struct FfiSocketAddr { | ||
pub is_v4: u8, // 1 if IPv4, 0 if IPv6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be
struct FfiSocketAddr {
ip: FfiIpAddr,
port: u16
}
@@ -565,6 +593,7 @@ impl Crds { | |||
match value.value.data() { | |||
CrdsData::ContactInfo(_) => { | |||
self.nodes.swap_remove(&index); | |||
self.notify_remove_node(&value.value.pubkey()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All CrdsData is being notified during update, while only contact info is notified during remove.
Could be intended behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so CrdsData is only being updated on ContactInfo as well. See: https://github.com/gregcusack/solana/blob/bd9dbe00404343a01072a75970a5520dbb426c21/gossip/src/crds.rs#L256-L258
this^ function does the check for ContactInfo
instead of the check being done in crds.insert()
.
ya i don't either. However, I am not sure how possible it is to create an FFI interface that is completely safe... |
#[allow(unused_variables)] | ||
fn notify_node_update(&self, interface: &FfiContactInfoInterface) -> Result<()> { | ||
Ok(()) | ||
} | ||
|
||
/// Called when a node is removed from the network | ||
/// TODO: may need to provide wrapper here? Also maybe ok | ||
/// if we marshall to repr(c) for this... | ||
#[allow(unused_variables)] | ||
fn notify_node_removal(&self, pubkey: &FfiPubkey) -> Result<()> { | ||
Ok(()) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also this is not a proper FFI interface since it is returning a Result<()>, so need to update. Although it may make sense to do this in stages. need to think about it
This is adding more work to Crds::insert while we hold an exclusive lock, so I would rather not to go with this approach. Better alternative is to pull ContactInfos only when needed or every once in a while (e.g. every 5 seconds, or 10 seconds, whatever). Similar logic to TTL expiry in ClusterNodesCache in turbine: See also: #46 (comment) |
Ya this is a good point
ya going to look into this approach this week. Geyser is more of a push service with the general idea pushing data into some backend DB that an RPC service can query. But we have to have some service sitting in front of the DB ingesting the streamed data. So, we could modify that service to periodically query a node and get the current set of known ContactInfos. Although this forces the Validator to implement some time of RPC (same RPC we are trying to remove from the valdiator) to handle and respond to these requests. |
In this PR, we pass an opaque pointer, If we end up changing What we could do, is define
and then define the extern "C" methods like:
Problem with this is that then all of these methods pollute the global namespace with the function names. But at least we could change Regardless if we go with a push or pull method, we still need some FFI interface. Curious to hear thoughts on this. |
gossip/src/contact_info_ffi.rs
Outdated
thiserror::Error, | ||
}; | ||
|
||
#[repr(C)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably best to give this an explicit u
type (ie. u32
)?
even with repr(C)
here, if we added enough variants then it could become something new.
Towards removing RPCs from the validator.
Summary of Changes
Stream crds node updates via geyser
Stream node removals from crds via geyser
Expose an FFI interface that wraps ContactInfo
FFI based off of FFI Transaction Interface here: #2125