-
Notifications
You must be signed in to change notification settings - Fork 50
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
Add deshred service #40
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Shivam Sandbhor <[email protected]>
proxy/src/deshred.rs
Outdated
if last_shred.0.last_in_slot() && slot_bucket.len() == (last_shred.0.index() + 1) as usize{ | ||
debug!("deshredding slot {:?}", slot); | ||
let shreds = slot_bucket.iter().map(|shred| shred.0.clone()).collect_vec(); | ||
|
||
let data = Shredder::deshred(shreds.as_slice()); | ||
if data.is_err() { | ||
debug!("failed to deshred shreds {:?}", data.err()); | ||
return; | ||
} | ||
let data = data.unwrap(); | ||
let entries: Result<Vec<Entry>, _> = bincode::deserialize(&data); | ||
if entries.is_ok() { | ||
let entries = entries.unwrap(); | ||
debug!("deshredded entries {:?}", entries); | ||
if entry_sender.receiver_count() > 0 { | ||
for entry in entries { | ||
let send_result = entry_sender.send(DeshredEntry{ | ||
num_hashes: entry.num_hashes, | ||
hash: entry.hash.to_bytes().to_vec(), | ||
// tbd: is bincode supported in other languages ? | ||
transactions: entry.transactions.iter().map(|t| bincode::serialize(t).unwrap()).collect_vec(), | ||
}); | ||
if send_result.is_err() { | ||
error!("failed to send deshredded entry to deshred server {:?}", send_result.err()); | ||
} | ||
} | ||
} | ||
shred_bucket_by_slot.remove(&slot); |
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.
Potential memory leak here if a slot bucket never fills. Not sure if that ever happens and how common it is.
Simple solution would be to drop the bucket after every interval regardless of it being filled.
Changed the submodule path to my repo. Ran Cargo fmt. Fixed the missing Arc import in heartbeat.rs
@segfaultdoc I added 9a21c91 to address the review |
Just bumping this up |
@sbs2001 mind if i modify your code in another branch? |
no problem :) |
PR depends on jito-labs/mev-protos#46
Added a grpc server, where clients can subscribe and listen to entries deshredded from the shreds received the shredstream proxy.
Example usage
--deshred-listen-address "127.0.0.1:50051
parameterHow it works
Packet to Shred: The proxy receives packets. Each packet is attempted to be deserialized into a Shred first. This is copied from https://github.com/anza-xyz/agave/blob/3dccb3e785ce8e7fc8370f983c81ee9cf4326de5/core/src/window_service.rs#L321
Shreds to Entry: Shreds are made from Entries. See anza code on how shreds are made here
We go from shreds to entry by collecting only unique data shreds into buckets labeled by the slot number. After inserting a shred, we check whether it's slot's bucket is full. A bucket is full if the bucket has a shred marked with
last_in_slot
and the bucket has total shreds equal to id of it'slast_in_slot
shred.Such a full bucket is deserialized into a a Entry object.
A subscribed client receives such live entry objects.