Skip to content

Conversation

jtimon
Copy link
Contributor

@jtimon jtimon commented Oct 30, 2014

EDIT:

This prepares AcceptToMemoryPool to be decoupled from Params() and creates a -policy command-line option to select the standard or test policy independently of the chain mode (ie main, testnet3, regtest).

It's based on #6068.
@petertodd already acked the concept here: #5521 (comment)

OLD:
Instead of being based on #5071 as initially, it doesn't go as far as that PR.
A rebased version of #5071 on top of this PR can be found here: https://github.com/jtimon/bitcoin/tree/nodepolicy_5180
Instead of being based on #5071 it is based on #5521 (plus one doubt-commit).

Please let's not delay policy.o even if it's only with minRelayTxFee.
Later proposals to expand policy.o become more readable once the first step has been walked.
Even better, later proposed changes to main.o may become proposed changes to policy.o!!
In my opinion the biggest development bottleneck is reviewing changes to main.o.

/EDIT
It's based on #5071 and eliminates Params().RequireStandard() by separating two policies for the 4 networks accessible with Params() as discussed in that PR.
It also includes a couple of "squashme" commits that solve my complains on #5071 in case you @luke-jr want to take them.

@jtimon
Copy link
Contributor Author

jtimon commented Oct 30, 2014

Since I touch chainparams, my version needed rebase...

@luke-jr
Copy link
Member

luke-jr commented Oct 30, 2014

Disagree with per-network policies and global Policy() function; the former overcomplicates modifications for no real benefit, and the latter would make multiple policies more difficult to add in circumstances where they would actually be desirable (ie, within the same running instance).

@jtimon jtimon force-pushed the nodepolicy2 branch 3 times, most recently from 1e64382 to f1b49db Compare October 31, 2014 20:18
@jtimon
Copy link
Contributor Author

jtimon commented Oct 31, 2014

It's not a per-network policy, please, read the code. It's quite the opposite actually: it's decoupling policies from networks.
Previously the user can only select 4 {policy, network} pairs: {standard, mainnet}, {test, testnet}, {test, regtest}, {standard, unitest}
With 2 separate policy classes the available combinations are 8: {standard, test} x {mainnet, testnet, regtest, unitest}.
It also simplifies modifications.

A pointer to an abstract class is by all means more flexible than a reference to a an extern object when it comes to support multiple policies.
With Policy::Factory() you can make as many of them as you want, as shown in the example.
If you want to avoid managing memory manually, Policy::Pool() can be used instead.
Of course, its interface can be simplified to Policy::FactoryPool() (hiding CPolicyPool class).
If we're not going to have several policies with different states for the same policy type, Policy::Simple() is enough..
You can even hide CNodePolicy, exposing the abstract class is enough.
In fact, what is the point in exposing the abstract class if you're not going to use polymorphism?

I will of course clean this up, but I hope this can convince you that CNodePolicy::fRequireStandardTx, exposing CNodePolicy and the extern CNodePolicy in main are mistakes.

I'm indifferent to "coins: GetTxFees method" because I don't see it as specially useful, but if the new method is not even going to be used (as in "SQUASHME: actually use GetTxFees method") I would say NACK. It seems completely orthogonal to the rest of the PR anyway.

@jtimon
Copy link
Contributor Author

jtimon commented Dec 30, 2014

Updated initial description.

@jtimon
Copy link
Contributor Author

jtimon commented Jan 3, 2015

Updated code and description again without IsDust() this time.

@jtimon jtimon changed the title Separate standard and testing policies Policy: Separate standard and testing policies Jan 3, 2015
@jtimon jtimon force-pushed the nodepolicy2 branch 5 times, most recently from 5cbc611 to ef91b0c Compare January 7, 2015 22:38
@jtimon
Copy link
Contributor Author

jtimon commented Jan 7, 2015

Rebased after #5521 has been merged for easier review.

@jtimon
Copy link
Contributor Author

jtimon commented Jan 13, 2015

Closing in favor of #5652

@jtimon
Copy link
Contributor Author

jtimon commented Jun 8, 2015

Updated after #6068 has been updated. Now the addition of the -policy option is left for the end as an optinal "squasheable" commit.

@jtimon jtimon force-pushed the nodepolicy2 branch 3 times, most recently from b26ea47 to 5f97028 Compare June 17, 2015 22:11
@jtimon jtimon force-pushed the nodepolicy2 branch 3 times, most recently from 3deba59 to 3eaa099 Compare June 25, 2015 11:39
@jtimon
Copy link
Contributor Author

jtimon commented Jun 25, 2015

Closing until some version of #6068 is merged.

@jtimon jtimon closed this Jun 25, 2015
@jtimon jtimon reopened this Jun 26, 2015
@jtimon jtimon closed this Jun 26, 2015
@jtimon
Copy link
Contributor Author

jtimon commented Jun 26, 2015

Updated opening description after rebasing and re-closing.

if (Params().RequireStandard() && !fRequireStandard)
return InitError(strprintf("acceptnonstdtxn is not currently supported for %s chain", chainparams.NetworkIDString()));
if (GetBoolArg("-acceptnonstdtxn", false))
return InitError(strprintf("acceptnonstdtxn is deprecated, use policy=test instead.", chainparams.NetworkIDString()));
Copy link
Member

Choose a reason for hiding this comment

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

acceptnonstdtxn affects only one facet of the policy. It shouldn't be deprecated unless you add a way to configure the flag some other way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The default -acceptnonstdtxn=0 is equivalent to the default -policy=standard.
To use the equivalent of -acceptnonstdtxn=1, you use -policy=test.
This has the advantages of decoupling policy from Params() and that adding new policies (say, -policy=fss_rbf) becomes easier in the future.
Anyway, this needs rebase.

@jtimon jtimon changed the title DEPENDENT: Policy: Separate standard and testing policies WIP: Policy: Separate standard and testing policies Jul 7, 2015
jtimon added 6 commits July 8, 2015 13:11
…y class implementing it

Rename 3 functions into CPolicy methods:

- IsStandard -> policy.ApproveScript
- IsStandardTx -> policy.ApproveTx
- AreInputsStandard -> policy.ApproveTxInputs
…tly of the chain

...by replacing CChainParams::fRequireStandard with CChainParams::strDefaultPolicy

Also expose it as an option (-policy=test) equivalent to -acceptnonstdtxn.
This decouples policy/policy.cpp from Params()
@jtimon
Copy link
Contributor Author

jtimon commented Jul 8, 2015

Updated without deprecating anything.
Now -policy overwrites the chain selection but -acceptnonstdtxn overwrites -policy (at least for policies standard and test, other policies may not even have a -acceptnonstdtxn option).
I don't care about keeping -acceptnonstdtxn even if you can just use -policy=test instead of -acceptnonstdtxn=1 (so keeping it is redundant), to me the important thing is decoupling policy from Params() and having a factory to make the creation maintenance of custom policies easier.

@jtimon
Copy link
Contributor Author

jtimon commented Jul 11, 2015

I only reopened to show and discuss the updated version. But, again, closing until there's a CPolicy interface class.

@jtimon jtimon closed this Jul 11, 2015
@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.

2 participants