fix(py): approve_attack_request + vyper verify version & query-ABI duplication#18
Open
Equious wants to merge 1 commit into
Open
fix(py): approve_attack_request + vyper verify version & query-ABI duplication#18Equious wants to merge 1 commit into
Equious wants to merge 1 commit into
Conversation
…y-ABI duplication
Three correctness fixes to battlechain-lib-py, found while verifying the
vyper-template flow live on testnet:
1. approve_attack_request (new) — mirrors JS `approveAttackRequest`. Self-approves a
pending attack request via the permissionless testnet MockRegistryModerator
(ATTACK_REQUESTED -> UNDER_ATTACK); raises on non-testnet. Adds the
`mock_registry_moderator_address` resolver, a `_boa` loader, and emits the
`MOCK_REGISTRY_MODERATOR_ABI` (the gen_abi ARTIFACTS map was missing
`registryModerator`, so the ABI was never generated — the root cause).
2. verify_contract vyper version — it sent a bare `v0.4.3`, but the explorer's
Sourcify verifier needs the full `0.4.3+commit.<hash>` (and no leading `v`) to
fetch the compiler; a bare version 404s ("Failed fetching vyper 0.4.3 for
platform linux"). Vyper verification never worked. Add `_resolve_vyper_version`
to derive the full version from the vyper releases mirror (as the explorer UI does).
3. query ABI duplication — `ATTACK_REGISTRY_QUERY_ABI` concatenated hand-written
copies of getAgreementState/getAgreementForContract/isTopLevelContractUnderAttack
onto an ATTACK_REGISTRY_ABI that (after regeneration) already contains them,
so boa raised "Ambiguous call to getAgreementState". It's now an alias.
All three verified live on testnet (approve -> UNDER_ATTACK; MockToken verified;
check_state returns UNDER_ATTACK). ruff clean, 33 tests pass.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Three
battlechain-lib-pycorrectness fixes, all found and verified live on testnet while exercising thevyper-templateflow end-to-end.1.
approve_attack_request(new) — Python↔JS parityJS exposes
approveAttackRequest; Python had no equivalent, so the vyper-template flow could never reachUNDER_ATTACK. Adds:safe_harbor.approve_attack_request(agreement)— self-approves via the permissionless testnetMockRegistryModerator(ATTACK_REQUESTED → UNDER_ATTACK); raises on non-testnet (mainnet approval is real DAO governance).config.mock_registry_moderator_address()resolver + a_boaloader.tools/gen_abi.py'sARTIFACTSmap omittedregistryModerator, soMOCK_REGISTRY_MODERATOR_ABIwas never generated. Added the mapping and regenerated.Verified live:
approve_attack_requestmoved a real agreement toUNDER_ATTACK (3).2.
verify_contractsent a malformed vyper versionIt submitted
v0.4.3— a bare version with a spuriousv. The explorer's Sourcify verifier fetches the compiler by version and needs the full0.4.3+commit.<hash>with no leadingv; a bare version 404s:Since the lib only supports
vyper-json, Vyper verification never worked. Added_resolve_vyper_version()to derive the fullX.Y.Z+commit.<hash>from the vyper releases mirror (same source the explorer UI uses;vyperdoesn't expose its commit hash at runtime). Falls back gracefully on lookup failure.Verified live: MockToken
0x1ce3…332E→✅ Verified.3.
ATTACK_REGISTRY_QUERY_ABIproduced duplicate entriesIt concatenated hand-written copies of
getAgreementState/getAgreementForContract/isTopLevelContractUnderAttackontoATTACK_REGISTRY_ABI— which (since the ABI was regenerated to include the read methods) already contains them. boa then raisedAmbiguous call to getAgreementState, breaking all three on-chain query helpers +check_state. Now a plain alias ofATTACK_REGISTRY_ABI.Verified live:
check_statereturnsUNDER_ATTACK (3).ruff clean; 33/33 tests pass.
🤖 Generated with Claude Code