Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
96440ed
Add concept of temporary softforks (buried only for now)
luke-jr Oct 4, 2025
0649862
Define no-op "reduced_data" buried deployment (no activation params)
luke-jr Oct 4, 2025
8fbae96
Use TAPROOT_CONTROL_MAX_NODE_COUNT_REDUCED for non-consensus Taproot …
luke-jr Oct 3, 2025
4d39592
Policy: Enforce SCRIPT_VERIFY_REDUCED_DATA as a policy rule
luke-jr Oct 4, 2025
2cd2c26
script: Define SCRIPT_VERIFY_REDUCED_DATA verification flag (unused) …
luke-jr Oct 6, 2025
a282204
script: Limit Taproot annex to 256 bytes for SCRIPT_VERIFY_REDUCED_DA…
luke-jr Oct 3, 2025
28b8a59
script: Forbid Taproot annex entirely with SCRIPT_VERIFY_REDUCED_DATA…
luke-jr Oct 3, 2025
5965fd7
script: Forbid OP_IF in Tapscript with SCRIPT_VERIFY_REDUCED_DATA (st…
luke-jr Oct 3, 2025
2d52966
script: Limit Taproot control block to 257 bytes for SCRIPT_VERIFY_RE…
luke-jr Oct 3, 2025
0a3de04
consensus: Enforce SCRIPT_VERIFY_REDUCED_DATA if DEPLOYMENT_REDUCED_D…
luke-jr Oct 4, 2025
e58a2dd
Limit datacarriersize config to MAX_OUTPUT_DATA_SIZE (=83 B)
luke-jr Oct 4, 2025
a4bf597
consensus: Add no-op flags to CheckTxInputs function
luke-jr Oct 3, 2025
d492ab5
consensus: Define CheckTxInputsRules::OutputSizeLimit flag (unused) t…
luke-jr Oct 7, 2025
66f88cf
consensus: When CheckTxInputsRules::OutputSizeLimit is enforced (stil…
luke-jr Oct 7, 2025
0c1e17d
QA: rpc_getdescriptoractivity: Use RAW_OP_TRUE for test_no_address
luke-jr Oct 7, 2025
d87bd14
QA: test_framework/wallet: Turn MiniWalletMode.RAW_P2PK into actually…
luke-jr Oct 7, 2025
6073e11
RPC/Mempool: Provide tx memory usage in testmempoolaccept
luke-jr Oct 8, 2025
b251fc6
QA: test_framework/mempool_util: Calibrate fill_mempool bulk tx size …
luke-jr Oct 8, 2025
b2e1e5a
Bugfix: QA: mempool_limit: Use "usage" rather than "bytes"
luke-jr Oct 8, 2025
d6b6fa4
QA: test_framework: Use multiple OP_RETURNs to pad transactions rathe…
luke-jr Oct 7, 2025
db3665e
consensus: Enforce CheckTxInputsRules::OutputSizeLimit when DEPLOYMEN…
luke-jr Oct 4, 2025
d8e8129
Policy: Do not allow user to bypass SCRIPT_VERIFY_DISCOURAGE_{UPGRADA…
luke-jr Oct 4, 2025
d290220
consensus: Enforce SCRIPT_VERIFY_DISCOURAGE_{UPGRADABLE_WITNESS_PROGR…
luke-jr Oct 4, 2025
2b8b339
Simple check for and invalidating (TBD) bad block
luke-jr Oct 12, 2025
0a11dfe
Define a service bit for BIP148
luke-jr May 31, 2017
6f6c89e
Add questionmark to end of BIP148 service bit string, and add to bitc…
luke-jr Oct 20, 2025
5366187
Preferentially peer with nodes enforcing BIP148 to avoid partitioning…
luke-jr May 31, 2017
1da8414
Append UA string with UASF-ReducedData:0.1/
luke-jr Oct 20, 2025
27caa3a
tests: fix feature_cltv, feature_dersig, mempool_accept, and mempool_…
moneybadger1 Nov 1, 2025
7bd0376
tests: fix BIP148 service bit
moneybadger1 Nov 1, 2025
a734c94
test: Adapt functional tests to MAX_OUTPUT_SCRIPT_SIZE=34 consensus l…
3c853b6299 Nov 1, 2025
5d22a09
test: Skip test_segwit_versions subtest (conflicts with DEPLOYMENT_RE…
3c853b6299 Nov 2, 2025
2082d6c
Fix p2p_1p1c_network test by using dynamic feerates based on mempool …
dathonohm Nov 2, 2025
3fb8ee2
Fix interface_bitcoin_cli test to accept BIP148 service bit
dathonohm Nov 3, 2025
fbe877e
Fix p2p_addrv2_relay test to handle BIP148 service bit CompactSize en…
dathonohm Nov 3, 2025
6c8bccf
Fix addpeeraddress RPC to include NODE_BIP148 service flag
dathonohm Nov 3, 2025
c78685f
Refactor: Include all reduced_data verify flags in REDUCED_DATA_MANDA…
luke-jr Nov 3, 2025
8a21fcb
validation: Extend CheckInputScripts to allow overriding script valid…
luke-jr Nov 3, 2025
29d8e6f
validation: Exempt inputs spending UTXOs prior to ReducedDataHeightBe…
luke-jr Nov 3, 2025
00d4b2b
fixup! test: skip test_segwit_versions subtest conflicting with DEPLO…
luke-jr Nov 3, 2025
b534afc
Rename BIP148 service bit to BIP444
luke-jr Nov 3, 2025
2b9e3bc
clientversion: Rename fork to UASF-BIP444
luke-jr Nov 3, 2025
fdff989
test: implement functional tests for UASF-ReducedData Spec
3c853b6299 Nov 5, 2025
17beb82
test: Add UTXO height-based REDUCED_DATA enforcement test
dathonohm Nov 7, 2025
66769ef
test: Update tests for REDUCED_DATA consensus limits
dathonohm Nov 7, 2025
a719bb0
test: Replace thresh() with and_v() in descriptor test
dathonohm Nov 7, 2025
93d3816
test: Add NODE_BIP444 service flag to peer connection tests
dathonohm Nov 7, 2025
3ff937c
Change all BIP444 references to UASF-ReducedData
dathonohm Nov 9, 2025
bdb42cb
Convert DEPLOYMENT_REDUCED_DATA to temporary BIP9 MASF
dathonohm Nov 14, 2025
5005fc4
test: functional tests for BIP9 temporary deployment of REDUCED_DATA
dathonohm Nov 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/bitcoin-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,8 @@ class NetinfoRequestHandler : public BaseRequestHandler
str += 'T';
} else if (s == "UTREEXO_TMP?") {
str += 'y';
} else if (s == "UASF_REDUCED_DATA?") {
str += '4';
} else {
str += ToLower(s[0]);
}
Expand Down Expand Up @@ -765,6 +767,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
" \"T\" - UTREEXO_ARCHIVE peer can handle Utreexo proof requests for all historical blocks\n"
" \"y\" - UTREEXO_TMP? peer can handle Utreexo proof requests\n"
" \"r\" - REPLACE_BY_FEE? peer supports replacement of transactions without BIP 125 signalling\n"
" \"4\" - UASF_REDUCED_DATA? peer enforces the ReducedData User-Activated SoftFork\n"
" \"m\" - MALICIOUS? peer openly seeks to aid in bypassing network policy/spam filters (OR to sabotage nodes that seek to)\n"
" \"u\" - UNKNOWN: unrecognized bit flag\n"
" v Version of transport protocol used for the connection\n"
Expand Down
13 changes: 10 additions & 3 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ void ReadRegTestArgs(const ArgsManager& args, CChainParams::RegTestOptions& opti

for (const std::string& strDeployment : args.GetArgs("-vbparams")) {
std::vector<std::string> vDeploymentParams = SplitString(strDeployment, ':');
if (vDeploymentParams.size() < 3 || 4 < vDeploymentParams.size()) {
throw std::runtime_error("Version bits parameters malformed, expecting deployment:start:end[:min_activation_height]");
if (vDeploymentParams.size() < 3 || 5 < vDeploymentParams.size()) {
throw std::runtime_error("Version bits parameters malformed, expecting deployment:start:end[:min_activation_height[:active_duration]]");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would prefer if you split up "Convert DEPLOYMENT_REDUCED_DATA to temporary BIP9 MASF" into 3 commits:

  1. Adding expiry support to versionbit deployments
  2. Support for overriding active_duration on regtest
  3. Adding the new reduced_data deployment (drop the commits adding the buried version)

}
CChainParams::VersionBitsParameters vbparams{};
if (!ParseInt64(vDeploymentParams[1], &vbparams.start_time)) {
Expand All @@ -94,12 +94,19 @@ void ReadRegTestArgs(const ArgsManager& args, CChainParams::RegTestOptions& opti
} else {
vbparams.min_activation_height = 0;
}
if (vDeploymentParams.size() >= 5) {
if (!ParseInt32(vDeploymentParams[4], &vbparams.active_duration)) {
throw std::runtime_error(strprintf("Invalid active_duration (%s)", vDeploymentParams[4]));
}
} else {
vbparams.active_duration = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

std::numeric_limits<int>::max() would make more sense here than 0

}
bool found = false;
for (int j=0; j < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++j) {
if (vDeploymentParams[0] == VersionBitsDeploymentInfo[j].name) {
options.version_bits_parameters[Consensus::DeploymentPos(j)] = vbparams;
found = true;
LogPrintf("Setting version bits activation parameters for %s to start=%ld, timeout=%ld, min_activation_height=%d\n", vDeploymentParams[0], vbparams.start_time, vbparams.timeout, vbparams.min_activation_height);
LogPrintf("Setting version bits activation parameters for %s to start=%ld, timeout=%ld, min_activation_height=%d, active_duration=%d\n", vDeploymentParams[0], vbparams.start_time, vbparams.timeout, vbparams.min_activation_height, vbparams.active_duration);
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/chainparamsbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman)
argsman.AddArg("-testactivationheight=name@height.", "Set the activation height of 'name' (segwit, bip34, dersig, cltv, csv). (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
argsman.AddArg("-testnet", "Use the testnet3 chain. Equivalent to -chain=test. Support for testnet3 is deprecated and will be removed in an upcoming release. Consider moving to testnet4 now by using -testnet4.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-testnet4", "Use the testnet4 chain. Equivalent to -chain=testnet4.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-vbparams=deployment:start:end[:min_activation_height]", "Use given start/end times and min_activation_height for specified version bits deployment (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-vbparams=deployment:start:end[:min_activation_height[:active_duration]]", "Use given start/end times, min_activation_height, and active_duration for specified version bits deployment (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-signet", "Use the signet chain. Equivalent to -chain=signet. Note that the network is defined by the -signetchallenge parameter", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-signetchallenge", "Blocks must satisfy the given script to be considered valid (only for signet networks; defaults to the global default signet test network challenge)", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-signetblocktime", "Difficulty adjustment will target a block time of the given amount in seconds (only for custom signet networks, must have -signetchallenge set; defaults to 10 minutes)", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, OptionsCategory::CHAINPARAMS);
Expand Down
1 change: 1 addition & 0 deletions src/clientversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ std::string FormatSubVersion(const std::string& name, int nClientVersion, const
return "Knots:" + CLIENT_BUILD.substr(pos + 6) + "/";
}();
ua += ua_knots;
ua += "UASF-ReducedData:0.1/";
Copy link
Collaborator

Choose a reason for hiding this comment

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

This makes sense if you're going to have an activation client, but not so much for a merge into mainline Knots.

}
return ua;
}
Expand Down
3 changes: 3 additions & 0 deletions src/consensus/consensus.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ static constexpr unsigned int LOCKTIME_VERIFY_SEQUENCE = (1 << 0);
*/
static constexpr int64_t MAX_TIMEWARP = 600;

static constexpr unsigned int MAX_OUTPUT_SCRIPT_SIZE{34};
static constexpr unsigned int MAX_OUTPUT_DATA_SIZE{83};

#endif // BITCOIN_CONSENSUS_CONSENSUS_H
21 changes: 21 additions & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ constexpr bool ValidDeployment(BuriedDeployment dep) { return dep <= DEPLOYMENT_
enum DeploymentPos : uint16_t {
DEPLOYMENT_TESTDUMMY,
DEPLOYMENT_TAPROOT, // Deployment of Schnorr/Taproot (BIPs 340-342)
DEPLOYMENT_REDUCED_DATA, // Temporary deployment of UASF-ReducedData
// NOTE: Also add new deployments to VersionBitsDeploymentInfo in deploymentinfo.cpp
MAX_VERSION_BITS_DEPLOYMENTS
};
Expand All @@ -52,6 +53,9 @@ struct BIP9Deployment {
* boundary.
*/
int min_activation_height{0};
/** For temporary softforks: number of blocks the deployment remains active after activation.
* 0 means permanent (never expires). */
int active_duration{0};

/** Constant for nTimeout very far in the future. */
static constexpr int64_t NO_TIMEOUT = std::numeric_limits<int64_t>::max();
Expand Down Expand Up @@ -94,6 +98,9 @@ struct Params {
* Note that segwit v0 script rules are enforced on all blocks except the
* BIP 16 exception blocks. */
int SegwitHeight;
/** Block heights during which Reduced Data is active */
int ReducedDataHeightBegin{std::numeric_limits<int>::max()};
int ReducedDataHeightEnd{std::numeric_limits<int>::max()};
Comment on lines +101 to +103
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the purpose of this with the MASF variant?

/** Don't warn about unknown BIP 9 activations below this height.
* This prevents us from warning about the CSV and segwit activations. */
int MinBIP9WarningHeight;
Expand Down Expand Up @@ -149,6 +156,20 @@ struct Params {
} // no default case, so the compiler can warn about missing cases
return std::numeric_limits<int>::max();
}

int DeploymentHeightEnd(BuriedDeployment dep) const
{
switch (dep) {
case DEPLOYMENT_HEIGHTINCB:
case DEPLOYMENT_CLTV:
case DEPLOYMENT_DERSIG:
case DEPLOYMENT_CSV:
case DEPLOYMENT_SEGWIT:
// These are forever
break;
} // no default case, so the compiler can warn about missing cases
return std::numeric_limits<int>::max();
}
Comment on lines +159 to +172
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again, seems useless/wrong with your MASF concept.

};

} // namespace Consensus
Expand Down
12 changes: 11 additions & 1 deletion src/consensus/tx_verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,24 @@ int64_t GetTransactionSigOpCost(const CTransaction& tx, const CCoinsViewCache& i
return nSigOps;
}

bool Consensus::CheckTxInputs(const CTransaction& tx, TxValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, CAmount& txfee)
bool Consensus::CheckTxInputs(const CTransaction& tx, TxValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, CAmount& txfee, const CheckTxInputsRules rules)
{
// are the actual inputs available?
if (!inputs.HaveInputs(tx)) {
return state.Invalid(TxValidationResult::TX_MISSING_INPUTS, "bad-txns-inputs-missingorspent",
strprintf("%s: inputs missing/spent", __func__));
}

// NOTE: CheckTransaction is arguably the more logical place to do this, but it's context-independent, so this is probably the next best place for now
if (rules.test(CheckTxInputsRules::OutputSizeLimit)) {
for (const auto& txout : tx.vout) {
if (txout.scriptPubKey.empty()) continue;
if (txout.scriptPubKey.size() > ((txout.scriptPubKey[0] == OP_RETURN) ? MAX_OUTPUT_DATA_SIZE : MAX_OUTPUT_SCRIPT_SIZE)) {
return state.Invalid(TxValidationResult::TX_PREMATURE_SPEND, "bad-txns-vout-script-toolarge");

Choose a reason for hiding this comment

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

Nit: wherever it says toolarge may want to replace with too-large

Copy link
Collaborator

Choose a reason for hiding this comment

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

Typically these are structured from parent to child, and toolarge is a logical single element.

}
}
}

CAmount nValueIn = 0;
for (unsigned int i = 0; i < tx.vin.size(); ++i) {
const COutPoint &prevout = tx.vin[i].prevout;
Expand Down
26 changes: 25 additions & 1 deletion src/consensus/tx_verify.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,38 @@ class TxValidationState;

/** Transaction validation functions */

class CheckTxInputsRules {
using underlying_type = unsigned int;
underlying_type m_flags;
constexpr explicit CheckTxInputsRules(underlying_type flags) noexcept : m_flags(flags) {}

enum class Rule {
None = 0,
OutputSizeLimit = 1 << 0,
};

public:
using enum Rule;

constexpr CheckTxInputsRules(Rule rule) noexcept : m_flags(static_cast<underlying_type>(rule)) {}

[[nodiscard]] constexpr bool test(CheckTxInputsRules rules) const noexcept {
return (m_flags & rules.m_flags) == rules.m_flags;
}

[[nodiscard]] constexpr CheckTxInputsRules operator|(const CheckTxInputsRules other) const noexcept {
return CheckTxInputsRules{m_flags | other.m_flags};
}
};

namespace Consensus {
/**
* Check whether all inputs of this transaction are valid (no double spends and amounts)
* This does not modify the UTXO set. This does not check scripts and sigs.
* @param[out] txfee Set to the transaction fee if successful.
* Preconditions: tx.IsCoinBase() is false.
*/
[[nodiscard]] bool CheckTxInputs(const CTransaction& tx, TxValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, CAmount& txfee);
[[nodiscard]] bool CheckTxInputs(const CTransaction& tx, TxValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, CAmount& txfee, CheckTxInputsRules rules);
} // namespace Consensus

/** Auxiliary functions for transaction validation (ideally should not be exposed) */
Expand Down
5 changes: 5 additions & 0 deletions src/deploymentinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_B
/*.name =*/ "taproot",
/*.gbt_force =*/ true,
},
{
/*.name =*/ "reduced_data",
/*.gbt_force =*/ true,
},
};

std::string DeploymentName(Consensus::BuriedDeployment dep)
Expand Down Expand Up @@ -50,5 +54,6 @@ std::optional<Consensus::BuriedDeployment> GetBuriedDeployment(const std::string
} else if (name == "csv") {
return Consensus::BuriedDeployment::DEPLOYMENT_CSV;
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: unnecessary whitespace change

return std::nullopt;
}
32 changes: 28 additions & 4 deletions src/deploymentstatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,50 @@
inline bool DeploymentActiveAfter(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::BuriedDeployment dep, [[maybe_unused]] VersionBitsCache& versionbitscache)
{
assert(Consensus::ValidDeployment(dep));
return (pindexPrev == nullptr ? 0 : pindexPrev->nHeight + 1) >= params.DeploymentHeight(dep);
const auto next_block_height = (pindexPrev == nullptr ? 0 : pindexPrev->nHeight + 1);
return next_block_height >= params.DeploymentHeight(dep) && next_block_height <= params.DeploymentHeightEnd(dep);
}

inline bool DeploymentActiveAfter(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos dep, VersionBitsCache& versionbitscache)
{
assert(Consensus::ValidDeployment(dep));
return ThresholdState::ACTIVE == versionbitscache.State(pindexPrev, params, dep);
if (ThresholdState::ACTIVE != versionbitscache.State(pindexPrev, params, dep)) {
return false;
}
// Check if temporary deployment has expired
Copy link
Collaborator

Choose a reason for hiding this comment

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

This logic is missing in some of the other functions here

const auto& deployment = params.vDeployments[dep];
if (deployment.active_duration > 0) {
const int activation_height = versionbitscache.StateSinceHeight(pindexPrev, params, dep);
const int next_block_height = (pindexPrev == nullptr ? 0 : pindexPrev->nHeight + 1);
if (next_block_height > activation_height + deployment.active_duration) {

Choose a reason for hiding this comment

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

Note: nodes with different activation heights will disagree on the expiry block, which introduces chain split risk.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nodes disagreeing on consensus rules would be a chain split risk regardless. But why would they disagree?

return false;
}
}
return true;
}

/** Determine if a deployment is active for this block */
inline bool DeploymentActiveAt(const CBlockIndex& index, const Consensus::Params& params, Consensus::BuriedDeployment dep, [[maybe_unused]] VersionBitsCache& versionbitscache)
{
assert(Consensus::ValidDeployment(dep));
return index.nHeight >= params.DeploymentHeight(dep);
return index.nHeight >= params.DeploymentHeight(dep) && index.nHeight <= params.DeploymentHeightEnd(dep);
}

inline bool DeploymentActiveAt(const CBlockIndex& index, const Consensus::Params& params, Consensus::DeploymentPos dep, VersionBitsCache& versionbitscache)
{
assert(Consensus::ValidDeployment(dep));
return DeploymentActiveAfter(index.pprev, params, dep, versionbitscache);
if (ThresholdState::ACTIVE != versionbitscache.State(index.pprev, params, dep)) {
return false;
}
// Check if temporary deployment has expired
const auto& deployment = params.vDeployments[dep];
if (deployment.active_duration > 0) {
const int activation_height = versionbitscache.StateSinceHeight(index.pprev, params, dep);
if (index.nHeight > activation_height + deployment.active_duration) {
return false;
}
}
return true;
}

/** Determine if a deployment is enabled (can ever be active) */
Expand Down
26 changes: 24 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,8 @@ void SetupServerArgs(ArgsManager& argsman, bool can_listen_ipc)
argsman.AddArg("-datacarriercost", strprintf("Treat extra data in transactions as at least N vbytes per actual byte (default: %s)", DEFAULT_WEIGHT_PER_DATA_BYTE / 4.0), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
argsman.AddArg("-datacarrierfullcount", strprintf("Apply datacarriersize limit to all known datacarrier methods (default: %u)", DEFAULT_DATACARRIER_FULLCOUNT), ArgsManager::ALLOW_ANY | (DEFAULT_DATACARRIER_FULLCOUNT ? uint32_t{ArgsManager::DEBUG_ONLY} : 0), OptionsCategory::NODE_RELAY);
argsman.AddArg("-datacarriersize",
strprintf("Maximum size of data in data carrier transactions we relay and mine, in bytes (default: %u)",
strprintf("Maximum size of data in data carrier transactions we relay and mine, in bytes (maximum %s, default: %u)",
MAX_OUTPUT_DATA_SIZE,
MAX_OP_RETURN_RELAY),
ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
argsman.AddArg("-maxscriptsize", strprintf("Maximum size of scripts (including the entire witness stack) we relay and mine, in bytes (default: %s)", DEFAULT_SCRIPT_SIZE_POLICY_LIMIT), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
Expand Down Expand Up @@ -966,7 +967,7 @@ namespace { // Variables internal to initialization process only

int nMaxConnections;
int available_fds;
ServiceFlags g_local_services = ServiceFlags(NODE_NETWORK_LIMITED | NODE_WITNESS);
ServiceFlags g_local_services = ServiceFlags(NODE_NETWORK_LIMITED | NODE_WITNESS | NODE_UASF_REDUCED_DATA);

Choose a reason for hiding this comment

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

By broadcasting the UASF flag by default, doesn't that risk network partition before sufficient adoption?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This should only be used for the 8 outgoing connections. Incoming connections from old nodes are accepted.

int64_t peer_connect_timeout;
std::set<BlockFilterType> g_enabled_filter_types;

Expand Down Expand Up @@ -2135,6 +2136,27 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
return;
}

constexpr uint256 bad_block_hash{"0000000000000000000000000000000000000000000000000000000000000000"};

Choose a reason for hiding this comment

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

Is this a placeholder? Specify an actual bad block or remove.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Indeed, this code only makes sense for the (now removed) reactive activation.

Instead, this PR should implement detecting that it's on an invalid chain at startup and rewinding.

Copy link
Author

Choose a reason for hiding this comment

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

Will remove.

BlockValidationState state;
CBlockIndex* pblockindex;
{
LOCK(chainman.GetMutex());
pblockindex = chainman.m_blockman.LookupBlockIndex(bad_block_hash);
if (pblockindex && !pblockindex->IsValid(BLOCK_VALID_UNKNOWN)) {
// Already marked invalid
pblockindex = nullptr;
}
}
if (pblockindex) {
if (!chainman.ActiveChainstate().InvalidateBlock(state, pblockindex)) {
state.Error("InvalidateBlock failed (is your node too pruned?)");
}
if (state.IsValid()) {
chainman.ActiveChainstate().ActivateBestChain(state);
}
Assert(state.IsValid());
}

// Start indexes initial sync
if (!StartIndexBackgroundSync(node)) {
bilingual_str err_str = _("Failed to start indexes, shutting down..");
Expand Down
Loading