-
Notifications
You must be signed in to change notification settings - Fork 38.7k
rpc: "addpeeraddress tried" return error on failure #28998
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
rpc: "addpeeraddress tried" return error on failure #28998
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. |
pablomartin4btc
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 ACK
jonatack
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 ACK
|
Concept ACK. it's nice to clearly define success/failure paths for |
|
Maybe get #29007 in first. I've addressed the minor comments here, but I think it makes sense to draft this PR for now until #29007 is in. With #29007 we can test the collision case when |
cf54bc7 to
4f25184
Compare
|
approach ACK
since right now the only way addresses are kicked off is triggered by a collision, removing addresses from addrman would require introducing new test-only code paths. in addition to being a bigger effort, it would increase the surface area of potential issues in the future. eg. if someone tried to use it with mainnet code. when I was learning addrman, it took a while for me to wrap my head around the only-removed-by-collision logic (how it works, the reasoning, etc.), and I find it valuable for the tests to encourage devs familiarizing with the pattern that's used in the wild. this is to provide some context behind my approach ACK. the solution proposed here is scoped to the RPC code, which is appropriate for improving the currently misleading RPC interface. |
sr-gi
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
It is a pity that "failed-adding-to-tried" cannot be tested on demand, however, this at least gets rid of the intermittent failure when a collision is found in tried.
I think the tests can be made more exhaustive though, check comment inline.
4f25184 to
fbb02be
Compare
fbb02be to
4477a37
Compare
|
Rebased on #29007, which allows us to check the Also, as I'm touching it already, I've dropped the now unused (since 2cc8ca1) mocktime from This is ready for review again. |
|
Concept ACK I had this issue when writing #28869. |
4477a37 to
bb0f618
Compare
|
Rebased with #29639 merged due to #29639 (comment). |
stratospher
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.
tested ACK bb0f618.
not touched in this PR but addpeerinfo in test_addpeeraddress doesn't exist. 😳
if you retouch, do you want to include stratospher@09c849e since it only affects addpeeraddress and getrawaddrman and is a simple fix?
When trying to add an address to the IP address manager tried table,
it's first added to the new table and then moved to the tried table.
Previously, adding a conflicting address to the address manager's
tried table with test-only `addpeeraddress tried=true` RPC would
return `{ "success": true }`. However, the address would not be added
to the tried table, but would remain in the new table. This caused,
e.g., issue 28964.
This is fixed by returning `{ "success": false, "error":
"failed-adding-to-tried" }` for failed tried table additions. Since
the address remaining in the new table can't be removed (the address
manager interface does not support removing addresses at the moment
and adding this seems to be a bigger effort), an error message is
returned. This indicates to a user why the RPC failed and allows
accounting for the extra address in the new table.
Also:
To check the number of addresses in each addrman table,
the addrman checks were re-run and the log output of this check
was asserted. Ideally, logs shouldn't be used as an interface
in automated tests. To avoid asserting the logs, use the getaddrmaninfo
and getrawaddrman RPCs (which weren't implemented when the test was added).
Removing the "getnodeaddress" calls would also remove the addrman checks
from the test, which could reduce the test coverage. To avoid this,
these are kept.
current check to make sure that detailed help for hidden RPC is displayed won't work because the assertion isn't sufficient. Even if unknown RPCs are passed, RPC names would still be present in node.help().
bb0f618 to
99954f9
Compare
|
Addressed feedback and included stratospher@09c849e |
stratospher
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.
reACK 99954f9. 🚀
brunoerg
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.
utACK 99954f9
|
ACK 99954f9 |
99954f9 test: fix test to ensure hidden RPC is present in detailed help (stratospher) 0d01f6f test: remove unused mocktime in test_addpeeraddress (0xb10c) 6205466 rpc: "addpeeraddress tried" return error on failure (0xb10c) Pull request description: When trying to add an address to the IP address manager tried table, it's first added to the new table and then moved to the tried table. Previously, adding a conflicting address to the address manager's tried table with test-only `addpeeraddress tried=true` RPC would return `{ "success": true }`. However, the address would not be added to the tried table, but would remain in the new table. This caused, e.g., issue bitcoin#28964. This is fixed by new returning `{ "success": false, "error": "..." }` for failed tried table additions. Since the address remaining in the new table can't be removed (the address manager interface does not support removing addresses at the moment and adding this seems to be a bigger effort), an error message is returned. This indicates to a user why the RPC failed and allows accounting for the extra address in the new table. This is done in the functional test for the `getrawaddrman` RPC. Fixes bitcoin#28964 ACKs for top commit: achow101: ACK 99954f9 stratospher: reACK 99954f9. 🚀 brunoerg: utACK 99954f9 Tree-SHA512: 2f1299410c0582ebc2071271ba789a8abed905f9a510821f77afbcf2a555ec31397578ea55cbcd162fb828be27afedd3246c7b13ad8883f2f745bb8e04364a76
99954f9 test: fix test to ensure hidden RPC is present in detailed help (stratospher) 0d01f6f test: remove unused mocktime in test_addpeeraddress (0xb10c) 6205466 rpc: "addpeeraddress tried" return error on failure (0xb10c) Pull request description: When trying to add an address to the IP address manager tried table, it's first added to the new table and then moved to the tried table. Previously, adding a conflicting address to the address manager's tried table with test-only `addpeeraddress tried=true` RPC would return `{ "success": true }`. However, the address would not be added to the tried table, but would remain in the new table. This caused, e.g., issue bitcoin#28964. This is fixed by new returning `{ "success": false, "error": "..." }` for failed tried table additions. Since the address remaining in the new table can't be removed (the address manager interface does not support removing addresses at the moment and adding this seems to be a bigger effort), an error message is returned. This indicates to a user why the RPC failed and allows accounting for the extra address in the new table. This is done in the functional test for the `getrawaddrman` RPC. Fixes bitcoin#28964 ACKs for top commit: achow101: ACK 99954f9 stratospher: reACK 99954f9. 🚀 brunoerg: utACK 99954f9 Tree-SHA512: 2f1299410c0582ebc2071271ba789a8abed905f9a510821f77afbcf2a555ec31397578ea55cbcd162fb828be27afedd3246c7b13ad8883f2f745bb8e04364a76 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Add test for adding valid address to new table first - Add critical test case for 'failed-adding-to-tried' error path - Add test for already-present new address failing with 'failed-adding-to-new' - Add collision test case with grinded address 1.2.5.45 - Fix test expectations to match actual addrman state These changes complete the Bitcoin backport by including all the test coverage for the new error handling paths in addpeeraddress RPC.
When trying to add an address to the IP address manager tried table, it's first added to the new table and then moved to the tried table. Previously, adding a conflicting address to the address manager's tried table with test-only
addpeeraddress tried=trueRPC would return{ "success": true }. However, the address would not be added to the tried table, but would remain in the new table. This caused, e.g., issue #28964.This is fixed by new returning
{ "success": false, "error": "..." }for failed tried table additions. Since the address remaining in the new table can't be removed (the address manager interface does not support removing addresses at the moment and adding this seems to be a bigger effort), an error message is returned. This indicates to a user why the RPC failed and allows accounting for the extra address in the new table. This is done in the functional test for thegetrawaddrmanRPC.Fixes #28964