Skip to content

Conversation

luke-jr
Copy link
Member

@luke-jr luke-jr commented Oct 10, 2014

Initially populated with policy-specific code moved from AcceptToMemoryPool.

This should make no actual changes, just refactor code. If any change in behaviour is found, it is a bug in this pull request, please report it even if you think it's a good idea.

@@ -0,0 +1,103 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
Copy link

Choose a reason for hiding this comment

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

Nit: Just MIT

Copy link
Member Author

Choose a reason for hiding this comment

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

Just copying it from main.cpp, where the code came from. If you want it changed here, make a convincing argument to change it there first.

Copy link
Contributor

Choose a reason for hiding this comment

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

All files need changing, but instead of doing it all at once, we're just changing it as files are updated. Please use just MIT.

Copy link
Contributor

Choose a reason for hiding this comment

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

This has been discussed already. I though we had merged a PR changing everything to just MIT already.
That would be simpler than warning people every time they copy the license from an outdated place.

@luke-jr luke-jr force-pushed the nodepolicy branch 2 times, most recently from ad1dcdb to 7c9d476 Compare October 11, 2014 03:41
bool fRateLimit = false;
if (!policy.AcceptMemPoolEntry(pool, state, entry, view, fRateLimit))
return false;
if (!fLimitFree)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why bother with fRateLimit/fLimitFree at all here, since the logic boils down to:

fRateLimit = !fLimitFree ? false : false

You could just write:

if (!policy.AcceptMemPoolEntry(pool, state, entry, view, false))
    return false;

if (!policy.RateLimitTx(pool, state, entry, view))
    return false;

Is it the idea that more behaviour will be added here or?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not all transactions should be rate limited, for different reasons, some of which are policy (contracts with retailers?), some of which are not (local user manually wants to broadcast a transaction).

Copy link
Member Author

Choose a reason for hiding this comment

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

Notice fRateLimit is passed to AcceptMemPoolEntry by reference, and it may (and does in some cases by default) change it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, the pass by reference was what I was missing. LGTM then.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree this feels confusing. I wonder if it ought to be moved onto CValidationState so any step of the process can set it?

@luke-jr luke-jr force-pushed the nodepolicy branch 3 times, most recently from ba69a22 to 752418d Compare October 12, 2014 02:30
@@ -55,6 +56,7 @@ unsigned int nCoinCacheSize = 5000;
CFeeRate minRelayTxFee = CFeeRate(1000);

CTxMemPool mempool(::minRelayTxFee);
CNodePolicy policy;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we even need an object for policy? isnt it all static?
Maybe best to just do a Params()-style Policy()?

Copy link
Contributor

Choose a reason for hiding this comment

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

A params-style global hidden behind a function you mean?
I prefer a class.

Copy link
Member Author

Choose a reason for hiding this comment

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

@TheBlueMatt It isn't inherently static. It might be nice to one day have nodes with multiple policies, using different ones based on transaction sources and mempools...

@jtimon
Copy link
Contributor

jtimon commented Oct 12, 2014

Idea ACK. @petertodd should also like this since he was positive about it when I proposed in #4298
On the class name, why not just CPolicy? Maybe better CStandardPolicy if we're going to later add an abstract CPolicy that CStandardPolicy (and maybe CReplaceByFeePolicy) derive from.
More things out of main.o, yes!

@@ -650,6 +650,8 @@ bool AppInit2(boost::thread_group& threadGroup)
const char* pszP2SH = "/P2SH/";
COINBASE_FLAGS << std::vector<unsigned char>(pszP2SH, pszP2SH+strlen(pszP2SH));

policy.fRequireStandardTx = Params().RequireStandard();
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this should be called here. This should be in policy.cpp and the field in Policy is not really required.

Copy link
Member Author

Choose a reason for hiding this comment

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

This has to be called here. When CNodePolicy is initialised, Policy() might not have been yet.

@jtimon
Copy link
Contributor

jtimon commented Oct 12, 2014

It would be easier to review if you first just moved code as functions with a move-only commit (without indentations) and then created the class and cleaned up. Like @jgarzik did in #4646

@luke-jr
Copy link
Member Author

luke-jr commented Oct 26, 2014

Rebased with requested changes.

@jtimon
Copy link
Contributor

jtimon commented Dec 21, 2014

Needs rebase. On top of #5521 ?
As said I would avoid the boolean attribute, it doesn't accomplish its goal of decoupling chainparams from policy.

@jtimon
Copy link
Contributor

jtimon commented Dec 29, 2014

Here's a rebased version (not on top of #5521): https://github.com/jtimon/bitcoin/commits/nodepolicy_old

@jtimon
Copy link
Contributor

jtimon commented Dec 30, 2014

Here's a version rebased on top of #5114: https://github.com/jtimon/bitcoin/tree/nodepolicy_dust
Here's a version rebased on top of #5114 and #5521: https://github.com/jtimon/bitcoin/tree/nodepolicy_5521_dust
And, finally, here's a version on top of the updated #5180: https://github.com/jtimon/bitcoin/tree/nodepolicy_5180

@jgarzik
Copy link
Contributor

jgarzik commented Jul 23, 2015

Closing. No ACKs after a while, and it is intertwined with otherwise fast-moving policy code changes getting merged into the tree.

If this is in error, it can always be re-opened.

@jgarzik jgarzik closed this Jul 23, 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants