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 absurdly high fee message to validation state #5913
Conversation
There is no need for a reject code, as this can never trigger for peer-to-peer initiated transactions, so it can never result in a reject message. If you really need a reject code, add a REJECT_LOCAL or something, reserved for conditions that can only trigger locally (and mark it is an implementation detail, not related to BIP 61. |
@sipa I believe there should be a code, in case RPC users want to catch the error without having to match the text. Any convention for numbering or could I choose any arbitrary code? (0x60 perhaps) |
Well you can't pick anything that could potentially be later used in the P2P protocol, which why I would prefer no actual code. If there really is a need for RPC error codes separately from what the peer to peer protocol does, perhaps there should just be two codes. In general, I think it's not possible to predict all possible reason for rejecting things, and not really viable to have codes for everything. |
I'm not sure what you mean by adding REJECT_LOCAL, should I create an error code which will be overloaded for any local error? How about REJECT_LOCAL = 0x00. |
3fcf266
to
2694c95
Compare
You could use reject codes > 0x100 for local-only conditions. These cannot be passed over the P2P network. |
@laanwj Is it okay to change reject message codes to |
@shaulkf Changing the internal type is fine with me, otherwise I wouldn't have suggested it. But be careful that you don't accidentally change the type that is sent in the protocol. |
utACK |
Needs rebase. I suggest leaving the const reject message codes (now in consensus/validation.h) as unsigned char, changing CValidationState as you already do, and putting the local codes in main.h (for now). |
Also:
|
Needs rebase. |
f13aaf5
to
692dbde
Compare
Rebased and changed according to @luke-jr's recommendation |
692dbde
to
cf69dc5
Compare
Thanks @paveljanik, pushed a fix and rebased, this is a remnant from a change I ended up reverting. I agree regarding |
cf69dc5
to
a651403
Compare
@shaulkf Please fix the warning. |
Something like this needed?
|
Not sure, that might change the protocol. Maybe: CBlockReject reject = {(unsigned char)state.GetRejectCode(), state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), pindex->GetBlockHash()}; |
Right. |
Need this for #6519 |
utACK. Maybe this also needs an assert before sending out a reject message that the chRejectCode is in the right range. |
Yes, good point. I'll add it during merge. |
@@ -497,4 +497,7 @@ extern CBlockTreeDB *pblocktree; | |||
*/ | |||
int GetSpendHeight(const CCoinsViewCache& inputs); | |||
|
|||
/** local "reject" message codes for RPC which can not be triggered by p2p trasactions */ |
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.
Ever since we bitcoin#5913 have been sending invalid reject messages for transactions and blocks.
ca489c9 [Tests] Fix expected error messages (random-zebra) 9f84c52 Consensus: Remove calls to error() and FormatStateMessage() (random-zebra) 0e4d964 Move mempool rejections to new debug category (random-zebra) e0db16d Add information to errors in ConnectBlock, CheckBlock (random-zebra) d4ed81c Remove most logging from transaction validation (random-zebra) 94b2577 Add function to convert CValidationState to a human-readable message (random-zebra) 1ddc88f Introduce REJECT_INTERNAL codes for local AcceptToMempool errors (random-zebra) 55e00a2 Add debug message to CValidationState for optional extra information (random-zebra) 05cf74b Add absurdly high fee message to validation state (for RPC propagation) (random-zebra) Pull request description: - change `CValidationState::chRejectCode` to int - add `CValidationState::strDebugMessage` for optional information - add `FormatStateMessage` function to convert CValidationState to a human-readable message - introduce REJECT_INTERNAL rejection codes for ATMP and make their logging optional - remove unnecessary direct logging in `CheckTransaction`, `AcceptToMemoryPool`, `CheckTxInputs`, `CScriptCheck::operator()` - add detailed state information to the errors in `CheckBlock` and `ConnectBlock` Backported from: - bitcoin#5913 - bitcoin#6519 - bitcoin#7287 ACKs for top commit: Fuzzbawls: ACK ca489c9 furszy: re ACK ca489c9 and merging Tree-SHA512: ab972801fa45c2f84abf84790b0f0f22dc5668e170f51785f3cfbf806bda7988f55bbd43c24ae591ffe3bd62190f6cd99a3b640373c431ab92c0ddcabea1c999
ZIP 239 preparations 4 Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#5913 - Replaces #3111. - Includes an extra commit included by upstream in the merge outside the PR. - bitcoin/bitcoin#6519 - bitcoin/bitcoin#7179 - bitcoin/bitcoin#7853 - bitcoin/bitcoin#7960
ZIP 239 preparations 4 Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#5913 - Replaces #3111. - Includes an extra commit included by upstream in the merge outside the PR. - bitcoin/bitcoin#6519 - bitcoin/bitcoin#7179 - bitcoin/bitcoin#7853 - bitcoin/bitcoin#7960
ZIP 239 preparations 4 Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#5913 - Replaces #3111. - Includes an extra commit included by upstream in the merge outside the PR. - bitcoin/bitcoin#6519 - bitcoin/bitcoin#7179 - bitcoin/bitcoin#7853 - bitcoin/bitcoin#7960
Currently error message isn't propagating to RPC.
Not sure how reject constants should be numbered, for now I arbitrarily chose 0x44, please advise.