Skip to content

fix: update user paid fee for cointype ZETA to use correct denomination#4542

Open
kingpinXD wants to merge 4 commits intomainfrom
fix-zeta-gas-refunds
Open

fix: update user paid fee for cointype ZETA to use correct denomination#4542
kingpinXD wants to merge 4 commits intomainfrom
fix-zeta-gas-refunds

Conversation

@kingpinXD
Copy link
Member

@kingpinXD kingpinXD commented Feb 5, 2026

Description

Closes https://github.com/zeta-chain/protocol-private/issues/381

How Has This Been Tested?

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Note

Medium Risk
Touches cross-chain fee accounting used for stability-pool funding and user refunds; a denomination mismatch could change refund amounts, though the change is small and now enforced by E2E assertions.

Overview
Updates ZETA gas-payment accounting so OutboundParams.UserGasFeePaid is stored in the outbound gas token denomination (matching GasLimit * GasPrice) rather than the swapped ZETA amount, aligning it with stability-pool/refund math.

Adds E2E coverage for withdrawals (legacy ZETA, ZETA, ETH, ERC20) that fetch chain params (stability pool percentage) and assert outbound gas accounting via a new utils.VerifyOutboundGasAccounting helper, logging the computed stability-pool and user-refund amounts.

Written by Cursor Bugbot for commit d4f2701. Configure here.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed ZETA denomination handling for user-paid fees
    • Corrected gas fee accounting to record actual gas-token amounts instead of Zeta equivalents
  • Tests

    • Enhanced end-to-end withdrawal tests with gas accounting verification and refund amount logging

@kingpinXD kingpinXD requested a review from a team as a code owner February 5, 2026 14:16
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 5, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review
📝 Walkthrough

Walkthrough

This pull request updates denomination handling for ZETA coin type in user-paid gas fees, modifying how fees are recorded in cross-chain transactions. It introduces gas accounting verification utilities and enhances E2E tests to validate outbound gas refund calculations using chain stability pool parameters.

Changes

Cohort / File(s) Summary
Documentation
changelog.md
Added changelog entry documenting the denomination handling fix for ZETA coin type in user-paid fees.
Cross-Chain Gas Handling
x/crosschain/keeper/gas_payment.go
Modified PayGasInZetaAndUpdateCctx to record user gas fees in actual gas-token denomination rather than Zeta-equivalent amount in UserGasFeePaid field.
E2E Testing Utilities
e2e/utils/zetacore.go
Introduced GasRefundAmounts struct and VerifyOutboundGasAccounting function to compute and validate outbound gas refund components using stability pool percentages and gas accounting calculations.
E2E Withdrawal Tests
e2e/e2etests/legacy/test_zeta_withdraw.go, e2e/e2etests/test_erc20_withdraw.go, e2e/e2etests/test_eth_withdraw.go, e2e/e2etests/test_zeta_withdraw.go
Enhanced all withdrawal test flows to retrieve EVM chain IDs, fetch chain parameters via ObserverClient, and verify outbound gas accounting against StabilityPoolPercentage with logging of refund amounts.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and concisely describes the primary change: updating user-paid fee denomination handling for ZETA coin type, which aligns with the core objective of the changeset.
Description check ✅ Passed The description covers the core objective and includes a testing checklist, though some sections are incomplete (development environment, unit tests, and GitHub Actions remain unchecked).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-zeta-gas-refunds

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@changelog.md`:
- Line 13: The changelog entry has a mismatched PR reference: the label "[4342]"
does not match the linked URL "https://github.com/zeta-chain/node/pull/4542";
update the markdown so the numeric label matches the URL (change "[4342]" to
"[4542]" in the entry that reads "update user paid fee for cointype ZETA to use
correct denomination") or if the label is correct, change the URL to the PR with
ID 4342 so both parts match.
🧹 Nitpick comments (1)
e2e/utils/zetacore.go (1)

504-569: Add a sanity check for stabilityPoolPercentage before refund split.

If chain params ever return a value >100, userRefundAmount can underflow (math.Uint panic). A clear assertion makes failures easier to diagnose.

Proposed fix
  totalRemainingFees := userGasFeePaid.Sub(outboundTxFeePaid)
  usableRemainingFees := crosschainkeeper.PercentOf(totalRemainingFees, crosschaintypes.UsableRemainingFeesPercentage)
 
+ require.LessOrEqual(t, stabilityPoolPercentage, uint64(100), "StabilityPoolPercentage must be <= 100")
  stabilityPoolAmount := crosschainkeeper.PercentOf(usableRemainingFees, stabilityPoolPercentage)
  userRefundAmount := usableRemainingFees.Sub(stabilityPoolAmount)

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.

3 participants