Skip to content

Conversation

@mzumsande
Copy link
Contributor

@mzumsande mzumsande commented Mar 12, 2024

The nKey of the addrman is generated the first time the node is started with an empty peers.dat. Therefore, restarting a node or turning it off and on again won't make a previously non-deterministic addrman deterministic.
This could lead to intermittent failures in feature_asmap.py and rpc_net.py

Fixes #29634

@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 12, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK stratospher, brunoerg, kevkevinpal, 0xB10C
Concept ACK BrandonOdiwuor

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #28998 (rpc: "addpeeraddress tried" return error on failure by 0xB10C)

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.

@0xB10C
Copy link
Contributor

0xB10C commented Mar 12, 2024

Concept ACK

Hope you saw #29007 (comment)

@mzumsande mzumsande force-pushed the 202403_fix_feature_asmap branch 2 times, most recently from 82f4ecf to bdf80d1 Compare March 12, 2024 18:23
@mzumsande
Copy link
Contributor Author

Concept ACK

Hope you saw #29007 (comment)

Thanks, yes I saw that. It's the same underlying issue - in feature_asmap.py we didn't use restart_node but stop_node and then start_node, so the current fix is not to use clear_addrman=True, but make addrman deterministic from the start.

The nKey of the addrman is generated the first time the node is
started. Therefore, restarting a node or turning it off and on
again won't make a previously non-deterministic addrman
deterministic.

Co-authored-by: 0xb10c <[email protected]>
@brunoerg
Copy link
Contributor

Concept ACK

Copy link
Contributor

@stratospher stratospher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested ACK 432a542.

oh nice catch @mzumsande, @0xB10C! so nKey from Addrman's constructor is always overwritten by previously stored nKey obtained from Unserialize().

I've checked the test logs in feature_asmap.py and rpc_net.py to verify that deterministic nKey is being used in the tests now.

@DrahtBot DrahtBot requested review from 0xB10C and brunoerg March 14, 2024 05:49
Copy link
Contributor

@brunoerg brunoerg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crACK 432a542

Copy link
Contributor

@BrandonOdiwuor BrandonOdiwuor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK

@kevkevinpal
Copy link
Contributor

ACK 432a542

ran this command grep -nri "restart_node" ./test/functional to check for where -test=addrman' is used and saw that we were just missing it in test/functional/rpc_net.py`

was not able to test this locally on my machine as I am on mac

@DrahtBot DrahtBot requested a review from BrandonOdiwuor March 19, 2024 01:26
self.num_nodes = 1
self.extra_args = [["-checkaddrman=1"]] # Do addrman checks on all operations.
# Do addrman checks on all operations and use deterministic addrman
self.extra_args = [["-checkaddrman=1", "-test=addrman"]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't clear_addrman = true required in the restart_node call inside test_asmap_interaction_with_addrman_containing_entries function below?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case it's not needed. set_test_params() is called before the node is first started. clear_addrman = True would only be required if the node was running and a non-deterministic addrman had been created before.

Copy link
Contributor

@rkrux rkrux Mar 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation. 🙌

Copy link
Contributor

@0xB10C 0xB10C left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 432a542

def test_addpeeraddress(self):
self.log.info("Test addpeeraddress")
self.restart_node(1, ["-checkaddrman=1", "-test=addrman"])
# The node has an existing, non-deterministic addrman from a previous test.
Copy link
Contributor

@rkrux rkrux Mar 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which is that previous test? Should we add the name in the comment?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any previous test that started the node without a deterministic addrman. I don't think it's needed in the comment.

@fanquake fanquake merged commit 9f2609d into bitcoin:master Mar 19, 2024
@mzumsande mzumsande deleted the 202403_fix_feature_asmap branch March 20, 2024 20:00
@bitcoin bitcoin locked and limited conversation to collaborators Mar 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

10 participants