Skip to content
Bitcoin Roots

v31.1-roots.1 · Commit 2: [PATCH 02/17] feat(policy): preserve Roots parsing and local transaction checks

src/init.cpp

Before: src/init.cpp · After: src/init.cpp

File metadata
index fb4b8fa9e27a34882e789a643cecdee5e0efb212..ac87cf0a531d0b7d931d635cc72f5fb69b82a436 100644

Download original patch · Release notes

Diff rows 1–70 of 70. Line numbers refer to the original before/after files.

+ Added− RemovedUnmarked lines are context.

Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.

src/init.cpp CHANGED
@@ -669,6 +669,29 @@ void SetupServerArgs(ArgsManager& argsman, bool can_listen_ipc)
669
669
 
670
670
  SetupChainParamsBaseOptions(argsman);
671
671
 
672
+ argsman.AddArg("-acceptunknownwitness", strprintf("Relay transactions sending to unknown or future witness script versions (default: %u)", DEFAULT_ACCEPTUNKNOWNWITNESS) + " Values: 0 or 1; no value means 1.", ArgsManager::ALLOW_ANY | ArgsManager::STRICT_NEGATION, OptionsCategory::NODE_RELAY);
673
+ argsman.AddArg("-dustdynamic=<value>", "Staged parsing only; enforcement is deferred to L8 graph policy. See doc/feature-contracts/policy-parsing.md for accepted grammar.", ArgsManager::ALLOW_ANY | ArgsManager::STRICT_NEGATION | ArgsManager::DEBUG_ONLY, OptionsCategory::NODE_RELAY);
674
+ argsman.AddArg("-bytespersigopstrict", strprintf("Minimum bytes per sigop in transactions we relay and mine (integer 0 to 4294967295; default: %u)", DEFAULT_BYTES_PER_SIGOP_STRICT), ArgsManager::ALLOW_ANY | ArgsManager::STRICT_NEGATION, OptionsCategory::NODE_RELAY);
675
+ argsman.AddArg("-datacarriercost=<value>", "Staged parsing only; enforcement is deferred to L8 graph policy. See doc/feature-contracts/policy-parsing.md for accepted grammar.", ArgsManager::ALLOW_ANY | ArgsManager::STRICT_NEGATION | ArgsManager::DEBUG_ONLY, OptionsCategory::NODE_RELAY);
676
+ argsman.AddArg("-datacarrierfullcount", strprintf("Apply datacarriersize limit to all known data-carrier methods (default: %u)", DEFAULT_DATACARRIER_FULLCOUNT) + " Values: 0 or 1; no value means 1.", ArgsManager::ALLOW_ANY | ArgsManager::STRICT_NEGATION | (DEFAULT_DATACARRIER_FULLCOUNT ? uint32_t{ArgsManager::DEBUG_ONLY} : 0), OptionsCategory::NODE_RELAY);
677
+ argsman.AddArg("-permitbaredatacarrier", strprintf("Relay transactions with data carrier outputs and no monetary outputs (default: %u)", DEFAULT_PERMITBAREDATACARRIER) + " Values: 0 or 1; no value means 1.", ArgsManager::ALLOW_ANY | ArgsManager::STRICT_NEGATION, OptionsCategory::NODE_RELAY);
678
+ argsman.AddArg("-acceptnonstddatacarrier", strprintf("Relay nonstandard data carrier outputs (default: %u)", DEFAULT_ACCEPT_NON_STD_DATACARRIER) + " Values: 0 or 1; no value means 1.", ArgsManager::ALLOW_ANY | ArgsManager::STRICT_NEGATION, OptionsCategory::NODE_RELAY);
679
+ argsman.AddArg("-permitephemeral", "Permit ephemeral policy exceptions: send, dust, anchor, reject, or 0, optionally prefixed with '-'. Tokens are separated by ',' or '+'; 0 disables all, empty or 1 enables all (default: anchor only)", ArgsManager::ALLOW_ANY | ArgsManager::STRICT_NEGATION, OptionsCategory::NODE_RELAY);
680
+ argsman.AddArg("-subdustfeepenalty=<value>", "Staged parsing only; enforcement is deferred to L8 graph policy. See doc/feature-contracts/policy-parsing.md for accepted grammar.", ArgsManager::ALLOW_ANY | ArgsManager::STRICT_NEGATION | ArgsManager::DEBUG_ONLY, OptionsCategory::NODE_RELAY);
681
+ argsman.AddArg("-maxscriptsize=<n>", strprintf("Maximum size of scripts (including the witness stack) we relay and mine (integer 0 to 4294967295; default: %s)", DEFAULT_SCRIPT_SIZE_POLICY_LIMIT), ArgsManager::ALLOW_ANY | ArgsManager::STRICT_NEGATION, OptionsCategory::NODE_RELAY);
682
+ argsman.AddArg("-maxtxlegacysigops", strprintf("Maximum legacy sigops in transactions we relay and mine (integer 0 to 4294967295; default: %s)", MAX_TX_LEGACY_SIGOPS), ArgsManager::ALLOW_ANY | ArgsManager::STRICT_NEGATION, OptionsCategory::NODE_RELAY);
683
+ argsman.AddArg("-mempoolreplacement=<value>", "Staged parsing only; enforcement is deferred to L8 graph policy. See doc/feature-contracts/policy-parsing.md for accepted grammar.", ArgsManager::ALLOW_ANY | ArgsManager::STRICT_NEGATION | ArgsManager::DEBUG_ONLY, OptionsCategory::NODE_RELAY);
684
+ argsman.AddArg("-mempoolfullrbf", "Staged legacy alias; replacement enforcement is deferred to L8 graph policy.", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::NODE_RELAY);
685
+ argsman.AddArg("-mempooltruc=<value>", "Staged parsing only; enforcement is deferred to L8 graph policy. See doc/feature-contracts/policy-parsing.md for accepted grammar.", ArgsManager::ALLOW_ANY | ArgsManager::STRICT_NEGATION | ArgsManager::DEBUG_ONLY, OptionsCategory::NODE_RELAY);
686
+ argsman.AddArg("-minrelaycoinblocks=<n>", strprintf("Minimum coin blocks a transaction must spend to be relayed (integer 0 to 9223372036854775807; default: %s)", 0), ArgsManager::ALLOW_ANY | ArgsManager::STRICT_NEGATION, OptionsCategory::NODE_RELAY);
687
+ argsman.AddArg("-minrelaymaturity=<n>", strprintf("Minimum input maturity before relay (integer 0 to 2147483647; default: %s)", 0), ArgsManager::ALLOW_ANY | ArgsManager::STRICT_NEGATION, OptionsCategory::NODE_RELAY);
688
+ argsman.AddArg("-permitbareanchor", strprintf("Relay transactions that only have ephemeral anchor outputs (default: %u)", DEFAULT_PERMITBAREANCHOR) + " Values: 0 or 1; no value means 1.", ArgsManager::ALLOW_ANY | ArgsManager::STRICT_NEGATION, OptionsCategory::NODE_RELAY);
689
+ argsman.AddArg("-permitbarepubkey", strprintf("Relay legacy pubkey outputs (default: %u)", DEFAULT_PERMIT_BAREPUBKEY) + " Values: 0 or 1; no value means 1.", ArgsManager::ALLOW_ANY | ArgsManager::STRICT_NEGATION, OptionsCategory::NODE_RELAY);
690
+ argsman.AddArg("-spkreuse=<value>", "Staged parsing only; enforcement is deferred to L8 graph policy. See doc/feature-contracts/policy-parsing.md for accepted grammar.", ArgsManager::ALLOW_ANY | ArgsManager::STRICT_NEGATION | ArgsManager::DEBUG_ONLY, OptionsCategory::NODE_RELAY);
691
+ argsman.AddArg("-rejecttokens", strprintf("Refuse to relay or mine transactions involving non-bitcoin tokens (default: %u)", DEFAULT_REJECT_TOKENS) + " Values: 0 or 1; no value means 1.", ArgsManager::ALLOW_ANY | ArgsManager::STRICT_NEGATION, OptionsCategory::NODE_RELAY);
692
+ argsman.AddArg("-rejectparasites", strprintf("Refuse to relay or mine parasitic overlay protocols (default: %u)", DEFAULT_REJECT_PARASITES) + " Values: 0 or 1; no value means 1.", ArgsManager::ALLOW_ANY | ArgsManager::STRICT_NEGATION, OptionsCategory::NODE_RELAY);
693
+ argsman.AddArg("-blockmaxsize=<value>", "Staged parsing only; enforcement is deferred to L9 mining. See doc/feature-contracts/policy-parsing.md for accepted grammar.", ArgsManager::ALLOW_ANY | ArgsManager::STRICT_NEGATION | ArgsManager::DEBUG_ONLY, OptionsCategory::NODE_RELAY);
694
+ argsman.AddArg("-blockprioritysize=<value>", "Staged parsing only; enforcement is deferred to L9 mining. See doc/feature-contracts/policy-parsing.md for accepted grammar.", ArgsManager::ALLOW_ANY | ArgsManager::STRICT_NEGATION | ArgsManager::DEBUG_ONLY, OptionsCategory::NODE_RELAY);
672
695
  argsman.AddArg("-acceptnonstdtxn", strprintf("Relay and mine \"non-standard\" transactions (test networks only; default: %u)", DEFAULT_ACCEPT_NON_STD_TXN), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::NODE_RELAY);
673
696
  argsman.AddArg("-incrementalrelayfee=<amt>", strprintf("Fee rate (in %s/kvB) used to define cost of relay, used for mempool limiting and replacement policy. (default: %s)", CURRENCY_UNIT, FormatMoney(DEFAULT_INCREMENTAL_RELAY_FEE)), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::NODE_RELAY);
674
697
  argsman.AddArg("-dustrelayfee=<amt>", strprintf("Fee rate (in %s/kvB) used to define dust, the value of an output such that it will cost more than its value in fees at this fee rate to spend it. (default: %s)", CURRENCY_UNIT, FormatMoney(DUST_RELAY_TX_FEE)), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::NODE_RELAY);
@@ -677,7 +700,7 @@ void SetupServerArgs(ArgsManager& argsman, bool can_listen_ipc)
677
700
  argsman.AddArg("-datacarrier", strprintf("Relay and mine data carrier transactions (default: %u)", DEFAULT_ACCEPT_DATACARRIER), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
678
701
  argsman.AddArg("-datacarriersize",
679
702
  strprintf("Relay and mine transactions whose data-carrying raw scriptPubKeys in aggregate "
680
- "are of this size or less, allowing multiple outputs (default: %u)",
703
+ "are of this size or less, allowing one OP_RETURN output (default: %u)",
681
704
  MAX_OP_RETURN_RELAY),
682
705
  ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
683
706
  argsman.AddArg("-permitbaremultisig", strprintf("Relay transactions creating non-P2SH multisig outputs (default: %u)", DEFAULT_PERMIT_BAREMULTISIG), ArgsManager::ALLOW_ANY,
@@ -918,6 +941,12 @@ bool AppInitBasicSetup(const ArgsManager& args, std::atomic<int>& exit_status)
918
941
 
919
942
  bool AppInitParameterInteraction(const ArgsManager& args)
920
943
  {
944
+ if (auto result = ValidateRootsPolicyOptions(args); !result) return InitError(util::ErrorString(result));
945
+ for (const char* option : {"-datacarriercost", "-subdustfeepenalty", "-mempoolreplacement", "-mempoolfullrbf", "-mempooltruc", "-spkreuse", "-dustdynamic", "-blockmaxsize", "-blockprioritysize"}) {
946
+ if (args.IsArgSet(option)) {
947
+ InitWarning(Untranslated(strprintf("%s is parsed but not enforced in this staged candidate; graph policy and mining implementations are pending.", option)));
948
+ }
949
+ }
921
950
  const CChainParams& chainparams = Params();
922
951
  // ********************************************************* Step 2: parameter interactions
923
952
 
@@ -1092,6 +1121,8 @@ bool AppInitParameterInteraction(const ArgsManager& args)
1092
1121
  }
1093
1122
  }
1094
1123
 
1124
+ g_script_size_policy_limit = args.GetIntArg("-maxscriptsize", DEFAULT_SCRIPT_SIZE_POLICY_LIMIT);
1125
+ nBytesPerSigOpStrict = args.GetIntArg("-bytespersigopstrict", DEFAULT_BYTES_PER_SIGOP_STRICT);
1095
1126
  nBytesPerSigOp = args.GetIntArg("-bytespersigop", nBytesPerSigOp);
1096
1127
 
1097
1128
  if (!g_wallet_init_interface.ParameterInteraction()) return false;
@@ -1312,10 +1343,9 @@ static ChainstateLoadResult InitAndLoadChainstate(
1312
1343
 
1313
1344
  const CChainParams& chainparams = Params();
1314
1345
 
1315
- CTxMemPool::Options mempool_opts{
1316
- .check_ratio = chainparams.DefaultConsistencyChecks() ? 1 : 0,
1317
- .signals = node.validation_signals.get(),
1318
- };
1346
+ CTxMemPool::Options mempool_opts{};
1347
+ mempool_opts.check_ratio = chainparams.DefaultConsistencyChecks() ? 1 : 0;
1348
+ mempool_opts.signals = node.validation_signals.get();
1319
1349
  Assert(ApplyArgsManOptions(args, chainparams, mempool_opts)); // no error can happen, already checked in AppInitParameterInteraction
1320
1350
  bilingual_str mempool_error;
1321
1351
  Assert(!node.mempool); // Was reset above