Skip to content

policy: correct (lower) the dust threshold for Taproot outputs - #22779

Closed
darosior wants to merge 2 commits into
bitcoin:masterfrom
darosior:taproot_dust_limit
Closed

darosior wants to merge 2 commits into
bitcoin:masterfrom
darosior:taproot_dust_limit

Conversation

@darosior

Copy link
Copy Markdown
Member

It was calculated as if it needed a compressed pubkey + a DER encoded
ECDSA signature.

Eventually i believe it would be good to prevent future overlooks by not applying the dust check to unknown witness versions and aborting if witness_version > current_version. Had a commit that starts doing that but removed it as it made this simple fix PR needlessly more complex.

Comment thread src/policy/policy.cpp Resolved
@theStack

Copy link
Copy Markdown
Contributor

Concept ACK

1 similar comment
@sipa

sipa commented Aug 23, 2021

Copy link
Copy Markdown
Member

Concept ACK

Comment thread src/test/transaction_tests.cpp Resolved
@darosior
darosior force-pushed the taproot_dust_limit branch from a7efad7 to b1a8a41 Compare August 24, 2021 07:45
Comment thread src/policy/policy.cpp Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

More of a meta-comment:

If GetDustThreshold attempts to calculate the cost at which it's economical to spend an output, why is nSize initialized to GetSerializedSize(txout)? When spending the dust output, the size of the txout isn't in the spending tx unless the spending tx also spends to the same output type. This heuristic/initialization doesn't make sense to me because if we take P2WSH as an example (w/ dust limit of 330), 330 - fees < 330 it is impossible to spend to the same output type unless other inputs are added. It seems to me that if witness version non-zero is being changed, this could be a place to fix or clarify this calculation for witness version non-zero.

@ariard

ariard commented Aug 24, 2021

Copy link
Copy Markdown
Contributor

Concept ACK

Eventually i believe it would be good to prevent future overlooks by not applying the dust check to unknown witness versions and aborting if witness_version > current_version.

IIUC, you're aiming to return IsDust() == true for any transaction with witness outputs superior to current version, wouldn't this be a revert of #15846 ? As we don't know what would be the minimal spent or we can pick-up an arbitrary amount e.g 1000 sats, and consider the effective dust threshold for future type will be lower. And as such minimize risks of policy tightening changes.

@darosior

darosior commented Aug 24, 2021 via email

Copy link
Copy Markdown
Member Author

Comment thread src/policy/policy.cpp Resolved
@ariard

ariard commented Aug 24, 2021 •

Copy link
Copy Markdown
Contributor

No, i'm aiming to do the opposite: not call IsDust for witness versions >1, effectively having IsDust == false for any witness version from the future.

Hmmmm so you could propagate transactions SegWit v2+ with nValue == 0 and as such freely write on the UTXO set? Unknown witness outputs are standard iirc.

@darosior

Copy link
Copy Markdown
Member Author

Hmmmm so you could propagate transactions SegWit v2+ with nValue == 0 and as such freely write on the UTXO set? Unknown witness outputs are standard iirc.

You are right, i shouldn't reply to Github comments at 11:21PM :p
Maybe it could be made of a fixed value (this one, or another large one so we don't tighten it when introducing a new version). Anyways i don't intend to (address it in this PR and) modify the existing behaviour, just to refactor the code to prevent a future overlook.

It was calculated as if it needed a compressed pubkey + a DER encoded
ECDSA signature.

Note that this commit intentionally keeps the existing behaviour of
applying the latest witness program version computation to all newer
versions.

Signed-off-by: Antoine Poinsot <[email protected]>
@darosior
darosior force-pushed the taproot_dust_limit branch from b1a8a41 to 9155f6c Compare August 25, 2021 07:31
@ariard

ariard commented Aug 26, 2021

Copy link
Copy Markdown
Contributor

Code Review ACK 9155f6c

Maybe it could be made of a fixed value (this one, or another large one so we don't tighten it when introducing a new version). Anyways i don't intend to (address it in this PR and) modify the existing behaviour, just to refactor the code to prevent a future overlook.

Yes honestly I think we should revamp our approach w.r.t to dust outputs, from a hard non-propagating threshold to a feerate penalty approach, that way adjustable by L2 nodes at broadcast time in function of mempool congestion. Though need to work-out a design first and discussion better left to the ML :)

@TheBlueMatt

Copy link
Copy Markdown
Contributor

Concept NACK. I don't think it makes sense to be lowering the dust levels in bitcoin generally. The context for the dust levels was calculated many years ago, I don't think it applies anymore.

@benthecarman benthecarman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review ACK 9155f6c

Comment thread src/policy/policy.cpp
// sum the sizes of the parts of a transaction input
// with 75% segwit discount applied to the script size.
nSize += (32 + 4 + 1 + (107 / WITNESS_SCALE_FACTOR) + 4);
if (witnessversion == 0) {

@JeremyRubin JeremyRubin Aug 30, 2021 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit:prefer a switch statement here

@JeremyRubin

Copy link
Copy Markdown
Contributor

Concept NACK --

I think we should either remove the dust limit entirely or not muck around with it.

Dust limits are not incentive compatible with miner preferences and if they are they can be configured by users individually.

That said, it's CR-Ack for me for this code, which seems to be improving the dust nSize calculation (which should be independent of any actual fee policy, the code could be cleaned up to make it have a min somewhere later but we shouldn't confuse byte counting with thresholds).

@maflcko

maflcko commented Aug 31, 2021

Copy link
Copy Markdown
Member

Maybe split off the added tests from the behaviour change, because they seem useful on their own?

@darosior

Copy link
Copy Markdown
Member Author

@MarcoFalke done in #22846

@TheBlueMatt i too am of the opinion that we should not decrease the dust thresholds, but i think that if we want to keep the same dust thresholds for Taproot outputs we should instead raise DUST_RELAY_TX_FEE instead of keeping the wrong computation. But this would unfortunately be a security issue for (some) L2s relying on it..

I don't think the rationale of "dust threshold was calculated many years ago, let's not fix it for a new output type unused on the network yet" holds. It was adapted for Segwit v0 and now Segwit v1 should be "penalized"?
In any case, i think that even if we want to keep it larger for Taproot outputs than for Segwit v0 outputs we should document it instead of having the current "at least a 33-bytes pubkey and an ECDSA signature are required to spend" rationale for any Segwit output.

@TheBlueMatt

Copy link
Copy Markdown
Contributor

@TheBlueMatt i too am of the opinion that we should not decrease the dust thresholds, but i think that if we want to keep the same dust thresholds for Taproot outputs we should instead raise DUST_RELAY_TX_FEE instead of keeping the wrong computation. But this would unfortunately be a security issue for (some) L2s relying on it..

Indeed, I don't think we can in any practical sense increase the dust threshold for deployed things, for exactly the reason you specify. I also agree with you that, ideally, we'd increase DUST_RELAY_TX_FEE, but given that we agree that we cannot, the only thing we can do is not make the problem worse for, which I'd argue this does.

I'm not really sure why "consistency" here matters, the numbers are too low, reducing them is not great, so lets not do that :).

@DrahtBot

DrahtBot commented Sep 1, 2021

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #22846 (policy: unit test Segwit dust thresholds by darosior)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

maflcko pushed a commit that referenced this pull request Sep 2, 2021
97cea1a policy: unit test Segwit dust thresholds (Antoine Poinsot)

Pull request description:

  This is the unit testing part of #22779, hence without the threshold modification.

ACKs for top commit:
  MarcoFalke:
    cr ACK 97cea1a
  benthecarman:
    crACK 97cea1a

Tree-SHA512: 96fb194709ae44364455eb920ed3ecff2e11e5327e0a72b9eeec9f9445894302099a0c4ffb1e0c8d4d523c0bfe06c57f1ebb0c03cf3389a73f518e3b174c45aa
@DrahtBot

DrahtBot commented Sep 2, 2021

Copy link
Copy Markdown
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

darosior added a commit to darosior/bitcoin that referenced this pull request Sep 2, 2021
…Taproot

A "correction" of what seemed to be an overlook was initially proposed in
PR bitcoin#22779. It was deemed unnecessary to further reduce the dust level,
so document the intention.

Signed-off-by: Antoine Poinsot <[email protected]>
@darosior

darosior commented Sep 2, 2021

Copy link
Copy Markdown
Member Author

I think Matt is right. Closing this one in favour of documenting the behaviour in #22863 .

@darosior darosior closed this Sep 2, 2021
@luke-jr

luke-jr commented Sep 20, 2021

Copy link
Copy Markdown
Contributor

But this would unfortunately be a security issue for (some) L2s relying on it..

Then those L2s are broken. Policy is never a guarantee and should not be treated like one.

IMO you should reopen this.

laanwj added a commit that referenced this pull request Oct 15, 2021
d873db7 policy: document we intentionally don't lower the dust threshold for Taproot (Antoine Poinsot)

Pull request description:

  Following discussions in #22779 .

ACKs for top commit:
  benthecarman:
    ACK d873db7
  ariard:
    Code Review ACK d873db7
  theStack:
    ACK d873db7

Tree-SHA512: 1f5d20dce767f8a74d57ece47a7f6b881741f508896131b8433600cccf9e4262892603b46521d1bb69d5c83b450f24a16731341072a471c1f2c9adad682af895
@bitcoin bitcoin locked and limited conversation to collaborators Oct 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.