Skip to content

Conversation

@petertodd
Copy link
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.

@jtimon
Copy link
Contributor

jtimon commented Dec 21, 2014

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.

@petertodd
Copy link
Contributor Author

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

@jtimon
Copy link
Contributor

jtimon commented Dec 21, 2014

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.

@petertodd
Copy link
Contributor Author

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

@jtimon
Copy link
Contributor

jtimon commented Dec 21, 2014

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.

@petertodd
Copy link
Contributor Author

@jtimon Yup, ACK DefaultPolicy()

@jtimon
Copy link
Contributor

jtimon commented Dec 27, 2014

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?

@jtimon
Copy link
Contributor

jtimon commented Dec 29, 2014

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.

src/main.cpp Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

s/reason/"non-final"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

@petertodd
Copy link
Contributor Author

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

@jtimon
Copy link
Contributor

jtimon commented Jan 3, 2015

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.

@gmaxwell
Copy link
Contributor

gmaxwell commented Jan 4, 2015

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

(Lock can be removed in another patch)

@jtimon
Copy link
Contributor

jtimon commented Jan 4, 2015

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

@gmaxwell
Copy link
Contributor

gmaxwell commented Jan 4, 2015

I think it's fine to remove.

Previous behavior with IsFinalTx() being an IsStandard() rule was rather
confusing and interferred with testing of protocols that depended on
nLockTime.
@petertodd
Copy link
Contributor Author

@jtimon @gmaxwell Removed.

@jtimon
Copy link
Contributor

jtimon commented Jan 4, 2015

reACK

@rnicoll
Copy link
Contributor

rnicoll commented Jan 5, 2015

Tested ACK

@laanwj
Copy link
Member

laanwj commented Jan 7, 2015

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

ACK

@laanwj laanwj merged commit 0ea28ba into bitcoin:master Jan 7, 2015
laanwj added a commit that referenced this pull request Jan 7, 2015
0ea28ba Reject non-final txs even in testnet/regtest (Peter Todd)
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants