Skip to content

Commit 8013554

Browse files
refactor: leave the retiring golden route untouched
check_all_providers is slated for removal, so routing its chain names through ForeignChain::label was churn in a file on its way out. Also drops two comments that restated the code beside them.
1 parent fda06c0 commit 8013554

3 files changed

Lines changed: 36 additions & 95 deletions

File tree

crates/e2e-tests/src/foreign_chain_mock.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ impl MockServerExt {
7575
}
7676
}
7777

78-
/// Answered by every EVM mock regardless of the chain it stands in for, so a test probing one has
79-
/// to expect Base's id.
8078
pub const MOCK_EVM_CHAIN_ID: u64 = 8453;
8179
pub const MOCK_BLOCK_HASH: &str =
8280
"0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20";

crates/e2e-tests/tests/foreign_chain_probe.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ fn base_chain_config(rpc_url: &str, expected_network: u64, provider: &str) -> Fo
3030
}
3131
}
3232

33-
/// Both nodes point one Base provider at the same mock and differ only in the fingerprint they
34-
/// expect, so the healthy gauge is the only one that separates them.
3533
#[tokio::test]
3634
#[expect(non_snake_case)]
3735
async fn foreign_chain_probe__should_publish_provider_health_on_startup() {

crates/foreign-chain-health-check/src/lib.rs

Lines changed: 36 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use foreign_chain_rpc_interfaces::sui::GrpcSuiClient;
3131
use http::{HeaderName, HeaderValue};
3232
use mpc_node_config::foreign_chains::RpcProviderName;
3333
use mpc_node_config::{ForeignChainConfig, ForeignChainProviderConfig, ForeignChainsConfig};
34-
use near_mpc_contract_interface::types::ForeignChain;
3534

3635
pub use network::Network;
3736
pub use results::{ProviderResult, Status};
@@ -58,111 +57,71 @@ pub async fn check_all_providers(
5857
mark_not_configured("ethereum", &mut out);
5958
}
6059
if let Some(cfg) = &fc.base {
61-
run_evm::<Base>(ForeignChain::Base, cfg, golden.base, network, &mut out).await;
60+
run_evm::<Base>("base", cfg, golden.base, network, &mut out).await;
6261
} else {
63-
mark_not_configured(ForeignChain::Base, &mut out);
62+
mark_not_configured("base", &mut out);
6463
}
6564
if let Some(cfg) = &fc.bnb {
66-
run_evm::<Bnb>(ForeignChain::Bnb, cfg, golden.bnb, network, &mut out).await;
65+
run_evm::<Bnb>("bnb", cfg, golden.bnb, network, &mut out).await;
6766
} else {
68-
mark_not_configured(ForeignChain::Bnb, &mut out);
67+
mark_not_configured("bnb", &mut out);
6968
}
7069
if let Some(cfg) = &fc.arbitrum {
71-
run_evm::<Arbitrum>(
72-
ForeignChain::Arbitrum,
73-
cfg,
74-
golden.arbitrum,
75-
network,
76-
&mut out,
77-
)
78-
.await;
70+
run_evm::<Arbitrum>("arbitrum", cfg, golden.arbitrum, network, &mut out).await;
7971
} else {
80-
mark_not_configured(ForeignChain::Arbitrum, &mut out);
72+
mark_not_configured("arbitrum", &mut out);
8173
}
8274
if let Some(cfg) = &fc.polygon {
83-
run_evm::<Polygon>(
84-
ForeignChain::Polygon,
85-
cfg,
86-
golden.polygon,
87-
network,
88-
&mut out,
89-
)
90-
.await;
75+
run_evm::<Polygon>("polygon", cfg, golden.polygon, network, &mut out).await;
9176
} else {
92-
mark_not_configured(ForeignChain::Polygon, &mut out);
77+
mark_not_configured("polygon", &mut out);
9378
}
9479
if let Some(cfg) = &fc.hyper_evm {
95-
run_evm::<HyperEvm>(
96-
ForeignChain::HyperEvm,
97-
cfg,
98-
golden.hyper_evm,
99-
network,
100-
&mut out,
101-
)
102-
.await;
80+
run_evm::<HyperEvm>("hyper_evm", cfg, golden.hyper_evm, network, &mut out).await;
10381
} else {
104-
mark_not_configured(ForeignChain::HyperEvm, &mut out);
82+
mark_not_configured("hyper_evm", &mut out);
10583
}
10684
if let Some(cfg) = &fc.avalanche {
107-
run_evm::<Avalanche>(
108-
ForeignChain::Avalanche,
109-
cfg,
110-
golden.avalanche,
111-
network,
112-
&mut out,
113-
)
114-
.await;
85+
run_evm::<Avalanche>("avalanche", cfg, golden.avalanche, network, &mut out).await;
11586
} else {
116-
mark_not_configured(ForeignChain::Avalanche, &mut out);
87+
mark_not_configured("avalanche", &mut out);
11788
}
11889
if let Some(cfg) = &fc.adi {
119-
run_evm::<Adi>(ForeignChain::Adi, cfg, golden.adi, network, &mut out).await;
90+
run_evm::<Adi>("adi", cfg, golden.adi, network, &mut out).await;
12091
} else {
121-
mark_not_configured(ForeignChain::Adi, &mut out);
92+
mark_not_configured("adi", &mut out);
12293
}
12394
if let Some(cfg) = &fc.abstract_chain {
124-
run_evm::<Abstract>(
125-
ForeignChain::Abstract,
126-
cfg,
127-
golden.abstract_chain,
128-
network,
129-
&mut out,
130-
)
131-
.await;
95+
run_evm::<Abstract>("abstract", cfg, golden.abstract_chain, network, &mut out).await;
13296
} else {
133-
mark_not_configured(ForeignChain::Abstract, &mut out);
97+
mark_not_configured("abstract", &mut out);
13498
}
13599
if let Some(cfg) = &fc.bitcoin {
136100
run_bitcoin(cfg, golden.bitcoin, network, &mut out).await;
137101
} else {
138-
mark_not_configured(ForeignChain::Bitcoin, &mut out);
102+
mark_not_configured("bitcoin", &mut out);
139103
}
140104
if let Some(cfg) = &fc.starknet {
141105
run_starknet(cfg, golden.starknet, network, &mut out).await;
142106
} else {
143-
mark_not_configured(ForeignChain::Starknet, &mut out);
107+
mark_not_configured("starknet", &mut out);
144108
}
145109
if let Some(cfg) = &fc.aptos {
146110
run_aptos(cfg, golden.aptos, network, &mut out).await;
147111
} else {
148-
mark_not_configured(ForeignChain::Aptos, &mut out);
112+
mark_not_configured("aptos", &mut out);
149113
}
150114
if let Some(cfg) = &fc.sui {
151115
run_sui(cfg, golden.sui, network, &mut out).await;
152116
} else {
153-
mark_not_configured(ForeignChain::Sui, &mut out);
117+
mark_not_configured("sui", &mut out);
154118
}
155119

156120
// Configured but not yet supported by the node (see verify_foreign_tx/sign.rs).
157121
if let Some(cfg) = &fc.solana {
158-
mark_skipped(
159-
ForeignChain::Solana,
160-
cfg,
161-
"not yet supported by the node",
162-
&mut out,
163-
);
122+
mark_skipped("solana", cfg, "not yet supported by the node", &mut out);
164123
} else {
165-
mark_not_configured(ForeignChain::Solana, &mut out);
124+
mark_not_configured("solana", &mut out);
166125
}
167126

168127
out
@@ -213,7 +172,7 @@ async fn run_check(timeout: Duration, fut: impl Future<Output = anyhow::Result<(
213172
}
214173

215174
async fn run_evm<Chain: EvmChain + Send + Sync>(
216-
chain: ForeignChain,
175+
chain: &'static str,
217176
cfg: &ForeignChainConfig,
218177
vector: Option<BlockHashVector>,
219178
network: Network,
@@ -235,7 +194,7 @@ async fn run_evm<Chain: EvmChain + Send + Sync>(
235194
}
236195
};
237196
out.push(ProviderResult {
238-
chain: chain.label(),
197+
chain,
239198
provider: provider_name(name),
240199
status,
241200
});
@@ -249,12 +208,7 @@ async fn run_bitcoin(
249208
out: &mut Vec<ProviderResult>,
250209
) {
251210
let Some(vector) = vector else {
252-
mark_skipped(
253-
ForeignChain::Bitcoin,
254-
cfg,
255-
&no_reference_reason(network),
256-
out,
257-
);
211+
mark_skipped("bitcoin", cfg, &no_reference_reason(network), out);
258212
return;
259213
};
260214
let timeout = timeout_of(cfg);
@@ -269,7 +223,7 @@ async fn run_bitcoin(
269223
}
270224
};
271225
out.push(ProviderResult {
272-
chain: ForeignChain::Bitcoin.label(),
226+
chain: "bitcoin",
273227
provider: provider_name(name),
274228
status,
275229
});
@@ -283,12 +237,7 @@ async fn run_starknet(
283237
out: &mut Vec<ProviderResult>,
284238
) {
285239
let Some(vector) = vector else {
286-
mark_skipped(
287-
ForeignChain::Starknet,
288-
cfg,
289-
&no_reference_reason(network),
290-
out,
291-
);
240+
mark_skipped("starknet", cfg, &no_reference_reason(network), out);
292241
return;
293242
};
294243
let timeout = timeout_of(cfg);
@@ -303,7 +252,7 @@ async fn run_starknet(
303252
}
304253
};
305254
out.push(ProviderResult {
306-
chain: ForeignChain::Starknet.label(),
255+
chain: "starknet",
307256
provider: provider_name(name),
308257
status,
309258
});
@@ -317,7 +266,7 @@ async fn run_aptos(
317266
out: &mut Vec<ProviderResult>,
318267
) {
319268
let Some(vector) = vector else {
320-
mark_skipped(ForeignChain::Aptos, cfg, &no_reference_reason(network), out);
269+
mark_skipped("aptos", cfg, &no_reference_reason(network), out);
321270
return;
322271
};
323272
let timeout = timeout_of(cfg);
@@ -342,7 +291,7 @@ async fn run_aptos(
342291
}
343292
};
344293
out.push(ProviderResult {
345-
chain: ForeignChain::Aptos.label(),
294+
chain: "aptos",
346295
provider: provider_name(name),
347296
status,
348297
});
@@ -360,7 +309,7 @@ async fn run_sui(
360309
out: &mut Vec<ProviderResult>,
361310
) {
362311
let Some(vector) = vector else {
363-
mark_skipped(ForeignChain::Sui, cfg, &no_reference_reason(network), out);
312+
mark_skipped("sui", cfg, &no_reference_reason(network), out);
364313
return;
365314
};
366315
let timeout = timeout_of(cfg);
@@ -370,7 +319,7 @@ async fn run_sui(
370319
Ok(client) => run_check(timeout, checks::check_sui(client, vector.chain_id)).await,
371320
};
372321
out.push(ProviderResult {
373-
chain: ForeignChain::Sui.label(),
322+
chain: "sui",
374323
provider: provider_name(name),
375324
status,
376325
});
@@ -395,25 +344,21 @@ fn prepare_sui(
395344
}
396345

397346
fn mark_skipped(
398-
chain: ForeignChain,
347+
chain: &'static str,
399348
cfg: &ForeignChainConfig,
400349
reason: &str,
401350
out: &mut Vec<ProviderResult>,
402351
) {
403352
for name in cfg.providers.keys() {
404-
out.push(ProviderResult::skipped(
405-
chain.label(),
406-
provider_name(name),
407-
reason,
408-
));
353+
out.push(ProviderResult::skipped(chain, provider_name(name), reason));
409354
}
410355
}
411356

412357
/// A chain absent from the config has no providers to enumerate; emit one
413358
/// placeholder [`ProviderResult`] so it still appears in the returned results.
414-
fn mark_not_configured(chain: ForeignChain, out: &mut Vec<ProviderResult>) {
359+
fn mark_not_configured(chain: &'static str, out: &mut Vec<ProviderResult>) {
415360
out.push(ProviderResult::skipped(
416-
chain.label(),
361+
chain,
417362
"-".to_string(),
418363
"not configured",
419364
));

0 commit comments

Comments
 (0)