Skip to content

Conversation

@morcos
Copy link
Contributor

@morcos morcos commented Apr 26, 2017

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.

Copy link
Contributor

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?

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 think this is possible, but it wasn't clear to me we wanted it here.
Perhaps that could be added later

Copy link
Contributor

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; }

Copy link
Member

@sipa sipa Apr 27, 2017

Choose a reason for hiding this comment

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

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay. Fair point.

@morcos
Copy link
Contributor Author

morcos commented May 18, 2017

rebased

};

/* Enumeration of reason for returned fee estimate */
enum FeeReason {
Copy link
Member

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?

}
}

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",
Copy link
Member

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.

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

utACK d0fb0f6, though needs rebase (conflicted with #10390).

}
}

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",
Copy link
Contributor

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)

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));
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be returnedTarget?

Copy link
Contributor Author

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

/* Enumeration of reason for returned fee estimate */
enum FeeReason {
NONE = 0,
HALF_ESTIMATE = 1,
Copy link
Contributor

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.

MAXTXFEE = 9
};

static std::map<FeeReason, std::string> FeeReasonString = {
Copy link
Contributor

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.

}
}

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",
Copy link
Contributor

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)?

Copy link
Contributor Author

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

@morcos
Copy link
Contributor Author

morcos commented Jun 8, 2017

Addressed comments and squashed/rebased
debugEstimates.ver2 --> debugEstimates.ver2.squash --> debugEstimates.ver2.rebased

Copy link
Contributor

@ryanofsky ryanofsky left a 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.

MAXTXFEE,
};

const std::string StringForFeeReason(FeeReason reason);
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 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).

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

Copy link
Contributor

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)

@morcos
Copy link
Contributor Author

morcos commented Jun 13, 2017

addressed nit

Copy link
Contributor

@ryanofsky ryanofsky left a 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.

MAXTXFEE,
};

const std::string StringForFeeReason(FeeReason reason);
Copy link
Contributor

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)

@morcos
Copy link
Contributor Author

morcos commented Jun 13, 2017

oops, actually addressed nit this time.

Copy link
Contributor

@ryanofsky ryanofsky left a 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

@laanwj
Copy link
Member

laanwj commented Jun 15, 2017

utACK 1bebfc8

@laanwj laanwj merged commit 1bebfc8 into bitcoin:master Jun 15, 2017
laanwj added a commit that referenced this pull request Jun 15, 2017
…ateTransaction

1bebfc8 Output Fee Estimation Calculations in CreateTransaction (Alex Morcos)

Tree-SHA512: e25a27f7acbbc3a666d5d85da2554c5aaec4c923ee2fdbcfc532c29c6fbdec3c9e0d6ae6044543ecc339e7bd81df09c8d228e0b53a2c5c2dae0f1098c9453272
paveljanik added a commit to paveljanik/bitcoin that referenced this pull request Jun 15, 2017
sipa added a commit that referenced this pull request Jun 16, 2017
…0284

cc0ed26 Supress struct/class mismatch warnings introduced in #10284. (Pavel Janík)

Tree-SHA512: 16a6870401b5227c276931841f188479ed5960cf38d8e685f222f58550744c9fcf96a2ea3f2be9a0b1a8d0856a802fc4ec38df7bf90cd5de1f3fe20c4ca15b9d
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Aug 12, 2019
… in CreateTransaction

1bebfc8 Output Fee Estimation Calculations in CreateTransaction (Alex Morcos)

Tree-SHA512: e25a27f7acbbc3a666d5d85da2554c5aaec4c923ee2fdbcfc532c29c6fbdec3c9e0d6ae6044543ecc339e7bd81df09c8d228e0b53a2c5c2dae0f1098c9453272
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Aug 12, 2019
…d in bitcoin#10284

cc0ed26 Supress struct/class mismatch warnings introduced in bitcoin#10284. (Pavel Janík)

Tree-SHA512: 16a6870401b5227c276931841f188479ed5960cf38d8e685f222f58550744c9fcf96a2ea3f2be9a0b1a8d0856a802fc4ec38df7bf90cd5de1f3fe20c4ca15b9d
@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