server/asset/eth: Fix unset contractVer in TokenBackend#12
Open
peterzen wants to merge 1 commit into
Open
Conversation
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.
There was a problem hiding this comment.
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’sAssetBackend.contractVerfrom the token’s configured contract version. - Zero-initialize
gasFeeCap/gasTipCapfor fallback-constructed redeem coins to prevent nil dereference inFeeRate(). - Add/extend tests covering version match/mismatch behavior, tx-not-found fallback behavior, relay redeem behavior, and
CoinNotFoundErrorclassification.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TokenBackend()never setAssetBackend.contractVer, so it stayed at 0 for every token regardless of actual contract version.relayBaseCoinand avoid a nilbig.Intpanic inFeeRate.