-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Always log debug information for fee calculation in CreateTransaction #10284
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
Conversation
src/wallet/feebumper.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would logging the fee estimation details during bumpfee (all call to GetMinimumFee) be possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
supernit: use brackets if (feeCalc) { feeCalc->reason = FeeReason::FALLBACK; }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. Fair point.
|
rebased |
src/policy/fees.h
Outdated
| }; | ||
|
|
||
| /* Enumeration of reason for returned fee estimate */ | ||
| enum FeeReason { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! That should give a lot of info for troubleshooting this.
ryanofsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be returnedTarget?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be LogPrint(BCLog::ESTIMATEFEE... (ie only log if estimatefee logs are enabled)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's meant to get logged even if you have not selected any debug log categories
|
Addressed comments and squashed/rebased |
ryanofsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 436207e. Looks good. Changes since previous review were rebase, cleaned up feereason enum/strings, fixed ui target string.
src/policy/fees.h
Outdated
| MAXTXFEE, | ||
| }; | ||
|
|
||
| const std::string StringForFeeReason(FeeReason reason); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Const is actually still here (you removed it from the definition but not declaration)
|
oops, actually addressed nit this time. |
ryanofsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 1bebfc8, const is gone
|
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.