fix: report zero native balance and gas#304
Conversation
There was a problem hiding this comment.
Code Review
This pull request simplifies the Ethereum JSON-RPC facade by hardcoding gas-related values to zero and removing corresponding configuration parameters (native_balance_wei, gas_price_wei, and gas_limit). Specifically, GasPrice, MaxPriorityFeePerGas, EffectiveGasPrice, and BaseFeePerGas now always return 0, while native token GetBalance also always reports 0. This change ensures MetaMask compatibility for zero-value ERC-20 transfers without requiring a fake native balance. Tests and configuration files have been updated accordingly. No review comments were provided, so there is no additional feedback to address.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #304 +/- ##
=======================================
Coverage ? 30.49%
=======================================
Files ? 150
Lines ? 11260
Branches ? 0
=======================================
Hits ? 3434
Misses ? 7554
Partials ? 272
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
The EVM facade reported a fake 1000-coin native balance and a 1 gwei gas price so MetaMask's `balance >= value + gasLimit*gasPrice` pre-flight check would pass. The fake balance is confusing — users with no native coin see 1000. There is no native gas token, so report 0. Since the facade only accepts zero-value ERC-20 transfers, MetaMask's check collapses to `0 >= 0` as long as gas is also 0, so transfers still go through. Gas price and the cosmetic gas limit are fixed values, not deployment knobs, so hardcode them in code and drop them from config: - native balance: always 0 (token.Native.GetBalance) - gas price: always 0 (eth_gasPrice, maxPriorityFeePerGas, baseFeePerGas, effectiveGasPrice) - gas limit: service.DefaultGasLimit (21000), cosmetic only The relayer's ethereum.gas_limit (real on-chain gas) is unaffected.
a9c528d to
8d2d440
Compare
PR #304 (in v0.5.2) removed NativeBalanceWei from both token.Config and ethrpc.Config. The heredoc still emitted token.native_balance_wei, which strict YAML unmarshal rejects: yaml: unmarshal errors: line 36: field native_balance_wei not found in type token.Config Just drop the line — the new schema doesn't need it.
Problem
The EVM JSON-RPC facade reported a fake 1000-coin native balance and a 1 gwei gas price purely to satisfy MetaMask's client-side pre-flight check (
balance >= value + gasLimit*gasPrice). The fake balance is confusing — a user with no native coin sees 1000 in MetaMask.Fix
There is no native gas token, so report 0. Because the facade only accepts zero-value ERC-20 transfers, MetaMask's check collapses to
0 >= 0— so transfers still go through as long as gas is also 0. This requires zeroing every fee surface MetaMask reads (gas price, maxPriorityFeePerGas, block baseFeePerGas, receipt effectiveGasPrice), not justeth_gasPrice.Since the gas price and the cosmetic gas limit are fixed values rather than per-deployment knobs, they are hardcoded in code and removed from config:
0(token.Native.GetBalance)0acrosseth_gasPrice,maxPriorityFeePerGas, blockbaseFeePerGas, receipteffectiveGasPriceservice.DefaultGasLimit(21000), cosmetic onlyRemoved from config:
eth_rpc.gas_price_wei,eth_rpc.gas_limit,eth_rpc.native_balance_wei(the last was a dead field — never read), andtoken.native_balance_wei. Also dropped the now-deadtoken.Service.isUserRegistered.Notes
go build,go vet, and the full test suite pass.