Skip to content

server/asset/eth: Fix unset contractVer in TokenBackend#12

Open
peterzen wants to merge 1 commit into
masterfrom
fix-eth-token-backend-contract-version
Open

server/asset/eth: Fix unset contractVer in TokenBackend#12
peterzen wants to merge 1 commit into
masterfrom
fix-eth-token-backend-contract-version

Conversation

@peterzen

@peterzen peterzen commented Jul 3, 2026

Copy link
Copy Markdown
Owner
  • TokenBackend() never set AssetBackend.contractVer, so it stayed at 0 for every token regardless of actual contract version.
  • That field gates the tx-not-found redeem fallback and relay (gasless) coin construction, so v1 tokens (usdc.polygon, usdc.eth, etc.) hit a spurious "wrong contract version" error whenever a redeem tx lagged the node, and gasless token redemptions failed outright.
  • Fix sets the field correctly; also zero-inits the fallback coin's gas fields to match relayBaseCoin and avoid a nil big.Int panic in FeeRate.

TokenBackend() never set AssetBackend.contractVer, leaving it at the
zero value regardless of the token's actual contract version. That
field is read directly by the tx-not-found redeem fallback and by
relay coin construction, so v1 tokens (e.g. usdc.polygon) hit a
spurious "wrong contract version" error whenever a redeem tx wasn't
yet visible to the node, and gasless (relay) token redemptions failed
outright. Also zero-initializes the fallback coin's gas fields to
match relayBaseCoin and avoid a nil big.Int panic in FeeRate.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes Ethereum token backends incorrectly leaving AssetBackend.contractVer unset (always 0), which broke v1 token redemption flows that rely on the backend’s configured contract version (tx-not-found redemption fallback and relay/gasless redemption coin construction). Adds regression tests to ensure correct contract version wiring and correct CoinNotFoundError sentinel behavior, and prevents a nil *big.Int panic when calling FeeRate() on fallback/relay-constructed coins.

Changes:

  • Set TokenBackend’s AssetBackend.contractVer from the token’s configured contract version.
  • Zero-initialize gasFeeCap/gasTipCap for fallback-constructed redeem coins to prevent nil dereference in FeeRate().
  • Add/extend tests covering version match/mismatch behavior, tx-not-found fallback behavior, relay redeem behavior, and CoinNotFoundError classification.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
server/asset/eth/eth.go Ensures token backends correctly carry the token contract version into AssetBackend.
server/asset/eth/coiner.go Prevents nil big.Int gas fields in tx-not-found fallback redeem coins (avoids FeeRate panic).
server/asset/eth/eth_test.go Adds a regression test for token backend contract version propagation; extends redemption tests for tx-not-found/version behaviors.
server/asset/eth/coiner_test.go Extends newRedeemCoin tests and adds relay redeem coverage, including CoinNotFoundError sentinel expectations.

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

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