Skip to content

Latest commit

 

History

History

server

Ogmios (Server)

Synopsis

Ogmios is a webserver which acts as a proxy for talking to a cardano-node. Upon request, it establishes a node-to-client connection with a Cardano node and forward messages from a client application to the node (and vice-versa). Ogmios aims to be as capable as a Cardano node (w.r.t. node-to-client protocols). Yet, since the internals are statically typed, new additions in the node (e.g. new queries) needs to be mapped correctly internally and, translated as JSON.

Ogmios does a little more than that, as it offers also some monitoring capabilities and embeds an HTTP server.

Architecture

Ogmios is constructed as a three-layer Haskell cake, which aims at being a simple and maintainable architecture for Haskell applications. Effects are separated from the business logic, and the entire application is stitched together in a very thin layer.

Server Architecture Diagram

Modules Overview

Top-Level

Where top-level code lies, stitching together the various parts of the applications and exposing a high-level interface for building an executable.

Modules
             ^  ─── Ogmios.hs
             |      ├── Options.hs
Application  |      ├── Prelude.hs
             v      └── Version.hs
Data

Contains data-structures and non-effectful code. Since Ogmios is mainly a codec translation layer, this is where most of the code (75%) lies. In particular, all the JSON encoders and decoders are defined here, as well as the JSON-WSP machinery behind all requests and responses.

Modules
             ^  ─── Data
             |       ├── EraTranslation.hs
             |       ├── Health.hs
             |       ├── Json.hs
             |       ├── Json
             |       │   ├── Prelude.hs
             |       │   ├── Orphans.hs
             |       │   ├── Query.hs
             |       │   ├── Byron.hs
             |       │   ├── Shelley.hs
             |       │   ├── Allegra.hs
             |       │   ├── Mary.hs
             |       │   ├── Alonzo.hs
       Data  |       │   └── Babbage.hs
             |       ├── Metrics.hs
             |       ├── Protocol.hs
             |       └── Protocol
             |           ├── ChainSync.hs
             |           ├── StateQuery.hs
             |           ├── TxMonitor.hs
             v           └── TxSubmission.hs
App

Effectful code written leveraging Haskell's type-class as an effect system. This is where the client-side (where cardano-node acts as a server) implementation of ouroboros mini-protocols resides. This is also where we define the HTTP server and WebSocket server handlers.

Modules
             ^  ─── App
             |      ├── Health.hs
             |      ├── Metrics.hs
             |      ├── Configuration.hs
             |      ├── Protocol.hs
             |      ├── Protocol
             |      │   ├── ChainSync.hs
      Logic  |      │   ├── StateQuery.hs
             |      │   ├── TxMonitor.hs
             |      │   └── TxSubmission.hs
             |      ├── Server.hs
             |      └── Server
             |          ├── Http.hs
             |          └── WebSocket.hs
             v
Control

A thin abstraction layer for I/O effects. This is based off io-sim with a few additions custom to Ogmios. The goal of these modules isn't to be a generic all-purpose I/O abstraction, but rather, something tailored to the project, that defines a clear interface for effects and that encapsulate their actual interpretation in one place. This allows for the rest of the code to remains mostly IO-free.

Modules
             ^  ─── Control
             |      ├── Exception.hs
             |      ├── MonadAsync.hs
             |      ├── MonadClock.hs
    Effects  |      ├── MonadLog.hs
             |      ├── MonadMetrics.hs
             |      ├── MonadOuroboros.hs
             |      ├── MonadSTM.hs
             v      └── MonadWebSocket.hs