Skip to content

Conversation

@maflcko
Copy link
Member

@maflcko maflcko commented Apr 10, 2018

Moving the orphan processing into a new function makes it possible to call it from other places. E.g. sendrawtransaction or when a transaction is received via a NetMsgType different from TX.

Also, add test coverage for the function in our unit functional test framework.

Copy link
Contributor

@Empact Empact Apr 11, 2018

Choose a reason for hiding this comment

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

Looks like lRemovedTxn still needs to be cleared in this method, unless moving it wholly into ProcessOrphans is appropriate.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, that indeed looks ugly right now. I will rebase this on #11775, which removes lRemovedTxn in whole.

@Empact
Copy link
Contributor

Empact commented Apr 11, 2018

Concept ACK, both for the addition of testing and due to the fact that ProcessMessage is >1300 lines at the moment. Would be great if other applications of the method were ready, to help inform its interface.

@skeees
Copy link
Contributor

skeees commented Apr 11, 2018

This is a move-only commit - so maybe not the right place - but it might be nice to separate the misbehaving peer punishment logic from the re-attempting to accept orphans to the mempool logic - good first step though

Because many listeners (eg wallet) will want both types of events
to be well-ordered, they are parallel and connected on the backend.
However, they are exposed separately to clients to separate the
logic (and because, hopefully, eventually, they can be exposed to
external clients of Bitcoin Core via libconsensus or similar).
This removes the whole ConnectTrace object, which may make it
slightly harder to remove the unbounded-memory-during-reorg bug
by throwing blocks out of memory and re-loading them from disk
later. Comments are added to validationinterface to note where
this should likely happen instead of ConnectTrace.
Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

utACK aaaa4569b1ef49ce6f031325f03d171de55d8419 for both test code and moveonly refactoring code (I didn't have any comments on the moveonly code).

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like it woud be more robust (prevent hangs if the node wasn't disconnected) to call network_thread_join after disconnect_p2ps. This is the pattern used most other places (except feature_block for some reason). This would also make shutdown order the reverse of initialization order, which is a good pattern in general.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree. Should be fixed in both places.

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems not great to immediately start, stop, and restart the network thread. Could just split up the reconnect method up into connect / disconnect methods to avoid this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe just take a num_connections=1 optional argument and shorten to

for _ in range(num_connections):
    self.nodes[0].add_p2p_connection(P2PDataStore())

Copy link
Contributor

Choose a reason for hiding this comment

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

Check for reject reason below is now dropped (I guess is because the mininode is no longer whitelisted), so might be clearer to update this comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can the expect_disconnect case actually wait and verify the disconnect happened?

Copy link
Contributor

Choose a reason for hiding this comment

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

More test description would be helpful here (it took me a while to figure it out): Test confirms that mininode 1 doesn't get disconnected right away after sending the node an invalid orphan transaction. It then confirms mininode 1 is disconnected later when mininode 0 provides the missing parent which makes it possible to detect the orphan was invalid.

At least this explains the tx_withhold and tx_orphan_2_invalid parts of the new test. I still don't know why tx_orphan_1, tx_orphan_2_no_fee, and tx_orphan_2_valid are added and what they are testing for.

Copy link
Contributor

Choose a reason for hiding this comment

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

What is "may be rejected by policy" referring to and which transactions does it apply to?

Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice just for clarity if this could explicitly verify mininode 1 was disconnected and mininode is still connected. I understand the condition is implied from the peer count combined with expect_disconnect=False above, but it's not clear why this can't just be tested directly.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could make sense to rebase the test commit before the refactoring commit, to make it clear existing code is supposed to pass the new test.

Or maybe just put the new test in a standalone PR if the refactoring is going to be held up by #11775 anyway (#12935 (comment)).

@maflcko maflcko force-pushed the Mf1804-ProcessOrphans branch 3 times, most recently from 4dee1ea to 246b0d7 Compare April 16, 2018 20:11
@maflcko maflcko force-pushed the Mf1804-ProcessOrphans branch from 246b0d7 to 0c2bc58 Compare April 16, 2018 20:32
@maflcko maflcko closed this May 10, 2018
@maflcko maflcko deleted the Mf1804-ProcessOrphans branch May 10, 2018 20:07
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants