stacks-core icon indicating copy to clipboard operation
stacks-core copied to clipboard

`PeerNetwork` state must survive from neon node to nakamoto node.

Open kantai opened this issue 1 year ago • 2 comments

This can be done using the JoinHandle returns.

kantai avatar Feb 08 '24 18:02 kantai

This should include the socket to avoid #4547

kantai avatar Mar 19 '24 14:03 kantai

If this isn't done, could lead to an empty 5-6 blocks once 3.0 kicks off

saralab avatar Apr 23 '24 14:04 saralab

Can I just transfer the entire p2p thread like we do with the monitoring thread? Like this:

let monitoring_thread = neon_loop.take_monitoring_thread();
let naka = NakaRunLoop::new(
    /* ... */
    monitoring_thread,
);

jbencin avatar May 07 '24 20:05 jbencin

Yes I believe you can

On Tue, May 7, 2024, 4:21 PM Jeff Bencin @.***> wrote:

Can I just transfer the entire p2p thread like we do with the monitoring thread? Like this:

let monitoring_thread = neon_loop.take_monitoring_thread();let naka = NakaRunLoop::new( /* ... */ monitoring_thread,);

— Reply to this email directly, view it on GitHub https://github.com/stacks-network/stacks-core/issues/4355#issuecomment-2099236882, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADQJKZLLSKQWXQ7ST5J5RTZBEZUFAVCNFSM6AAAAABDAH33SOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJZGIZTMOBYGI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

jcnelson avatar May 07 '24 20:05 jcnelson

Can I just transfer the entire p2p thread like we do with the monitoring thread? Like this:

After looking into this a bit more, I don't think this would work. PeerThread holds a copy of Globals, which would reference a closed MPSC channel:

pub struct Globals<T> {
    // ...
    /// Writer endpoint to the relayer thread
    pub relay_send: SyncSender<T>,
}

I don't think there is anything else that becomes invalid after the neon runloop terminates, but it seems safer to pass PeerNetwork than to pass PeerThread and try to manually update any invalid references

jbencin avatar May 08 '24 15:05 jbencin

Closed by #4767

jbencin avatar May 14 '24 12:05 jbencin