Repository navigation
Description
Spun out of the multi-agent review on #1137 (type-design finding). Pre-existing; noting it while the resolver family is fresh.
Problem
The chain_ctx resolver structs carry contract addresses as unvalidated String, so every consumer must remember to parse them:
Resolved.capacity_bond_address: String(chain_ctx.rs:60) — re-parsed withparse_addressat three sites:register.rs:41,bond.rs:29,setup.rs:185ResolvedAppeal.slash_appeal_address: String(:163) — re-parsed atappeal.rs:31ResolvedPublish.{publisher_registry,origin_assignment}_address: Option<String>(:257-258) — each unwrapped + parsed inregistry_ctx/assignment_ctx(publish.rs:51,:77)
The invariant "a Resolved carries a usable address" is true in practice but not by construction. Nothing stops a new consumer from reading the String and skipping the parse.
The zero-address guard in resolve_appeal (chain_ctx.rs:188) is the sharpest symptom — it validates by string-munging:
anyhow::ensure!(
slash_appeal_address.trim_start_matches("0x").bytes().any(|b| b != b'0'),
"slash_appeal_address must not be the zero address — ..."
);Correct, but it's a stringly-typed stand-in for addr != Address::ZERO, and it emits the misleading "must not be the zero address" for an empty string.
Suggested fix
Change the fields to alloy::primitives::Address / Option<Address> and parse inside resolve / resolve_appeal / resolve_publish. These already return anyhow::Result<_>, so no new failure mode is introduced, and the labelled error is preserved by reusing the existing parse_address.
Payoff:
- Deletes the four duplicate parse sites for the required addresses.
- Turns the zero-address check into
ensure!(addr != Address::ZERO). - Makes "a
Resolvedholds a valid address" true by construction.
Keep the Option on ResolvedPublish — each publish subcommand legitimately needs only one of the two contracts, so requiring both would be wrong. The two ok_or_else messages in registry_ctx / assignment_ctx are correctly per-subcommand and should not be hoisted into the resolver; only the payload type changes (Option<String> → Option<Address>).
Out of scope for this issue
The other parse_address call sites (fetch.rs, channel.rs, bundle_pull.rs, and the --provider-address / operator-list parses) resolve from different structs or from raw user args, and are fine as-is.
Activity
chore: tech-debt batch — watcher comment rot, publish CLI dedup, watc…