Remove p2pEnabled from Chain interface #16503

pull ariard wants to merge 1 commits into bitcoin:master from ariard:2019-07-remove-p2p-chain changing 4 files +3 −12
  1. ariard commented at 11:08 pm on July 30, 2019: member
    RPC server starts in warmup mode, it can’t process yet calls, then follows connection manager initialization and finally RPC server get out of warmup mode. RPC calls shouldn’t be able to get P2P disabled errors because once we initialize g_connman it’s not unset until shutdown, after RPC server has been stopped. @mzumsande comment in #15713 let me thought that p2pEnabled was maybe useless, g_connman is always initialized before RPC server is getting out of warmup. These checks against P2P state were introduced in https://github.com/bitcoin/bitcoin/pull/8085/commits/5b446dd5b11d4f403554bc2dd5a7a94c7d20422a.
  2. promag commented at 11:46 pm on July 30, 2019: member

    Also when CWalletTx::RelayWalletTransaction is called g_connman is already set and the scheduler is stopped before g_connman is released. AFAICT this change is correct. I was thinking adding assert(g_connman) in interfaces::ChainImpl::relayTransaction but probably it’s unnecessary.

    ACK 18d6a81505123e703be87aa31eeb7fb48b5d50bd.

  3. DrahtBot added the label RPC/REST/ZMQ on Jul 30, 2019
  4. DrahtBot added the label Wallet on Jul 30, 2019
  5. DrahtBot commented at 2:41 am on July 31, 2019: member

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

    Conflicts

    No conflicts as of last run.

  6. laanwj requested review from theuni on Jul 31, 2019
  7. laanwj commented at 6:14 am on July 31, 2019: member

    ~0 on this

    Needs review by @theuni, he probably knows the reasoning behind this. I think the intent was that it’s possible to run the node without P2P enabled at all, even though it’s currently not an option.

    (or maybe the idea was to make various parts more loosely coupled to have more flexibility in the initialization sequence)

    assert(g_connman) in interfaces::ChainImpl::relayTransaction

    Yes, please do this. Otherwise, in the case of a bug in the initialization sequence that skips the P2P initialization it runs into a null pointer exception.

  8. fanquake added the label Waiting for author on Jul 31, 2019
  9. promag commented at 7:43 am on July 31, 2019: member

    (or maybe the idea was to make various parts more loosely coupled to have more flexibility in the initialization sequence) @laanwj I don’t think just checking p2pEnabled() is enough for that, it’s not thread safe and it doesn’t retain the CConnMan.

  10. ariard commented at 2:29 pm on July 31, 2019: member

    I would argue that removing global use in ChainImpl move forward getting the P2P self-contained, which is an ongoing project I think.

    Yes of course @theuni should know the reason and if checks are still relevant.

    Note : #15713 is removing relayTransaction on the p2p check, wallet should just submit txn to mempool

  11. MarcoFalke commented at 3:19 pm on July 31, 2019: member
    Concept ACK per @ariard and @promag . I prefer the way #15713 does it by returning TransactionError::P2P_DISABLED when connman is not there.
  12. jnewbery commented at 3:39 pm on August 1, 2019: member

    ACK 18d6a81505123e703be87aa31eeb7fb48b5d50bd

    assert(g_connman) in interfaces::ChainImpl::relayTransaction

    Seems reasonable. I’d add a comment saying something like:

    g_connman is assigned before chain clients are started, and reset after chain clients are stopped. g_connman should never be null for calls over the Chain interface.

  13. DrahtBot added the label Needs rebase on Aug 2, 2019
  14. MarcoFalke removed the label Waiting for author on Aug 7, 2019
  15. MarcoFalke commented at 8:32 pm on August 7, 2019: member
    @ariard Are you still working on this?
  16. ariard commented at 8:53 pm on August 7, 2019: member
    Yes, still waiting Concept ACK by @theuni to go further
  17. jnewbery commented at 10:00 pm on August 7, 2019: member
    No need to allow this to be blocked by one person. I suggest you keep this rebased so it’s ready to merge.
  18. ariard force-pushed on Aug 8, 2019
  19. ariard commented at 2:00 am on August 8, 2019: member
    Rebased at 6e08957. RelayWalletTransaction P2P check has been removed due to #15713 merge, which also added a g_connman assertion in BroadcastTransaction.
  20. DrahtBot removed the label Needs rebase on Aug 8, 2019
  21. MarcoFalke commented at 6:32 pm on August 8, 2019: member

    unsigned ACK 6e089572a79de38a08692b23b8a139171082139b (only looked at the diff on GitHub)

    I think it makes sense to remove obviously dead code. And if it wasn’t dead code, it would be racy and result in either an assert failure or a segmentation fault. If such a check is ever needed in the future, it should be added at that time.

  22. jnewbery commented at 6:44 pm on August 8, 2019: member

    Do you mind adding a comment to the assert(g_connman) in BroadcastTransaction()? Something like:

    “BroadcastTransaction can be called by the RPC server or wallet. g_connman is assigned before chain clients and the RPC server are started, and reset after chain clients adn the RPC are stopped are stopped. g_connman should never be null here.”

  23. Remove p2pEnabled from Chain interface
    RPC server starts in warmup mode, it can't
    process yet calls, then follows connection manager
    initialization and finally RPC server get out of
    warmup mode. RPC calls shouldn't be able to get
    P2P disabled errors because once we initialize
    g_connman it's not unset until shutdown, after
    RPC server has been stopped.
    b7b9f6e4ce
  24. ariard force-pushed on Aug 9, 2019
  25. ariard commented at 3:00 am on August 9, 2019: member
    Comment added at b7b9f6e
  26. promag commented at 7:40 am on August 9, 2019: member
    ACK b7b9f6e4cee262004643e2fe03d56cb47fdbf5c2
  27. jnewbery commented at 1:34 pm on August 9, 2019: member
    ACK b7b9f6e4cee262004643e2fe03d56cb47fdbf5c2
  28. MarcoFalke referenced this in commit 9ab9d63569 on Aug 9, 2019
  29. MarcoFalke merged this on Aug 9, 2019
  30. MarcoFalke closed this on Aug 9, 2019

  31. theuni commented at 1:54 pm on August 10, 2019: member

    Sorry for the delay. Post-merge concept ACK.

    Chain was the wrong place for this anyway.

  32. deadalnix referenced this in commit a4830c0892 on Sep 5, 2020
  33. Munkybooty referenced this in commit 5d4969b10b on Nov 25, 2021
  34. Munkybooty referenced this in commit 420ddf58ff on Nov 25, 2021
  35. MarcoFalke locked this on Dec 16, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-17 12:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me