rpc: Push down safe mode checks #11179

pull laanwj wants to merge 1 commits into bitcoin:master from laanwj:2017_08_safemode_pushdown changing 14 files +189 −150
  1. laanwj commented at 12:26 pm on August 28, 2017: member

    This contains most of the changes of #10563 “remove safe mode” by @achow101, but doesn’t remove the safe mode yet, but put an ObserveSafeMode() check in (all 23) individual calls which used to have okSafeMode=false.

    This cleans up the ugly “okSafeMode” flag from the dispatch tables, which is not a concern for the RPC server.

    Extra-author: Wladimir J. van der Laan laanwj@gmail.com

  2. laanwj added the label RPC/REST/ZMQ on Aug 28, 2017
  3. laanwj force-pushed on Aug 28, 2017
  4. meshcollider commented at 1:38 pm on August 28, 2017: contributor
    Concept ACK, cleans it up a lot :+1:
  5. in src/rpc/rawtransaction.cpp:41 in f9ec0b5083 outdated
    36 #include <univalue.h>
    37 
    38+void ObserveSafeMode()
    39+{
    40+    std::string strWarning = GetWarnings("rpc");
    41+    if (strWarning != "" && !gArgs.GetBoolArg("-disablesafemode", DEFAULT_DISABLE_SAFEMODE))
    


    promag commented at 1:47 pm on August 28, 2017:
    Missing {.

    laanwj commented at 2:12 pm on August 28, 2017:
    This was simply moved code, but whatever, I’ll add it if people care about this change at all.

    promag commented at 2:15 pm on August 28, 2017:
    Then rename strWarning to warning? 🙏
  6. in src/rpc/rawtransaction.cpp:38 in f9ec0b5083 outdated
    33 
    34 #include <stdint.h>
    35 
    36 #include <univalue.h>
    37 
    38+void ObserveSafeMode()
    


    promag commented at 1:53 pm on August 28, 2017:
    What is the reason to add it here? Move to rpc/server.{cpp,h}?

    laanwj commented at 2:11 pm on August 28, 2017:
    No, whereever it belongs it doesn’t belong in server.cpp|h, the whole point here is that the concern of safemode is independent from the RPC server and is a bitcoin-specific concern.
  7. promag commented at 2:06 pm on August 28, 2017: member
    Didn’t test, but with this change it is possible run help command where before OnRPCPreCommand prevented it?
  8. laanwj commented at 2:12 pm on August 28, 2017: member

    Didn’t test, but with this change it is possible run help command where before OnRPCPreCommand prevented it?

    Yes, that should be possible, I put the checks after the help check everywhere.

  9. promag commented at 11:38 pm on August 28, 2017: member
    Beside the new file rpc/rawtransaction.h, utACK f9ec0b5.
  10. sipa commented at 0:52 am on August 29, 2017: member
    Concept ACK, nice
  11. achow101 commented at 1:00 am on August 29, 2017: member
    Concept ACK. I think the ObserveSafeMode implementation and definition should only be in the wallet RPCs in (wallet/rpcwallet.{cpp/h}) since that is really the only place that safe mode is actually observed. For signrawtransaction, maybe make it only do safe mode when wallet is enabled?
  12. laanwj commented at 7:30 am on August 29, 2017: member

    Concept ACK. I think the ObserveSafeMode implementation and definition should only be in the wallet RPCs in (wallet/rpcwallet.{cpp/h}) since that is really the only place that safe mode is actually observed

    Fine with me, although that’d no longer make this a pure refactor. I carefully preserved the current set of safe-mode-enforced calls for that reason, even though it seemed a bit silly to me at times.

    For signrawtransaction, maybe make it only do safe mode when wallet is enabled?

    If the implementation is used by even one call in rpctransaction.cpp, even if conditional on ENABLE_WALLET, it needs to be defined there. This is to avoid library linking circularity: libbitcoin_server cannot* depend on anything defined in the libbitcoin_wallet library.

    So if people agree on that I’m fine with adding a commit “Observe safe mode only for wallet RPCs” which moves ObserveSafeMode and everything related to the wallet, and removes it from the rawtransaction calls. If that creates any kind of disagreement, though, I’d suggest that that is addressed in a later PR.

    *: this is being violated in some places and some linkers are kind enough to accommodate this (#7965), but I will not make it worse

  13. promag commented at 7:45 am on August 29, 2017: member
    This is fine as is, let’s change the behavior only in a followup PR.. what about rpc/safe.h instead?
  14. laanwj force-pushed on Aug 29, 2017
  15. laanwj commented at 8:00 am on August 29, 2017: member
    Good idea, moved the safemode enforcement as well as the DEFAULT constant to a new src/rpc/safemode.(h|cpp). f9ec0b5a3ecc1e
  16. in src/rpc/safemode.cpp:9 in a3ecc1e499 outdated
    0@@ -0,0 +1,13 @@
    1+#include "safemode.h"
    2+
    3+#include "rpc/protocol.h"
    4+#include "util.h"
    5+#include "warnings.h"
    6+
    7+void ObserveSafeMode()
    8+{
    9+    std::string strWarning = GetWarnings("rpc");
    


    promag commented at 8:04 am on August 29, 2017:
    std::string warning =
  17. in src/rpc/safemode.cpp:10 in a3ecc1e499 outdated
     5+#include "warnings.h"
     6+
     7+void ObserveSafeMode()
     8+{
     9+    std::string strWarning = GetWarnings("rpc");
    10+    if (strWarning != "" && !gArgs.GetBoolArg("-disablesafemode", DEFAULT_DISABLE_SAFEMODE))
    


    promag commented at 8:05 am on August 29, 2017:
    Missing braces.
  18. in src/rpc/safemode.h:12 in a3ecc1e499 outdated
     7+
     8+static const bool DEFAULT_DISABLE_SAFEMODE = true;
     9+
    10+void ObserveSafeMode();
    11+
    12+#endif //  BITCOIN_RPC_SAFEMODE_H
    


    promag commented at 8:06 am on August 29, 2017:
    Remove extra space.
  19. promag commented at 8:07 am on August 29, 2017: member
    :trollface:
  20. rpc: Push down safe mode checks
    This contains most of the changes of 10563 "remove safe mode", but doesn't
    remove the safe mode yet, but put an `ObserveSafeMode()` check in
    individual calls with okSafeMode=false.
    
    This cleans up the ugly "okSafeMode" flag from the dispatch tables,
    which is not a concern for the RPC server.
    
    Extra-author: Wladimir J. van der Laan <laanwj@gmail.com>
    ec6902d0ea
  21. laanwj force-pushed on Aug 29, 2017
  22. laanwj commented at 8:11 am on August 29, 2017: member
    Right. a3ecc1eec6902d
  23. promag commented at 9:11 am on August 29, 2017: member
    utACK ec6902d. Ty.
  24. meshcollider commented at 12:16 pm on August 29, 2017: contributor
  25. achow101 commented at 1:48 pm on August 29, 2017: member

    utACK ec6902d0ea2bbe75179684fc71849d5e34647a14

    If the implementation is used by even one call in rpctransaction.cpp, even if conditional on ENABLE_WALLET, it needs to be defined there. This is to avoid library linking circularity: libbitcoin_server cannot* depend on anything defined in the libbitcoin_wallet library.

    Ugh circular linking. Lets not do that then.

  26. jonasschnelli commented at 9:17 pm on August 29, 2017: contributor
    Concept ACK
  27. dcousens approved
  28. laanwj merged this on Sep 5, 2017
  29. laanwj closed this on Sep 5, 2017

  30. laanwj referenced this in commit e0e3cbbf08 on Sep 5, 2017
  31. PastaPastaPasta referenced this in commit 8333834ba6 on Sep 19, 2019
  32. PastaPastaPasta referenced this in commit 1f901a183b on Sep 19, 2019
  33. PastaPastaPasta referenced this in commit dac32edd38 on Sep 23, 2019
  34. PastaPastaPasta referenced this in commit 6886855c4f on Sep 24, 2019
  35. PastaPastaPasta referenced this in commit 4bce5f1364 on Nov 19, 2019
  36. PastaPastaPasta referenced this in commit 21116f9a30 on Nov 21, 2019
  37. PastaPastaPasta referenced this in commit f95269fd92 on Dec 9, 2019
  38. PastaPastaPasta referenced this in commit 6e3c4f1cbd on Jan 1, 2020
  39. PastaPastaPasta referenced this in commit 7279aba8da on Jan 2, 2020
  40. PastaPastaPasta referenced this in commit 5be58aa8f4 on Jan 2, 2020
  41. PastaPastaPasta referenced this in commit 1c4757b707 on Jan 2, 2020
  42. PastaPastaPasta referenced this in commit 4d8a9cb294 on Jan 2, 2020
  43. PastaPastaPasta referenced this in commit d059a9f91b on Jan 2, 2020
  44. PastaPastaPasta referenced this in commit 02568d9104 on Jan 2, 2020
  45. PastaPastaPasta referenced this in commit 09ed6a45e1 on Jan 3, 2020
  46. ckti referenced this in commit db1810df8e on Mar 28, 2021
  47. theStack referenced this in commit 6780a095d8 on Jun 10, 2021
  48. MarcoFalke referenced this in commit 356f421fb0 on Jun 10, 2021
  49. sidhujag referenced this in commit 31c5f63f87 on Jun 10, 2021
  50. rebroad referenced this in commit 8770290a33 on Jun 23, 2021
  51. PastaPastaPasta referenced this in commit 7f080abaa0 on Jun 27, 2021
  52. PastaPastaPasta referenced this in commit ca589641fe on Jun 28, 2021
  53. rebroad referenced this in commit e8b5e2ee3f on Jun 28, 2021
  54. PastaPastaPasta referenced this in commit 82805d1cff on Jun 29, 2021
  55. gades referenced this in commit 3434ead3db on Jun 30, 2021
  56. PastaPastaPasta referenced this in commit e2588d6307 on Jul 1, 2021
  57. PastaPastaPasta referenced this in commit e3358c084e on Jul 1, 2021
  58. PastaPastaPasta referenced this in commit 2a15402593 on Jul 15, 2021
  59. PastaPastaPasta referenced this in commit 505d06300e on Jul 15, 2021
  60. PastaPastaPasta referenced this in commit 289c8772a8 on Jul 16, 2021
  61. gabriel-bjg referenced this in commit fea0de1e90 on Jul 16, 2021
  62. DrahtBot locked this on Sep 8, 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