From e646cf4edcdde846bdbfe09d737a5ef4b4339f1f Mon Sep 17 00:00:00 2001 From: panos Date: Sun, 8 Nov 2026 21:34:46 +0800 Subject: [PATCH] fix(devnet): register all fee tokens in call mode Devnet pre-registered L2WETH (token 2) with a balanceSlot, unlike mainnet/testnet which only use call-mode fee tokens. Align genesis so local fee-token testing matches production. --- .../morph-chain-ops/genesis/devnet_tokens.go | 12 +++++++----- .../morph-chain-ops/genesis/devnet_tokens_test.go | 13 ++++++++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ops/l2-genesis/morph-chain-ops/genesis/devnet_tokens.go b/ops/l2-genesis/morph-chain-ops/genesis/devnet_tokens.go index 28016dc06..602b4023b 100644 --- a/ops/l2-genesis/morph-chain-ops/genesis/devnet_tokens.go +++ b/ops/l2-genesis/morph-chain-ops/genesis/devnet_tokens.go @@ -36,6 +36,10 @@ type DevnetTestToken struct { // Token 1: BTC - for testing high-value asset price queries (all data sources support) // Token 2: ETH - for testing gas token benchmark and relative price calculation // Token 3: BGB - for testing platform token and CEX-specific data sources +// +// All three register without a balanceSlot so fee deduction uses the EVM-call +// path (balanceOf/transfer), matching mainnet and testnet. Slot-mode fee +// tokens are retired on those networks. func GetDevnetTestTokens() []DevnetTestToken { return []DevnetTestToken{ { @@ -49,11 +53,9 @@ func GetDevnetTestTokens() []DevnetTestToken { Scale: big.NewInt(1e8), }, { - TokenID: 2, - TokenAddress: common.HexToAddress("0x5300000000000000000000000000000000000011"), // L2WETH predeploy address - // WrappedEther keeps _balances at slot 0; slot 3 is _name. - BalanceSlot: common.Hash{}, - NeedBalanceSlot: true, + TokenID: 2, + TokenAddress: common.HexToAddress("0x5300000000000000000000000000000000000011"), // L2WETH predeploy address + NeedBalanceSlot: false, Decimals: 18, Scale: big.NewInt(1e18), }, diff --git a/ops/l2-genesis/morph-chain-ops/genesis/devnet_tokens_test.go b/ops/l2-genesis/morph-chain-ops/genesis/devnet_tokens_test.go index dfe87e09f..5202a4f6d 100644 --- a/ops/l2-genesis/morph-chain-ops/genesis/devnet_tokens_test.go +++ b/ops/l2-genesis/morph-chain-ops/genesis/devnet_tokens_test.go @@ -57,9 +57,10 @@ func TestSetDevnetTestTokensStorageLayout(t *testing.T) { } } -// TestDevnetTestTokenDefinitions pins the two properties that cannot be derived from -// the encoding itself: WETH's balance slot is a real slot 0 rather than "no slot", and -// the placeholder addresses stay out of the precompile range. +// TestDevnetTestTokenDefinitions pins the properties that cannot be derived from +// the encoding itself: every pre-registered token uses the call-mode path (no +// balanceSlot), WETH stays on the L2WETH predeploy, and placeholder addresses +// stay out of the precompile range. func TestDevnetTestTokenDefinitions(t *testing.T) { byID := make(map[uint16]DevnetTestToken) for _, token := range GetDevnetTestTokens() { @@ -68,11 +69,13 @@ func TestDevnetTestTokenDefinitions(t *testing.T) { weth := byID[2] require.Equal(t, predeploys.L2WETHAddr, weth.TokenAddress) - require.True(t, weth.NeedBalanceSlot, "WrappedEther keeps _balances at slot 0, which still needs to be registered") - require.Equal(t, common.Hash{}, weth.BalanceSlot) lowestNonPrecompile := big.NewInt(0xff) for _, token := range byID { + require.False(t, token.NeedBalanceSlot, + "token %d must use call-mode fee deduction to match mainnet/testnet", token.TokenID) + require.Equal(t, common.Hash{}, token.BalanceSlot) + require.Positive(t, new(big.Int).SetBytes(token.TokenAddress.Bytes()).Cmp(lowestNonPrecompile), "token %d address %s falls in the precompile range", token.TokenID, token.TokenAddress)