feat(cli): cross-check liquidator contract bytecode at startup (closes #399)#407
Merged
feat(cli): cross-check liquidator contract bytecode at startup (closes #399)#407
Conversation
053b694 to
5ffacc4
Compare
…#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.
5ffacc4 to
ea35e3b
Compare
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
verify_liquidator_deployed(provider, liquidator, chain_name, profile_tag)helper. Emptyeth_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).AaveFlashLoan::connect, only when both[flashloan.aave_v3_bsc]and[liquidator.<chain>]are configured. Scan-only chains skip by construction.provider.get_code_at(addr).block_id(BlockId::latest()).await.Test plan
cargo test -p charon-cli --bin charon verify_liquidator— 4/4 pass.cargo build -p charon-cliclean.cargo clippy -p charon-cli --tests -- -D warningsclean.Closes
#399
Follow-up
Wire the same check into
run_replayonce #395 lands. Replay never broadcasts so the operator impact is bounded; tracked separately.