Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add txids with non-standard inputs to reject filter #19620

Merged
merged 2 commits into from Aug 6, 2020

Conversation

sdaftuar
Copy link
Member

Our policy checks for non-standard inputs depend only on the non-witness
portion of a transaction: we look up the scriptPubKey of the input being
spent from our UTXO set (which is covered by the input txid), and the p2sh
checks only rely on the scriptSig portion of the input.

Consequently it's safe to add txids of transactions that fail these checks to
the reject filter, as the witness is irrelevant to the failure. This is helpful
for any situation where we might request the transaction again via txid (either
from txid-relay peers, or if we might fetch the transaction via txid due to
parent-fetching of orphans).

Further, in preparation for future witness versions being deployed on the
network, ensure that WITNESS_UNKNOWN transactions are rejected in
AreInputsStandard(), so that transactions spending v1 (or greater) witness
outputs will fall into this category of having their txid added to the reject
filter.

@sdaftuar
Copy link
Member Author

I need to test this still myself, but I wanted to open this as a potential alternative to feeling the need to backport #18044 (as @jnewbery has proposed in #19606) in order to protect older software from wasting bandwidth in the event of taproot activation in the future.

I have a branch where I backported this patch to 0.20 here: https://github.com/sdaftuar/bitcoin/tree/2020-07-reject-unknown-wit-0.20.

Note that this PR should be independently useful to mitigate an issue @ariard brought up here: #18044 (comment)

Copy link
Contributor

@jnewbery jnewbery left a comment

Choose a reason for hiding this comment

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

Concept ACK. Looks like a good change.

I think we might independently want to backport wtxid relay. It's really not that difficult of a backport, and we eventually want wtxid to be the standard way to relay txs and getting it into v0.20 would help with that.

src/validation.cpp Show resolved Hide resolved
@JeremyRubin
Copy link
Contributor

Concept ACK and lite code review ACK.

It seems to me that this change won't help that much in the future upgrade case because even though this fixes witness versions things like leaf versions in taproot (which may be upgraded more often) will require a witness dependent check, and can't be txid reject filtered, unless we made it a policy that transactions spending taproots that mix and match leaf versions are non-standard (but only detectable in the case where an previous attempted witness is nonstandard).

@sdaftuar
Copy link
Member Author

sdaftuar commented Jul 29, 2020

It seems to me that this change won't help that much in the future upgrade case [...]

@JeremyRubin I agree, this is a bandaid to help this particular scenario. Going forward, wtxid-relay + a change to the p2p protocol for announcing/requesting unconfirmed ancestors of a transaction by wtxid seems like the right way to solve this type of problem more generally.

@sipa
Copy link
Member

sipa commented Jul 29, 2020

@sdaftuar @naumenkogs Random idea about this: post-Erlay it may make sense to have a message "i do not have have dependencies of txid txid", at which point both sides add all known direct and indirect unconfirmed parents of txid they know of to their to-be-broadcast set; if erlay is in effect, the overlap will get cancelled out automatically.

@sdaftuar
Copy link
Member Author

Updated some comments and also used this same logic when processing orphans.

@DrahtBot
Copy link
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:

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.

Copy link
Contributor

@jnewbery jnewbery left a comment

Choose a reason for hiding this comment

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

Code changes look good to me. One suggested change to a comment inline.

I think a functional test would be useful here. This change depends on the ordering of checks in ATMP, so there could potentially be subtle interactions there. Proving this out with a test for txid-relay peers and orphan fetching would be great.

src/net_processing.cpp Outdated Show resolved Hide resolved
@sdaftuar
Copy link
Member Author

Happy to include a functional test if anyone is able to put one together for this.

@JeremyRubin
Copy link
Contributor

@instagibbs might?

@instagibbs
Copy link
Member

I think this deserves a test and shouldn't be too bad. I'll take a crack at it this weekend.

Copy link
Member

@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.

utACK

@sipa
Copy link
Member

sipa commented Jul 31, 2020

Code review ACK acdd7f3. A test would be nice.

src/validation.cpp Show resolved Hide resolved
src/net_processing.cpp Show resolved Hide resolved
@instagibbs
Copy link
Member

instagibbs commented Jul 31, 2020 via email

src/policy/policy.cpp Show resolved Hide resolved
src/policy/policy.cpp Show resolved Hide resolved
@instagibbs
Copy link
Member

Turns out there's already a nice natural spot for the test, feel free to snipe: instagibbs@57f782d

@instagibbs
Copy link
Member

ACK ada658f

@sdaftuar
Copy link
Member Author

sdaftuar commented Aug 3, 2020

Thanks @instagibbs! I added your test change here.

sdaftuar and others added 2 commits August 4, 2020 13:29
Our policy checks for non-standard inputs depend only on the non-witness
portion of a transaction: we look up the scriptPubKey of the input being
spent from our UTXO set (which is covered by the input txid), and the p2sh
checks only rely on the scriptSig portion of the input.

Consequently it's safe to add txids of transactions that fail these checks to
the reject filter, as the witness is irrelevant to the failure. This is helpful
for any situation where we might request the transaction again via txid (either
from txid-relay peers, or if we might fetch the transaction via txid due to
parent-fetching of orphans).

Further, in preparation for future witness versions being deployed on the
network, ensure that WITNESS_UNKNOWN transactions are rejected in
AreInputsStandard(), so that transactions spending v1 (or greater) witness
outputs will fall into this category of having their txid added to the reject
filter.
@jnewbery
Copy link
Contributor

jnewbery commented Aug 6, 2020

Code review ACK 9f88ded

@ajtowns
Copy link
Contributor

ajtowns commented Aug 6, 2020

ACK 9f88ded - code review

@laanwj laanwj added this to Blockers in High-priority for review Aug 6, 2020
@fanquake fanquake merged commit 6d85435 into bitcoin:master Aug 6, 2020
@fanquake fanquake removed this from Blockers in High-priority for review Aug 6, 2020
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Aug 7, 2020
9f88ded test addition of unknown segwit spends to txid reject filter (Gregory Sanders)
7989901 Add txids with non-standard inputs to reject filter (Suhas Daftuar)

Pull request description:

  Our policy checks for non-standard inputs depend only on the non-witness
  portion of a transaction: we look up the scriptPubKey of the input being
  spent from our UTXO set (which is covered by the input txid), and the p2sh
  checks only rely on the scriptSig portion of the input.

  Consequently it's safe to add txids of transactions that fail these checks to
  the reject filter, as the witness is irrelevant to the failure. This is helpful
  for any situation where we might request the transaction again via txid (either
  from txid-relay peers, or if we might fetch the transaction via txid due to
  parent-fetching of orphans).

  Further, in preparation for future witness versions being deployed on the
  network, ensure that WITNESS_UNKNOWN transactions are rejected in
  AreInputsStandard(), so that transactions spending v1 (or greater) witness
  outputs will fall into this category of having their txid added to the reject
  filter.

ACKs for top commit:
  ajtowns:
    ACK 9f88ded - code review
  jnewbery:
    Code review ACK 9f88ded
  ariard:
    Code Review/Tested ACK 9f88ded
  naumenkogs:
    utACK 9f88ded
  jonatack:
    ACK 9f88ded

Tree-SHA512: 1e93c0a5b68cb432524780ffc0093db893911fdfed9e2ed17f888e59114cc75d2a07062aefad4e5ce2e87c9270886117a8abb3c78fb889c9b9f31967f1777148
sdaftuar added a commit to sdaftuar/bitcoin that referenced this pull request Aug 7, 2020
Our policy checks for non-standard inputs depend only on the non-witness
portion of a transaction: we look up the scriptPubKey of the input being
spent from our UTXO set (which is covered by the input txid), and the p2sh
checks only rely on the scriptSig portion of the input.

Consequently it's safe to add txids of transactions that fail these checks to
the reject filter, as the witness is irrelevant to the failure. This is helpful
for any situation where we might request the transaction again via txid (either
from txid-relay peers, or if we might fetch the transaction via txid due to
parent-fetching of orphans).

Further, in preparation for future witness versions being deployed on the
network, ensure that WITNESS_UNKNOWN transactions are rejected in
AreInputsStandard(), so that transactions spending v1 (or greater) witness
outputs will fall into this category of having their txid added to the reject
filter.

Github-Pull: bitcoin#19620
Rebased-From: 7989901
sdaftuar pushed a commit to sdaftuar/bitcoin that referenced this pull request Aug 7, 2020
sdaftuar added a commit to sdaftuar/bitcoin that referenced this pull request Aug 7, 2020
Our policy checks for non-standard inputs depend only on the non-witness
portion of a transaction: we look up the scriptPubKey of the input being
spent from our UTXO set (which is covered by the input txid), and the p2sh
checks only rely on the scriptSig portion of the input.

Consequently it's safe to add txids of transactions that fail these checks to
the reject filter, as the witness is irrelevant to the failure. This is helpful
for any situation where we might request the transaction again via txid (either
from txid-relay peers, or if we might fetch the transaction via txid due to
parent-fetching of orphans).

Further, in preparation for future witness versions being deployed on the
network, ensure that WITNESS_UNKNOWN transactions are rejected in
AreInputsStandard(), so that transactions spending v1 (or greater) witness
outputs will fall into this category of having their txid added to the reject
filter.

Github-Pull: bitcoin#19620
Rebased-From: 7989901
sdaftuar pushed a commit to sdaftuar/bitcoin that referenced this pull request Aug 7, 2020
sdaftuar added a commit to sdaftuar/bitcoin that referenced this pull request Aug 7, 2020
Our policy checks for non-standard inputs depend only on the non-witness
portion of a transaction: we look up the scriptPubKey of the input being
spent from our UTXO set (which is covered by the input txid), and the p2sh
checks only rely on the scriptSig portion of the input.

Consequently it's safe to add txids of transactions that fail these checks to
the reject filter, as the witness is irrelevant to the failure. This is helpful
for any situation where we might request the transaction again via txid (either
from txid-relay peers, or if we might fetch the transaction via txid due to
parent-fetching of orphans).

Further, in preparation for future witness versions being deployed on the
network, ensure that WITNESS_UNKNOWN transactions are rejected in
AreInputsStandard(), so that transactions spending v1 (or greater) witness
outputs will fall into this category of having their txid added to the reject
filter.

Github-Pull: bitcoin#19620
Rebased-From: 7989901
sdaftuar pushed a commit to sdaftuar/bitcoin that referenced this pull request Aug 7, 2020
sdaftuar added a commit to sdaftuar/bitcoin that referenced this pull request Aug 7, 2020
Our policy checks for non-standard inputs depend only on the non-witness
portion of a transaction: we look up the scriptPubKey of the input being
spent from our UTXO set (which is covered by the input txid), and the p2sh
checks only rely on the scriptSig portion of the input.

Consequently it's safe to add txids of transactions that fail these checks to
the reject filter, as the witness is irrelevant to the failure. This is helpful
for any situation where we might request the transaction again via txid (either
from txid-relay peers, or if we might fetch the transaction via txid due to
parent-fetching of orphans).

Further, in preparation for future witness versions being deployed on the
network, ensure that WITNESS_UNKNOWN transactions are rejected in
AreInputsStandard(), so that transactions spending v1 (or greater) witness
outputs will fall into this category of having their txid added to the reject
filter.

Github-Pull: bitcoin#19620
Rebased-From: 7989901
sdaftuar pushed a commit to sdaftuar/bitcoin that referenced this pull request Aug 7, 2020
sdaftuar added a commit to sdaftuar/bitcoin that referenced this pull request Aug 10, 2020
Our policy checks for non-standard inputs depend only on the non-witness
portion of a transaction: we look up the scriptPubKey of the input being
spent from our UTXO set (which is covered by the input txid), and the p2sh
checks only rely on the scriptSig portion of the input.

Consequently it's safe to add txids of transactions that fail these checks to
the reject filter, as the witness is irrelevant to the failure. This is helpful
for any situation where we might request the transaction again via txid (either
from txid-relay peers, or if we might fetch the transaction via txid due to
parent-fetching of orphans).

Further, in preparation for future witness versions being deployed on the
network, ensure that WITNESS_UNKNOWN transactions are rejected in
AreInputsStandard(), so that transactions spending v1 (or greater) witness
outputs will fall into this category of having their txid added to the reject
filter.

Github-Pull: bitcoin#19620
Rebased-From: 7989901
sdaftuar pushed a commit to sdaftuar/bitcoin that referenced this pull request Aug 10, 2020
sdaftuar added a commit to sdaftuar/bitcoin that referenced this pull request Aug 11, 2020
Our policy checks for non-standard inputs depend only on the non-witness
portion of a transaction: we look up the scriptPubKey of the input being
spent from our UTXO set (which is covered by the input txid), and the p2sh
checks only rely on the scriptSig portion of the input.

Consequently it's safe to add txids of transactions that fail these checks to
the reject filter, as the witness is irrelevant to the failure. This is helpful
for any situation where we might request the transaction again via txid (either
from txid-relay peers, or if we might fetch the transaction via txid due to
parent-fetching of orphans).

Further, in preparation for future witness versions being deployed on the
network, ensure that WITNESS_UNKNOWN transactions are rejected in
AreInputsStandard(), so that transactions spending v1 (or greater) witness
outputs will fall into this category of having their txid added to the reject
filter.

Github-Pull: bitcoin#19620
Rebased-From: 7989901
sdaftuar pushed a commit to sdaftuar/bitcoin that referenced this pull request Aug 11, 2020
jonasschnelli added a commit that referenced this pull request Aug 28, 2020
52c3bec test addition of unknown segwit spends to txid reject filter (Gregory Sanders)
2ea826c Add txids with non-standard inputs to reject filter (Suhas Daftuar)

Pull request description:

  Backport of #19620 to 0.19.

ACKs for top commit:
  instagibbs:
    utACK 52c3bec
  jnewbery:
    utACK 52c3bec
  jonasschnelli:
    utACK 52c3bec

Tree-SHA512: 76b52d3fb0f9d88674dd186dee611bf0a2349b17549ef7909b4b37ace5b64d4edce56d71410e7b743e7e7d18855b84ff4b555a5edac26f67786abb9a264fa256
fanquake added a commit that referenced this pull request Sep 4, 2020
107cf15 test addition of unknown segwit spends to txid reject filter (Gregory Sanders)
06f9c5c Add txids with non-standard inputs to reject filter (Suhas Daftuar)

Pull request description:

  Backport of #19620 to 0.20.

ACKs for top commit:
  instagibbs:
    utACK 107cf15
  fjahr:
    utACK 107cf15
  jnewbery:
    utACK 107cf15

Tree-SHA512: d89c75fefdb6b50f40adfcf3cfdb2a791122e4d6a5903cb553c664042963577beb97a73319f9d1cb8320d32846778233c95255812c37fb4c7b1b25da161a6595
backpacker69 referenced this pull request in peercoin/peercoin Sep 8, 2020
Our policy checks for non-standard inputs depend only on the non-witness
portion of a transaction: we look up the scriptPubKey of the input being
spent from our UTXO set (which is covered by the input txid), and the p2sh
checks only rely on the scriptSig portion of the input.

Consequently it's safe to add txids of transactions that fail these checks to
the reject filter, as the witness is irrelevant to the failure. This is helpful
for any situation where we might request the transaction again via txid (either
from txid-relay peers, or if we might fetch the transaction via txid due to
parent-fetching of orphans).

Further, in preparation for future witness versions being deployed on the
network, ensure that WITNESS_UNKNOWN transactions are rejected in
AreInputsStandard(), so that transactions spending v1 (or greater) witness
outputs will fall into this category of having their txid added to the reject
filter.

Github-Pull: #19620
Rebased-From: 7989901
backpacker69 referenced this pull request in peercoin/peercoin Sep 8, 2020
Bushstar pushed a commit to Bushstar/omnicore that referenced this pull request Oct 21, 2020
Our policy checks for non-standard inputs depend only on the non-witness
portion of a transaction: we look up the scriptPubKey of the input being
spent from our UTXO set (which is covered by the input txid), and the p2sh
checks only rely on the scriptSig portion of the input.

Consequently it's safe to add txids of transactions that fail these checks to
the reject filter, as the witness is irrelevant to the failure. This is helpful
for any situation where we might request the transaction again via txid (either
from txid-relay peers, or if we might fetch the transaction via txid due to
parent-fetching of orphans).

Further, in preparation for future witness versions being deployed on the
network, ensure that WITNESS_UNKNOWN transactions are rejected in
AreInputsStandard(), so that transactions spending v1 (or greater) witness
outputs will fall into this category of having their txid added to the reject
filter.

Github-Pull: bitcoin#19620
Rebased-From: 7989901
Bushstar pushed a commit to Bushstar/omnicore that referenced this pull request Oct 21, 2020
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Sep 9, 2021
Summary:
Nothing in the PR's description is relevant to use, but having a special subcategory of TX_NOT_STANDARD for non-standard inputs seems reasonable.

Our codebase already adds those txid to the recentRejectFilter, so most of the changes do not apply.

This is a backport of [[bitcoin/bitcoin#19620 | core#19620]]

bitcoin/bitcoin@7989901

Test Plan: `ninja all check-all`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D10061
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 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.

None yet