Skip to content

test: Add SyncWithValidationInterfaceQueue to mockscheduler RPC#28118

Merged
fanquake merged 2 commits into
bitcoin:masterfrom
maflcko:2307-test-mock-sync-
Jul 30, 2023
Merged

test: Add SyncWithValidationInterfaceQueue to mockscheduler RPC#28118
fanquake merged 2 commits into
bitcoin:masterfrom
maflcko:2307-test-mock-sync-

Conversation

@maflcko

@maflcko maflcko commented Jul 21, 2023

Copy link
Copy Markdown
Member

There should be no risk or downside in adding a call to SyncWithValidationInterfaceQueue here. In fact, it will make tests less brittle. For example,

MarcoFalke added 2 commits July 21, 2023 14:44
node_context is never null, but if it was, it would lead to a nullptr
dereference in node_context->scheduler. Just use EnsureAnyNodeContext
everywhere for more robust, consistent, and correct code.
@DrahtBot

DrahtBot commented Jul 21, 2023

Copy link
Copy Markdown
Contributor

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

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK TheCharlatan, furszy

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

@sedited sedited left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ACK fabef12

Seems like the correct thing to do here anyway. Also reproduced the feature_fee_estimation behavior change.

@furszy furszy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Little topic, mainly to not mix RPC commands responsibilities.

Why not implementing this on the test framework instead?

Could add a proxy function mockscheduler to test_node.py that calls to the real mockscheduler and, subsequently to syncwithvalidationinterfacequeue.

@maflcko

maflcko commented Jul 28, 2023

Copy link
Copy Markdown
Member Author

Why not implementing this on the test framework instead?

That just seems brittle, and bloated, for no reason? It is brittle because one may miss to implement a proxy, as they'll have to be done for the bitcoin-cli utility and the python rpc wrapper, and devs can still accidentally sidestep it. It is bloated because it will be more than one line of code.

@furszy

furszy commented Jul 28, 2023

Copy link
Copy Markdown
Member

That just seems brittle, and bloated, for no reason? It is brittle because one may miss to implement a proxy, as they'll have to be done for the bitcoin-cli utility and the python rpc wrapper, and devs can still accidentally sidestep it. It is bloated because it will be more than one line of code.

I'm not really strong here but It just seems a bit error-prone to always call to the syncwithvalidationinterfacequeue internally after bumping the scheduler timeout and not before. Existing callbacks using the node's time to operate could be affected and perform differently (sometimes we might want this, some others we might not?). And thought that it would be easier to change/adapt when calls are done outside of the RPC command.

About the tests bloat, it should just be a:

def mockscheduler(self, time):
    self.__getattr__('mockscheduler')(time)
    self.__getattr__('syncwithvalidationinterfacequeue')()

But it is just a gut feeling. All good either way.

@maflcko

maflcko commented Jul 28, 2023

Copy link
Copy Markdown
Member Author

Existing callbacks using the node's time to operate could be affected and perform differently

No, they shouldn't be affected by this change. The scheduler thread is already free to behave at any time as-if syncwithvalidationinterfacequeue was just called.

This will only reduce intermittent test failure rates where the test assumed that the scheduler thread behaved as-if syncwithvalidationinterfacequeue was called and that it must happen within a specific time. As explained in the description there are tests with this assumption. This pull request fixes those tests, and all other cases of the same kind in all current and future tests.

@furszy furszy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Code review ACK fabef12. Convinced by checking all current tests usages.
Thanks Marco.

@fanquake fanquake merged commit 64440bb into bitcoin:master Jul 30, 2023
@maflcko maflcko deleted the 2307-test-mock-sync- branch July 30, 2023 10:41
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Aug 9, 2023
…ckscheduler RPC

fabef12 refactor: Use EnsureAnyNodeContext (MarcoFalke)
fa16406 test: Add SyncWithValidationInterfaceQueue to mockscheduler RPC (MarcoFalke)

Pull request description:

  There should be no risk or downside in adding a call to `SyncWithValidationInterfaceQueue` here. In fact, it will make tests less brittle. For example,

  * If one sets the timeouts in `test/functional/feature_fee_estimation.py` to `0`, on `master` the test will fail and here it will pass.
  * It may avoid a rare (theoretic) intermittent issue in https://github.com/bitcoin/bitcoin/pull/28108/files#r1268966663

ACKs for top commit:
  TheCharlatan:
    ACK fabef12
  furszy:
    Code review ACK fabef12. Convinced by checking all current tests usages.

Tree-SHA512: c9e9a536a8721d1b3f267a66b40578b34948892301affdcad121ef8e02bf17037305d0dd53aa94b1b064753e66f9cfb31823b916b707a9d812627f502b818003
@bitcoin bitcoin locked and limited conversation to collaborators Jul 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants