Reject non-final txs even in testnet/regtest #5521

pull petertodd wants to merge 1 commits into bitcoin:master from petertodd:anti-delorean changing 1 files +20 −23
  1. petertodd commented at 5:43 AM on December 21, 2014: contributor

    Previous behavior with IsFinalTx() being an IsStandard() rule was rather confusing and interferred with testing of protocols that depended on nLockTime. A particularly bad example is with CHECKLOCKTIMEVERIFY where it gave the impression that the CLTV opcode didn't do anything as CLTV-using txs that aren't yet minable because the locktimes haven't been reached are accepted.

  2. jtimon commented at 12:58 PM on December 21, 2014: contributor

    utACK. I also wonder if this check should be part of the node's policy as in #5071 or it should be left in main. At least "chainActive.Height() + 1" doesn't seem to be something you should call from policy.o, at most pass it as parameter.

  3. jtimon cross-referenced this on Dec 21, 2014 from issue Introduce CNodePolicy for putting isolated node policy code and parameters on by luke-jr
  4. petertodd commented at 2:44 PM on December 21, 2014: contributor

    @jtimon How is this sanely a node policy thing? We're talking about whether or not we accept transactions that can't be mined to the mempool; remember the nLockTime can be any amount in the future.

  5. jtimon commented at 2:59 PM on December 21, 2014: contributor

    That's what I'm saying, this probably shouldn't go with the policy code. Thus this change is good for a later move of Params().RequireStandard() && !IsStandardTx(tx, reason) to policy.

  6. petertodd commented at 3:08 PM on December 21, 2014: contributor

    @jtimon Oh, you mean should #5071 include this pull-req? Sure, but anyway IMO this pull-req makes sense to merge regardless of what we do with policy in a wider sense.

    FWIW I keep meaning to making IsStandard() something you can turn off via a command-line flag, as it makes testing software on testnet/regtest annoying due to the differences in behavior.

  7. jtimon commented at 3:53 PM on December 21, 2014: contributor

    Yes, this PR makes sense independently, just saying that it also makes sense from the policy-encapsulation perspective. About decoupling policy selection from network (chainparams) selection, in #5180 I proposed to turn bool CChainParams::RequireStandard() into std::string CChainParams::DefaultPolicy() so that the user selection of policy overwrites the default per-network while remaining backwards compatible with what one would expect from each mode without knowing about the new policy parameter. I could rebase that or make a simpler version with a subset of #5071 if there's interest.

  8. petertodd commented at 4:09 PM on December 21, 2014: contributor

    @jtimon Yup, ACK DefaultPolicy()

  9. petertodd cross-referenced this on Dec 25, 2014 from issue Mempool only CHECKLOCKTIMEVERIFY (BIP65) verification by petertodd
  10. jtimon commented at 8:15 PM on December 27, 2014: contributor

    A few questions:

    1. Doesn't the access to chainActive.Height() require you to AssertLockHeld(cs_main) even though it's going to be checked again in IsFinalTx() ?

    2. After removing that access to chainActive from IsStandardTx(), why does it need to AssertLockHeld(cs_main)? Only for fIsBareMultisigStd and minRelayTxFee? Aren't those set only on init?

  11. jtimon commented at 3:16 PM on December 29, 2014: contributor

    To be clear, this is what I'm suggesting: https://github.com/jtimon/bitcoin/commits/5521 Maybe it is a bad suggestion for some reason I'm missing.

  12. in src/main.cpp:None in bd3f7f023a outdated
     930 | +    // can't know what timestamp the next block will have, and there aren't
     931 | +    // timestamp applications where it matters.
     932 | +    if (!IsFinalTx(tx, chainActive.Height() + 1))
     933 | +        return state.DoS(0,
     934 | +                         error("AcceptToMemoryPool : non-final"),
     935 | +                         REJECT_NONSTANDARD, reason);
    


    jtimon commented at 10:45 PM on December 29, 2014:

    s/reason/"non-final"


    petertodd commented at 4:35 AM on January 3, 2015:

    Thanks!

  13. jtimon cross-referenced this on Dec 30, 2014 from issue WIP: Policy: Separate standard and testing policies by jtimon
  14. petertodd commented at 4:31 AM on January 3, 2015: contributor

    @jtimon AcceptToMemoryPool has an AssertLockHeld(cs_main); at the beginning of the function, so we don't need another. That said I do think you are correct that IsStandardTx() doesn't need to have cs_main locked anymore. @sipa @gmaxwell @laanwj Care to confirm this?

  15. petertodd force-pushed on Jan 3, 2015
  16. jtimon commented at 3:17 PM on January 3, 2015: contributor

    Yeah, the main point is that it is not required in IsStandardTx(), that if it was needed, it was only for the access to activeChain, making the function more independent from main to move it out later.

  17. gmaxwell commented at 5:58 PM on January 4, 2015: contributor

    utACK. Just wrote a almost bytewise identical patch (my update to the comment was slightly more minimal).

    (Lock can be removed in another patch)

  18. jtimon commented at 6:21 PM on January 4, 2015: contributor

    @gmaxwell thoughts on removing AssertLockHeld(cs_main); from IsStandardTx() within this PR?

  19. gmaxwell commented at 7:06 PM on January 4, 2015: contributor

    I think it's fine to remove.

  20. Reject non-final txs even in testnet/regtest
    Previous behavior with IsFinalTx() being an IsStandard() rule was rather
    confusing and interferred with testing of protocols that depended on
    nLockTime.
    0ea28baeb8
  21. petertodd commented at 7:22 PM on January 4, 2015: contributor

    @jtimon @gmaxwell Removed.

  22. petertodd force-pushed on Jan 4, 2015
  23. jtimon commented at 10:46 PM on January 4, 2015: contributor

    reACK

  24. rnicoll commented at 12:44 AM on January 5, 2015: contributor

    Tested ACK

  25. laanwj commented at 3:27 PM on January 7, 2015: member

    @petertodd I've also checked and indeed, nothing is being done that requires cs_main lock anymore.

    ACK

  26. laanwj merged this on Jan 7, 2015
  27. laanwj closed this on Jan 7, 2015

  28. laanwj referenced this in commit 8e4578af0f on Jan 7, 2015
  29. jtimon cross-referenced this on Jan 13, 2015 from issue Policy: Continue policy movements by jtimon
  30. rnicoll cross-referenced this on Jan 14, 2015 from issue Enable limited TX replacement by rnicoll
  31. bitcoin locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-20 06:55 UTC