Skip to content

Reduced Data Temporary Softfork, implemented as a modified BIP9 temporary deployment#238

Open
dathonohm wants to merge 34 commits intobitcoinknots:29.x-knotsfrom
dathonohm:uasf-modified-bip9
Open

Reduced Data Temporary Softfork, implemented as a modified BIP9 temporary deployment#238
dathonohm wants to merge 34 commits intobitcoinknots:29.x-knotsfrom
dathonohm:uasf-modified-bip9

Conversation

@dathonohm
Copy link
Copy Markdown

@dathonohm dathonohm commented Nov 24, 2025

ReducedData Temporary Softfork (BIP-110/RDTS)

Implementation of BIP-110 for Bitcoin Knots.

Versionbits extensions

  • max_activation_height (mutually exclusive with timeout) with BIP8/148-style mandatory signaling enforcement
  • active_duration for temporary deployments (expiry after ~1 year) and a corresponding EXPIRED BIP9 state
  • Per-deployment activation threshold (55% for RDTS instead of global 95%)

Consensus rules (when DEPLOYMENT_REDUCED_DATA is active)

  • Output scripts limited to 34 bytes (OP_RETURN limited to 83 bytes)
  • Data push size limit reduced to 256 bytes (SCRIPT_VERIFY_REDUCED_DATA), except BIP16 redeemScript
  • DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM, DISCOURAGE_UPGRADABLE_TAPROOT_VERSION, DISCOURAGE_OP_SUCCESS enforced at consensus level
  • Taproot annex forbidden
  • Taproot control block limited to 257 bytes (tree depth 7)
  • OP_IF/OP_NOTIF forbidden in Tapscript
  • Empty witness required for P2A spends
  • UTXO-height exemption: inputs spending UTXOs created before activation are exempt from script rules

Other features

  • The above rules are enforced unconditionally in policy
  • NODE_REDUCED_DATA service bit (bit 27) with preferential peering
  • DNS seed filtering for BIP-110 nodes (x8000009)
  • Up to 2 non-BIP110 outbound peers allowed

Commit structure (34 commits)

The commits have been structured such that every commit passes all tests (except for the coin_age_priority UBSan issue which is fixed outside this PR). The BIP9 modifications are placed first, since the actual consensus validation changes depend on the existence of DEPLOYMENT_REDUCED_DATA (originally a buried deployment).

Two commits are intentionally large because their changes break a large amount of tests, so test adaptations that must land atomically are bundled: 45c004e30e and 983555f940.

@GregTonoski
Copy link
Copy Markdown

Let me suggest adding a note that OP_RETURN is deprecated in help texts, please.

Comment thread src/validation.cpp
Comment thread src/validation.cpp Outdated
Comment thread src/script/interpreter.cpp
@cal-gooo
Copy link
Copy Markdown

what's the timeline to get this merged so the signaling can use this implementation?

@dathonohm
Copy link
Copy Markdown
Author

dathonohm commented Dec 1, 2025

There is no specific timeline to get this merged into Knots, as it is not confirmed that it will be eligible for merging, even when complete. However, I am aiming to have this draft ready for review in the next few days.

Miner signaling can still use this deployment if the activation client is released after the start of the signaling period (which is today, so this will definitely happen).

@dathonohm
Copy link
Copy Markdown
Author

dathonohm commented Dec 2, 2025

All comments from #234 are now addressed.

Undrafting since the code is relatively stable now.

Still needs rebase.

@dathonohm
Copy link
Copy Markdown
Author

@GregTonoski

Let me suggest adding a note that OP_RETURN is deprecated in help texts, please.

OP_RETURN is not deprecated; it is merely limited to 83 bytes in consensus.

@dathonohm dathonohm marked this pull request as ready for review December 2, 2025 23:29
@dathonohm
Copy link
Copy Markdown
Author

dathonohm commented Dec 3, 2025

Rebased on v29.2.knots20251110.

Ready for review.

@stackingsaunter
Copy link
Copy Markdown

Concept NACK

There shouldn't be any emergency softfork to address spam without at least a sketeched out permanent solution

@dathonohm
Copy link
Copy Markdown
Author

@stackingsaunter Please keep conceptual discussion to the BIP PR. This PR is for code review only.

Comment thread src/script/interpreter.cpp
Comment thread src/validation.cpp
Comment thread src/script/interpreter.cpp
Comment thread src/validation.cpp
Comment thread src/kernel/chainparams.cpp
Comment thread src/deploymentstatus.h
Comment thread src/validation.cpp Outdated
Comment thread src/deploymentstatus.h Outdated
Comment thread src/chainparams.cpp
Copy link
Copy Markdown
Collaborator

@luke-jr luke-jr left a comment

Choose a reason for hiding this comment

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

Review not complete yet

Comment thread src/deploymentstatus.h Outdated
Comment thread src/rpc/blockchain.cpp Outdated
Comment thread src/rpc/blockchain.cpp Outdated
Comment thread src/rpc/blockchain.cpp
Comment thread src/rpc/blockchain.cpp
Comment thread src/versionbits.cpp Outdated
Comment thread src/chainparams.cpp Outdated
@dathonohm dathonohm requested a review from luke-jr December 27, 2025 02:59
@dathonohm
Copy link
Copy Markdown
Author

dathonohm commented Jan 3, 2026

All review comments are now addressed.

CI is now fully passing (except for the "test each commit" job).

A tag has been created for the current version, RC2 (identical to this branch except for the last commit, which updates the UA string for BIP-110).

Next I will make a release for RC2, and clean up the commit history here.

Comment thread src/validation.cpp
Comment thread src/script/interpreter.cpp
Comment thread src/validation.cpp Outdated
Comment thread src/protocol.h Outdated
Comment thread src/txmempool.cpp
Comment thread test/functional/rpc_net.py
Comment thread src/validation.cpp Outdated
@dathonohm
Copy link
Copy Markdown
Author

I have begun work on RC3.

RC2's branch is archived here (the prior state of this PR, commit 5a54af7, is the penultimate commit on that branch).

RC3 will include some minor improvements to peer discovery and the guix build, as well as better testing against non-110 peers.

Comment thread src/consensus/tx_verify.cpp Outdated
Comment thread src/script/descriptor.cpp
Comment thread src/rpc/blockchain.cpp
Comment thread src/script/interpreter.cpp
@luke-jr
Copy link
Copy Markdown
Collaborator

luke-jr commented Feb 5, 2026

Let me suggest adding a note that OP_RETURN is deprecated in help texts, please.

OP_RETURN is not deprecated; it is merely limited to 83 bytes in consensus.

datacarriersize is not deprecated, but OP_RETURN is. Documenting it is out of scope for this PR, though.

Copy link
Copy Markdown
Collaborator

@luke-jr luke-jr left a comment

Choose a reason for hiding this comment

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

Would prefer to squash/eliminate things like the UA changes and BIP444 references (added and replaced).

note to self: this review was up to f4045f3

Comment thread test/functional/p2p_segwit.py Outdated
Comment thread test/functional/interface_bitcoin_cli.py Outdated
Comment thread test/functional/p2p_node_network_limited.py Outdated
Comment thread src/rpc/blockchain.cpp Outdated
Comment thread src/validation.cpp Outdated
Comment thread test/functional/mempool_limit.py
Comment thread src/policy/coin_age_priority.cpp Outdated
// at which all the in-chain inputs of the tx were included in blocks.
// Typical usage of GetPriority with chainActive.Height() will ensure this.
int heightDiff = currentHeight - cachedHeight;
int heightDiff = int(currentHeight) - int(cachedHeight);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixes UBSan unsigned integer overflow: 432 - 433 can't be represented in unsigned int (https://github.com/dathonohm/bitcoin/actions/runs/19997804442, ASan+UBSan job). The cast makes the subtraction signed so the dResult < 0 check on line 114 works correctly. Same pattern as line 70 in the same file (introduced in 28b7673).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As the comment says, calling this with a currentHeight < cachedHeight is invalid...

Copy link
Copy Markdown
Author

@dathonohm dathonohm Mar 5, 2026

Choose a reason for hiding this comment

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

Removing this commit to expose the failure, then I'll work on a fix. This is an upstream bug.

Comment thread ci/test/00_setup_env_native_centos.sh
Comment thread src/kernel/chainparams.cpp Outdated
Comment thread src/consensus/tx_verify.h Outdated
luke-jr pushed a commit that referenced this pull request Apr 15, 2026
luke-jr pushed a commit that referenced this pull request Apr 15, 2026
luke-jr pushed a commit that referenced this pull request Apr 15, 2026
luke-jr pushed a commit that referenced this pull request Apr 15, 2026
…eight and set vbrequired during mandatory signaling

Github-Pull: #238
Rebased-From: 1bf0c35
luke-jr added a commit that referenced this pull request Apr 15, 2026
…Taproot logic; adapt tests

Co-Authored-By: Dathon Ohm <dathonohm@proton.me>

Github-Pull: #238
Rebased-From: f664525
luke-jr added a commit that referenced this pull request Apr 15, 2026
Co-Authored-By: Dathon Ohm <dathonohm@proton.me>

Github-Pull: #238
Rebased-From: 41abcea
luke-jr added a commit that referenced this pull request Apr 15, 2026
…to reduce data push size limit to 256 bytes (except for P2SH redeemScript push); adapt tests

Co-Authored-By: Dathon Ohm <dathonohm@proton.me>
Co-Authored-By: Léo Haf <leo@haf.ovh>

Github-Pull: #238
Rebased-From: f595e6a
luke-jr added a commit that referenced this pull request Apr 15, 2026
luke-jr added a commit that referenced this pull request Apr 15, 2026
…ill unused)

Co-Authored-By: Dathon Ohm <dathonohm@proton.me>
Co-Authored-By: Léo Haf <leo@haf.ovh>

Github-Pull: #238
Rebased-From: e1ae973
luke-jr added a commit that referenced this pull request Apr 15, 2026
…DUCED_DATA (still unused)

Github-Pull: #238
Rebased-From: 4743b66
luke-jr pushed a commit that referenced this pull request Apr 15, 2026
luke-jr added a commit that referenced this pull request Apr 15, 2026
luke-jr added a commit that referenced this pull request Apr 15, 2026
…o cap output scripts at 83 bytes

Github-Pull: #238
Rebased-From: 34621ba
luke-jr added a commit that referenced this pull request Apr 15, 2026
…l never), limit non-OP_RETURN scripts to 34 bytes and OP_RETURN outputs to 83 bytes

MAX_OUTPUT_DATA_SIZE constant definition moved here from its original commit (4a8d8d0) due to commit reordering.

Co-Authored-By: Dathon Ohm <dathonohm@proton.me>

Github-Pull: #238
Rebased-From: 091c18c
luke-jr added a commit that referenced this pull request Apr 15, 2026
luke-jr pushed a commit that referenced this pull request Apr 15, 2026
luke-jr added a commit that referenced this pull request Apr 15, 2026
luke-jr added a commit that referenced this pull request Apr 15, 2026
…T_REDUCED_DATA is active; adapt tests

Wire OutputSizeLimit to deployment with unconditional mempool enforcement. Adapt test framework and functional tests for 34-byte output script limit and 83-byte OP_RETURN limit.

Test fixes from: 8257367, c609a45, 9194f6f, b141420, e011d53, fc62079, a065a59, 4f371cf, 5ee8102, ebe821e (partial)

Co-Authored-By: Dathon Ohm <dathonohm@proton.me>
Co-Authored-By: 3c853b6299 <3c853b6299@pm.me>
Co-Authored-By: moneybadger1 <moneybadger1@proton.me>
Co-Authored-By: Léo Haf <leohaf@orangepill.ovh>

Github-Pull: #238
Rebased-From: 45c004e
luke-jr pushed a commit that referenced this pull request Apr 15, 2026
luke-jr added a commit that referenced this pull request Apr 15, 2026
…AM,UPGRADABLE_TAPROOT_VERSION,OP_SUCCESS} on blocks when DEPLOYMENT_REDUCED_DATA is active

Co-Authored-By: Léo Haf <leo@haf.ovh>
Co-Authored-By: Dathon Ohm <dathonohm@proton.me>

Github-Pull: #238
Rebased-From: 881d4ab
luke-jr added a commit that referenced this pull request Apr 15, 2026
luke-jr added a commit that referenced this pull request Apr 15, 2026
…ation flags on a per-input basis

Github-Pull: #238
Rebased-From: 48118a7
luke-jr added a commit that referenced this pull request Apr 15, 2026
…height from reduced_data script validation rules

Bugfix: validation: Do not cache the result of CheckInputScripts if flags_per_input is used (and avoid using it when unnecessary)

Co-Authored-By: Dathon Ohm <dathonohm@proton.me>
Co-Authored-By: Lőrinc <pap.lorinc@gmail.com>

Github-Pull: #238
Rebased-From: 71722a2
luke-jr pushed a commit that referenced this pull request Apr 15, 2026
Co-Authored-By: Dathon Ohm <dathonohm@proton.me>
Co-Authored-By: Léo Haf <leohaf@orangepill.ovh>

Github-Pull: #238
Rebased-From: a6ac602
luke-jr pushed a commit that referenced this pull request Apr 15, 2026
Co-Authored-By: Léo Haf <leohaf@orangepill.ovh>
Co-Authored-By: Lőrinc <pap.lorinc@gmail.com>

Github-Pull: #238
Rebased-From: 3428f6c
luke-jr pushed a commit that referenced this pull request Apr 15, 2026
Co-Authored-By: Léo Haf <leohaf@orangepill.ovh>

Github-Pull: #238
Rebased-From: 14dd104
luke-jr pushed a commit that referenced this pull request Apr 15, 2026
Github-Pull: #238
Rebased-From: 1b1ef4f
luke-jr added a commit that referenced this pull request Apr 15, 2026
…BLE_WITNESS_PROGRAM,UPGRADABLE_TAPROOT_VERSION,OP_SUCCESS}

Github-Pull: #238
Rebased-From: 90760ff
luke-jr pushed a commit that referenced this pull request Apr 15, 2026
…x8000009; adapt tests

Squash of:
- b662a23 Define a service bit for BIP148
- 0db5282 Add questionmark to end of BIP148 service bit string, and add to bitcoin-cli
- b5a77cd Preferentially peer with nodes enforcing RDTS; rename BIP148 references to ReducedData; adapt tests
- 85289a3 net: ask DNS seed for x8000009 (original: ea8c1ee)

Define a service bit for BIP148

Github-Pull: bitcoin#10532
Rebased-From: cd74a23fcf9588199e196ab31bc64972400c2027

Add questionmark to end of BIP148 service bit string, and add to bitcoin-cli

Preferentially peer with nodes enforcing RDTS; rename BIP148 references to ReducedData; adapt tests

Combines: preferential peering (367b344), BIP148->ReducedData rename (85a78b8), service bit test fixes (f98fe90, ebe821e, 5efab4a, 4b757d8, f648a21).

net: ask DNS seed for x8000009

Co-Authored-By: Luke Dashjr <luke-jr+git@utopios.org>
Co-Authored-By: 3c853b6299 <3c853b6299@pm.me>
Co-Authored-By: Léo Haf <leohaf@orangepill.ovh>

Github-Pull: #238
Rebased-From: 983555f
luke-jr pushed a commit that referenced this pull request Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.