Skip to content

feat(cli): cross-check liquidator contract bytecode at startup (closes #399)#407

Merged
obchain merged 2 commits intomainfrom
feat/399-liquidator-bytecode-check
May 2, 2026
Merged

feat(cli): cross-check liquidator contract bytecode at startup (closes #399)#407
obchain merged 2 commits intomainfrom
feat/399-liquidator-bytecode-check

Conversation

@obchain
Copy link
Copy Markdown
Owner

@obchain obchain commented May 2, 2026

Summary

  • New verify_liquidator_deployed(provider, liquidator, chain_name, profile_tag) helper. Empty eth_getCode → bail with deploy-context-aware remediation (fork: forge create + dev-0 nonce reset reminder; mainnet: verify configured address vs deploy receipt, do NOT redeploy without confirming).
  • Hooked into the venus pipeline assembly right before AaveFlashLoan::connect, only when both [flashloan.aave_v3_bsc] and [liquidator.<chain>] are configured. Scan-only chains skip by construction.
  • API: provider.get_code_at(addr).block_id(BlockId::latest()).await.
  • 4 httpmock tests covering: fork-mode empty bytecode + forge hint, mainnet-mode empty bytecode + config hint, non-empty bytecode passes, RPC error aborts with eth_getCode context.

Test plan

  • cargo test -p charon-cli --bin charon verify_liquidator — 4/4 pass.
  • cargo build -p charon-cli clean.
  • cargo clippy -p charon-cli --tests -- -D warnings clean.

Closes

#399

Follow-up

Wire the same check into run_replay once #395 lands. Replay never broadcasts so the operator impact is bounded; tracked separately.

@obchain obchain force-pushed the feat/399-liquidator-bytecode-check branch from 053b694 to 5ffacc4 Compare May 2, 2026 20:28
obchain added 2 commits May 3, 2026 02:03
…#399)

A misconfigured fork (skipped dev-0 nonce reset, wrong signer,
mismatched contract_address) silently produced "every simulation
reverts" with no operator-facing signal. New verify_liquidator_deployed
helper calls eth_getCode on the configured liquidator address at
startup; empty bytecode aborts with a deploy-context-aware remediation
hint (fork: re-run forge create + check dev-0 nonce reset; mainnet:
verify the configured address against the deploy receipt rather than
redeploying).

Hooked into the venus pipeline assembly right before AaveFlashLoan
connect, only when both [flashloan.aave_v3_bsc] and [liquidator.<chain>]
are configured. Scan-only chains skip by construction.

API: provider.get_code_at(addr).block_id(BlockId::latest()).await.
The explicit latest pin is kept despite alloy's default to keep intent
visible at the call site.

Four httpmock tests:
- empty_bytecode_on_fork_aborts_with_forge_hint
- empty_bytecode_on_mainnet_uses_config_hint_not_redeploy (locks in
  the deploy-context-aware message wording)
- non_empty_bytecode_passes
- rpc_error_aborts

dev-deps: httpmock, reqwest, url (already in workspace).

Follow-up tracked separately: wire the same check into run_replay
(#395) once that lands.
@obchain obchain force-pushed the feat/399-liquidator-bytecode-check branch from 5ffacc4 to ea35e3b Compare May 2, 2026 20:33
@obchain obchain merged commit 6b05dc2 into main May 2, 2026
4 checks passed
@obchain obchain deleted the feat/399-liquidator-bytecode-check branch May 2, 2026 20:39
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