feat(seismic-rpc): eth_getBalance returns native by default, opt-in for gas-token balance#403
Open
HenryMBaldwin wants to merge 1 commit into
Open
feat(seismic-rpc): eth_getBalance returns native by default, opt-in for gas-token balance#403HenryMBaldwin wants to merge 1 commit into
HenryMBaldwin wants to merge 1 commit into
Conversation
…or gas-token balance eth_getBalance previously returned the effective balance max(native, usdc·10^12), which surprised users expecting standard native-balance semantics (and was inconsistent with eth_getAccount/eth_getProof, which already return native). - balance() now returns the native balance. - A new optional eth_getBalance(address, block, includeGasToken) parameter restores the effective balance when set to true; absent/false yields native. Backward compatible with standard 2-arg callers. - The gas-allowance path (estimateGas/call) is unchanged, so accounts holding only the SRC20 gas stablecoin can still pay/estimate gas. Tests: unit test for the effective-balance math (the first coverage of the USDC balance path), e2e test for native-default + opt-in plumbing.
Contributor
|
Modifies LGTM — This is a well-implemented behavioral change with comprehensive test coverage and proper error handling. The code correctly separates concerns between native balance (default) and effective balance (opt-in), uses proper Seismic test setup with correct chain specs, and includes no security vulnerabilities or secret key exposure risks. |
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.
Problem
eth_getBalancereturned the effective balancemax(native, usdc·10^12)(native vs. the SRC20 gas stablecoin, internally named "usdc"). This was causing confusion for users.Change
balance()now returns the native balance — the default, standard behavior. This also resolves the 1206 inconsistency (all account-inspection RPCs now agree on native by default).eth_getBalance(address, block, includeGasToken?).true→ effectivemax(native, usdc·10^12); absent/false→ native. Backward compatible — standard 2-arg callers get native.estimateGas/call) is unchanged, so accounts holding only the gas stablecoin can still estimate/pay gas even though their reported balance is native.Tests
usdc.rs): seeds a USDC balance viaMockEthProviderand checks the effective math (USDC>native→ scaled USDC;native>USDC→ native; no-USDC → native). This is the first test exercising the USDC balance path.integration.rs): standard 2-argeth_getBalance→ native; explicit opt-out → native; opt-in accepted.Live verification
Ran a standalone node against a custom genesis that pre-allocated 5 USDC of storage for an address (native = 1 wei), then queried over
curl:eth_getBalance(addr, latest)0x1(native)eth_getBalance(addr, latest, false)0x1(native)eth_getBalance(addr, latest, true)0x4563918244f40000= 5·10^18 (effective)