Always log debug information for fee calculation in CreateTransaction#10284
Always log debug information for fee calculation in CreateTransaction#10284laanwj merged 1 commit intobitcoin:masterfrom
Conversation
src/wallet/feebumper.cpp
Outdated
There was a problem hiding this comment.
Would logging the fee estimation details during bumpfee (all call to GetMinimumFee) be possible?
There was a problem hiding this comment.
I think this is possible, but it wasn't clear to me we wanted it here.
Perhaps that could be added later
src/wallet/wallet.cpp
Outdated
There was a problem hiding this comment.
supernit: use brackets if (feeCalc) { feeCalc->reason = FeeReason::FALLBACK; }
There was a problem hiding this comment.
No. From https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md:
If an if only has a single-statement then-clause, it can appear on the same line as the if, without braces. In every other case, braces are required, and the then and else clauses must appear correctly indented on a new line.
|
rebased |
src/policy/fees.h
Outdated
| }; | ||
|
|
||
| /* Enumeration of reason for returned fee estimate */ | ||
| enum FeeReason { |
There was a problem hiding this comment.
shouldn't this be "enum class" to avoid the enum values from leaking into global scope?
src/wallet/wallet.cpp
Outdated
| } | ||
| } | ||
|
|
||
| LogPrintf("Fee Calculation: Fee:%s Bytes:%u Tgt:%d (requested %d) Reason:\"%s\" Decay %.5f: Estimation: (%g - %g) %.2f%% %.1f/(%.1f %d mem %.1f out) Fail: (%g - %g) %.2f%% %.1f/(%.1f %d mem %.1f out)\n", |
There was a problem hiding this comment.
Nice! That should give a lot of info for troubleshooting this.
src/wallet/wallet.cpp
Outdated
| } | ||
| } | ||
|
|
||
| LogPrintf("Fee Calculation: Fee:%s Bytes:%u Tgt:%d (requested %d) Reason:\"%s\" Decay %.5f: Estimation: (%g - %g) %.2f%% %.1f/(%.1f %d mem %.1f out) Fail: (%g - %g) %.2f%% %.1f/(%.1f %d mem %.1f out)\n", |
There was a problem hiding this comment.
Should Fee:%s be Fee:%d? (maybe it doesn't matter)
src/qt/sendcoinsdialog.cpp
Outdated
| std::max(feeRate.GetFeePerK(), CWallet::GetRequiredFee(1000))) + "/kB"); | ||
| ui->labelSmartFee2->hide(); | ||
| ui->labelFeeEstimation->setText(tr("Estimated to begin confirmation within %n block(s).", "", estimateFoundAtBlocks)); | ||
| ui->labelFeeEstimation->setText(tr("Estimated to begin confirmation within %n block(s).", "", feeCalc.desiredTarget)); |
There was a problem hiding this comment.
Should this be returnedTarget?
There was a problem hiding this comment.
damn, i made that same bug elsewhere. thx
src/policy/fees.h
Outdated
| /* Enumeration of reason for returned fee estimate */ | ||
| enum FeeReason { | ||
| NONE = 0, | ||
| HALF_ESTIMATE = 1, |
There was a problem hiding this comment.
Could drop all these = 1, = 2.
src/policy/fees.h
Outdated
| MAXTXFEE = 9 | ||
| }; | ||
|
|
||
| static std::map<FeeReason, std::string> FeeReasonString = { |
There was a problem hiding this comment.
Should make this const. Also maybe prefer to declare this as a const char*[] array, or as a function mapping enum values to strings, or as a function returning a static map. Global objects like this have constructors that need to run before main() and will cumulatively slow down program startup. Also because this is a static global in a header file, the constructor will run once for every .cpp file that includes this.
src/wallet/wallet.cpp
Outdated
| } | ||
| } | ||
|
|
||
| LogPrintf("Fee Calculation: Fee:%s Bytes:%u Tgt:%d (requested %d) Reason:\"%s\" Decay %.5f: Estimation: (%g - %g) %.2f%% %.1f/(%.1f %d mem %.1f out) Fail: (%g - %g) %.2f%% %.1f/(%.1f %d mem %.1f out)\n", |
There was a problem hiding this comment.
Should this be LogPrint(BCLog::ESTIMATEFEE... (ie only log if estimatefee logs are enabled)?
There was a problem hiding this comment.
It's meant to get logged even if you have not selected any debug log categories
|
Addressed comments and squashed/rebased |
src/policy/fees.h
Outdated
| MAXTXFEE, | ||
| }; | ||
|
|
||
| const std::string StringForFeeReason(FeeReason reason); |
There was a problem hiding this comment.
I don't think there's any benefit to making this const (cases where you do want this are pretty rare https://stackoverflow.com/questions/8716330/purpose-of-returning-by-const-value).
There was a problem hiding this comment.
Const is actually still here (you removed it from the definition but not declaration)
|
addressed nit |
ryanofsky
left a comment
There was a problem hiding this comment.
utACK 7c287a7b5df6f33f3b7723496590e72cdd7fed2e. Only change is removed const.
src/policy/fees.h
Outdated
| MAXTXFEE, | ||
| }; | ||
|
|
||
| const std::string StringForFeeReason(FeeReason reason); |
There was a problem hiding this comment.
Const is actually still here (you removed it from the definition but not declaration)
|
oops, actually addressed nit this time. |
|
utACK 1bebfc8 |
…ateTransaction 1bebfc8 Output Fee Estimation Calculations in CreateTransaction (Alex Morcos) Tree-SHA512: e25a27f7acbbc3a666d5d85da2554c5aaec4c923ee2fdbcfc532c29c6fbdec3c9e0d6ae6044543ecc339e7bd81df09c8d228e0b53a2c5c2dae0f1098c9453272
… in CreateTransaction 1bebfc8 Output Fee Estimation Calculations in CreateTransaction (Alex Morcos) Tree-SHA512: e25a27f7acbbc3a666d5d85da2554c5aaec4c923ee2fdbcfc532c29c6fbdec3c9e0d6ae6044543ecc339e7bd81df09c8d228e0b53a2c5c2dae0f1098c9453272
…d in bitcoin#10284 cc0ed26 Supress struct/class mismatch warnings introduced in bitcoin#10284. (Pavel Janík) Tree-SHA512: 16a6870401b5227c276931841f188479ed5960cf38d8e685f222f58550744c9fcf96a2ea3f2be9a0b1a8d0856a802fc4ec38df7bf90cd5de1f3fe20c4ca15b9d
This is a first pass at always logging a single line of information whenever CreateTransaction is invoked which will help debug any problems in fee calculation or estimation.
Built on top of #10199 and #10283, only the last commit is new.