Skip to content

Commit 17266a1

Browse files
committed
Merge #13090: Remove Safe mode (achow101)
d8e9a2a Remove "rpc" category from GetWarnings (Wladimir J. van der Laan) 7da3b0a rpc: Move RPC_FORBIDDEN_BY_SAFE_MODE code to reserved section (Wladimir J. van der Laan) 2ae705d Remove Safe mode (Andrew Chow) Pull request description: Rebase of #10563. Safe mode was [disabled by default and deprecated in 0.16](https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-0.16.0.md#safe-mode-disabled-by-default), so probably should be removed for 0.17. > Rationale: > > Safe mode is useless. It only disables some RPC commands when large work forks are detected. Nothing else is affected by safe mode. It seems that very few people would be affected by safe mode. The people who use Core as a wallet are primarily using it through the GUI, which safe mode does not effect. In the GUI, transactions will still be made as normal; only a warning is displayed. > > I also don't think that we should be disabling RPC commands or any functionality in general. If we do, it should be done consistently, which safe mode is not. If we want to keep the idea of a safe mode around, I think that the current system needs to go first before a new system can be implemented. Tree-SHA512: 067938f47ca6e879fb6c3c4e21f9946fd7c5da3cde67ef436f1666798c78d049225b9111dc97064f42b3bc549d3915229fa19ad5a634588f381e34fc65d64044
2 parents 487dcbe + d8e9a2a commit 17266a1

File tree

11 files changed

+7
-90
lines changed

11 files changed

+7
-90
lines changed

src/Makefile.am

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ BITCOIN_CORE_H = \
137137
rpc/client.h \
138138
rpc/mining.h \
139139
rpc/protocol.h \
140-
rpc/safemode.h \
141140
rpc/server.h \
142141
rpc/rawtransaction.h \
143142
rpc/register.h \
@@ -223,7 +222,6 @@ libbitcoin_server_a_SOURCES = \
223222
rpc/misc.cpp \
224223
rpc/net.cpp \
225224
rpc/rawtransaction.cpp \
226-
rpc/safemode.cpp \
227225
rpc/server.cpp \
228226
script/sigcache.cpp \
229227
timedata.cpp \

src/init.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include <policy/policy.h>
3232
#include <rpc/server.h>
3333
#include <rpc/register.h>
34-
#include <rpc/safemode.h>
3534
#include <rpc/blockchain.h>
3635
#include <script/standard.h>
3736
#include <script/sigcache.h>
@@ -448,9 +447,7 @@ std::string HelpMessage(HelpMessageMode mode)
448447
strUsage += HelpMessageOpt("-checkblockindex", strprintf("Do a full consistency check for mapBlockIndex, setBlockIndexCandidates, chainActive and mapBlocksUnlinked occasionally. (default: %u)", defaultChainParams->DefaultConsistencyChecks()));
449448
strUsage += HelpMessageOpt("-checkmempool=<n>", strprintf("Run checks every <n> transactions (default: %u)", defaultChainParams->DefaultConsistencyChecks()));
450449
strUsage += HelpMessageOpt("-checkpoints", strprintf("Disable expensive verification for known chain history (default: %u)", DEFAULT_CHECKPOINTS_ENABLED));
451-
strUsage += HelpMessageOpt("-disablesafemode", strprintf("Disable safemode, override a real safe mode event (default: %u)", DEFAULT_DISABLE_SAFEMODE));
452450
strUsage += HelpMessageOpt("-deprecatedrpc=<method>", "Allows deprecated RPC method(s) to be used");
453-
strUsage += HelpMessageOpt("-testsafemode", strprintf("Force safe mode (default: %u)", DEFAULT_TESTSAFEMODE));
454451
strUsage += HelpMessageOpt("-dropmessagestest=<n>", "Randomly drop 1 of every <n> network messages");
455452
strUsage += HelpMessageOpt("-stopafterblockimport", strprintf("Stop running after importing blocks from disk (default: %u)", DEFAULT_STOPAFTERBLOCKIMPORT));
456453
strUsage += HelpMessageOpt("-stopatheight", strprintf("Stop running after reaching the given height in the main chain (default: %u)", DEFAULT_STOPATHEIGHT));

src/rpc/protocol.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ enum RPCErrorCode
4646

4747
//! General application defined errors
4848
RPC_MISC_ERROR = -1, //!< std::exception thrown in command handling
49-
RPC_FORBIDDEN_BY_SAFE_MODE = -2, //!< Server is in safe mode, and command is not allowed in safe mode
5049
RPC_TYPE_ERROR = -3, //!< Unexpected type was passed as parameter
5150
RPC_INVALID_ADDRESS_OR_KEY = -5, //!< Invalid address or key
5251
RPC_OUT_OF_MEMORY = -7, //!< Ran out of memory during operation
@@ -88,6 +87,9 @@ enum RPCErrorCode
8887

8988
//! Backwards compatible aliases
9089
RPC_WALLET_INVALID_ACCOUNT_NAME = RPC_WALLET_INVALID_LABEL_NAME,
90+
91+
//! Unused reserved codes, kept around for backwards compatibility. Do not reuse.
92+
RPC_FORBIDDEN_BY_SAFE_MODE = -2, //!< Server is in safe mode, and command is not allowed in safe mode
9193
};
9294

9395
UniValue JSONRPCRequestObj(const std::string& strMethod, const UniValue& params, const UniValue& id);

src/rpc/rawtransaction.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <policy/rbf.h>
2020
#include <primitives/transaction.h>
2121
#include <rpc/rawtransaction.h>
22-
#include <rpc/safemode.h>
2322
#include <rpc/server.h>
2423
#include <script/script.h>
2524
#include <script/script_error.h>
@@ -1108,8 +1107,6 @@ UniValue sendrawtransaction(const JSONRPCRequest& request)
11081107
+ HelpExampleRpc("sendrawtransaction", "\"signedhex\"")
11091108
);
11101109

1111-
ObserveSafeMode();
1112-
11131110
std::promise<void> promise;
11141111

11151112
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL});
@@ -1217,8 +1214,6 @@ UniValue testmempoolaccept(const JSONRPCRequest& request)
12171214
);
12181215
}
12191216

1220-
ObserveSafeMode();
1221-
12221217
RPCTypeCheck(request.params, {UniValue::VARR, UniValue::VBOOL});
12231218
if (request.params[0].get_array().size() != 1) {
12241219
throw JSONRPCError(RPC_INVALID_PARAMETER, "Array must contain exactly one raw transaction for now");

src/rpc/safemode.cpp

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/rpc/safemode.h

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/wallet/rpcdump.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include <chain.h>
66
#include <key_io.h>
7-
#include <rpc/safemode.h>
87
#include <rpc/server.h>
98
#include <validation.h>
109
#include <script/script.h>
@@ -204,7 +203,6 @@ UniValue abortrescan(const JSONRPCRequest& request)
204203
+ HelpExampleRpc("abortrescan", "")
205204
);
206205

207-
ObserveSafeMode();
208206
if (!pwallet->IsScanning() || pwallet->IsAbortingRescan()) return false;
209207
pwallet->AbortRescan();
210208
return true;

src/wallet/rpcwallet.cpp

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <policy/rbf.h>
1818
#include <rpc/mining.h>
1919
#include <rpc/rawtransaction.h>
20-
#include <rpc/safemode.h>
2120
#include <rpc/server.h>
2221
#include <rpc/util.h>
2322
#include <script/sign.h>
@@ -525,8 +524,6 @@ UniValue sendtoaddress(const JSONRPCRequest& request)
525524
+ HelpExampleRpc("sendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", 0.1, \"donation\", \"seans outpost\"")
526525
);
527526

528-
ObserveSafeMode();
529-
530527
// Make sure the results are valid at least up to the most recent block
531528
// the user could have gotten from another RPC command prior to now
532529
pwallet->BlockUntilSyncedToCurrentChain();
@@ -607,8 +604,6 @@ UniValue listaddressgroupings(const JSONRPCRequest& request)
607604
+ HelpExampleRpc("listaddressgroupings", "")
608605
);
609606

610-
ObserveSafeMode();
611-
612607
// Make sure the results are valid at least up to the most recent block
613608
// the user could have gotten from another RPC command prior to now
614609
pwallet->BlockUntilSyncedToCurrentChain();
@@ -724,8 +719,6 @@ UniValue getreceivedbyaddress(const JSONRPCRequest& request)
724719
+ HelpExampleRpc("getreceivedbyaddress", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", 6")
725720
);
726721

727-
ObserveSafeMode();
728-
729722
// Make sure the results are valid at least up to the most recent block
730723
// the user could have gotten from another RPC command prior to now
731724
pwallet->BlockUntilSyncedToCurrentChain();
@@ -798,8 +791,6 @@ UniValue getreceivedbylabel(const JSONRPCRequest& request)
798791
+ HelpExampleRpc("getreceivedbylabel", "\"tabby\", 6")
799792
);
800793

801-
ObserveSafeMode();
802-
803794
// Make sure the results are valid at least up to the most recent block
804795
// the user could have gotten from another RPC command prior to now
805796
pwallet->BlockUntilSyncedToCurrentChain();
@@ -879,8 +870,6 @@ UniValue getbalance(const JSONRPCRequest& request)
879870
+ HelpExampleRpc("getbalance", "\"*\", 6")
880871
);
881872

882-
ObserveSafeMode();
883-
884873
// Make sure the results are valid at least up to the most recent block
885874
// the user could have gotten from another RPC command prior to now
886875
pwallet->BlockUntilSyncedToCurrentChain();
@@ -933,8 +922,6 @@ UniValue getunconfirmedbalance(const JSONRPCRequest &request)
933922
"getunconfirmedbalance\n"
934923
"Returns the server's total unconfirmed balance\n");
935924

936-
ObserveSafeMode();
937-
938925
// Make sure the results are valid at least up to the most recent block
939926
// the user could have gotten from another RPC command prior to now
940927
pwallet->BlockUntilSyncedToCurrentChain();
@@ -980,7 +967,6 @@ UniValue movecmd(const JSONRPCRequest& request)
980967
+ HelpExampleRpc("move", "\"timotei\", \"akiko\", 0.01, 6, \"happy birthday!\"")
981968
);
982969

983-
ObserveSafeMode();
984970
LOCK2(cs_main, pwallet->cs_wallet);
985971

986972
std::string strFrom = LabelFromValue(request.params[0]);
@@ -1039,8 +1025,6 @@ UniValue sendfrom(const JSONRPCRequest& request)
10391025
+ HelpExampleRpc("sendfrom", "\"tabby\", \"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", 0.01, 6, \"donation\", \"seans outpost\"")
10401026
);
10411027

1042-
ObserveSafeMode();
1043-
10441028
// Make sure the results are valid at least up to the most recent block
10451029
// the user could have gotten from another RPC command prior to now
10461030
pwallet->BlockUntilSyncedToCurrentChain();
@@ -1170,8 +1154,6 @@ UniValue sendmany(const JSONRPCRequest& request)
11701154

11711155
if (request.fHelp || request.params.size() < 2 || request.params.size() > 8) throw std::runtime_error(help_text);
11721156

1173-
ObserveSafeMode();
1174-
11751157
// Make sure the results are valid at least up to the most recent block
11761158
// the user could have gotten from another RPC command prior to now
11771159
pwallet->BlockUntilSyncedToCurrentChain();
@@ -1683,8 +1665,6 @@ UniValue listreceivedbyaddress(const JSONRPCRequest& request)
16831665
+ HelpExampleRpc("listreceivedbyaddress", "6, true, true, \"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\"")
16841666
);
16851667

1686-
ObserveSafeMode();
1687-
16881668
// Make sure the results are valid at least up to the most recent block
16891669
// the user could have gotten from another RPC command prior to now
16901670
pwallet->BlockUntilSyncedToCurrentChain();
@@ -1735,8 +1715,6 @@ UniValue listreceivedbylabel(const JSONRPCRequest& request)
17351715
+ HelpExampleRpc("listreceivedbylabel", "6, true, true")
17361716
);
17371717

1738-
ObserveSafeMode();
1739-
17401718
// Make sure the results are valid at least up to the most recent block
17411719
// the user could have gotten from another RPC command prior to now
17421720
pwallet->BlockUntilSyncedToCurrentChain();
@@ -1974,8 +1952,6 @@ UniValue listtransactions(const JSONRPCRequest& request)
19741952
}
19751953
if (request.fHelp || request.params.size() > 4) throw std::runtime_error(help_text);
19761954

1977-
ObserveSafeMode();
1978-
19791955
// Make sure the results are valid at least up to the most recent block
19801956
// the user could have gotten from another RPC command prior to now
19811957
pwallet->BlockUntilSyncedToCurrentChain();
@@ -2088,8 +2064,6 @@ UniValue listaccounts(const JSONRPCRequest& request)
20882064
+ HelpExampleRpc("listaccounts", "6")
20892065
);
20902066

2091-
ObserveSafeMode();
2092-
20932067
// Make sure the results are valid at least up to the most recent block
20942068
// the user could have gotten from another RPC command prior to now
20952069
pwallet->BlockUntilSyncedToCurrentChain();
@@ -2202,8 +2176,6 @@ UniValue listsinceblock(const JSONRPCRequest& request)
22022176
+ HelpExampleRpc("listsinceblock", "\"000000000000000bacf66f7497b7dc45ef753ee9a7d38571037cdb1a57f663ad\", 6")
22032177
);
22042178

2205-
ObserveSafeMode();
2206-
22072179
// Make sure the results are valid at least up to the most recent block
22082180
// the user could have gotten from another RPC command prior to now
22092181
pwallet->BlockUntilSyncedToCurrentChain();
@@ -2339,8 +2311,6 @@ UniValue gettransaction(const JSONRPCRequest& request)
23392311
+ HelpExampleRpc("gettransaction", "\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
23402312
);
23412313

2342-
ObserveSafeMode();
2343-
23442314
// Make sure the results are valid at least up to the most recent block
23452315
// the user could have gotten from another RPC command prior to now
23462316
pwallet->BlockUntilSyncedToCurrentChain();
@@ -2407,8 +2377,6 @@ UniValue abandontransaction(const JSONRPCRequest& request)
24072377
);
24082378
}
24092379

2410-
ObserveSafeMode();
2411-
24122380
// Make sure the results are valid at least up to the most recent block
24132381
// the user could have gotten from another RPC command prior to now
24142382
pwallet->BlockUntilSyncedToCurrentChain();
@@ -2889,7 +2857,6 @@ UniValue listlockunspent(const JSONRPCRequest& request)
28892857
+ HelpExampleRpc("listlockunspent", "")
28902858
);
28912859

2892-
ObserveSafeMode();
28932860
LOCK2(cs_main, pwallet->cs_wallet);
28942861

28952862
std::vector<COutPoint> vOutpts;
@@ -2968,8 +2935,6 @@ UniValue getwalletinfo(const JSONRPCRequest& request)
29682935
+ HelpExampleRpc("getwalletinfo", "")
29692936
);
29702937

2971-
ObserveSafeMode();
2972-
29732938
// Make sure the results are valid at least up to the most recent block
29742939
// the user could have gotten from another RPC command prior to now
29752940
pwallet->BlockUntilSyncedToCurrentChain();
@@ -3126,8 +3091,6 @@ UniValue listunspent(const JSONRPCRequest& request)
31263091
+ HelpExampleRpc("listunspent", "6, 9999999, [] , true, { \"minimumAmount\": 0.005 } ")
31273092
);
31283093

3129-
ObserveSafeMode();
3130-
31313094
int nMinDepth = 1;
31323095
if (!request.params[0].isNull()) {
31333096
RPCTypeCheckArgument(request.params[0], UniValue::VNUM);
@@ -3300,7 +3263,6 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
33003263
+ HelpExampleCli("sendrawtransaction", "\"signedtransactionhex\"")
33013264
);
33023265

3303-
ObserveSafeMode();
33043266
RPCTypeCheck(request.params, {UniValue::VSTR});
33053267

33063268
// Make sure the results are valid at least up to the most recent block

src/warnings.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ void SetfLargeWorkInvalidChainFound(bool flag)
4040
std::string GetWarnings(const std::string& strFor)
4141
{
4242
std::string strStatusBar;
43-
std::string strRPC;
4443
std::string strGUI;
4544
const std::string uiAlertSeperator = "<hr />";
4645

@@ -51,9 +50,6 @@ std::string GetWarnings(const std::string& strFor)
5150
strGUI = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
5251
}
5352

54-
if (gArgs.GetBoolArg("-testsafemode", DEFAULT_TESTSAFEMODE))
55-
strStatusBar = strRPC = strGUI = "testsafemode enabled";
56-
5753
// Misc warnings like out of disk space and clock is wrong
5854
if (strMiscWarning != "")
5955
{
@@ -63,21 +59,19 @@ std::string GetWarnings(const std::string& strFor)
6359

6460
if (fLargeWorkForkFound)
6561
{
66-
strStatusBar = strRPC = "Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.";
62+
strStatusBar = "Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.";
6763
strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.");
6864
}
6965
else if (fLargeWorkInvalidChainFound)
7066
{
71-
strStatusBar = strRPC = "Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.";
67+
strStatusBar = "Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.";
7268
strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.");
7369
}
7470

7571
if (strFor == "gui")
7672
return strGUI;
7773
else if (strFor == "statusbar")
7874
return strStatusBar;
79-
else if (strFor == "rpc")
80-
return strRPC;
8175
assert(!"GetWarnings(): invalid parameter");
8276
return "error";
8377
}

src/warnings.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,10 @@ bool GetfLargeWorkForkFound();
1515
void SetfLargeWorkInvalidChainFound(bool flag);
1616
/** Format a string that describes several potential problems detected by the core.
1717
* strFor can have three values:
18-
* - "rpc": get critical warnings, which should put the client in safe mode if non-empty
1918
* - "statusbar": get all warnings
2019
* - "gui": get all warnings, translated (where possible) for GUI
2120
* This function only returns the highest priority warning of the set selected by strFor.
2221
*/
2322
std::string GetWarnings(const std::string& strFor);
2423

25-
static const bool DEFAULT_TESTSAFEMODE = false;
26-
2724
#endif // BITCOIN_WARNINGS_H

0 commit comments

Comments
 (0)