-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
refactor: Make all validation error actions explicit #11016
Conversation
chain/sub/incoming.go
Outdated
case xerrors.Is(err, messagepool.ErrMessageValueTooHigh): | ||
fallthrough | ||
case xerrors.Is(err, messagepool.ErrTooManyPendingMessages): | ||
case xerrors.Is(err, messagepool.ErrNotEnoughFunds): | ||
fallthrough | ||
case xerrors.Is(err, messagepool.ErrNonceGap): | ||
fallthrough | ||
case xerrors.Is(err, messagepool.ErrGasFeeCapTooLow): | ||
fallthrough | ||
case xerrors.Is(err, messagepool.ErrNonceTooLow): | ||
fallthrough | ||
case xerrors.Is(err, messagepool.ErrExistingNonce): | ||
return pubsub.ValidationIgnore | ||
default: | ||
case xerrors.Is(err, messagepool.ErrInvalidToAddr): |
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'm not sure if any of these should be "reject" as they can happen during forks/syncing.
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.
To be clear, this is exactly the current behavior. Below are the errors we mark as reject:
ErrMessageTooBig
ErrMessageValueTooHigh
ErrNotEnoughFunds
ErrInvalidToAddr
Are you saying none of these should be marked as reject? @Stebalien
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.
Yeah, I know. I'm saying that they only "too big" should likely be an error. But we should check this with @arajasek first.
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 think they're all fine to treat as REJECT, except ErrNotEnoughFunds
.
ErrMessageValueTooHigh
is trying to send more than 2B FIL, while ErrInvalidToAddr
is just checking for non-nil recipient, both of which seem fine to REJECT.
Agreed that ErrNotEnoughFunds
should be an IGNORE, though.
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.
Ah, I see. Sg.
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.
Whether or not there are enough available funds depends on the tipset against which the message is checked, other messages in the message pool, etc.
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, so you could have funds available when the txn was created but subsequently created txns which also used up the funds could have been executed first leaving insufficient funds for the first one. Is that right?
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.
Pretty sure that we want ErrNotEnoughFunds to be reject, otherwise I can just spam the network with RBF messages from an address with barely any fil
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.
@magik6k But none of those messages would actually get added to anyone's mempools (assuming you don't have the FIL for it). You'll just spam and get ignored?
Sounds like you're maybe saying ErrRBFTooLowPremium
should be a reject? Which I...might agree with...maybe?
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.
Hmm, I guess if we ignore, those messages won't get very far anyways, so it either doesn't really matter, or ignore is leaning on a slightly safer side when it comes to pubsub scoring.
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'm not sure I agree with the idea of this PR. I do think we want to be rejecting by default, and only carving out ignores for very specific benign cases.
In general, its better practice to be more specific for erroneous cases, especially where an error results in a significant penalty
Unfortunately, a lowered peer score is the smaller penalty here. What you really don't want is to be not punishing peers that spam you invalid messages (eg. aren't validly signed, aren't actually messages but garbage data, etc.)
Could you elaborate on this? Why is a lowered peer score the smaller penalty when we've noticed especially in this recent case, that it has drastic implications for a peer not actually doing anything wrong? Bringing the erroneous cases to be stated explicitly has benefits as can be witnessed in this very PR discussion. Previously, most people weren't even aware of whats being rejected |
Because otherwise I (an attacker) can send you an endless stream of bad messages, and have you spend all your time validating (invalid) signatures / reading state / generally wasting time. I think you need to be built to respond to bad actors, assume errors are malicious, and only carve out very specific exceptions.
I'm not sure how much a static map achieves, because you'll still have some "default" action you take for errors that aren't defined in that map. I do think this winds up being a binary decision -- either REJECT all errors, with a carveout for specific typed IGNOREs, or IGNORE all errors, with a carveout for specific typed REJECTs. |
This makes sense. However, here #11016 (comment) you mentioned that for an ErrNotEnoughFunds error we could set it as IGNORE because even if someone spams you it doesn't add to the mpool |
No tests? |
There's no new logic here. Just a comment and making the errors more explicit |
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.
LGTM
Related Issues
Proposed Changes
Additional Info
Checklist
Before you mark the PR ready for review, please make sure that:
<PR type>: <area>: <change being made>
fix: mempool: Introduce a cache for valid signatures
PR type
: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, testarea
, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps