Skip to content

Conversation

@jtimon
Copy link
Contributor

@jtimon jtimon commented Jan 25, 2015

main::GetMinRelayFee() is only called from main::AcceptToMemoryPool().
By in-lining in we can make some code simplifications and test that no new money is being created before calling main::AreInputsStandard(), instead of doing it in https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L1032 after all those free transaction special cases.
Even removing the nFees < 0 check would be safe since it is repeated in https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L1073 via https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L1471
But moving it up seems more DoS-safe.
I've done the refactor step by step to to help with review.

@jtimon
Copy link
Contributor Author

jtimon commented Feb 3, 2015

Needed rebase

@jtimon jtimon changed the title Change: Refactor: inline main:GetMinRelayFee() in main:AcceptToMemoryPool() Policy: Change: Refactor: inline main:GetMinRelayFee() in main:AcceptToMemoryPool() Mar 25, 2015
@jtimon
Copy link
Contributor Author

jtimon commented Jun 25, 2015

@luke-jr you once said you would like GetMinRelayFee to become part of policy, I would prefer to destroy it (and then pick it up as part of a new CPolicy method) instead.
Do you like this?
By the way, in case it wasn't clear, this is supposed to be a 1 commit PR, as said it is just separated for easier review.

@jtimon
Copy link
Contributor Author

jtimon commented Jun 26, 2015

I bet it will take very long until I have to rebase this because the refactored code is way too ugly for anyone to want to touch it. Hopefully by the time this gets any attention, +47 −67 while 0-functional-changes will be enough of an argument in favor of this single-commit refactor (I know, I have to s/SQUASHME:/fixup! but as said that may never happen because this may never need rebase). I would love to hear @morcos 's opinion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably "insufficient fee" should be replaced with "bad-txns-fee-negative" to better keep track of the validation duplication.

@jtimon jtimon changed the title Policy: Change: Refactor: inline main:GetMinRelayFee() in main:AcceptToMemoryPool() Policy: Refactor: inline main:GetMinRelayFee() in main:AcceptToMemoryPool() Jun 26, 2015
@morcos
Copy link
Contributor

morcos commented Jun 26, 2015

I took a first pass at reviewing this. I think if you're going to do a refactor here, you should improve the readability of the code. Although I like this code better than the original in some ways, it feels like you over optimized it instead of clarifying it.

In any case, I don't feel strongly, if you get some concept ACK's, I'm happy to test it for you.

I don't think your second commit is right though, why do you think minRelayTxFee is in MoneyRange already?

@jtimon
Copy link
Contributor Author

jtimon commented Jun 27, 2015

Well, I was hoping that by doing the stuff change by change it could become obvious for reviewers that this doesn't change anything functionally, but thanks for the testing offer (probably better to do it after some more review like you say).

I don't think your second commit is right though, why do you think minRelayTxFee is in MoneyRange already?

You are right, I thought, ParseMoney had a moneyRange check. I should add one there or in https://github.com/bitcoin/bitcoin/blob/master/src/init.cpp#L817

The other place where minRelayTxFee is initialized is in https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L67

I will fix that commit.

Re optimizing: that's just a nice side effect. The main goal is to reduce the amount of code before moving it to policy.

@jtimon
Copy link
Contributor Author

jtimon commented Jun 29, 2015

Updated fixing the second commit. Also reword "SQUASHME:" with "fixup!" in the commit descriptions.

@jtimon
Copy link
Contributor Author

jtimon commented Jul 6, 2015

Rebased

@jtimon jtimon closed this Jul 16, 2015
@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.

3 participants