Skip to content
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

size calculation is wrong for large transactions #210

Closed
jackstar12 opened this issue Oct 14, 2024 · 5 comments · Fixed by #211
Closed

size calculation is wrong for large transactions #210

jackstar12 opened this issue Oct 14, 2024 · 5 comments · Fixed by #211

Comments

@jackstar12
Copy link

jackstar12 commented Oct 14, 2024

The internal size calculation seems to be off for large transactions.
https://liquid.network/tx/06be290faffd9e56b12bea7729d979d21e60351cccb4acc76a099614a607fcc1
This transaction was created with a fee rate of 102 sat/kvbyte, but resulted in an actual rate of 100 sat/kvbyte.
I manually checked that https://github.com/Blockstream/gdk/blob/master/src/ga_tx.cpp#L1171 is right, since:
(61760+3)/4 = 15440,75
So the problem should be somewhere inside https://github.com/Blockstream/gdk/blob/master/src/ga_tx.cpp#L1099

@jgriffiths
Copy link
Contributor

Hi @jackstar12

Can you confirm the following please?:

  • The version of gdk that you used
  • How the transaction was created (e.g. GA_create_transaction/GA_create_redeposit_transaction)
  • Whether or not a hardware wallet/external signer was used vs the default software wallet
  • If using a HWW, (a) whether you are indicating that low-R signatures are supported in the signer config and (b) whether you are actually producing low-R sigs in this case

On initial tx creation, the size estimation typically overestimates the tx size compared to the final size by 1-2 vbytes per expected signature per input, (depending on the signer). This is because some signatures will end up 1-2 vbytes smaller as a quirk of the DER encoding for ECDSA sigs. The expected result of this is that the actual fee rate will be slightly higher than the desired fee rate in some cases. This is reflected in the calculated_fee_rate (actual) vs fee_rate (desired) fields of the JSON returned by GA_create_transaction. Once the tx is signed these values will be updated to the actual value of the final signed tx.

If calculated_fee_rate is lower than fee_rate after calling GA_create_transaction then I can confirm that is a bug, meaning gdk has underestimated the size rather than overestimating it. If you can reproduce this behaviour it should be easy to determine the cause if you can send me the full resulting transaction JSON. I've asked one of our team to reach out to you with my contact details so you can pass that to me privately.

@jackstar12
Copy link
Author

jackstar12 commented Oct 14, 2024

  • The version of gdk that you used

0.73.2

  • How the transaction was created (e.g. GA_create_transaction/GA_create_redeposit_transaction)

GA_create_transaction

  • Whether or not a hardware wallet/external signer was used vs the default software wallet

Default software wallet, singlesig

If you can reproduce this behaviour it should be easy to determine the cause if you can send me the full resulting transaction JSON.

Havent been able to reproduce it locally yet. The issue has only occured on mainnet so far

@jgriffiths
Copy link
Contributor

Hi @jackstar12

We have reproduced this and are working on a fix now.

@jgriffiths
Copy link
Contributor

Hi @jackstar12 this issue is fixed in #211 which will be released shortly as v0.73.3.

Thanks for reporting!

@jgriffiths
Copy link
Contributor

Hi @jackstar12

As discussed offline, the fixes applied for weight calculation are not the cause of the issue you reported here (as they don't apply to p2wpkh inputs which your tx example contains)..

The underlying issue is that the min relay fee being returned from esplora is < 0.1 sat/vbyte. We are tracking this issue internally and should have a resolution soon (we are determining whether the problem lies in electrs and/or can/should be worked around on the gdk side).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants