Skip to content
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

Exponse block/unblock functionality in da service #1122

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

pradovic
Copy link
Contributor

@pradovic pradovic commented Mar 11, 2025

1. What does this PR implement?

Exponse block/unblock functionality in da service. This is the PR that enables the follow up which is adding http block/unblock functionality.

2. Does the code have enough context to be clearly understood?

Yes.

3. Who are the specification authors and who is accountable for this PR?

@bacv, @pradovic.

4. Is the specification accurate and complete?

Yes, but still debating.

5. Does the implementation introduce changes in the specification?

No.

Checklist

Warning

Do not merge the PR if any of the following is missing:

  • 1. Description added.
  • 2. Context and links to Specification document(s) added.
  • 3. Main contact(s) (developers and specification authors) added
  • 4. Implementation and Specification are 100% in sync including changes. This is critical.
  • 5. Link PR to a specific milestone.

@pradovic pradovic changed the title Feat block peer http api Block/Unblock peer http api Mar 11, 2025
Copy link
Collaborator

@danielSanchezQ danielSanchezQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bacv is this for testing purposes? If so it should not be exposed in builds.

@bacv
Copy link
Member

bacv commented Mar 11, 2025

@bacv is this for testing purposes? If so it should not be exposed in builds.

No, this is to block unblock unwanted peers in DA network (malicious for example).

@danielSanchezQ
Copy link
Collaborator

@bacv is this for testing purposes? If so it should not be exposed in builds.

No, this is to block unblock unwanted peers in DA network (malicious for example).

why http api then? 🤔

@bacv
Copy link
Member

bacv commented Mar 11, 2025

why http api then?

At the moment temporal (with cooldown) or permantent (until unblocked) blocking is performed by DA Monitor - we want user to allow to modify this behaviour manually.

@danielSanchezQ
Copy link
Collaborator

danielSanchezQ commented Mar 11, 2025

why http api then?

At the moment temporal (with cooldown) or permantent (until unblocked) blocking is performed by DA Monitor - we want user to allow to modify this behaviour manually.

I'm not sure this should happen manually. We can add a the blacklist/whitelist behaviour instead.

@pradovic pradovic changed the title Block/Unblock peer http api Exponse block/unblock functionality in da service Mar 11, 2025
@pradovic
Copy link
Contributor Author

pradovic commented Mar 11, 2025

why http api then?

At the moment temporal (with cooldown) or permantent (until unblocked) blocking is performed by DA Monitor - we want user to allow to modify this behaviour manually.

I'm not sure this should happen manually. We can add a the blacklist/whitelist behaviour instead.

Happy to change if needed. @bacv, @danielSanchezQ If you guys like we could also discuss it and spec out what needs to be done.
From what I see connection monitor has a list of malicious peers, which is kind of a blacklist. I don't have enough context to know if we need to distinguish between malicious and blacklisted peers, but they both seem to be blocked until unblocked.

@pradovic pradovic marked this pull request as ready for review March 11, 2025 15:13
@bacv
Copy link
Member

bacv commented Mar 11, 2025

I'm not sure this should happen manually. We can add a the blacklist/whitelist behaviour instead.

How will you remove blacklisted peers if you change your mind?

@bacv
Copy link
Member

bacv commented Mar 11, 2025

From what I see connection monitor has a list of malicious peers, which is kind of a blacklist

Yes monitor behaviour is already based on the linked behaviour - it is actually a superset, because it has temporary blocking.

@danielSanchezQ
Copy link
Collaborator

I'm not sure this should happen manually. We can add a the blacklist/whitelist behaviour instead.

How will you remove blacklisted peers if you change your mind?

Maybe I'm missing something.I thought blacklisting was done through the manager policies. If a misbehaving peer is detected maybe is blacklisted right? If it is added automatically, we should have an automated policy for removing them as well.

@danielSanchezQ
Copy link
Collaborator

From what I see connection monitor has a list of malicious peers, which is kind of a blacklist

Yes monitor behaviour is already based on the linked behaviour - it is actually a superset, because it has temporary blocking.

Ok, so monitor behaviour does track that. I thought it was the connection manager, hence my confusion.

@bacv
Copy link
Member

bacv commented Mar 11, 2025

I thought blacklisting was done through the manager policies.

Yes, the decisions are made through the Policy - based on policy:

  • Balancer decides how many connections should be per subnetwork at a given time.
  • Monitor decides if a peer is unhealthy or malicious based on error rate coming through the connection.

Even if the policy would have a way to determine when the peer is considered not malicious again, I think a user should have a way to block/unblock chosen peers, lets say because some new information about bad actors behind couple of nodes was uncovered.

@bacv
Copy link
Member

bacv commented Mar 11, 2025

The PR looks good, one command seems worth adding - a command to get the list of currently blocked peers - what do you think @danielSanchezQ @pradovic ? Could it be added here or maybe not required.

@danielSanchezQ
Copy link
Collaborator

The PR looks good, one seems worth adding - a command to get the list of currently blocked peers - what do you think @danielSanchezQ @pradovic ? Could it be added here or maybe not required.

Yep, seems good as other services may need of that. Btw, As this command are growing, better to nest them.

pub enum ManagePeer {
    BlockPeer {
        peer_id: PeerId,
        response_sender: oneshot::Sender<bool>,
    },
    UnblockPeer {
        peer_id: PeerId,
        response_sender: oneshot::Sender<bool>,
    },
    BlacklistedPeers {
        response_sender: oneshot::Sender<Vec<PeerId>>
    }
}

/// Message that the backend replies to
#[derive(Debug)]
pub enum DaNetworkMessage {
    /// Kickstart a network sapling
    RequestSample {
        subnetwork_id: SubnetworkId,
        blob_id: BlobId,
    },
  ManagePeer(ManagePeer)
}

Names are orientative...

@pradovic pradovic requested review from danielSanchezQ and bacv March 11, 2025 18:29
@pradovic
Copy link
Contributor Author

@bacv, @danielSanchezQ Thanks for the input! Everything should be implemented now. I am not sure do we need a call for temporary block as well, and should temporary blocked peers be part of blacklisted call. It is similar functionality, but not quite the same, as @bacv already mentioned.

@@ -75,6 +78,13 @@ impl SamplingEvent {
}
}

#[derive(Debug)]
pub enum PeerRequest {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just idea, could this be MonitorCommand as it goes directly to the monitor behaviour?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, fixed!

@bacv
Copy link
Member

bacv commented Mar 11, 2025

Thanks for the input! Everything should be implemented now. I am not sure do we need a call for temporary block

Temporal block is to disconnect from unhealty peers with a hope that after some time has passed their operation will go back to normal. The cooldown interval is set in the config, and unless it's set to minutes, not seconds, then the user shouldn't be required to unblock them. Having unhealthy peer unblocked wouldn't change the outcome - if it fails to respond to the messages or refuses the connection, I don't see the reason to keep it unblocked manually.

@pradovic pradovic added this to the Iteration 10 milestone Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants