fix(core): reject zero-address liquidator in validate()#304
Closed
obchain wants to merge 1 commit into
Closed
Conversation
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.
This was referenced Apr 23, 2026
Owner
Author
|
Absorbed into main:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Config::validateskipped a non-zero check onliquidator.contract_address. Default config ships0x0;eth_callto address zero returns empty bytes (no revert), so the simulator silently "passed" any calldata — a false-positive gate to live submission.ConfigError::ZeroAddressLiquidator, firing invalidate()whencontract_address == Address::ZERO && !allow_public_mempool. Overloads the existingallow_public_mempoolflag 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)
contract_address = 0x0...0,allow_public_mempool = false(default).validate()->PrivateRpcRequiredcheck passes (private RPC set), thenZeroAddressLiquidatorfires.allow_public_mempool = true, both checks skipped.Check ordering
PrivateRpcRequiredfires beforeZeroAddressLiquidator— 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 --workspacecleanblockchain-code-reviewer: APPROVE (no blockers;#[non_exhaustive]leaves room for a futureallow_placeholder_liquidatorsplit)