Skip to content

feat: adjustable fee rate mode#283

Open
frolvanya wants to merge 4 commits into
mainfrom
feat/adjustable-fee-rate-mode
Open

feat: adjustable fee rate mode#283
frolvanya wants to merge 4 commits into
mainfrom
feat/adjustable-fee-rate-mode

Conversation

@frolvanya

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds an “adjustable fee rate” mode for UTXO withdrawals so callers (and the CLI) can optionally auto-lower the effective fee rate to fit an on-chain max_gas_fee constraint, instead of always failing when the estimated gas fee exceeds that cap.

Changes:

  • Introduces FeeRate (Strict vs CapToMaxGasFee) in omni-connector and wires it into BTC transfer submission paths.
  • Adds utxo_utils::max_fee_rate_for_gas_fee() (an inverse helper for BTC gas fee estimation).
  • Exposes the behavior via bridge-cli with a new --fee-rate-mode {exact,adjustable} flag.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Cargo.lock Bumps crate versions to reflect published changes.
bridge-sdk/utxo-utils/src/lib.rs Refactors BTC tx size calc + adds inverse helper for deriving a max fee rate from a gas-fee cap.
bridge-sdk/utxo-utils/Cargo.toml Bumps utxo-utils version.
bridge-sdk/connectors/omni-connector/src/omni_connector.rs Adds FeeRate strategy and implements “cap to max_gas_fee” logic for BTC submission.
bridge-sdk/connectors/omni-connector/Cargo.toml Bumps omni-connector version and changes edition to 2024.
bridge-cli/src/omni_connector_command.rs Adds CLI FeeRateMode and plumbs it into connector calls.
bridge-cli/Cargo.toml Bumps bridge-cli version.
Comments suppressed due to low confidence (1)

bridge-sdk/connectors/omni-connector/src/omni_connector.rs:3621

  • CapToMaxGasFee may not achieve its goal when max_gas_fee < 141 (the constant overhead): max_fee_rate_for_gas_fee will compute new_rate = 0, but get_gas_fee still returns 141, so the adjustable path can never satisfy max_gas_fee and near_submit_btc_transfer will still fail with InsufficientUTXOGasFee. Consider explicitly detecting this case (or, more generally, re-checking new_gas_fee <= max) and returning a clearer error early, so callers don’t expect the transaction to be broadcastable.
        if allow_cap
            && let Some(max) = max_gas_fee
            && gas_fee > u128::from(max)
            && let Some(new_rate) =
                utxo_utils::max_fee_rate_for_gas_fee(chain, num_inputs, num_outputs, max)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread bridge-sdk/connectors/omni-connector/src/omni_connector.rs
Comment thread bridge-sdk/utxo-utils/src/lib.rs Outdated
Comment thread bridge-sdk/connectors/omni-connector/Cargo.toml Outdated
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 this pull request may close these issues.

2 participants