Skip to content

Conversation

@gmaxwell
Copy link
Contributor

@gmaxwell gmaxwell commented Jan 4, 2017

Performing signing in the inner loop has terrible performance
when many passes through are needed to complete the selection.

Signing before the algorithm is complete also gets in the way
of correctly setting the fee (e.g. preventing over-payment when
the fee required goes down on the final selection.)

Use of the dummy might overpay on the signatures by a couple bytes
in uncommon cases where the signatures' DER encoding is smaller
than the dummy: Who cares? (Probability ~= 1/256^(bytes/2.))

@fanquake fanquake added the Wallet label Jan 4, 2017
@gmaxwell gmaxwell changed the title [Wallet] Do not perform ECDSA in the fee calculation inner loop. [Wallet] Do not perform ECDSA signing in the fee calculation inner loop. Jan 4, 2017
@laanwj
Copy link
Member

laanwj commented Jan 4, 2017

Concept ACK - I thought this was already the case!

@jonasschnelli
Copy link
Contributor

Concept ACK.

@morcos
Copy link
Contributor

morcos commented Jan 4, 2017

Concept ACK, will review. I was wondering about this myself. This will also make #9404 even a smaller change as we won't need to track variance.

@sipa
Copy link
Member

sipa commented Jan 4, 2017

Concept ACK. I knew it wasn't the case, but it seems to obvious...

@morcos
Copy link
Contributor

morcos commented Jan 4, 2017

utACK aaa3cfc

Copy link
Member

Choose a reason for hiding this comment

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

A nice by-product of this change is that the signing is factored out. Which means that at some point this huge function could be split into multiple clearly defined functions.

Copy link
Member

Choose a reason for hiding this comment

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

Agree!

@laanwj
Copy link
Member

laanwj commented Jan 5, 2017

utACK aaa3cfc

@morcos
Copy link
Contributor

morcos commented Jan 5, 2017

@gmaxwell oh hmm... You are now signing outside of cs_main, cs_wallet.
I suppose that is ok?

@sipa
Copy link
Member

sipa commented Jan 5, 2017 via email

Copy link
Member

@sipa sipa left a comment

Choose a reason for hiding this comment

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

utACK aaa3cfc485bc570a3e537349130a3471a8a4d3a8

Copy link
Member

Choose a reason for hiding this comment

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

This is a bit confusing to me. We're not elimining the dummy signatures in order to do fee calculation, but removing the dummy signatures which were added in order to do fee calculation.

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 reordered the sentence to make it more clear that I mean the "for fee estimation dummies". Should be fixed.

Copy link
Member

Choose a reason for hiding this comment

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

Feel like switching this to for (const auto& coin : setCoins) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There were only a couple extra changes to do all of them and avoid making the function inconsistent in its usage, so I did. Fixed.

Copy link
Member

Choose a reason for hiding this comment

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

Agree!

Performing signing in the inner loop has terrible performance
 when many passes through are needed to complete the selection.

Signing before the algorithm is complete also gets in the way
 of correctly setting the fee (e.g. preventing over-payment when
 the fee required goes down on the final selection.)

Use of the dummy might overpay on the signatures by a couple bytes
 in uncommon cases where the signatures' DER encoding is smaller
 than the dummy: Who cares?
@gmaxwell
Copy link
Contributor Author

gmaxwell commented Jan 5, 2017

@morcos

oh hmm... You are now signing outside of cs_main, cs_wallet. I suppose that is ok?

It's not outside of the lock unless I'm missing something!

@morcos
Copy link
Contributor

morcos commented Jan 5, 2017

@gmaxwell oops, yeah i was misreading braces..

well maybe you should move it out?
:)

Copy link
Member

@sdaftuar sdaftuar left a comment

Choose a reason for hiding this comment

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

utACK b3d7b1c

@sipa
Copy link
Member

sipa commented Jan 5, 2017

utACK b3d7b1c

@sipa sipa merged commit b3d7b1c into bitcoin:master Jan 5, 2017
sipa added a commit that referenced this pull request Jan 5, 2017
…tion inner loop.

b3d7b1c Wallet: Do not perform ECDSA in the fee calculation inner loop. (Gregory Maxwell)
codablock pushed a commit to codablock/dash that referenced this pull request Jan 18, 2018
…calculation inner loop.

b3d7b1c Wallet: Do not perform ECDSA in the fee calculation inner loop. (Gregory Maxwell)
andvgal pushed a commit to energicryptocurrency/gen2-energi that referenced this pull request Jan 6, 2019
…calculation inner loop.

b3d7b1c Wallet: Do not perform ECDSA in the fee calculation inner loop. (Gregory Maxwell)
CryptoCentric pushed a commit to absolute-community/absolute that referenced this pull request Feb 26, 2019
…calculation inner loop.

b3d7b1c Wallet: Do not perform ECDSA in the fee calculation inner loop. (Gregory Maxwell)
CryptoCentric pushed a commit to absolute-community/absolute that referenced this pull request Feb 26, 2019
…calculation inner loop.

b3d7b1c Wallet: Do not perform ECDSA in the fee calculation inner loop. (Gregory Maxwell)
Fuzzbawls added a commit to PIVX-Project/PIVX that referenced this pull request Dec 19, 2020
…fee calculation loop

e5aab53 Refactor: initialize dummy Spend/Output descriptions only once (random-zebra)
6099737 Sapling: Skip proofs and signatures during fee calculation loop (random-zebra)
5d8ba3d Sapling: add option to skip ProveAndSing in TransactionBuilder::Build (random-zebra)
efd7139 Sapling: Decouple ProveAndSign from Build (random-zebra)
44620de [Wallet] Do not perform ECDSA signing in the fee calculation inner loop (random-zebra)

Pull request description:

  First commit backports bitcoin#9465.
  Following commits adapt the same idea to sapling transactions, including also the spend/output descriptors.

  This gives a **huge** speed-up in the transaction-creation process (especially with many inuputs and/or outputs).

  Down-side: less time for the awesome shield animation in the GUI :)

  ~~Built on top of #2064 to remove the conflicts.~~

ACKs for top commit:
  furszy:
    Nice one!, ACK e5aab53
  Fuzzbawls:
    ACK e5aab53

Tree-SHA512: 22fb95e8f5d635e7031e911edcfed66b6f15168ca8027ad3080ce01f8e93b1032a86988d9463425eb4f2755f286b299328910538d23fe15bbee8cfbc3763b8fe
@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.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants