Skip to content

Remove constant in Bitcoin fee calculation #1081

Closed

Description

@lubtd

We use a constant in btc_signer.go for the fee calculation:

estimateFee := 0.0001 // 10,000 sats, should be good for testnet

However, in the bitcoin ZRC20 contract we read a GAS_LIMIT value to determine the tokens to burn for the fees.

There might be a discrepancy and if the value paid in the contract is lower than the value used for the actual tx, then it becomes a net loss for the tss signer.

Activity

  1. added
    zetaclient
    security
    on Sep 1, 2023
  2. lubtd commented on Sep 8, 2023

    @lubtd
    ContributorAuthor

    After having a look, we actually only use estimateFee for selecting UTXOs and not the effective fees.

    However, in the code we use txSize*gasPrice for the fees which may result in a lower fees paid on ZetaChain if the ZRC20 GasLimit is not set high compared to the tx size.

    We also adjust the fees if too low:

    if fees.Int64() < int64(minFee*1e8) {
    	fmt.Printf("fees %d is less than minFee %f; use minFee", fees, minFee*1e8)
    	fees = big.NewInt(int64(minFee * 1e8))
    }
    

    Which can result in the same problem, a lower fee paid on ZetaChain

  3. brewmaster012 commented on Sep 8, 2023

    @brewmaster012
    Collaborator

    yeah, gas fee in bitcoin might be tricky. I can see two problems:

    1. our bitcoin outbound tx can be of variable size--zetacored does not know current UTXOs and cannot know exact size of the tx when scheduling. We could set a high size here as we have maximum 20 input UTXOs.
    2. how to deal with stuck tx due to low fee? RBF?

    cc @ws4charlie

  4. lubtd commented on Oct 16, 2023

    @lubtd
    ContributorAuthor

    Can be closed as we now use the gas limit for max tx size

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    securityzetaclient

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions