Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions ops/l2-genesis/morph-chain-ops/genesis/devnet_tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
{
Expand All @@ -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),
},
Expand Down
13 changes: 8 additions & 5 deletions ops/l2-genesis/morph-chain-ops/genesis/devnet_tokens_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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)

Expand Down
Loading