Skip to content

Only relay Taproot spends if next block has it active#20165

Merged
maflcko merged 2 commits intobitcoin:masterfrom
sipa:202010_taproot_policy
Nov 2, 2020
Merged

Only relay Taproot spends if next block has it active#20165
maflcko merged 2 commits intobitcoin:masterfrom
sipa:202010_taproot_policy

Conversation

@sipa
Copy link
Member

@sipa sipa commented Oct 16, 2020

There should be no change to mempool transaction behavior for witness v1 transactions as long as no activation is defined. Until that point, we should treat the consensus rules as under debate, and for soft-fork safety, that means spends should be treated as non-standard.

It's possible to go further: don't relay them unless the consensus rules are actually active for the next block. This extends non-relay to the period where a deployment is defined, started, locked in, or failed. I see no downsides to this, and the code change is very simple.

@sipa
Copy link
Member Author

sipa commented Oct 16, 2020

A suggestion that is not included here is rejecting the creation of witness v1 spends during a period preceding activation to protect users sending to such outputs too early. It's easy to add if desired, but perhaps less necessary.

@sdaftuar Doing this for the entire defined/started/lockedin period adds additional non-homogeneity to network relay policy. @ajtowns suggested doing it only during during the lockedin period, to provide a short but still coordinated window of additional protection.

Copy link
Contributor

@kallewoof kallewoof left a comment

Choose a reason for hiding this comment

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

utACK 6d568731862b1d888fa8db9effb3663dfe8e0e46

@Sjors
Copy link
Member

Sjors commented Oct 16, 2020

utACK 6d56873

@naumenkogs
Copy link
Contributor

utACK 6d568731862b1d888fa8db9effb3663dfe8e0e46


Could you elaborate on what this means:

@ajtowns suggested doing it only during during the lockedin period, to provide a short but still coordinated window of additional protection.

@sdaftuar
Copy link
Member

Concept ACK the change suggested in this PR.

A suggestion that is not included here is rejecting the creation of witness v1 spends during a period preceding activation to protect users sending to such outputs too early. It's easy to add if desired, but perhaps less necessary.

@sdaftuar Doing this for the entire defined/started/lockedin period adds additional non-homogeneity to network relay policy. @ajtowns suggested doing it only during during the lockedin period, to provide a short but still coordinated window of additional protection.

I'm not sure I entirely see a reason for concern over the non-homogeneity of network relay policy with respect to anyone-can-spend outputs; in my view, taproot-enabled software (by which I mean software that is aware of all the taproot consensus changes, necessarily including activation criteria for enforcing those rules) should differ from other software with how it treats v1 addresses, because it is the only software that actually knows what they mean.

One way to think about this is that if the community is using bitcoind to determine whether it's reasonable to relay a transaction creating a v1 output, that having the taproot-enabled-version of bitcoind correctly say "no" prior to activation is a useful thing to do. In the absence of us implementing that behavior, how would a user implement such footgun protection on their own?

Arguably, we could ship a taproot-enabled version of bitcoind that relayed such transactions anyway, if the user requested (eg by command-line option or something); but none of the reasons that come to mind right now of why someone might want to use such an option seem very good to me.

@sipa
Copy link
Member Author

sipa commented Oct 20, 2020

@naumenkogs Some background, this was discussed on the last IRC dev meeting, where I brought up two things we can do:

  • Making sure spending of witnesses isn't standard until an activation is defined (as the node shouldn't behave differently up to that point)
  • Making sure creating witness v1 outputs are not allowed to protect users potentially accidentally creating anyonecanspend outputs if they do it too soon, for some period of time prior to activation.

The PR here only does the first, as I think there are a few trade-offs to consider regarding the second.

@ajtowns
Copy link
Contributor

ajtowns commented Oct 20, 2020

Concept ACK -- I think it makes sense to not do any "create witness v1 outputs" protection until an activation method is defined.

Making spends non-standard is valuable for signet (where standardness and consensus aren't all that different, so making something standard but not consensus-enforced means it can be relied on in practice).

@sipa sipa added this to the 0.21.0 milestone Oct 20, 2020
@maflcko
Copy link
Member

maflcko commented Oct 21, 2020

Concept ACK will review when I am done reading through the other taproot changes

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. Presumably this code can be reverted once taproot has been activated for some time?

I don't understand one change in the functional test.

@maflcko
Copy link
Member

maflcko commented Oct 28, 2020

I checked out the test and ran it against master, without failure. Similarly running master against this test didn't result in a failure either.

Concept ACK on not changing policy for creation of v1 outputs

ACK 6d568731862b1d888fa8db9effb3663dfe8e0e46 👉

Show signature and timestamp

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

ACK 6d568731862b1d888fa8db9effb3663dfe8e0e46 👉
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUiJ3gv/Tup4S2s8VROgkpG7Z37qdFDkuUn/omhACbpk6K8U5upmoDbGQ/lS/uwP
8FSDlp/hKpMd8HQZqe1RmiCjqQx0rpEpiIFHz4KcFlCm9hBUOE5slj/7iaNmRXd2
NdUOldyFQ6dY1xxSTq7yVPVe0NFHWa47TpHaxU+RVuL2aLjT5av548OBxnZv5BEi
OTTzxP6si98pG9cICSqKCQiCUDCD6+7LH3WfcjGHio1xN0QKYGnPyesTjgBFMvR4
7CmjzXChqQkq9St/ZsbTzfMC67ittfN6x5NKFvvKygtg7Fsg1FGg/xHaNMfWvQbi
Ox3HPyBKMNhZZ7xnn0/zitNAjOpu01kuNetNcadkraXF7wVuuF+dSgJ2VKIC67Wa
YZGN9NNCjo81uk2vjiZ7n5utOtituIP1g8foifD4sLaIsqdON1marySSAR+ofOwe
FTg904KgJuLAo2pNamg6xzZN3UggHulRvrl+OHeKtBjooX/86P62XoMDwA0QiB9U
e7LP7/p/
=1Z1m
-----END PGP SIGNATURE-----

Timestamp of file with hash 2b92f56206799ab5e32a77050772e4eae3c8dec7e90cd81d50688289a0789af3 -

@sipa sipa force-pushed the 202010_taproot_policy branch from 6d56873 to 5482545 Compare October 30, 2020 22:42
@sipa sipa force-pushed the 202010_taproot_policy branch from 5482545 to 3d0556d Compare October 30, 2020 22:53
@Sjors
Copy link
Member

Sjors commented Oct 31, 2020

utACK 3d0556d

@maflcko
Copy link
Member

maflcko commented Nov 2, 2020

review ACK 3d0556d 🏓
did not review the test, but verified that it fails on master-bitcoind

Show signature and timestamp

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

review ACK 3d0556d41087f945ed0a47a5d770076ad42ce432 🏓
did not review the test, but verified that it fails on master-bitcoind
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUiIewv+NBxdImuTTZykq150lh7oI7Zw0umuVp4rGQT5rG4+pqIKAxTaXXoP3L7C
VNB+9/8WRXZVjBkkNnuytermCB4EvrbzUQtHGgrrpzCFxmdlZ3s0wYqOChVfTmo+
dUU2Iu8OTE5uUI4SOBw7O7xOTK5uzo8NRM43eqqBVHPFsxanHGOx3zX+AqADA3Ry
ykc/LSOVPJiSGESvoOiFRBMTQPNjirFeE9efWv9ILiQ75gpcXmuHPWs7xhvCm65e
4Q25GBqR29mVRk4GXdO3Zl2I7xM3m7LqxMCNLOEhlVvrJLVClC65JAk5qf/kQsXC
QlVm/jcV4uwEseXB4XlTlGlvQFM1Rg32dk2ARcI/k2i61OtcNzYeQ6g6qg1k7cYi
KtrGIJ848imI3NHmQyfOGL5bXBLRqNLNwjimG1qVWISnCFDOnuWfvxHCaagBbyyK
iNgTkQuE2CX9h97q5m1rPBQARoDKY15DWeqUUThOYuen0kUDkM668ixDjQHFPWa8
iOuqbiUf
=iTZF
-----END PGP SIGNATURE-----

Timestamp of file with hash 995b925e09b8d1e7f45089547fb58deb2eb37a0a2f9be02f451aa790b742d490 -

@jnewbery
Copy link
Contributor

jnewbery commented Nov 2, 2020

utACK 3d0556d

@maflcko maflcko merged commit c5ec036 into bitcoin:master Nov 2, 2020
Copy link
Member

@jonatack jonatack 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, posthumous ACK 3d0556d

Verified the updated test fails on pre-merge master with

  File "test/functional/feature_taproot.py", line 1457, in run_test
    self.test_spenders(self.nodes[0], spenders_taproot_inactive(), input_counts=[1])
  File "test/functional/feature_taproot.py", line 1426, in test_spenders
    assert_raises_rpc_error(-26, None, node.sendrawtransaction, tx.serialize().hex(), 0)
  File "/home/jon/projects/bitcoin/bitcoin/test/functional/test_framework/util.py", line 123, in assert_raises_rpc_error
    assert try_rpc(code, message, fun, *args, **kwds), "No exception raised"
AssertionError: No exception raised

* Check for standard transaction types
* @param[in] mapInputs Map of previous transactions that have outputs we're spending
* @param[in] mapInputs Map of previous transactions that have outputs we're spending
* @param[in] taproot_active Whether or taproot consensus rules are active (used to decide whether spends of them are permitted)
Copy link
Member

Choose a reason for hiding this comment

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

525cbd4 omit "or" or s/or/or not/

// Check for non-standard pay-to-script-hash in inputs
if (fRequireStandard && !AreInputsStandard(tx, m_view)) {
const auto& params = args.m_chainparams.GetConsensus();
auto taproot_state = VersionBitsState(::ChainActive().Tip(), params, Consensus::DEPLOYMENT_TAPROOT, versionbitscache);
Copy link
Member

Choose a reason for hiding this comment

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

525cbd4 perhaps s/auto/ThresholdState/ like validation.cpp::L1834 and mining.cpp::L820

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

10 participants