-
Notifications
You must be signed in to change notification settings - Fork 38.6k
rpc: simpler setban and new ban manipulation commands #19825
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
Conversation
155f3d1 to
192b151
Compare
192b151 to
6ce8989
Compare
|
Because bans have specific durations I'm not sure if this is a good change. Should a 1 hour ban of foo/16 stop you from adding a 1 year ban of foo/24? Right now I already have to undo every ban before adding it to make sure it's not rejected and as a result ends up expiring prematurely. But if any wider banned blocked every narrower ban, I'm not sure how I could programmatically handle that. I'd have to have crazy logic interrogated the banlist and broke every larger ban into smaller ones when a smaller one with a different time period was added. Instead, I think it should just be consistent in that each ban doesn't interact with an different ban. And when I add a ban for an already existing prefix, it should extend the ban if the new one has a later expiration time. It would be fine to canonicalize actually equivalent bans (e.g. 1.2.3.4/24 = 1.2.3.0/24). |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
6ce8989 to
ab96960
Compare
Totally fair. I can't see either how clients will be able to make tooling with sane logic. I am going to think this through and update the PR with a better solution. Thanks for the feedback and a potential solution, @gmaxwell ! |
|
Concept ACK on making this consistent. I'll review once you have an updated proposal that addresses gmaxwell's input. |
Potential solutionLet Case s1 ⊂ s0: Case s1 ⊇ s0: Case no overlap: Unban: |
|
I think that approach makes sense; it's equivalent to treating every ban as a per-IP thing, and remembering the longest-duration ban for each. One question I have is how to make clearbanned consistent with that? This is a bit confusing:
And this:
While:
I think the most reasonable thing requiring an exact match for some ban record when unbanning, but also make it delete all (longer) subranges? |
|
I don't really like the banning add removal doing fancy logic. This will make it extremely hard to have external software add bans, even with the newly proposed behaviour. It's also unlike access-lists on any networking device I've ever worked with. What is the downside of the obvious behaviour? There is a list of bans, some of which are shorter-than-maximum-CIDR, add adds to the list, clear removes from it. If you have overlapping bans, ... so? You might expect them to have different durations, or they may come from different sources. The only limitation I'm aware with that approach is that if you want to remove a ban affecting a specific host or subnet more care might be required to remove all... but that could be addressed with a "removeall" e.g. Then you can get exact management of the ban list via add/remove, but also get a "just make this host work" removal if that's what you want. This also doesn't make the resulting banlist depend on the order that you did the insertions, which I believe the logic proposed a few messages up would do (e.g. if you insert less specific then more specific you won't get the same result as more than less (as their times won't match, so in one case you'll just get the less specific and the other case you'll get both). I also have a preference for not returning errors when the action the user wants is accomplished, I've had more than a few people using my ban list complain about the wall of errors when they update... though assuming it didn't return an error when it extended the duration, I think that issue would already be eliminated by the changes we've discussed. |
|
I agree with the idea that we should interpret I also agree that unintended side effects like Further agree, on not returning an error when the user intent is accomplished (by a pre-existing ban entry) even if it does not create a new ban entry - I will update the code to reflect that. (Updated the proposal above as well)
The one thing I am unsure about is not consolidating ban entries where possible. In my rookie opinion, After a couple attempts, I am not able to see how this proposal will mean the banlist will depend on the order of insertions so long as |
|
The most common usage is a relative time, so the times won't be consistent. :) |
|
Ah, I see. So it's safe to say that the banlist would not depend on the order of insertions. |
|
I think it would with what you're suggesting. You're suggesting that if there is a shorter wider block, and I insert a longer narrower block-- both get added. But if there is a shorter narrower block and I add a longer wider block the shorter block is removed. If I give both a relative lifetime of 1 day then make the two calls a second apart, then the resulting set of bans depends on the order. |
ab96960 to
60a4290
Compare
|
@gmaxwell I still think we are in agreement that equivalent Script 1: Script 2: Unless I am missing something, per the current RPC semantics, these are not equivalent instructions and the node will behave differently. In order for the node to behave differently and comply with the instructions, the banlists will have to be different. For the use case you are trying to accomplish (atomic, bulk additions with relative timestamps), I think there are two ways we can be successful:
I think another interesting thing this conversation highlights is our expectation of where canonical state lives. i.e. Do we expect that |
b9b6e0a to
9cc54bd
Compare
Current state of this PRWhat does the current patch at tip
|
|
I agree with @gmaxwell's suggestion here: #19825 (comment) that we shouldn't try to do any clever logic. I think the behaviour should be:
and then add two new commands:
|
…unctions - consolidate Ban() functions - setban logic is simpler: adding a subset ban will not throw an error
Unbanning a non-banned subnet should not raise an rpc error
0c3b11d to
a2a36f9
Compare
|
Rebased. Ready for further review. |
|
Needs rebase to drop already merged hunks in the fuzz tests |
| case NET_IPV4: | ||
| case NET_IPV6: | ||
| valid = true; | ||
| valid = addr.IsValid(); |
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.
what is this change exactly about? Why is it relevant to the given PR?
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.
I see it's kinda used below in the same commit 80044bd, but splitting this change out (e.g. do it first) would simplify the review.
|
Okay, a lot of things here:
|
I don't understand why are these changes required? The errors right now look correct.
Concept ACK for |
|
Are you still working on this? |
|
@achow101 yes i'd like to, if there's enough interest in the idea. i'm going to work through getting BIP324 PRs up to date with the new mechanisms introduced in the BIP recently and then I can rebase this. |
|
🐙 This pull request conflicts with the target branch and needs rebase. |
|
There hasn't been much activity lately and the patch still needs rebase. What is the status here?
|
|
I'm ok with marking this up for grabs or closing it. |
Initially motivated by: https://github.com/bitcoin/bitcoin/pull/19219/files#r442410269
Objectives:
BanManfunctionsChanges:
BanMan::Ban(CNetAddr&)and useBanMan::Ban(CSubNet&)instead (ips are subnets of one)setban subnet/ip addnow allows adding a ban entry for an ip in an already banned subnet. No error will be thrown so long as the user intent is accomplished.BanMan::Unban(CNetAddr&)and useBanMan::Unban(CSubNet&)instead (ips are subnets of one)BanMan::IsBanned(CSubNet&)setban ip removeallto remove all ban entries that include an IP addresslistbanned ipto return all ban entries that include an IP address