Skip to content

feat(bridge): ERC-8004 Day 2 — registry_reader.py + web3.py mainnet wiring#22

Merged
kenneives merged 1 commit into
mainfrom
feat/erc8004-day2-registry-reader
May 22, 2026
Merged

feat(bridge): ERC-8004 Day 2 — registry_reader.py + web3.py mainnet wiring#22
kenneives merged 1 commit into
mainfrom
feat/erc8004-day2-registry-reader

Conversation

@kenneives
Copy link
Copy Markdown
Member

Summary

Day 2 of the 3-day ERC-8004 bridge MVP. Wires web3.py against Ethereum mainnet so AgentGraph can read entries from the three EIP-8004 registries (Identity / Reputation / Validation) and surface them as ERC8004Entry Pydantic models for downstream normalization (Day 3).

Closes #86. Day 3 (#87) lands attestation_normalizer.py + score_ingest.py + src/trust/score.py integration next.

Architecture decisions

  • Web3 injected, not hiddenERC8004RegistryReader(web3, config) accepts a Web3 instance as a constructor argument. Tests pass MagicMock. Production passes Web3(HTTPProvider(alchemy_url)). No monkeypatching, no globals.
  • Async-ready, sync-default — Day 2 ships a synchronous reader because the trust score recompute job (which will consume this in Day 3) is already sync. An AsyncHTTPProvider-backed variant is trivial to add later without changing the reader's public API.
  • ABI as overridable artifactabi/erc8004_registry.json is the minimal canonical ABI inferred from EIP-8004 semantics (getEntry, entryCount, EntrySubmitted). Override via ERC8004_ABI_PATH env var when the finalised EIP-8004 ABI lands. No hardcoded ABI tuples scattered through the code.
  • Optional dependencyweb3 + eth-account land in [project.optional-dependencies].erc8004 rather than as hard deps. The main backend stays lean; ERC-8004 is opt-in via env config + pip install agentgraph[erc8004].

Test plan

  • Unit tests with mocked Web3: 13/13 PASS, 1 live skipped
    • URN parsing across all 3 registries
    • Negative entry_id rejection
    • Empty subjectDidNone
    • exists=falseRegistryReadError
    • RPC connection exception wrapped to RegistryReadError
    • entry_count() success + failure paths
    • is_reachable() for mainnet / chain-id mismatch / RPC down
  • Live mainnet smoke against Alchemy free tier: 1/1 PASS
    • Confirms RPC responds, chain_id=1, block height > 25M
    • Skipped by default; runs when ETH_RPC_URL is set (which it is in both dev + prod)
$ cd /tmp/agbridge-test && python3 -m pytest agentgraph_bridge_erc8004/tests/test_registry_reader.py -v
================== 13 passed, 1 skipped, 2 warnings in 0.46s ===================

$ ETH_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/<KEY> python3 -m pytest -k TestLiveMainnetSmoke
======================== 1 passed, 2 warnings in 0.67s =========================

What's NOT in this PR (Day 3 scope)

  • Actual EIP-8004 mainnet contract addresses (ERC8004_*_ADDRESS env vars still point at placeholder zeros in config.py). Day 3 fixtures (#88) land these once the canonical EIP-8004 deployment is verified.
  • CTEF envelope parsing of the data field bytes (Day 3 attestation_normalizer.py)
  • Ed25519 signature verification on embedded CTEF attestation (Day 3)
  • Integration with src/trust/score.py composite score (EXTERNAL: 0.35 slot, Day 3)
  • 3 mainnet snapshot fixtures for offline reproduction (Day 3 #88)

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

…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.
@github-actions
Copy link
Copy Markdown

AgentGraph Trust Scan

Security Scan Grade: ? (0/100) — No summary available

Category Score

Findings: 0 critical, 0 high, 61 medium, 0 low

View full report | Add badge to README

This is a code security scan score. Full composite trust score (including identity verification and external signals) is available on AgentGraph.

@kenneives kenneives merged commit 6501e46 into main May 22, 2026
4 of 5 checks passed
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