This is a high-level rundown of the architecture of the elixir-omg
apps.
The below diagram demonstrates the various pieces and where this umbrella app fits in. NOTE only use the high-level diagram to get a vague idea, meaning of boxes/arrows may be imprecise.
Diagram illustrates the interactions described below.
This lists only interactions between the different processes that build up both the Child Chain Server and Watcher.
For responsibilities of the processes/modules look into respective docs in .ex
files.
NOTE:
- for
OMG
modules/processes look inapps/omg
- for
OMG.ChildChain
modules/processes look inapps/omg_child_chain
- for
OMG.Watcher
modules/processes look inapps/omg_watcher
- for
OMG.Eth
look inapps/omg_eth
- for
OMG.DB
look inapps/omg_db
- for
OMG.Performance
look inapps/omg_performance
- for
OMG.RPC
look inapps/omg_rpc
NOTE 2 The hexagonal shape hints towards component being a wrapper (port/adapter) to something external, versus rectangular shape being an internal component.
- writes blocks and UTXO set to
OMG.DB
- pushes freshly formed blocks to
OMG.ChildChain.FreshBlocks
- accepts child chain transactions, decodes, stateless-validates and executes on
OMG.State
- forwards
get_block
requests toOMG.ChildChain.FreshBlocks
- reverts to reading
OMG.DB
for old blocks
- reads Ethereum block height from
OMG.Eth
- synchronizes view of Ethereum block height of all enrolled processes (see other processes descriptions)
Actually OMG.EthereumEventListener
setup with :exiter
.
NOTE there's a multitude of exiter-related processes, which work along these lines, we're not listing them here
- pushes exit-related events to
OMG.State
on child chain server's side - pushes exit-related events to
OMG.Watcher.ExitProcessor
on watcher's side - pushes exit-related events to
WatcherDB
Actually OMG.EthereumEventListener
setup with :depositor
.
- pushes deposits to
OMG.State
- pushes deposits to
WatcherDB
- requests
form_block
onOMG.State
and takes block hashes in return - tracks Ethereum height and child chain block submission mining via
OMG.Eth
andOMG.RootChainCoordinator
OMG.ChildChain
calls it to get acceptable currencies and actual fee amounts to validate transactions
- tracks child chain blocks via
OMG.RootChainCoordinator
- manages concurrent
Task
's to pull blocks from child chain server API (JSON-RPC) - pushes decoded and statelessly valid blocks to
OMG.State
- pushes statefully valid blocks and transactions (acknowledged by
OMG.State
above) toWatcherDB
- emits block, transaction, consensus events to
OMG.Watcher.Eventer
- stops if
OMG.Watcher.ExitProcessor
reports a dangerous byzantine condition related to exits
- get various Ethereum events from
OMG.EthereumEventListener
- used only in Watcher
- validates exits
- emits byzantine events to
OMG.Watcher.Eventer
- spends finalizing exits in
OMG.State
- uses data stored in the
WatcherDB
to server user's requests - subscribes to event buses to
OMG.Watcher.Eventer
- pushes events to
Phoenix app
- exposes
OMG.ChildChain
(as configured by:omg_rpc, :child_chain_api_module
setting) via aphoenix
-driven HTTP-RPC interface
- executes requests to
OMG.RPC
- forces block forming by talking directly to
OMG.State
The confusing (and to be probably amended in the future) part is that we have two databases
An "intimate" database for OMG.State
that holds the UTXO set and blocks.
May be seen and read by other processes to sync on the persisted state of OMG.State
and UTXO set by consequence.
Non-relational data, so we're having a simple KV for this.
Implemented with leveldb
via ExlevelDB
, possibly to be swapped out for anything better in the future.
Each instance of either Child Chain Server or Watcher should have it's own instance.
Database necessary to properly ensure validity and availability of blocks and transactions
- it is read by
OMG.State
to discover the UTXO set on restart - it is read by many other processes to discover where they left off, on restart
A convenience database running alongside the Watcher only. Holds all information necessary to manage the funds held:
- UTXOs owned by user's particular address(es)
- all transactions to be able to challenge
- transaction history
Relational data, to be able to navigate through the transactions and UTXOs.
Implemented with Postgres (SQLite for test runs).
This database might be shared between Watchers, e.g. when it pertains to a single wallet provider running multiple eWallet
instances for scaling.