-
Notifications
You must be signed in to change notification settings - Fork 38.8k
rename TransactionError:ALREADY_IN_CHAIN #30212
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
rename TransactionError:ALREADY_IN_CHAIN #30212
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. 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. ConflictsNo conflicts as of last run. |
|
This addresses #19363 's concern:
...by now returning |
theStack
left a comment
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.
Concept and code-review ACK aa422bcb898b7e3aa8dca912d92016bd22cf243d
I agree that the proposed names are more to the point and less confusing.
ismaelsadeeq
left a comment
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.
Code Review ACK aa422bcb898b7e3aa8dca912d92016bd22cf243d
src/node/transaction.cpp
Outdated
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.
Nice, I think we should also rename the one in TxValidationResult enum.
g/TX_MISSING_INPUTS/TX_MISSING_INPUT_OR_SPENT/g
and update comments appropriately.
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 did consider this, but it felt much less exposed to the user, only via testmempoolaccept AFAIK:
result_inner.pushKV("reject-reason", "missing-inputs");Therefore as an "internal error", TX_MISSING_INPUTS (for any reason) it felt more accurate to me to leave as is? Very happy to be persuaded away from this viewpoint 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.
Therefore as an "internal error", TX_MISSING_INPUTS (for any reason) it felt more accurate to me to leave as is?
I was reviewing this based on the PR rationale in the OP. You stated that "a transaction's inputs are missing from the UTXO set, which could also be due to all inputs having already been spent (MISSING_INPUTS -> INPUTS_MISSING_OR_SPENT)." That's why I suggested that TxValidationResult one should be changed just for uniformity. But Internally, you're right TX_MISSING_INPUTS inferred or spent.
Maybe just update the testmempoolaccept reject reason since it's user-facing?
But if you agree, you may have to update some functional tests that use it and maybe a release note since users heavily use the RPC.
This is a non blocking comment.
This PR is an improvement and will close the issue
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 also don't understand why the first commit is needed. The error message is already correct (and unchanged in this pull request): Untranslated("Inputs missing or spent").
I'd say it is fine to drop the commit (or keep it if you want). Just a style nit, either is fine.
aa422bc to
b2b4b93
Compare
|
Rebased on master to fix merge conflict. Added an extra commit to cover |
ismaelsadeeq
left a comment
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.
re-ACK b2b4b932572c5bb1ffa3fc4f34e17130348fbc24
theStack
left a comment
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.
re-ACK b2b4b932572c5bb1ffa3fc4f34e17130348fbc24
b2b4b93 to
77ef75d
Compare
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.
Code review ACK 77ef75d3ce4bff76a0db730b57896dcf7e8f3988 if test failure is fixed (see comment below)
Note: I didn't totally follow the original issue or how these changes resolve it, but all the changes here seem reasonable regardless.
77ef75d to
a05f4ca
Compare
|
Code review ACK a05f4ca241045e8a4b295760590805f961c2e5e7. Just changed psbt error string and fixed a test since the last review. |
tdb3
left a comment
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.
Approach ACK
Good work increasing clarity. In the past I've had a head-scratching moment with some of these before I learned the nuances, so this should help people.
Left a comment about release notes.
Tested:
- Ran unit/functional tests locally (passed)
- Manually exercised the following scenario (regtest):
- Created a transaction (and broadcasted).
- Generated one block to confirm.
- Attempted to call
sendrawtransactionwith the newly confirmed transaction. - Received
Transaction outputs already in UTXO setas expected. - Performed
sendallto spent all UTXOs. - Re-attempted to call
sendrawtransactionwith the the spent transaction. - Received
bad-txns-inputs-missingorspent
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.
Although it's only the error message (and the number stays the same), I still think its appropriate to add a release note for the change to the user.
Release notes should be written for any PR that:
...
makes any other visible change to the end-user experience.
maflcko
left a comment
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.
Left a question. Also, I don't think this is a "refactor"
src/node/transaction.cpp
Outdated
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 also don't understand why the first commit is needed. The error message is already correct (and unchanged in this pull request): Untranslated("Inputs missing or spent").
I'd say it is fine to drop the commit (or keep it if you want). Just a style nit, either is fine.
src/rpc/protocol.h
Outdated
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.
95b09ed4741b9a15d7d285e248161d5a508f5586: The second commit is not a refactor, but claims to be one. However, it changes the rpc error messages. Also, it is removing the RPC_VERIFY_ALREADY_IN_CHAIN from this header. Either this is fine, in which case this whole "backward compat" section can be removed, or it is not fine, in which case the symbol needs to be restored. C.f. d29a291
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.
re: #30212 (comment)
Good catch. It is inconsistent to have added backwards compatible aliases previously when renaming and not add them now when renaming again. But it looks like the backwards compatibility section was added in 2014 when it was might have less clear whether aliases were needed. I'd say now aliases are probably not needed and it would be better to remove this section.
src/common/messages.cpp
Outdated
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.
a05f4ca241045e8a4b295760590805f961c2e5e7: This commit is not a refactor either.
ryanofsky
left a comment
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.
Agree on not calling the commits which change error messages refactoring. I do like first commit making error constant more consistent with error message, but agree it is not essential.
src/rpc/protocol.h
Outdated
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.
re: #30212 (comment)
Good catch. It is inconsistent to have added backwards compatible aliases previously when renaming and not add them now when renaming again. But it looks like the backwards compatibility section was added in 2014 when it was might have less clear whether aliases were needed. I'd say now aliases are probably not needed and it would be better to remove this section.
test/functional/rpc_psbt.py
Outdated
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.
In commit "refactor: PSBTError::MISSING_INPUTS" (a05f4ca241045e8a4b295760590805f961c2e5e7)
I wonder if "invalid transaction inputs" might be a clearer message for a user than "invalid inputs." (I had suggested "invalid inputs" but in this context it seems vague.)
ismaelsadeeq
left a comment
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.
Looking good to me 🥇
I will re-ACK after comments were addressed
a05f4ca to
76eb6f3
Compare
|
🚧 At least one of the CI tasks failed. HintsMake sure to run all tests locally, according to the documentation. The failure may happen due to a number of reasons, for example:
Leave a comment here, if you need help tracking down a confusing failure. |
When using `sendrawtransaction` the ALREADY_IN_CHAIN error help string may be confusing. Rename TransactionError::ALREADY_IN_CHAIN to TransactionError::ALREADY_IN_UTXO_SET and update the rpc help string. Remove backwards compatibility alias as no longer required.
76eb6f3 to
e9de0a7
Compare
tdb3
left a comment
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.
ACK e9de0a7
Re-ran tests in #30212 (review) (successful)
ismaelsadeeq
left a comment
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.
ACK e9de0a7
|
ryanofsky
left a comment
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.
Code review ACK e9de0a7.
Since last review, change has been simplified, no longer renaming PSBTError::MISSING_INPUTS to PSBTError::INPUTS_INVALID and no longer renaming TransactionError::MISSING_INPUTS to TransactionError::INPUTS_MISSING_OR_SPENT
I did think both of those renames were improvements, but it does simplify the PR to drop them. Also it makes it easier to see how this PR fixes #19363.
Also release notes were added
| "for manual rebroadcast may degrade privacy by leaking the transaction's origin, as\n" | ||
| "nodes will normally not rebroadcast non-wallet transactions already in their mempool.\n" | ||
| "\nA specific exception, RPC_TRANSACTION_ALREADY_IN_CHAIN, may throw if the transaction cannot be added to the mempool.\n" | ||
| "\nA specific exception, RPC_TRANSACTION_ALREADY_IN_UTXO_SET, may throw if the transaction cannot be added to the mempool.\n" |
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.
In commit "rpc: clarify ALREADY_IN_CHAIN rpc errors" (87b1880)
Was already the case before this PR, but this documentation seems misleading because "already in utxo set" error is not the only error that can be triggered if transaction can't be added to the mempool.
As #19363 reports BroadcastTransaction will start returning MISSING_INPUTS instead of ALREADY_IN_UTXO_SET after the outputs are spent. Also it looks like BroadcastTransaction can returns MEMPOOL_REJECTED and MEMPOOL_ERROR which get translated into RPC_TRANSACTION_REJECTED and RPC_TRANSACTION_ERROR. So 3 different error codes may be returned if the transaction can't be added to the mempool, not just 1
|
Does Alternatively, the error constant could be renamed, with the error text/string left in place. |
c6eca6f doc: add guidance for RPC to developer notes (tdb3) Pull request description: Adds guidance statements to the RPC interface section of the developer notes with examples of when to implement `-deprecatedrpc=`. Wanted to increase awareness of preferred RPC implementation approaches for newer contributors. This implements some of what's discussed in #29912 (comment) Opinions may differ, so please don't be shy. We want to make RPC as solid/safe as possible. Examples of discussions where guidelines/context might have added value: #30212 (comment) #29845 (comment) #30381 (review) #29954 (comment) #30410 (review) #30713 #30381 #29060 (review) ACKs for top commit: l0rinc: ACK c6eca6f fjahr: ACK c6eca6f maflcko: lgtm ACK c6eca6f jonatack: ACK c6eca6f Tree-SHA512: 01a98a8dc0eb91762b225d3278cdb4a5e380ceb7486fd096b4ad9122bed859cea8584d8996d3dce51272fdb792f4a793a1bd1c5445efeb87f0a30f9b6e59a790
Closes: #19363
Renaming this error improves clarity around the returned error both internally and externally when a transactions' outputs are already found in the utxo set (
TransactionError::ALREADY_IN_CHAIN -> TransactionError::ALREADY_IN_UTXO_SET)