-
Notifications
You must be signed in to change notification settings - Fork 111
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
feat: (BitcoinRBF-Step1) zetacore
feeds latest gas price to pending Bitcoin CCTXs
#3377
base: develop
Are you sure you want to change the base?
Conversation
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
zetacore
feeds latest gas price to pending Bitcoin CCTXszetacore
feeds latest gas price to pending Bitcoin CCTXs
zetacore
feeds latest gas price to pending Bitcoin CCTXszetacore
feeds latest gas price to pending Bitcoin CCTXs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (5)
x/observer/types/crosschain_flags.go (1)
8-10
: LGTM! Consider adding documentation about the rationale.The switch from block-based to time-based intervals is well-aligned with Bitcoin's characteristics. The 10-minute retry interval matches Bitcoin's average block time.
Consider adding a comment explaining why 10 minutes was chosen as the retry interval, relating it to Bitcoin's average block time.
testutil/sample/crypto.go (1)
106-111
: LGTM! Well-structured script generation function.The new function properly generates P2WPKH scripts with appropriate error handling.
Consider adding a comment explaining that this is specifically for testing purposes and shouldn't be used in production code.
x/crosschain/keeper/abci.go (2)
204-217
: Add documentation for Bitcoin fee rate implementation.The repurposing of
GasPriorityFee
for Bitcoin fee rate should be documented more clearly. Consider adding a comment explaining that in Bitcoin's context, this field stores the fee rate in sat/vB.// CheckAndUpdateCCTXGasPriceBTC updates the fee rate for the given Bitcoin chain CCTX +// Note: Bitcoin does not have a priority fee concept. The GasPriorityFee field is +// repurposed to store the current fee rate in satoshis per virtual byte (sat/vB). func CheckAndUpdateCCTXGasPriceBTC(
219-231
: Consider using constants for supported chains.The chain support logic is clear, but consider defining constants for supported chain types to make maintenance easier and prevent magic numbers.
+// Supported chain types for gas price updates +const ( + ChainTypeEVM = "evm" + ChainTypeBitcoin = "bitcoin" + ChainTypeZeta = "zeta" +) func IsCCTXGasPriceUpdateSupported(chainID int64, additionalChains []zetachains.Chain) bool { switch { case zetachains.IsZetaChain(chainID, additionalChains): return false case zetachains.IsEVMChain(chainID, additionalChains): return true case zetachains.IsBitcoinChain(chainID, additionalChains): return true default: return false } }x/crosschain/keeper/abci_test.go (1)
609-672
: Add edge cases to Bitcoin gas price tests.While the basic functionality is well tested, consider adding edge cases such as:
- Zero fee rate handling
- Maximum fee rate handling
- Invalid fee rate handling
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
changelog.md
(1 hunks)testutil/sample/crypto.go
(2 hunks)x/crosschain/keeper/abci.go
(5 hunks)x/crosschain/keeper/abci_test.go
(11 hunks)x/crosschain/module.go
(1 hunks)x/crosschain/types/cctx_test.go
(1 hunks)x/crosschain/types/revert_options_test.go
(1 hunks)x/observer/types/crosschain_flags.go
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
x/observer/types/crosschain_flags.go (1)
Pattern **/*.go
: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
x/crosschain/module.go (1)
Pattern **/*.go
: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
x/crosschain/types/revert_options_test.go (1)
Pattern **/*.go
: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
x/crosschain/types/cctx_test.go (1)
Pattern **/*.go
: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
testutil/sample/crypto.go (1)
Pattern **/*.go
: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
x/crosschain/keeper/abci_test.go (1)
Pattern **/*.go
: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
x/crosschain/keeper/abci.go (1)
Pattern **/*.go
: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
🔇 Additional comments (8)
x/crosschain/types/revert_options_test.go (1)
52-52
: LGTM! Clean adaptation to the new BtcAddressP2WPKH return type.The test correctly handles the new return type by explicitly converting the address to string format.
x/crosschain/module.go (1)
175-175
: LGTM! Consistent naming convention applied.The method name change follows Go's convention of treating acronyms as single words in camelCase (CCTX → CCTx).
testutil/sample/crypto.go (1)
95-104
: LGTM! Enhanced type safety with structured address type.The return type change from string to
*btcutil.AddressWitnessPubKeyHash
improves type safety and provides direct access to address functionality.x/crosschain/keeper/abci.go (2)
22-24
: LGTM! Function type renamed following Go conventions.The renaming of
CheckAndUpdateCctxGasPriceFunc
toCheckAndUpdateCCTXGasPriceFunc
follows Go's standard naming convention for acronyms.
Line range hint
30-102
: LGTM! Robust implementation of gas price update logic.The implementation correctly:
- Fetches and validates gas price increase flags
- Iterates through supported chains
- Handles errors appropriately
- Emits typed events for gas price increases
x/crosschain/types/cctx_test.go (1)
143-143
: LGTM! Improved Bitcoin address handling in tests.The change correctly uses the string representation of the Bitcoin address, ensuring proper address format handling in tests.
x/crosschain/keeper/abci_test.go (1)
674-729
: LGTM! Comprehensive chain support test coverage.The test cases thoroughly cover all supported and unsupported chains, ensuring proper gas price update behavior.
changelog.md (1)
5-8
: LGTM! Clear and concise feature documentation.The changelog entry clearly describes the new Bitcoin gas price update feature.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3377 +/- ##
===========================================
+ Coverage 63.22% 63.25% +0.02%
===========================================
Files 436 436
Lines 30636 30664 +28
===========================================
+ Hits 19369 19395 +26
- Misses 10432 10434 +2
Partials 835 835
|
Description
The problem:
If a tx gets broadcasted to Bitcoin network using latest fee rate, it is less likely to get stuck. In most cases, an outbound tx got stuck when
zetaclient
had used anoutdated lower fee rate
in CCTX to send it out to Bitcoin network.Bitcoin block time is
10 mins
and much longer than other chains. When a Bitcoin tx gets stuck, it can sit in the mempool for hours or days depending on traffic. Reducing the chance of having txs stuck in mempool will address the problem at its root cause. RBF will come as the last remedy.One of the long-term directions that guide us would be lowering the cross-chain gas fee. The gas price in the CCTX indicates how much gas was paid initially on the withdrawal. An outdated gas price should not guild TSS signers to file an outbound tx which will lead to either an
overpaid
orlong pending
outbound tx.We already had the
BTCOutboundGasPriceMultiplier = 2.0
to try avoid stuck outbound in mempool but we still have stuck txs since mainnet launch. This also explains why an outdated gas price misleads TSS signers. This multiplier needs to reduce to some level, like1.2
to balance the quick finality and unnecessary high withdrawal fees.The thoughts:
zetacore
feed latest fee rate (every 10 mins) to pending Bitcoin CCTXs in the methodCheckAndUpdateCCTXGasPriceBTC
.10
pending cctxsCCTX1, CCTX2, CCTX3, CCTX4,... CCTX10
in zetacore, and zetaclient have broadcasted4
outbounds[TX1, TX2, TX3, TX4]
and they all get stuck in mempool, so keysign stopped already.zetacore
has no idea of what had happened for these10 pending CCTXs
. Maybe outbound is pending in mempool (it is just a guess), Maybe TSS signers are not working smoothly, or maybe the RPC is down, nobody knows.4
txs in mempool, onlyTX4
needs to be bumped, so that the average fee rate of the4
txs will increase, making them a marketable package for miners.Tx4
,zetaclient
needs to know the latest fee rate, so it can bump the gas fee that accurately aligns with market.How Has This Been Tested?
Summary by CodeRabbit
Release Notes
New Features
Improvements
Technical Updates