New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CAmount: Small improvements related to CAmount #5430
Conversation
ACK on the change to As discussed on IRC, I don't agree readability being a sufficient reason to change the others as it's very subjective. |
ACK. If/when CAmount is made into its own class for type safety and sidechain extensibility reasons, implicit boolean conversion will no longer be desirable. The alternative |
The code in jtimon@710d428 doesn't compile giving the error:
So it seems boolean conversion is not compatible with our serialization templates. I can separate the two commits in different PRs if it's needed. |
Why are we changing consensus critical code for the sake of altcoins/sidechains? If there is no clear reason to change it, leave that code alone. Frankly we already have a huge number of changes coming down very quickly for v0.10 - I know I personally am finding it hard to find time for reviewing it all. Even bringing up the topic of alt-coins otherwise is loudly discouraged... Yet here you're making dangerous changes to Bitcoin Core just so you'll save money on programmers. As it is, it's not even clear why your sidechain code would even benefit, and of course, that's currently non-opensource software that benefits no-one other than a secretive commercial company. You know, I personally am working on what you guys would call a sidechains implementation, and as I want to offer new functionality over Bitcoin it doesn't share any code at all with Bitcoin. Nor do I ask to have Bitcoin Core changed for the sake of my client's commercial venture. Of course, maybe I'm biased - I do spend almost all my time on Bitcoin Core reviewing, writing unit tests, and increasing code coverage rather than breaking things... |
And before you reply complaining about this exact pull-req... Keep in mind how utterly tone-deaf this stuff is, for instance saying:
Especially as we've already handled the type safety issue elsewhere by making it a typedef, and more importantly, this is consensus critical code that nearly never needs to change at all. |
Seriously Peter? Changing
I don't want to sidetrack this discussion into a rehash of #4037, but changing from |
Like I said, I'm referring to the impact of this work in totality; not specifically this one single change. I think you missed the intent above, which was why you're arguing we need changes: ultimately for the sake of altcoins and sidechains more than Bitcoin Core's needs. Also every line changed does incur precious review effort; arguing against does too, but that can pay dividends in the future. Anyway, I don't recall seeing either of you doing much work with the consensus critical code before, especially in testing it - reimplementing it is a good learning experience as well. You'll find your enthusiasm for changing it goes down greatly once you get more experience working with it. |
Arguing against changes for the sake of arguing wastes everybody's time. Is this change harmful? No. The C++ standard states that implicit conversion of integers to boolean values is performed by comparing against zero, which is done explicitly here. It solves problems for people who are working with other changes to bitcoin's codebase. The change is innocuous and makes someone's life easier. Why bring politics into the development process? As to your ad hominum attacks, I suggest you take that elsewhere. |
Incidentally, this currently has nothing to do with sidechains. (And only commenting here because PT is oddly posting all around the internet saying it does, which makes no sense, and people are asking me... and answering once here is more efficient.) Jtimon has been doing code structure cleanups in Bitcoin core of this kind since something like March. The type changes stuff was done a while back and is justified for increased analyizability of the code (e.g. allowing for later improvements to type-safey of the sort that would have prevented the sighash_single bug). It was also easy to prove as safe. @petertodd you also ACKed the typedef conversion of the money type in #4067 yourself. The wallet.h change is obviously needed for consistency. The rest I don't have an opinion on. |
I'm pretty sure that these "dangerous changes" to "consensus critical code" (wallet.h, qt/guiutil.cpp and qt/receiverequestdialog.cpp no less) actually result in an identical build. |
On 7 December 2014 11:46:56 GMT+00:00, Gregory Maxwell notifications@github.com wrote:
Mark's ACK above which specifically mentions sidechains as a reason to make this change; as has been advocated elsewhere by him and the pull-req author. (elsewhere altcoins have been brought up as the reason to make these changes too) You'll note how I did not NACK this parch specifically; I simply want to be sure the overall plan is to continue the overall criteria for changing code in Bitcoin remains whether or not it will benefit Bitcoin users rather than niche special interests. Mark: I work with the Bitcoin Core codebase as well in the context of altcoins, as does @btcdrak, and neither of us advocate changing it for the sake of that work regardless of how convenient it would make it for our niche use. |
Absolutely. |
Bitcoin benefits from more typesafe, more modular code. |
-----BEGIN PGP SIGNED MESSAGE----- On 7 December 2014 12:00:25 GMT+00:00, "Jorge Timón" notifications@github.com wrote:
Like I said, this exact pull req I was not specifically arguing against. (which is a utACK BTW) Rather the next step being advocated above as the followup - change consensus critical code by changing CAmount - is the issue. Obviously if that hadn't been brought up I'd have said nothing at all...
Please do - I'll put up 250mBTC for that. iQFQBAEBCAA6BQJUhEsUMxxQZXRlciBUb2RkIChsb3cgc2VjdXJpdHkga2V5KSA8 |
I completely agree that the criterion for inclusion in Bitcoin Core should whether it benefits Bitcoin, and should be weighed against the risks it introduces for Bitcoin. And readable, robust, auditable, transparent, and more flexible code is a benefit too. Regarding this pull request in particular: it continues a transformation of the code to abstract the handling of monetary amounts. IMHO, low benefit, but given that it's trivial and not touching consensus code, also low risk. Regarding changing the type of monetary amounts: that's an idea that started a long time ago (see #4067, #4234, #4614, #5117, and #5308), and has had plenty of discussion. I believe the bottom line was that changing the type would make things clearer, but a separate class wouldn't outweigh the risks. Do we need to have that discussion again? (I don't want to use the "this was discussed before, we should never ever come back to it!" argument, but it does seem very late to bring this up). Regarding motivations and conflict of interest: you can't ask more than people being honest about why they want a change. |
@petertodd @maaku Clearly these kind of changes were specifically proposed to benefit altcoins and sidechains back in April 2014 and there were objections (as well as other comments in that ticket). Refactoring of Bitcoin Core should be beneficial to Bitcoin Core first and foremost. If it has additional benefits for 3rd party, that's great, but should not be the primary intention for it.
I will also pledge 250mBTC towards such a tool. |
What purpose are you commenting here for? I'm having trouble extracting it from your message. The stuff your're linking to was a prior approach. What was adopted was a recommendation by wumpus (and supported by many, incl. petertodd). The whole motivation for it here is making things cleaner and more explicitly typed. So I am unable to tell what view your message is intended to express. |
I do plan to submit more changes related to CAmount but since a class was not wanted I am precisely trying to isolate the changes that could easily be accepted (as I thought these trivial changes would be). |
@gmaxwell My concerns are general - I am concerned that OP is still advocating for changes for non-Bitcoin Core purposes (i.e. for the benefit of altcoins). Relocating code for modularity aside, I worry about the amount of consensus critical code being touched without express need to do so. I feel there is an elephant in the room, so let me address it at the risk of being wrong: I'm objecting to making changes specifically so that altcoins and sidechains maintenance is easier, as it means we must touch consensus critical code. The only reason to touch consensus code IMO is to either fix bugs or specifically change the behaviour on purpose. I am not against altcoins or sidechains, I am against doing things to bitcoin with the express purpose to benefit them. It's not like we're proposing a features that update consensus on purpose e.g. a new opcode for 2-way pegging (which obviously benefits altchains), if it benefits to Bitcoin's usecase. Such a proposal is a relatively small feature addition that that doesn't affect great swaths of consensus critical code with all the associated risks of introducing weird edge-case bugs in consensus; instead OP is repeatedly proposing to touch consensus critical code to assist altcoin maintenance which is not only unnecessary, but downright dangerous. |
We all agree on that, it has to be better for Bitcoin in general. IMO not because touching consensus should be avoided at all costs but because it what makes sense. Let's stop arguing about this, please.
This is a very different thing. "Not doing X only because of A", is very different from "Not doing X unless it is because of B".
If your opinion is that my contributions are unnecessary and downright dangerous I obviously disagree. Please, let's talk about the PR or move to another forum like the mailing list. I hope that it doesn't become a conversation about concrete people again. We should trust good and easy-to-review changes rather than people's reputation or pgp-signed commits. |
@btcdrak Please point to any changes you see to concensus code which you believe are misplaced. I'm still at a loss as to what you're going on about. This PR does none of the things you're talking about. |
Agreed. I went along with the CAmount change in the consensus code under the following conditions:
This pull is simply a continuation of that into some silly GUI and wallet code, so I don't think it should be controversial. |
Yes, my point is that we wrap up the CAmount-related changes here, and review and check them, to get that over with. It has become clear that no one is looking forward to having a new 'oh, we forgot CAmount in this place' pull every few days. |
I haven't found anything else. As said I plan to maintain a #4037-like patch but I'm not there yet. Here's what I have so far: https://github.com/jtimon/bitcoin/compare/noamount Maybe "Use FormatMoney() in CTxOut::ToString()"? Although, honestly I would just show Satoshis there instead of Bitcoins. |
Needs rebase but...closing. |
if (info.amount != 0)
is more readable thanif (info.amount)
. Also if CAmount was a class instead of a typedef, the conditional operator cannot be overloaded.The wallet should be using CAmount instead of int64_t.