policy: add -scriptsigcost to reprice pre-segwit scriptSig bytes - #343
Open
kwsantiago wants to merge 5 commits into
Open
policy: add -scriptsigcost to reprice pre-segwit scriptSig bytes#343kwsantiago wants to merge 5 commits into
kwsantiago wants to merge 5 commits into
Conversation
TestPackage() extrapolated a package's contribution to the block from its policy vsize, while AddToBlock() accumulates the real consensus weight. That is only correct while policy vsize is never below weight/4, which holds today because the only policy weight adjustment is the -datacarriercost surcharge, and that is never negative. A policy discount breaks it, and block assembly then exceeds -blockmaxweight. Track the consensus weight of each entry and its in-mempool ancestors, the same way ancestor sigop cost is already tracked, and use it in TestPackage(). This also resolves the TODO that was there. With extra_weight >= 0 the old estimate is always at least the package weight, so this accepts exactly the same packages as before.
Mirrors -datacarriercost: a fixed-point vbytes-per-actual-byte value, stored internally in weight units. The default leaves behavior unchanged.
Reprices scriptSig bytes in non-witness inputs, which consensus charges at WITNESS_SCALE_FACTOR. Data bytes are charged the higher of -datacarriercost and -scriptsigcost, so a scriptSig discount cannot be used to make embedded data cheaper. Consensus weight is untouched. Only the policy vsize changes, and it can now be reduced, so the entry vsize is clamped to stay positive.
kwsantiago
force-pushed
the
policy-scriptsig-cost
branch
from
July 25, 2026 15:26
da83f31 to
df23907
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #60
Adds
-scriptsigcost, which prices scriptSig bytes in non-witness inputs for policy purposes.0.25extends the witness discount to pre-segwit inputs, higher values bias against them. Only the vsize used for relay and mining changes, never consensus weight.1.0, ie unchanged behavior, matching how-datacarriercostships neutral-datacarriercostand-scriptsigcost, so the discount cannot be used to make embedded data cheaperLeft at the neutral default because discounting by default would relay pre-segwit spends at a lower effective feerate than the rest of the network. Say the word if you would rather it ship at
0.25.Based on #342, which block assembly needs once policy vsize can fall below consensus weight.
Screenshots
Options > Spam filtering, default (1.00):
Set to 0.25: