feat(bridge): ERC-8004 Day 2 — registry_reader.py + web3.py mainnet wiring#22
Merged
Merged
Conversation
…iring Day 2 of 3-day MVP per docs/internal/monday-may18-scope.md task #86. Closes #86; #87 (Day 3) next. Shipped: - registry_reader.py — ERC8004RegistryReader class wrapping Web3 + the three registry contracts. read_entry(urn) / read_entry_by_id / entry_count / is_reachable. Web3 injected, not hidden, so tests use MagicMock without monkeypatching imports. - abi/erc8004_registry.json — minimal canonical ABI fragments (getEntry, entryCount, EntrySubmitted event) inferred from EIP-8004 semantics. Overridable via ERC8004_ABI_PATH env var. Final EIP-8004 ABI swap is a Day 3 fixture task. - abi/__init__.py — load_registry_abi() with override path support - tests/test_registry_reader.py — 13 unit tests using MagicMock Web3 + 1 live mainnet smoke test (skipped unless ETH_RPC_URL set, passes locally against Alchemy free tier confirming chain_id=1 and block > 25M). - pyproject.toml — web3>=6.15 + eth-account in [erc8004] optional deps (not a hard dep on the main backend; ERC-8004 bridge is opt-in via env config). - __init__.py — exports ERC8004RegistryReader, RegistryReadError, make_reader_from_env. Version bumped 0.0.1 -> 0.1.0. Test runs: - Unit (13/13 PASS, 1 skipped): pytest agentgraph_bridge_erc8004/tests/ - Live smoke (1/1 PASS against Alchemy mainnet): ETH_RPC_URL=... pytest -k TestLiveMainnetSmoke Day 3 (#87) will add attestation_normalizer.py (CTEF envelope parse + Ed25519 verification on the data field), score_ingest.py (feed normalized attestations into the composite trust score EXTERNAL: 0.35 slot), and integrate with src/trust/score.py. Day 3 fixtures (#88) capture 3 mainnet-shaped snapshot fixtures once real EIP-8004 contract addresses lock in.
AgentGraph Trust ScanSecurity Scan Grade: ? (0/100) — No summary available
Findings: 0 critical, 0 high, 61 medium, 0 low View full report | Add badge to README
|
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
Day 2 of the 3-day ERC-8004 bridge MVP. Wires
web3.pyagainst Ethereum mainnet so AgentGraph can read entries from the three EIP-8004 registries (Identity / Reputation / Validation) and surface them asERC8004EntryPydantic models for downstream normalization (Day 3).Closes #86. Day 3 (#87) lands
attestation_normalizer.py+score_ingest.py+src/trust/score.pyintegration next.Architecture decisions
ERC8004RegistryReader(web3, config)accepts aWeb3instance as a constructor argument. Tests passMagicMock. Production passesWeb3(HTTPProvider(alchemy_url)). No monkeypatching, no globals.AsyncHTTPProvider-backed variant is trivial to add later without changing the reader's public API.abi/erc8004_registry.jsonis the minimal canonical ABI inferred from EIP-8004 semantics (getEntry,entryCount,EntrySubmitted). Override viaERC8004_ABI_PATHenv var when the finalised EIP-8004 ABI lands. No hardcoded ABI tuples scattered through the code.web3+eth-accountland in[project.optional-dependencies].erc8004rather than as hard deps. The main backend stays lean; ERC-8004 is opt-in via env config +pip install agentgraph[erc8004].Test plan
subjectDid→Noneexists=false→RegistryReadErrorRegistryReadErrorentry_count()success + failure pathsis_reachable()for mainnet / chain-id mismatch / RPC downETH_RPC_URLis set (which it is in both dev + prod)What's NOT in this PR (Day 3 scope)
ERC8004_*_ADDRESSenv vars still point at placeholder zeros inconfig.py). Day 3 fixtures (#88) land these once the canonical EIP-8004 deployment is verified.datafield bytes (Day 3attestation_normalizer.py)src/trust/score.pycomposite score (EXTERNAL: 0.35slot, Day 3)Files changed
src/agentgraph_bridge_erc8004/registry_reader.py(new, 174 LoC)src/agentgraph_bridge_erc8004/abi/__init__.py(new, 24 LoC)src/agentgraph_bridge_erc8004/abi/erc8004_registry.json(new, 28 LoC)src/agentgraph_bridge_erc8004/tests/test_registry_reader.py(new, 196 LoC, 13 tests + 1 live smoke)src/agentgraph_bridge_erc8004/__init__.py(+exports, version 0.0.1 → 0.1.0)pyproject.toml(+[erc8004]optional deps)🤖 Generated with Claude Code