refactor: extract foreign-chain-health-check library from config-tester - #3797
Conversation
Address PR #3797 review feedback: - Add an httpmock-driven check_all_providers test exercising a passing provider, a failing provider on the same chain, and a skipped (unsupported) chain in one run — proving one bad provider does not stop the others from being reported. - Keep the golden and checks modules crate-private; no consumer needs them (network and results stay public). - Drop the stale FCCT_ acronym from the test env-var name.
ad30f88 to
a1145b2
Compare
Move the golden reference transactions, per-provider checks, and the check_all_providers orchestration out of the foreign-chain-config-tester CLI into a new production library crate, so the MPC node can reuse them for a startup RPC health check without depending on the operator CLI (which carries clap/serde_yaml/toml). No behavior change: the CLI keeps its arg parsing, config-shape detection, and table rendering, and now consumes the shared crate. Part of #3764.
Address PR #3797 review feedback: - Add an httpmock-driven check_all_providers test exercising a passing provider, a failing provider on the same chain, and a skipped (unsupported) chain in one run — proving one bad provider does not stop the others from being reported. - Keep the golden and checks modules crate-private; no consumer needs them (network and results stay public). - Drop the stale FCCT_ acronym from the test env-var name.
a1145b2 to
9031612
Compare
Pull request overviewExtracts the provider-probing logic, golden vectors, and per-chain checks out of the foreign-chain-config-tester CLI into a new foreign-chain-health-check library so the MPC node can reuse them without pulling in clap/serde_yaml/toml. Network gets a FromStr impl (plus ParseNetworkError) instead of clap::ValueEnum, and ProviderResult/Status move to a shared results module. The CLI keeps arg parsing, config-shape detection, and table rendering. Changes:
Reviewed changesPer-file summary
FindingsBlocking (must fix before merge):
Non-blocking (nits, follow-ups, suggestions):
Warning: Issues found |
anodar
left a comment
There was a problem hiding this comment.
Please have a look at Blocking findings from claude and either address or explain why it doesn't apply.
In this particular case, I believe it's false positive:
The new check_all_providers keeps that branch only for sui. Result: the CLI-rendered table previously included a - not configured row for every absent chain; now it silently omits every unconfigured chain except sui.
clearly other chains have same exact branch for emitting unconfigured chain log.
| #[arg(long, value_enum)] | ||
| /// Network the reference transactions belong to. Auto-detected from | ||
| /// the config (`chain_id` / `mpc_contract_id`) when omitted. | ||
| #[arg(long, value_name = "NETWORK")] |
There was a problem hiding this comment.
Why drop value_enum? Auto-detection of contract doesn't always work (e.g. dev clusters), and with value_enum it would probably show possible values [mainnet | testnet].
There was a problem hiding this comment.
I wanted to keep the new foreign-chain-health-check crate completely free of clap. Since Network is moved into the new crate, deriving value_enum would pull clap into the new crate as well. CLI crate is also not allowed to implement value_enum from the outside either in the current dependency setup.
I made sure that the custom error string still lists the valid values, and its generated based on the code values so it won't drift.
I do see that this is quite a lot of code to achieve a worse version of what clap already offers. Should I instead pull in clap as optional dependency in foreign-chain-health-check?
There was a problem hiding this comment.
You can avoid pulling clap in that library crate by having separate CLI enum in main.rs e.g. NetworkArg and then implement from trait for Network (type from foreign chain health check lib) to convert CLI Network Arg type into it.
There was a problem hiding this comment.
I think pulling in optional clap dependency is better here and implemented that 58380d5. I feel having a separate CLI enum does allow using clap's CLI features, but additionally need to introduce more code to make sure the CLI enum and the lib enum are in sync.
| @@ -0,0 +1,537 @@ | |||
| //! Foreign-chain RPC provider health checks: probe every configured provider | |||
| //! with a fixed golden request and report a per-provider result. | |||
There was a problem hiding this comment.
with a fixed golden request
Not for SUI though.
There was a problem hiding this comment.
is it not possible for SUI, or just not yet implemented?
There was a problem hiding this comment.
Not possible for SUI.
Sui is the exception: its providers prune
transactions after a few weeks, so the check instead verifies the provider's
chain identity and inspects a transaction from its latest checkpoint.
There was a problem hiding this comment.
Added comments about SUI being an exception
That review did apply to an earlier version, and the blockers were addressed in c689402 Do we only trigger Claude review on the first publish? |
you can re-trigger it using @claude review. |
Pull request overviewExtracts the provider-probing logic, golden vectors, and per-chain checks out of Re-review after Changes:
Reviewed changesPer-file summary
FindingsNon-blocking (nits, follow-ups, suggestions):
✅ Approved |

Part of #3764. The plan (stacked, merge bottom-up):
foreign-chain-health-checklibrary from the config-tester CLIconfigured/healthyPrometheus counts/debug/node_configMoves the golden vectors, per-provider checks, and
check_all_providersout of the CLI into a new production crate, so the node can reuse them without depending on the CLI (which pulls in clap/serde_yaml/toml). The extraction itself is behavior-neutral.Notes for reviewers:
clapout of the library,Networkis parsed via aFromStrimpl (dedicatedParseNetworkError) instead ofclap::ValueEnum, and the CLI takes--networkasOption<Network>directly. Accepted values are unchanged (mainnet/testnet); the only user-visible difference is the invalid-value error text (nowexpected one of: mainnet, testnet).