-
Notifications
You must be signed in to change notification settings - Fork 5.4k
chore: migrate testnet network MegaETH Testnet v1 to MegaETH Testnet v2 #38426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
✨ Files requiring CODEOWNER review ✨✅ @MetaMask/confirmations (1 files, +9 -9)
🕵️ @MetaMask/extension-privacy-reviewers (2 files, +23 -3)
🧪 @MetaMask/qa (2 files, +23 -4)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR migrates the MegaETH Testnet from v1 (chain ID 0x18c6 / 6342) to v2 (chain ID 0x18c7 / 6343) across the MetaMask extension codebase. The migration updates the network's RPC endpoint from https://carrot.megaeth.com/rpc to https://timothy.megaeth.com/rpc, the block explorer from https://megaexplorer.xyz to https://megaeth-testnet-v2.blockscout.com, and standardizes the network name to "MegaETH Testnet". The changes include a state migration script that removes the v1 configuration and adds v2, along with updates to all network constants, test fixtures, and e2e tests.
- Adds migration #184 to transition user state from MegaETH Testnet v1 to v2
- Updates network constants to include both v1 (for backward compatibility) and v2 configurations
- Updates all test fixtures and e2e tests to use the new v2 network configuration
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| app/scripts/migrations/index.js | Registers migration #184 in the migrations list |
| app/scripts/migrations/184.ts | Implements the migration logic to add v2 config and remove v1 config from user state |
| app/scripts/migrations/184.test.ts | Adds tests for the migration functionality |
| app/scripts/controller-init/network-controller-init.ts | Temporarily adds v2 network manually and removes v1 from default networks |
| app/scripts/controller-init/network-controller-init.test.ts | Updates snapshot tests to reflect v2 configuration |
| shared/constants/network.ts | Adds v2 constants alongside existing v1 constants for backward compatibility |
| test/e2e/fixtures/fixture-builder.js | Updates fixture builder to use v2 configuration |
| test/e2e/fixtures/onboarding-fixture.json | Updates fixture to include v2 network and adds both v1 and v2 to NetworkEnablementController |
| test/e2e/mock-e2e.js | Adds v2 RPC host to blocklist for testing |
| test/e2e/mock-response-data/chain-id-network-chains.json | Updates mock chain data with v2 information |
| test/e2e/tests/network/network-connection.spec.ts | Updates e2e tests to use v2 chain ID |
| ui/pages/confirmations/hooks/useEIP7702Networks.test.ts | Updates test expectations to use v2 chain ID |
| privacy-snapshot.json | Adds v2 RPC host to privacy snapshot |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Builds ready [167e9bc]
UI Startup Metrics (1289 ± 100 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [5754e23]
UI Startup Metrics (1269 ± 123 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
1 similar comment
Builds ready [5754e23]
UI Startup Metrics (1269 ± 123 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [f061f95]
UI Startup Metrics (1288 ± 131 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [7a6d5fa]
UI Startup Metrics (1217 ± 112 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [b0c843c]
UI Startup Metrics (1278 ± 107 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
| } | ||
|
|
||
| // Add the MegaETH Testnet v2 network configuration to the enabled network map. | ||
| eip155NetworkMap[MEGAETH_TESTNET_V2_CONFIG.chainId] = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Migration loses v1 enabled state when setting v2
The migration deletes the v1 entry from eip155NetworkMap and then unconditionally sets v2 to false. This discards the user's enablement preference — if v1 was enabled (true), v2 will still be set to false (disabled). The enabled state from v1 should be preserved and applied to v2 instead of always hardcoding false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we default move to mainnet, hence we set megaETH testnet v2 to false (not enabled)
Builds ready [e5ec629]
UI Startup Metrics (1222 ± 110 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [378e4dd]
UI Startup Metrics (1223 ± 120 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [ed32150]
UI Startup Metrics (1250 ± 118 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
cf1c6e0 to
3f7d139
Compare
Builds ready [3f7d139]
UI Startup Metrics (1246 ± 112 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [433e702]
UI Startup Metrics (1305 ± 122 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [58d9591]
UI Startup Metrics (1273 ± 108 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
| "swap.api.cx.metamask.io", | ||
| "test.metamask-phishing.io", | ||
| "testnet-rpc.monad.xyz", | ||
| "timothy.megaeth.com", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is new RPC then should we remove the previous one(carrot.megaeth.com) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i try to keep the old one and clean up in other PR later, to ensure everything is okay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would do it in this PR as it introduce the new one and remove the old but I defer this to @MetaMask/extension-privacy-reviewers as they will review this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that we should remove the old one, but using another PR is fine
app/scripts/migrations/184.ts
Outdated
| global.sentry?.captureException?.( | ||
| new Error(`Migration ${version}: NetworkController not found.`), | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor - should we consider creating a tiny function for repetitive parts?
In e.g
global.sentry?.captureException?.(
new Error(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually i should just use captureException()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I mean is the creating a function something like below to improve readability of the code.
function captureError(error){
global.sentry?.captureException?.(
new Error(error)
)
}
It's a nit, so up for your preference
| "swap.api.cx.metamask.io", | ||
| "test.metamask-phishing.io", | ||
| "testnet-rpc.monad.xyz", | ||
| "timothy.megaeth.com", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Old RPC endpoint not removed from privacy snapshot
The new v2 MegaETH RPC endpoint timothy.megaeth.com is added, but the old v1 endpoint carrot.megaeth.com (at line 29) remains in the file. Since the migration removes the v1 network configuration and replaces it with v2, the old RPC host should also be removed from the privacy snapshot. This was also flagged by reviewer @OGPoyraz in the PR discussion. Keeping the deprecated endpoint in the allowlist is inconsistent with the migration's intent to fully replace v1 with v2.
OGPoyraz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmation changes LGTM
Builds ready [9d051fc]
UI Startup Metrics (1254 ± 116 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
seaona
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QA files LGTM! Nice update on the state-logs 🙏
Gudahtt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Privacy snapshot looks OK 👍
| initialNetworkControllerState.networkConfigurationsByChainId ?? {}; | ||
|
|
||
| // TODO: Remove this once the MegaETH Testnet v2 is released from the controller utils | ||
| networks['0x18c7'] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if someone already has this chain added? Do we need to only add this if the chain is not present? (If the chain is already present, then the migration should take care of fixing it.) Is this something to be concerned about?
|
|
||
| const megaethTestnetV1Configuration = networkConfigurationsByChainId[ | ||
| MEGAETH_TESTNET_V1_CHAIN_ID | ||
| ] as unknown as NetworkConfiguration; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we using a type assertion here? What if this chain is not present?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is okay,
as we have a check on below
megaethTestnetV1Configuration &&
isObject(megaethTestnetV1Configuration) &&
hasProperty(megaethTestnetV1Configuration, 'rpcEndpoints') &&
Array.isArray(megaethTestnetV1Configuration.rpcEndpoints) &&
```
| ] as unknown as NetworkConfiguration; | ||
|
|
||
| // Add the MegaETH Testnet v2 network configuration. | ||
| networkConfigurationsByChainId[MEGAETH_TESTNET_V2_CONFIG.chainId] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the user already has this chain, wouldn't we be overriding it completely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we try to override it with our config, thats what we want as well
| // Add the MegaETH Testnet v2 network configuration to the enabled network map. | ||
| eip155NetworkMap[MEGAETH_TESTNET_V2_CONFIG.chainId] = false; | ||
|
|
||
| // If the selected network client id is the old MegaETH Testnet v1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Why not update it to the new chain? We could look up the default RPC endpoint under the new chain in networkConfigurationsByChainId and then set selectedNetworkClientId to its networkClientId.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we found that it may more reliable to update to mainnet in that case
| chainId: '0x18c7', // 6343 | ||
| name: 'MegaETH Testnet', | ||
| nativeCurrency: 'MegaETH', | ||
| blockExplorerUrls: ['https://megaeth-testnet-v2.blockscout.com'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Isn't this information already available in shared/constants/network.ts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call, but this is for temp and removed soon once network controller bump up, i think we can keep it like that if u dont mind?
Description
This PR migrates the MegaETH Testnet from v1 (chain ID 0x18c6 / 6342) to v2 (chain ID 0x18c7 / 6343) across the MetaMask extension codebase.
The migration updates the network's RPC endpoint from https://carrot.megaeth.com/rpc to https://timothy.megaeth.com/rpc, the block explorer from https://megaexplorer.xyz to https://megaeth-testnet-v2.blockscout.com, and standardizes the network name to "MegaETH Testnet".
The changes include a state migration script that removes the v1 configuration and adds v2, along with updates to all network constants, test fixtures, and e2e tests.
Adds migration to transition user state from MegaETH Testnet v1 to v2
Updates network constants to include both v1 (for backward compatibility) and v2 configurations
Updates all test fixtures and e2e tests to use the new v2 network configuration
Changelog
CHANGELOG entry: Added new network client
megaeth-testnet-v2CHANGELOG entry: Removed network client
megaeth-testnetRelated issues
Fixes:
Manual testing steps
editon the network menu of MegaETH testnetScreenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Migrates MegaETH Testnet to chain 0x18c7 with new RPC/explorer, adds migration 184 to replace v1 config and switch selection, and updates constants, tests, fixtures, and privacy lists.
MegaETH Testnet v2config (chainId0x18c7, RPChttps://timothy.megaeth.com/rpc, explorerhttps://megaeth-testnet-v2.blockscout.com).MegaETH Testnet v1(0x18c6) from configs and enabled map; switchesselectedNetworkClientIdtomainnetif it referenced v1.megaeth-testnetfromADDITIONAL_DEFAULT_NETWORKS; temporarily injects0x18c7config into initial state.MEGAETH_TESTNET_V2acrossCHAIN_IDS, names, images, RPC map, currency maps, display names, test network lists, and ethers mapping; definesMEGAETH_TESTNET_V2_RPC_URL.megaeth-testnet-v2IDs/URLs; adjusts unit/e2e tests (including EIP-7702 networks ordering); comments out MegaETH v2 network-connection test temporarily.timothy.megaeth.comto privacy snapshot and e2e blocklist; updateschainid.networkmock for v2.Written by Cursor Bugbot for commit 9d051fc. This will update automatically on new commits. Configure here.