# can1357/hl architecture

> Architecture diagram of the GitHub repository can1357/hl, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/can1357/hl
- Repository: https://github.com/can1357/hl

## Overview

hl-recon is a recovered-source map of the Hyperliquid node, not a buildable application. Its principal workflow is processing exchange actions during block execution and exposing resulting chain and market state through public info and EVM RPC interfaces. The graph also preserves consensus/gossip, trading, EVM state, and persistence as distinct capabilities. Many subsystem links are necessarily omitted: the tree and README establish their roles, but sampled excerpts do not show their runtime wiring.

Main entry points: [`l1/exchange/exchange.rs`](https://github.com/can1357/hl/blob/main/l1/exchange/exchange.rs) (Exchange engine), [`info_server/handle_request.rs`](https://github.com/can1357/hl/blob/main/info_server/handle_request.rs) (Info HTTP dispatch), [`l1/abci/engine.rs`](https://github.com/can1357/hl/blob/main/l1/abci/engine.rs) (ABCI execution), [`node/consensus/server.rs`](https://github.com/can1357/hl/blob/main/node/consensus/server.rs) (Consensus server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_execution["Block execution"]
  node_abci["ABCI execution<br/>[engine.rs]"]
  node_action_handlers["Action handlers"]
end

subgraph group_trading["Exchange and trading"]
  node_exchange["Exchange engine<br/>[exchange.rs]"]
  node_orderbook["Order books"]
  node_clearinghouse["Perp clearinghouse<br/>[clearinghouse.rs]"]
  node_spot["Spot clearinghouse"]
  node_dex["DEX registry<br/>[dex_registry.rs]"]
  node_qty["Quantity arithmetic<br/>[mod.rs]"]
end

subgraph group_node_network["Node and consensus"]
  node_consensus["Consensus server<br/>[server.rs]"]
  node_gossip_rpc["Gossip RPC<br/>[gossip_rpc.rs]"]
  node_gossip_client["Gossip client"]
  node_node_start["Node startup<br/>[startup.rs]"]
end

subgraph group_interfaces["Public interfaces"]
  node_info_request["Info request types<br/>[request.rs]"]
  node_info_dispatch["Info HTTP dispatch<br/>[handle_request.rs]"]
  node_info_routes["Info state routes"]
  node_evm_router["EVM method router<br/>[method_router.rs]"]
  node_evm_methods["EVM RPC methods<br/>[evm_rpc.rs]"]
  node_evm_forwarder["EVM write forwarder"]
  node_http_client["HTTP client<br/>[http_client.rs]"]
end

subgraph group_state["State and infrastructure"]
  node_evm_state["EVM state<br/>[evm_state.rs]"]
  node_db[("RocksDB wrappers<br/>[rocks_db.rs]")]
  node_block_reader["Block reader<br/>[block_reader.rs]"]
  node_db_home["Database home<br/>[db_home.rs]"]
end

node_client(("API clients"))
node_validators(("Validators and peers"))

node_client -->|"sends queries"| node_info_dispatch
node_info_dispatch -->|"dispatches requests"| node_info_request
node_info_dispatch -->|"routes queries"| node_info_routes
node_info_routes -->|"returns responses"| node_info_dispatch
node_client -->|"sends JSON-RPC"| node_evm_router
node_evm_router -->|"dispatches methods"| node_evm_methods
node_evm_methods -->|"forwards raw transactions"| node_evm_forwarder
node_evm_forwarder -.->|"uses HTTP client"| node_http_client
node_http_client -.->|"posts raw transactions"| node_evm_forwarder
node_validators -->|"participates in consensus"| node_consensus
node_consensus -.->|"handles gossip requests"| node_gossip_rpc
node_gossip_client -->|"sends RPC requests"| node_gossip_rpc
node_node_start -.->|"starts node services"| node_consensus
node_abci -->|"executes actions"| node_action_handlers
node_action_handlers -.->|"applies exchange actions"| node_exchange
node_exchange -.->|"updates orders"| node_orderbook
node_exchange -.->|"updates positions"| node_clearinghouse
node_exchange -.->|"applies spot actions"| node_spot
node_exchange -.->|"uses DEX registry"| node_dex
node_exchange -.->|"uses quantity types"| node_qty
node_abci -.->|"coordinates EVM state"| node_evm_state
node_abci -.->|"persists chain state"| node_db
node_db_home -.->|"manages database"| node_db
node_block_reader -.->|"reads blocks"| node_db

click node_abci "https://github.com/can1357/hl/blob/main/l1/abci/engine.rs"
click node_action_handlers "https://github.com/can1357/hl/tree/main/l1/exchange/handlers"
click node_exchange "https://github.com/can1357/hl/blob/main/l1/exchange/exchange.rs"
click node_orderbook "https://github.com/can1357/hl/blob/main/l1/book/book/impl_insert_order.rs"
click node_clearinghouse "https://github.com/can1357/hl/blob/main/l1/clearinghouse/clearinghouse.rs"
click node_spot "https://github.com/can1357/hl/blob/main/l1/spot_clearinghouse/spot_clearinghouse.rs"
click node_dex "https://github.com/can1357/hl/blob/main/l1/dex_registry/dex_registry.rs"
click node_qty "https://github.com/can1357/hl/blob/main/l1/qtys/mod.rs"
click node_consensus "https://github.com/can1357/hl/blob/main/node/consensus/server.rs"
click node_gossip_rpc "https://github.com/can1357/hl/blob/main/node/gossip_rpc.rs"
click node_gossip_client "https://github.com/can1357/hl/blob/main/node/gossip_rpc_client.rs"
click node_node_start "https://github.com/can1357/hl/blob/main/node/startup.rs"
click node_info_request "https://github.com/can1357/hl/blob/main/info_server/request.rs"
click node_info_dispatch "https://github.com/can1357/hl/blob/main/info_server/handle_request.rs"
click node_info_routes "https://github.com/can1357/hl/blob/main/info_server/abci_state_info_handler.rs"
click node_evm_router "https://github.com/can1357/hl/blob/main/evm_rpc/method_router.rs"
click node_evm_methods "https://github.com/can1357/hl/blob/main/evm_rpc/evm_rpc.rs"
click node_evm_forwarder "https://github.com/can1357/hl/blob/main/evm_rpc/evm_write_forwarder.rs"
click node_http_client "https://github.com/can1357/hl/blob/main/base/http_client.rs"
click node_evm_state "https://github.com/can1357/hl/blob/main/l1/evm/evm_state.rs"
click node_db "https://github.com/can1357/hl/blob/main/db/rocks_db.rs"
click node_block_reader "https://github.com/can1357/hl/blob/main/db/block_reader.rs"
click node_db_home "https://github.com/can1357/hl/blob/main/db/db_home.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_abci,node_action_handlers,node_client toneBlue
class node_exchange,node_orderbook,node_clearinghouse,node_spot,node_dex,node_qty toneAmber
class node_consensus,node_gossip_rpc,node_gossip_client,node_node_start toneMint
class node_info_request,node_info_dispatch,node_info_routes,node_evm_router,node_evm_methods,node_evm_forwarder,node_http_client toneRose
class node_evm_state,node_db,node_block_reader,node_db_home,node_validators toneIndigo
```

## Components

### Block execution

- [ABCI execution](https://github.com/can1357/hl/blob/main/l1/abci/engine.rs): `l1/abci/engine.rs`
- [Action handlers](https://github.com/can1357/hl/tree/main/l1/exchange/handlers): `l1/exchange/handlers`

### Exchange and trading

- [Exchange engine](https://github.com/can1357/hl/blob/main/l1/exchange/exchange.rs): `l1/exchange/exchange.rs`
- [Order books](https://github.com/can1357/hl/blob/main/l1/book/book/impl_insert_order.rs): `l1/book/book/impl_insert_order.rs`
- [Perp clearinghouse](https://github.com/can1357/hl/blob/main/l1/clearinghouse/clearinghouse.rs): `l1/clearinghouse/clearinghouse.rs`
- [Spot clearinghouse](https://github.com/can1357/hl/blob/main/l1/spot_clearinghouse/spot_clearinghouse.rs): `l1/spot_clearinghouse/spot_clearinghouse.rs`
- [DEX registry](https://github.com/can1357/hl/blob/main/l1/dex_registry/dex_registry.rs): `l1/dex_registry/dex_registry.rs`
- [Quantity arithmetic](https://github.com/can1357/hl/blob/main/l1/qtys/mod.rs): `l1/qtys/mod.rs`

### Node and consensus

- [Consensus server](https://github.com/can1357/hl/blob/main/node/consensus/server.rs): `node/consensus/server.rs`
- [Gossip RPC](https://github.com/can1357/hl/blob/main/node/gossip_rpc.rs): `node/gossip_rpc.rs`
- [Gossip client](https://github.com/can1357/hl/blob/main/node/gossip_rpc_client.rs): `node/gossip_rpc_client.rs`
- [Node startup](https://github.com/can1357/hl/blob/main/node/startup.rs): `node/startup.rs`

### Public interfaces

- [Info request types](https://github.com/can1357/hl/blob/main/info_server/request.rs): `info_server/request.rs`
- [Info HTTP dispatch](https://github.com/can1357/hl/blob/main/info_server/handle_request.rs): `info_server/handle_request.rs`
- [Info state routes](https://github.com/can1357/hl/blob/main/info_server/abci_state_info_handler.rs): `info_server/abci_state_info_handler.rs`
- [EVM method router](https://github.com/can1357/hl/blob/main/evm_rpc/method_router.rs): `evm_rpc/method_router.rs`
- [EVM RPC methods](https://github.com/can1357/hl/blob/main/evm_rpc/evm_rpc.rs): `evm_rpc/evm_rpc.rs`
- [EVM write forwarder](https://github.com/can1357/hl/blob/main/evm_rpc/evm_write_forwarder.rs): `evm_rpc/evm_write_forwarder.rs`
- [HTTP client](https://github.com/can1357/hl/blob/main/base/http_client.rs): `base/http_client.rs`

### State and infrastructure

- [EVM state](https://github.com/can1357/hl/blob/main/l1/evm/evm_state.rs): `l1/evm/evm_state.rs`
- [RocksDB wrappers](https://github.com/can1357/hl/blob/main/db/rocks_db.rs): `db/rocks_db.rs`
- [Block reader](https://github.com/can1357/hl/blob/main/db/block_reader.rs): `db/block_reader.rs`
- [Database home](https://github.com/can1357/hl/blob/main/db/db_home.rs): `db/db_home.rs`

### Other components

- **API clients**
- **Validators and peers**

## Connections

- API clients → Info HTTP dispatch: sends queries
- Info HTTP dispatch → Info request types: dispatches requests (evidence: `info_server/handle_request.rs`)
- Info HTTP dispatch → Info state routes: routes queries (evidence: `info_server/handle_request.rs`)
- Info state routes → Info HTTP dispatch: returns responses (evidence: `info_server/abci_state_info_handler.rs`)
- API clients → EVM method router: sends JSON-RPC
- EVM method router → EVM RPC methods: dispatches methods (evidence: `evm_rpc/method_router.rs`)
- EVM RPC methods → EVM write forwarder: forwards raw transactions (evidence: `evm_rpc/evm_rpc.rs`)
- EVM write forwarder → HTTP client: uses HTTP client
- HTTP client → EVM write forwarder: posts raw transactions
- Validators and peers → Consensus server: participates in consensus
- Consensus server → Gossip RPC: handles gossip requests
- Gossip client → Gossip RPC: sends RPC requests (evidence: `node/gossip_rpc_client.rs`)
- Node startup → Consensus server: starts node services
- ABCI execution → Action handlers: executes actions (evidence: `l1/abci/engine.rs`)
- Action handlers → Exchange engine: applies exchange actions
- Exchange engine → Order books: updates orders
- Exchange engine → Perp clearinghouse: updates positions
- Exchange engine → Spot clearinghouse: applies spot actions
- Exchange engine → DEX registry: uses DEX registry
- Exchange engine → Quantity arithmetic: uses quantity types
- ABCI execution → EVM state: coordinates EVM state
- ABCI execution → RocksDB wrappers: persists chain state
- Database home → RocksDB wrappers: manages database
- Block reader → RocksDB wrappers: reads blocks
