Skip to content

Commit f0a5124

Browse files
Supports MegaETH For L2EP (#4499)
1 parent 74cbb3f commit f0a5124

File tree

14 files changed

+243
-3
lines changed

14 files changed

+243
-3
lines changed

.changeset/many-houses-sin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@chainlink/layer2-sequencer-health-adapter': minor
3+
---
4+
5+
Supports MegaETH for L2EP

packages/sources/layer2-sequencer-health/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,20 @@ Adapter that checks the Layer 2 Sequencer status
6363
| | `XLAYER_HEALTH_ENDPOINT` | xLayer Health Endpoint | | |
6464
| | `XLAYER_CHAIN_ID` | The chain id to connect to xLayer | | 196 |
6565
| | `XLAYER_DELTA` | Maximum time in milliseconds from last seen block to consider Celo sequencer healthy | | 120000 (2 min) |
66+
| | `MEGAETH_RPC_ENDPOINT` | MegaETH RPC Endpoint | | https://mainnet.megaeth.com/rpc |
67+
| | `MEGAETH_HEALTH_ENDPOINT` | MegaETH Health Endpoint | | |
68+
| | `MEGAETH_CHAIN_ID` | The chain id to connect to MegaETH | | 4326 |
69+
| | `MEGAETH_DELTA` | Maximum time in milliseconds from last seen block to consider MegaETH sequencer healthy | | 120000 (2 min) |
6670

6771
For the adapter to be useful on the desired network, at least one endpoint (RPC or HEALTH) needs to provided
6872

6973
---
7074

7175
### Input Parameters
7276

73-
| Required? | Name | Description | Options | Defaults to |
74-
| :-------: | :-----: | :----------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------: | :---------: |
75-
|| network | Layer 2 Network to check | `arbitrum`, `optimism`, `base`, `linea`, `metis`, `scroll`, `starkware`, `zksync`, `ink`, `mantle`, `unichain`, `soneium`, `celo`, `xlayer` | |
77+
| Required? | Name | Description | Options | Defaults to |
78+
| :-------: | :-----: | :----------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------: | :---------: |
79+
|| network | Layer 2 Network to check | `arbitrum`, `optimism`, `base`, `linea`, `metis`, `scroll`, `starkware`, `zksync`, `ink`, `mantle`, `unichain`, `soneium`, `celo`, `xlayer`, `megaeth` | |
7680

7781
---
7882

packages/sources/layer2-sequencer-health/schemas/env.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,20 @@
233233
"description": "The blockchain id to connect to",
234234
"type": "string",
235235
"default": "196"
236+
},
237+
"MEGAETH_RPC_ENDPOINT": {
238+
"type": "string",
239+
"default": "https://mainnet.megaeth.com/rpc"
240+
},
241+
"MEGAETH_HEALTH_ENDPOINT": {
242+
"type": "string",
243+
"default": ""
244+
},
245+
"MEGAETH_CHAIN_ID": {
246+
"required": false,
247+
"description": "The blockchain id to connect to",
248+
"type": "string",
249+
"default": "4326"
236250
}
237251
},
238252
"allOf": [

packages/sources/layer2-sequencer-health/src/config/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export const ENV_UNICHAIN_RPC_ENDPOINT = 'UNICHAIN_RPC_ENDPOINT'
4242
export const ENV_SONEIUM_RPC_ENDPOINT = 'SONEIUM_RPC_ENDPOINT'
4343
export const ENV_CELO_RPC_ENDPOINT = 'CELO_RPC_ENDPOINT'
4444
export const ENV_XLAYER_RPC_ENDPOINT = 'XLAYER_RPC_ENDPOINT'
45+
export const ENV_MEGAETH_RPC_ENDPOINT = 'MEGAETH_RPC_ENDPOINT'
4546

4647
export const ENV_ARBITRUM_CHAIN_ID = 'ARBITRUM_CHAIN_ID'
4748
export const ENV_OPTIMISM_CHAIN_ID = 'OPTIMISM_CHAIN_ID'
@@ -56,6 +57,7 @@ export const ENV_UNICHAIN_CHAIN_ID = 'UNICHAIN_CHAIN_ID'
5657
export const ENV_SONEIUM_CHAIN_ID = 'SONEIUM_CHAIN_ID'
5758
export const ENV_CELO_CHAIN_ID = 'CELO_CHAIN_ID'
5859
export const ENV_XLAYER_CHAIN_ID = 'XLAYER_CHAIN_ID'
60+
export const ENV_MEGAETH_CHAIN_ID = 'MEGAETH_CHAIN_ID'
5961

6062
export const DEFAULT_ARBITRUM_CHAIN_ID = '42161'
6163
export const DEFAULT_OPTIMISM_CHAIN_ID = '10'
@@ -70,6 +72,7 @@ export const DEFAULT_UNICHAIN_CHAIN_ID = '130'
7072
export const DEFAULT_SONEIUM_CHAIN_ID = '1868'
7173
export const DEFAULT_CELO_CHAIN_ID = '42220'
7274
export const DEFAULT_XLAYER_CHAIN_ID = '196'
75+
export const DEFAULT_MEGAETH_CHAIN_ID = '4326'
7376

7477
export enum Networks {
7578
Arbitrum = 'arbitrum',
@@ -86,6 +89,7 @@ export enum Networks {
8689
Soneium = 'soneium',
8790
Celo = 'celo',
8891
Xlayer = 'xlayer',
92+
Megaeth = 'megaeth',
8993
}
9094

9195
export type EVMNetworks = Exclude<Networks, Networks.Starkware>
@@ -103,6 +107,7 @@ const DEFAULT_UNICHAIN_RPC_ENDPOINT = 'https://mainnet.unichain.org'
103107
const DEFAULT_SONEIUM_RPC_ENDPOINT = 'https://rpc.soneium.org'
104108
const DEFAULT_CELO_RPC_ENDPOINT = 'https://forno.celo.org'
105109
const DEFAULT_XLAYER_RPC_ENDPOINT = 'https://xlayerrpc.okx.com'
110+
const DEFAULT_MEGAETH_RPC_ENDPOINT = 'https://mainnet.megaeth.com/rpc'
106111

107112
export const RPC_ENDPOINTS: Record<EVMNetworks, string | undefined> = {
108113
[Networks.Arbitrum]: util.getEnv(ENV_ARBITRUM_RPC_ENDPOINT) || DEFAULT_ARBITRUM_RPC_ENDPOINT,
@@ -118,6 +123,7 @@ export const RPC_ENDPOINTS: Record<EVMNetworks, string | undefined> = {
118123
[Networks.Soneium]: util.getEnv(ENV_SONEIUM_RPC_ENDPOINT) || DEFAULT_SONEIUM_RPC_ENDPOINT,
119124
[Networks.Celo]: util.getEnv(ENV_CELO_RPC_ENDPOINT) || DEFAULT_CELO_RPC_ENDPOINT,
120125
[Networks.Xlayer]: util.getEnv(ENV_XLAYER_RPC_ENDPOINT) || DEFAULT_XLAYER_RPC_ENDPOINT,
126+
[Networks.Megaeth]: util.getEnv(ENV_MEGAETH_RPC_ENDPOINT) || DEFAULT_MEGAETH_RPC_ENDPOINT,
121127
}
122128

123129
export const CHAIN_IDS: Record<EVMNetworks, number | undefined | string> = {
@@ -160,6 +166,9 @@ export const CHAIN_IDS: Record<EVMNetworks, number | undefined | string> = {
160166
[Networks.Xlayer]:
161167
parseInt(util.getEnv(ENV_XLAYER_CHAIN_ID) || DEFAULT_XLAYER_CHAIN_ID) ||
162168
util.getEnv(ENV_XLAYER_CHAIN_ID),
169+
[Networks.Megaeth]:
170+
parseInt(util.getEnv(ENV_MEGAETH_CHAIN_ID) || DEFAULT_MEGAETH_CHAIN_ID) ||
171+
util.getEnv(ENV_MEGAETH_CHAIN_ID),
163172
}
164173

165174
export const CHAIN_DELTA: Record<Networks, number> = {
@@ -177,6 +186,7 @@ export const CHAIN_DELTA: Record<Networks, number> = {
177186
[Networks.Soneium]: Number(util.getEnv('SONEIUM_DELTA')) || DEFAULT_DELTA_TIME,
178187
[Networks.Celo]: Number(util.getEnv('CELO_DELTA')) || DEFAULT_DELTA_TIME,
179188
[Networks.Xlayer]: Number(util.getEnv('XLAYER_DELTA')) || DEFAULT_DELTA_TIME,
189+
[Networks.Megaeth]: Number(util.getEnv('MEGAETH_DELTA')) || DEFAULT_DELTA_TIME,
180190
}
181191

182192
const DEFAULT_METIS_HEALTH_ENDPOINT = 'https://andromeda-healthy.metisdevops.link/health'
@@ -262,6 +272,11 @@ export const HEALTH_ENDPOINTS: HeathEndpoints = {
262272
responsePath: [],
263273
processResponse: () => undefined,
264274
},
275+
[Networks.Megaeth]: {
276+
endpoint: util.getEnv('MEGAETH_HEALTH_ENDPOINT'),
277+
responsePath: [],
278+
processResponse: () => undefined,
279+
},
265280
}
266281

267282
const defaultProcessResponse = (data: unknown, network: Networks) =>

packages/sources/layer2-sequencer-health/src/endpoint/health.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const defaultRequireTxFailure = {
3232
[Networks.Soneium]: false,
3333
[Networks.Celo]: false,
3434
[Networks.Xlayer]: false,
35+
[Networks.Megaeth]: false,
3536
}
3637

3738
export type TInputParameters = {
@@ -56,6 +57,7 @@ export const inputParameters: InputParameters<TInputParameters> = {
5657
Networks.Soneium,
5758
Networks.Celo,
5859
Networks.Xlayer,
60+
Networks.Megaeth,
5961
],
6062
},
6163
requireTxFailure: {

packages/sources/layer2-sequencer-health/src/evm.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ export const sendEVMDummyTransaction = async (
105105
gasPrice: 0,
106106
to: wallet.address,
107107
},
108+
[Networks.Megaeth]: {
109+
value: 0,
110+
gasLimit: 0,
111+
gasPrice: 0,
112+
to: wallet.address,
113+
},
108114
}
109115
await race<ethers.providers.TransactionResponse>({
110116
timeout,
@@ -166,6 +172,10 @@ const lastSeenBlock: Record<EVMNetworks, { block: number; timestamp: number }> =
166172
block: 0,
167173
timestamp: 0,
168174
},
175+
[Networks.Megaeth]: {
176+
block: 0,
177+
timestamp: 0,
178+
},
169179
}
170180

171181
export const checkOptimisticRollupBlockHeight = (

packages/sources/layer2-sequencer-health/src/network.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const sequencerOnlineErrors: Record<Networks, string[]> = {
3434
[Networks.Soneium]: ['intrinsic gas too low: gas 0'],
3535
[Networks.Celo]: ['intrinsic gas too low'],
3636
[Networks.Xlayer]: ['intrinsic gas too low'],
37+
[Networks.Megaeth]: ['intrinsic gas too low'],
3738
}
3839

3940
export interface NetworkHealthCheck {
@@ -106,6 +107,7 @@ const isExpectedErrorMessage = (network: Networks, error: Error) => {
106107
[Networks.Soneium]: ['error', 'message'],
107108
[Networks.Celo]: ['error', 'message'],
108109
[Networks.Xlayer]: ['error', 'message'],
110+
[Networks.Megaeth]: ['error', 'message'],
109111
}
110112
return (Requester.getResult(error, paths[network]) as string) || ''
111113
}

packages/sources/layer2-sequencer-health/test/integration/__snapshots__/onchainFailKnown.test.ts.snap

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,28 @@ exports[`execute mantle network should return success when transaction submissio
132132
}
133133
`;
134134

135+
exports[`execute megaeth network should return failure if tx not required 1`] = `
136+
{
137+
"data": {
138+
"result": 1,
139+
},
140+
"jobRunID": "1",
141+
"result": 1,
142+
"statusCode": 200,
143+
}
144+
`;
145+
146+
exports[`execute megaeth network should return success when transaction submission is known 1`] = `
147+
{
148+
"data": {
149+
"result": 0,
150+
},
151+
"jobRunID": "1",
152+
"result": 0,
153+
"statusCode": 200,
154+
}
155+
`;
156+
135157
exports[`execute metis network should return failure if tx not required 1`] = `
136158
{
137159
"data": {

packages/sources/layer2-sequencer-health/test/integration/__snapshots__/onchainFailUnknown.test.ts.snap

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ exports[`execute mantle network should return failure when transaction submissio
5555
}
5656
`;
5757

58+
exports[`execute megaeth network should return failure when transaction submission is unknown 1`] = `
59+
{
60+
"data": {
61+
"result": 1,
62+
},
63+
"jobRunID": "1",
64+
"result": 1,
65+
"statusCode": 200,
66+
}
67+
`;
68+
5869
exports[`execute metis network should return failure when transaction submission is unknown 1`] = `
5970
{
6071
"data": {

packages/sources/layer2-sequencer-health/test/integration/__snapshots__/onchainSuccess.test.ts.snap

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,39 @@ exports[`execute mantle network should return transaction submission is successf
198198
}
199199
`;
200200

201+
exports[`execute megaeth network should return failure if tx not required even if it would be successful 1`] = `
202+
{
203+
"data": {
204+
"result": 1,
205+
},
206+
"jobRunID": "1",
207+
"result": 1,
208+
"statusCode": 200,
209+
}
210+
`;
211+
212+
exports[`execute megaeth network should return success when all methods succeed 1`] = `
213+
{
214+
"data": {
215+
"result": 0,
216+
},
217+
"jobRunID": "1",
218+
"result": 0,
219+
"statusCode": 200,
220+
}
221+
`;
222+
223+
exports[`execute megaeth network should return transaction submission is successful 1`] = `
224+
{
225+
"data": {
226+
"result": 0,
227+
},
228+
"jobRunID": "1",
229+
"result": 0,
230+
"statusCode": 200,
231+
}
232+
`;
233+
201234
exports[`execute metis network should return failure if tx not required even if it would be successful 1`] = `
202235
{
203236
"data": {

0 commit comments

Comments
 (0)