docs: Add architecture section to CLAUDE.md#1318
Conversation
Added comprehensive Architecture section covering core contracts (HubPool, SpokePool, Chain Adapters), key roles (Depositor, Relayer, Data Worker, Disputer, LP), protocol flow, cross-chain ownership model, supported chains, and key libraries. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
nicholaspai
left a comment
There was a problem hiding this comment.
Some ideas for adding more nuanced descriptions. Thanks for taking the initiative on this!
CLAUDE.md
Outdated
|
|
||
| | Role | Description | | ||
| |------|-------------| | ||
| | **Depositor** | Calls `deposit()` on origin SpokePool to initiate a cross-chain transfer | |
There was a problem hiding this comment.
Maybe we shouldn't specify a specific function since there are multiple entry points to depositing now, including sponsored, gasless flows?
CLAUDE.md
Outdated
| |------|-------------| | ||
| | **Depositor** | Calls `deposit()` on origin SpokePool to initiate a cross-chain transfer | | ||
| | **Relayer** | Fills deposits on destination chain by fronting tokens, later reimbursed via merkle proof | | ||
| | **Data Worker** | Off-chain agent that aggregates deposits/fills, constructs merkle trees, and calls `proposeRootBundle()` on HubPool (stakes a bond) | |
There was a problem hiding this comment.
Importantly also validates not just aggregates
CLAUDE.md
Outdated
|
|
||
| ### Protocol Flow | ||
|
|
||
| 1. **Deposit**: User locks tokens in origin SpokePool → `FundsDeposited` event emitted |
There was a problem hiding this comment.
Sets the amount of fees that they're willing to pay to a filler who fulfills their deposit.
Importantly, the relayer has a decision to determine if the deposit is profitable or not.
I think the profitability decision matrix is maybe important to reference because it might help contributors to be aware that fair prices need to be communicated to depositors somehow, currently done through a hosted API service or directly from an exclusive filler.
I think this will help improve future iterations of these contracts as they really should be "quote API aware" for example
CLAUDE.md
Outdated
| | Role | Description | | ||
| |------|-------------| | ||
| | **Depositor** | Calls `deposit()` on origin SpokePool to initiate a cross-chain transfer | | ||
| | **Relayer** | Fills deposits on destination chain by fronting tokens, later reimbursed via merkle proof | |
There was a problem hiding this comment.
Maybe worth noting that relayers compete with each other on speed and also their ability to manage their cross chain inventory
CLAUDE.md
Outdated
|
|
||
| | Role | Description | | ||
| |------|-------------| | ||
| | **Depositor** | Calls `deposit()` on origin SpokePool to initiate a cross-chain transfer | |
There was a problem hiding this comment.
Also maybe worth noting the depositor is a just an end user, not technical, doesn't have any other requirements besides wanting to move money across chains
CLAUDE.md
Outdated
| |------|-------------| | ||
| | **Depositor** | Calls `deposit()` on origin SpokePool to initiate a cross-chain transfer | | ||
| | **Relayer** | Fills deposits on destination chain by fronting tokens, later reimbursed via merkle proof | | ||
| | **Data Worker** | Off-chain agent that aggregates deposits/fills, constructs merkle trees, and calls `proposeRootBundle()` on HubPool (stakes a bond) | |
There was a problem hiding this comment.
Maybe worth noting that the dataworker is supposed to be able to handle sending a lot of on chain requests across different chains with a relatively longer lookback window than the relayer is expected to maintain.
The dataworker unlike the relayer is not expected to be "fast" but they are rpc- and to a lesser extent, compute-, intensive
|
@claude add all the changes suggested by @nicholaspai |
|
Claude finished @fusmanii's task in 1m 29s —— View job Implementing review feedback
SummaryAll review feedback from @nicholaspai has been incorporated into CLAUDE.md: Key Roles table updates:
Protocol Flow updates:
Changes have been committed and pushed to the PR branch. |
- Note depositor is end user with multiple entry points (deposit/sponsored/gasless) - Add relayer competition details (speed and inventory management) - Expand data worker description to include validation and performance characteristics - Add depositor fee setting and relayer profitability evaluation details - Explain pricing communication via API services or exclusive relayers Co-authored-by: Faisal Usmani <fusmanii@users.noreply.github.com>
CLAUDE.md
Outdated
|
|
||
| ### Supported Chains | ||
|
|
||
| SpokePools exist for: Ethereum, Arbitrum, Optimism, Base, Polygon, Polygon zkEVM, zkSync, Scroll, Linea, Blast, Boba, Lisk, WorldChain, Ink, Lens, Mode, and others via `Universal_SpokePool` (generic OP Stack). |
There was a problem hiding this comment.
`Universal_SpokePool` (generic OP Stack).
This looks incorrect. Instead, it's a Spoke that can be used on any EVM-like chain: L2 or L1 by proving ongoing Ethereum state updates via ZK proofs
CLAUDE.md
Outdated
| - **CircleCCTPAdapter** — USDC bridging via Circle's CCTP (V1/V2), with burn-limit splitting for large transfers | ||
| - **OFTTransportAdapter** — Token bridging via LayerZero OFT standard | ||
| - **MerkleLib** — Merkle proof verification with bitmap tracking to prevent double-claiming | ||
| - **Lockable** — Custom reentrancy guard used across SpokePools |
There was a problem hiding this comment.
I feel like this section is a bit bad. These are not key libraries (IMO). And token space is important to save. I'd remove it or perhaps just point to a libraries folder or something
|
@fusmanii great addition! I've noticed a few more things that we might want to change in These are no longer numbered :maybe just point to the directory?
Same with This is a bit dubious (maybe make shorter)
|
Replace hardcoded chain list with pointer to broadcast/deployed-addresses.md and remove the Key Libraries section to keep the doc concise. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Faisal Usmani <faisal.of.usmani@gmail.com>
Signed-off-by: Faisal Usmani <faisal.of.usmani@gmail.com>
Signed-off-by: Faisal Usmani <faisal.of.usmani@gmail.com>
Signed-off-by: Faisal Usmani <faisal.of.usmani@gmail.com>
Summary
Added a comprehensive Architecture section to CLAUDE.md that explains the Across Protocol's hub-and-spoke design for new contributors.
This documentation helps developers understand how the protocol coordinates fast cross-chain transfers with optimistic verification.