Skip to content

fix(core): reject zero-address liquidator in validate()#304

Closed
obchain wants to merge 1 commit into
mainfrom
fix/validate-zero-addr-liquidator
Closed

fix(core): reject zero-address liquidator in validate()#304
obchain wants to merge 1 commit into
mainfrom
fix/validate-zero-addr-liquidator

Conversation

@obchain
Copy link
Copy Markdown
Owner

@obchain obchain commented Apr 23, 2026

Summary

  • Local-mainnet validator caught that Config::validate skipped a non-zero check on liquidator.contract_address. Default config ships 0x0; eth_call to address zero returns empty bytes (no revert), so the simulator silently "passed" any calldata — a false-positive gate to live submission.
  • Added ConfigError::ZeroAddressLiquidator, firing in validate() when contract_address == Address::ZERO && !allow_public_mempool. Overloads the existing allow_public_mempool flag as the dev / testnet escape hatch (same operational footing as the private-RPC rule).

Stacking

Base: fix/config-unblock-startup (PR #303). Must merge #303 first.

Trace (live-mainnet start with placeholder address)

  1. Operator ships contract_address = 0x0...0, allow_public_mempool = false (default).
  2. validate() -> PrivateRpcRequired check passes (private RPC set), then ZeroAddressLiquidator fires.
  3. Start aborts with actionable error naming the chain.
  4. Dev/testnet path: set allow_public_mempool = true, both checks skipped.

Check ordering

PrivateRpcRequired fires before ZeroAddressLiquidator — locked by a new ordering test. Rationale: env-var fix is more actionable than a contract deploy.

Test plan

  • cargo test -p charon-core config:: -> 14/14 pass (3 new + test helper refactor)
  • cargo build --workspace clean
  • blockchain-code-reviewer: APPROVE (no blockers; #[non_exhaustive] leaves room for a future allow_placeholder_liquidator split)
  • Reviewer sign-off before merge

eth_call to address(0) returns empty bytes (no revert), so a config
that ships with liquidator.contract_address = 0x0 let the simulator
silently "pass" for any calldata, producing a false-positive gate to
live submission. Add ConfigError::ZeroAddressLiquidator, gated on
!allow_public_mempool so local anvil / testnet runs before a real
deploy still work.

Refactor test helper base_config(_, bool) -> base_config(_, Option<Address>)
plus a nonzero_liquidator sentinel so existing tests stay focused on
the rule they actually exercise.
@obchain
Copy link
Copy Markdown
Owner Author

obchain commented Apr 24, 2026

Absorbed into main:

@obchain obchain closed this Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant