Skip to content

Conversation

TheBlueMatt
Copy link
Contributor

@TheBlueMatt TheBlueMatt commented Aug 20, 2017

No sensible user will ever keep the default settings here, so not
having sensible defaults only serves to screw users who are
paying less attention, which makes for terrible defaults.

Additionally, support for block-size-limiting directly has been removed:

  • This removes block-size-limiting code in favor of GBT clients
    doing the limiting themselves (if at all).
  • -blockmaxsize is deprecated and only used to calculate an implied
    blockmaxweight, addressing confusion from multiple users.
  • getmininginfo's currentblocksize return value was returning
    garbage values, and has been removed, also removing a
    GetSerializeSize call in some block generation inner loops and
    potentially addressing some performance edge cases.

@luke-jr
Copy link
Member

luke-jr commented Aug 20, 2017

NACK, these are not sensible. If anything, they should be reduced.

@laanwj
Copy link
Member

laanwj commented Aug 21, 2017

Please, not again, no more defaults fighting...

@gmaxwell
Copy link
Contributor

gmaxwell commented Aug 23, 2017

ACK. The current settings are reprehensible: They result in guaranteed income reduction for anyone who follows them for almost no measurable benefit-- because as we see almost everyone maxes them out regardless. The losses are also not trivial, but are often about 5% of mining income-- which wasn't the case when they were last discussed but is now.

Luke's argument rests on an unlikely and now conclusively disproven theory that miners will individually act against their own short term economic best interests to preserve the usability of the network. This is demonstratively false and even if it were true, setting an economically rational default wouldn't change it. (these hypothetical altruistic miners would simply lower their defaults, if they existed)

To the limited extent that anyone does mine with these defaults (not much) they also make fee estimates less reliable by adding additional variance to the capacity of the network. A few blocks showing up underfilled is doing no one any favors-- it doesn't meaningfully reduce the initial synchronization time. All it does is lower the revenue of those who do it. To the extent that any of that is driven by a genuine desire to aid the network (rather than just misconfiguration)-- do we really want people who want to help to be less successful (and thus less able to add hashpower and increase their influence)

Setting the defaults in a way which virtually no one will use also has the problem of causing people to change the default and then when the way the options works needs to change their outdated settings can cause unexpected behavior. For example, there are many miners who have set the max size to a million bytes to override these broken defaults. And then with segwit they'll be producing undersized blocks unintentionally. They may even be paying enough attention to realize they need to change them, only to set them to 2 million bytes and still produce undefilled blocks.

Setting a reduced default against the traffic in the network today violates the principle the software should act in the interest of the people using it and in doing so shows disrespect where none is intended, it violates the principle that absent significant harm to it users it should act in the public interest (by making fee estimation less reliable).

IMO if it isn't reduced it should be removed completely. At least there is a strong argument that miners producing blocks which fail to confirm all transactions is harmful to the public interest, and improvements in block propagation have largely eliminated size based considerations as legitimate reasons to choose to produce a smaller block. (Moreover if one was for some reason still concerned about size impacts on propagation the received time sensitive framework from Suhas would be the right way to go about it, not simply reducing the maximum size.)

@laanwj
Copy link
Member

laanwj commented Aug 23, 2017

Previous discussion was here (possibly more, but these I could find in a quick search):

As we know all miners will override the defaults, and for other users the value doesn't matter, I think this is a pointless waste of energy, creating angry discussions unnecessarily.

I'm unsubscribing from this thread.

@TheBlueMatt TheBlueMatt changed the title Use a sensible default for blockmax{size,weight} Dont default to throwing away money for blockmax{size,weight} Aug 23, 2017
@janbraiins
Copy link
Contributor

Hi,
this make sense to me. From pool operator's prospective, we set this to max for the reasons stated by Greg. What is confusing is that without researching the code, it is not quite clear how each of the limits influence each other. A sane default for us was just to set blockmaxweight, having the core derive the blockmaxsize.
Jan

@gmaxwell
Copy link
Contributor

gmaxwell commented Aug 24, 2017

@honzik666 Right, the correct settings are to remove any mention of blockmaxsize from your configuration and set only blockmaxweight=4000000.

Blockmaxsize is a legacy option that wasn't even existent at first in the segwit settings. It doesn't make sense to use it, setting it (at least to anything other than the maximum of 4 million) will just lower your income.

@TheBlueMatt TheBlueMatt changed the title Dont default to throwing away money for blockmax{size,weight} Fix confusing blockmax{size,weight} options, dont default to throwing away money Aug 24, 2017
@TheBlueMatt
Copy link
Contributor Author

Pushed a new commit to hopefully help address the confusion that a few people have had on these options, which also fixes a bug or two in the process.

@@ -17,9 +17,9 @@ class CCoinsViewCache;
class CTxOut;

/** Default for -blockmaxsize, which controls the maximum size of block the mining code will create **/
static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 750000;
static const unsigned int DEFAULT_BLOCK_MAX_SIZE = MAX_BLOCK_SERIALIZED_SIZE - 1000;
Copy link
Member

Choose a reason for hiding this comment

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

delete instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@TheBlueMatt TheBlueMatt force-pushed the 2017-08-sane-default-limits branch from 8893ed7 to 10d21dc Compare August 24, 2017 18:43
@meshcollider
Copy link
Contributor

Concept ACK as discussed in meeting

src/miner.cpp Outdated
if (!fWeightSet) {
options.nBlockMaxWeight = options.nBlockMaxSize * WITNESS_SCALE_FACTOR;
options.nBlockMaxWeight = gArgs.GetArg("-blockmaxsize", DEFAULT_BLOCK_MAX_WEIGHT / WITNESS_SCALE_FACTOR) * WITNESS_SCALE_FACTOR;
}
Copy link
Member

Choose a reason for hiding this comment

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

Add an else branch here that gives an error "-blockmaxsize and -blockmaxweight cannot be set simultaneously".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@morcos
Copy link
Contributor

morcos commented Aug 24, 2017

Concept ACK

@luke-jr
Copy link
Member

luke-jr commented Aug 24, 2017

Miners have in recent years maxed out 1 MB. That is completely different from 4 MB, and does not prove they will increase to 4 MB immediately in any sense.

Luke's argument rests on an unlikely and now conclusively disproven theory that miners will individually act against their own short term economic best interests to preserve the usability of the network.

It has not been disproven. Miners have been given bad advice.

setting an economically rational default wouldn't change it.

Only in the case that the default doesn't matter. In which case, the argument to change the default falls apart completely.

For example, there are many miners who have set the max size to a million bytes to override these broken defaults. And then with segwit they'll be producing undersized blocks unintentionally.

If they want 1 MB, then their configuration of 1 MB should get them 1 MB. There is no such thing as undersized blocks.

Setting a reduced default against the traffic in the network today violates the principle the software should act in the interest of the people using it and in doing so shows disrespect where none is intended,

No such principle has been established. Defaults should within reason be what is best for Bitcoin as a whole.

it violates the principle that absent significant harm to it users it should act in the public interest (by making fee estimation less reliable).

Fee estimation is an unrelated matter. If it can't handle a variety of block sizes, that's a bug in the estimation logic.

improvements in block propagation have largely eliminated size based considerations as legitimate reasons to choose to produce a smaller block.

No, they haven't. Block propagation has been "solved" by centralised relay networks (FIBRE) and SPV mining, both of which are harmful to the network and not real solutions. Additionally, the most bandwidth-contrained users run in blocksonly mode, which doesn't benefit from compact blocks or other such improvements. Furthermore, none of this addresses the issue of blockchain size and IBD, at all.

Again, NACK.

(Maybe #3229 can be reopened?)

@jameshilliard
Copy link
Contributor

ACK

Block propagation has been "solved" by centralised relay networks (FIBRE) and SPV mining, both of which are harmful to the network and not real solutions.

Even without FIBRE or SPV mining it makes individual economic sense for miners to mine max weight blocks due to relatively high transaction fees and compact blocks having a significant improvement on propagation.

Copy link
Member

@sdaftuar sdaftuar 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, left a couple comments, plus I agree with @sipa's comment about preventing use of both -blockmaxweight and -blockmaxsize.

src/miner.cpp Outdated
@@ -241,19 +230,11 @@ bool BlockAssembler::TestPackage(uint64_t packageSize, int64_t packageSigOpsCost
// - serialized size (in case -blockmaxsize is in use)
bool BlockAssembler::TestPackageTransactions(const CTxMemPool::setEntries& package)
{
uint64_t nPotentialBlockSize = nBlockSize; // only used with fNeedSizeAccounting
Copy link
Member

Choose a reason for hiding this comment

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

The comment above needs to be updated to remove reference to serialized size.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

/** Default for -blockmaxweight, which controls the range of block weights the mining code will create **/
static const unsigned int DEFAULT_BLOCK_MAX_WEIGHT = 3000000;
static const unsigned int DEFAULT_BLOCK_MAX_WEIGHT = MAX_BLOCK_WEIGHT - 4000;
Copy link
Member

Choose a reason for hiding this comment

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

Isn't the - 4000 unnecessary here? We already separately reserve space for the coinbase in CreateNewBlock.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We've always had it and I'm skeptical of just removing it...I could absolutely see people accidentally building invalid blocks if we just remove it and they dont notice (which, given how much people appear to read release notes.......)

Copy link
Contributor

Choose a reason for hiding this comment

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

DEFAULT_BLOCK_MAX_WEIGHT is used to initialise the nBlockMaxWeight field in BlockAssembler::Options, but that's then used as BlockAssembler::nBlockMaxWeight = max(4000, min(MAX_BLOCK_WEIGHT-4000, options.nBlockMaxWeight)) in the BlockAssembler constructor, so it will already be trimmed.

So I think the "- 4000" here is a no op since min(MBW-4000,MBW) = min(MBW-4000,MBW-4000) = MBW-4000...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I see your point. Still, it feels misleading to print in the help text that the default value is 4000000 if thats outside the acceptable range.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah actually what I meant was that we also start off our block counter at a weight of 4000, so limiting to MAX_BLOCK_WEIGHT-4000 (both here and in BlockAssembler::BlockAssembler()) causes us to limit block sizes more than we probably intend. But not necessary to change here.

@luke-jr
Copy link
Member

luke-jr commented Aug 24, 2017

There are real use-cases to set both blockmaxsize and blockmaxweight: one might want to mine a block that has at most a weight of 3M, but never more than 1 MB for example.

@TheBlueMatt TheBlueMatt force-pushed the 2017-08-sane-default-limits branch from 10d21dc to 21e1f07 Compare August 24, 2017 21:34
@jtimon
Copy link
Contributor

jtimon commented Aug 24, 2017

As commented on IRC blockmaxsize doesn't make sense after segwit activation. I wouldn't even bother with the deprecation step, I would go straight to removal and just document it in the release notes once.
But if we're going to maintain both simultaneously for any longer I agree the 2 constants for the defaults and forbidding using both at the same time (ie like you can't use -testnet and -regtest at once) is the less insane option.
Do we have more examples of defaults depending on selections of other options?
If so, I think we should get rid of all of them independently of this PR.

Miners have in recent years maxed out 1 MB. That is completely different from 4 MB, and does not prove they will increase to 4 MB immediately in any sense.

I will treat any arguments regarding defaults as if they were arguments for a lower value for DEFAULT_BLOCK_MAX_WEIGHT, not as arguments for the removal/deprecation of blockmaxsize in itself.
Regarding all those arguments, here's all I have to say: I trust miners to end up doing what's economically better for them, but I'm not opposed to a very low default for DEFAULT_BLOCK_MAX_WEIGHT. I think that will only prove that the default won't matter at all unless it's economically optimal or close: otherwise it'll be a few accidental bad blocks, perhaps the lower the default the faster they will read about the option.
I'm also not opposed to saving the unnecessary disruption, since as others have argued that would only change their default to something unexpected.

Concept ACK

@jnewbery
Copy link
Contributor

Concept ACK. Will review soon.

src/miner.cpp Outdated
if (!fWeightSet) {
options.nBlockMaxWeight = options.nBlockMaxSize * WITNESS_SCALE_FACTOR;
options.nBlockMaxWeight = gArgs.GetArg("-blockmaxsize", DEFAULT_BLOCK_MAX_WEIGHT / WITNESS_SCALE_FACTOR) * WITNESS_SCALE_FACTOR;
Copy link
Contributor

Choose a reason for hiding this comment

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

Add warn about deprecation?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree. A deprecation warning here would be helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd prefer to not add more garbage to init, if possible (and printing every time a BlockAssembler is created also sucks, though it will do that now if you set both :( ). I think its fine, and since we're changing the defaults to something reasonable, removing the option a release later likely won't break anything.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then add the LogPrintf()s to InitParameterInteraction() in init.cpp instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ugh, fine.

@@ -214,7 +214,6 @@ UniValue getmininginfo(const JSONRPCRequest& request)

UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("blocks", (int)chainActive.Height()));
obj.push_back(Pair("currentblocksize", (uint64_t)nLastBlockSize));
Copy link
Contributor

Choose a reason for hiding this comment

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

Breaking change, needs release note.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, this should be included in release notes.

Also, please remove currentblocksize from help text (currently L198)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done and done.

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.

utACK. A couple of nits inline.

I think the second commit is good, but needs to be very explicitly communicated to users. Defaults changing unexpectedly under users' feet is a bad experience, even if the new default is better.

Deprecation of blockmaxsize should be swiftly followed by removal in the next release.

Side note: how does this not break any tests?! Do we not have any testing for mining size/weight accounting?

@@ -214,7 +214,6 @@ UniValue getmininginfo(const JSONRPCRequest& request)

UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("blocks", (int)chainActive.Height()));
obj.push_back(Pair("currentblocksize", (uint64_t)nLastBlockSize));
Copy link
Contributor

Choose a reason for hiding this comment

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

yes, this should be included in release notes.

Also, please remove currentblocksize from help text (currently L198)

@@ -175,7 +167,6 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
int64_t nTime1 = GetTimeMicros();

nLastBlockTx = nBlockTx;
nLastBlockSize = nBlockSize;
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a call below to GetSerializeSize() for logging the block size. We should remove that potentially expensive call and update the log to not print size as part of this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

src/miner.cpp Outdated
if (!fWeightSet) {
options.nBlockMaxWeight = options.nBlockMaxSize * WITNESS_SCALE_FACTOR;
options.nBlockMaxWeight = gArgs.GetArg("-blockmaxsize", DEFAULT_BLOCK_MAX_WEIGHT / WITNESS_SCALE_FACTOR) * WITNESS_SCALE_FACTOR;
Copy link
Contributor

Choose a reason for hiding this comment

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

Agree. A deprecation warning here would be helpful.

@TheBlueMatt TheBlueMatt force-pushed the 2017-08-sane-default-limits branch 2 times, most recently from 9bf4197 to 2fada8c Compare August 25, 2017 15:31
implied blockmaxweight, instead of limiting block size directly. Any miners who wish
to limit their blocks by size, instead of by weight, will have to do so manually by
removing transactions from their block template directly. The "currentblocksize" value
in getmininginfo has been removed.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is good, but I think the removal of currentblocksize in getmininginfo should [also?] go in a Low-level RPC changes section.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@TheBlueMatt TheBlueMatt force-pushed the 2017-08-sane-default-limits branch from 2fada8c to faeafe2 Compare August 25, 2017 16:06
@jnewbery
Copy link
Contributor

utACK faeafe2. Looks great.

@sipa
Copy link
Member

sipa commented Aug 25, 2017

utACK faeafe2

@luke-jr
Copy link
Member

luke-jr commented Aug 25, 2017

Again, hard NACK for all the unrefuted reasons already given.

@sipa
Copy link
Member

sipa commented Sep 11, 2017

@TheBlueMatt mining.py fails (conflict introduced by #11150).

* This removes block-size-limiting code in favor of GBT clients
  doing the limiting themselves (if at all).
* -blockmaxsize is deprecated and only used to calculate an implied
  blockmaxweight, addressing confusion from multiple users.
* getmininginfo's currentblocksize return value was returning
  garbage values, and has been removed, also removing a
  GetSerializeSize call in some block generation inner loops and
  potentially addressing some performance edge cases.
No sensible user will ever keep the default settings here, so not
having sensible defaults only serves to screw users who are
paying less attention, which makes for terrible defaults.
@TheBlueMatt TheBlueMatt force-pushed the 2017-08-sane-default-limits branch from faeafe2 to 6f703e9 Compare September 11, 2017 19:51
@TheBlueMatt
Copy link
Contributor Author

Rebased and fixed conflict.

@sipa sipa merged commit 6f703e9 into bitcoin:master Sep 11, 2017
sipa added a commit that referenced this pull request Sep 11, 2017
…lt to throwing away money

6f703e9 Add release notes describing blockmaxweight deprecation (Matt Corallo)
3dc263c Use a sensible default for blockmaxweight (Matt Corallo)
ba206d2 Deprecate confusing blockmaxsize, fix getmininginfo output (Matt Corallo)

Pull request description:

  No sensible user will ever keep the default settings here, so not
  having sensible defaults only serves to screw users who are
  paying less attention, which makes for terrible defaults.

  Additionally, support for block-size-limiting directly has been removed:

  * This removes block-size-limiting code in favor of GBT clients
    doing the limiting themselves (if at all).
  * -blockmaxsize is deprecated and only used to calculate an implied
    blockmaxweight, addressing confusion from multiple users.
  * getmininginfo's currentblocksize return value was returning
    garbage values, and has been removed, also removing a
    GetSerializeSize call in some block generation inner loops and
    potentially addressing some performance edge cases.

Tree-SHA512: 33010540faf5d6225ad575488b804e180a8d53a41be484ca2932a0485595e28da62f0ade4b279a6bf1c947c7ce389f51fde8651b2ba25deb25e766e0813b993c
@luke-jr
Copy link
Member

luke-jr commented Sep 19, 2017

I do think it should be project policy to focus on features that matter. And an option that everyone overrides serves nobody.

That assumes everyone sets it to the absolute no-op maximum. There is no evidence of this.

This PR is contentious, should not have been merged, and should be reverted.

@sdaftuar
Copy link
Member

I think this should be tagged for backport.

@maflcko maflcko added this to the 0.15.1 milestone Oct 28, 2017
@gmaxwell
Copy link
Contributor

gmaxwell commented Nov 2, 2017

ACK for backport.

@maflcko maflcko modified the milestones: 0.15.1, 0.15.0.2 Nov 2, 2017
@maflcko
Copy link
Member

maflcko commented Nov 2, 2017

Moved to 0.15.0.2 milestone for the convenience of miners.

@morcos morcos mentioned this pull request Nov 2, 2017
maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Nov 2, 2017
* This removes block-size-limiting code in favor of GBT clients
  doing the limiting themselves (if at all).
* -blockmaxsize is deprecated and only used to calculate an implied
  blockmaxweight, addressing confusion from multiple users.
* getmininginfo's currentblocksize return value was returning
  garbage values, and has been removed, also removing a
  GetSerializeSize call in some block generation inner loops and
  potentially addressing some performance edge cases.

Github-Pull: bitcoin#11100
Rebased-From: ba206d2
maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Nov 2, 2017
No sensible user will ever keep the default settings here, so not
having sensible defaults only serves to screw users who are
paying less attention, which makes for terrible defaults.

Github-Pull: bitcoin#11100
Rebased-From: 3dc263c
maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Nov 2, 2017
@Edgaralcaraz1 Edgaralcaraz1 mentioned this pull request May 18, 2021
Closed
@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.