HitchhikersFintech The Hitchhiker's Guide to Fintech Jakub Jakub Liška @ Pragmaxim                 Specialisation                • distributed data processing                • blockchains                                 Stack                • Scala ecosystem                • ZIO                • Akka-based implementations of CQRS                                 Ideally sustainable, green, meaningful software                that makes the world a better place.             Shared Shared traits of Centralized & Decentralized worlds                • Settlement between all involved parties                  ◦ all parties reach consensus about State                  ◦ finality = time required to reach consensus                  ◦ throughput = how many txs/s                • Event Sourcing — causality-based, replayable                  sequence of action & reaction                • Transaction Log Account Balances                  ◦ Tx = container of asset transfers between accounts                  ◦ Asset = anything of value, ownership                  ◦ Account = balance, container of assets                • Projections of the Tx Log for better insights             Jakub->Shared Paradigm Paradigm shift through analogy                 What software reminds me of:                                • Centralized — totalitarian state and                  centrally-controlled economy                • Decentralized — democratic state and                  free economy (slightly utopian)                • Hybrid — realistic balance and sustainability             Shared->Paradigm CentralBanking Centralized Banking                 WW II (Bretton Woods system)                • 3 decades of regulation, fixed rates worldwide                • Provided some financial stability                                 1970s – 2008 — deregulation                • 1970s: Nixon shock, floating rates, end of gold standard                • 1980s: derivatives, junk bonds                • 1990s: securitization, subprime mortgages                                 2008+ — printing money                • tx volume growing exponentially since Web 2.0             Shared->CentralBanking DecentralBanking Decentralized Banking                 Satoshi Nakamoto                • academia + years of Fintech work                • democratised, open-sourced banking                • inspired by decentralised file sharing                                 2nd-gen blockchains                • self-governance — DAO                • general-purpose, rich smart contracts                • sustainability issues & bottlenecks                                 3rd-gen blockchains                • high throughput, low finality (Solana, Avalanche)                  ◦ merkle-tree DB replacing RocksDB                • Relay-chain & Para-chain combination                  ◦ sustainability             Shared->DecentralBanking AssetCustody Asset Custody — bridge between worlds                • Robust multi-client wallet backed by DB                • Classic cryptography — PGP, BouncyCastle                • github.com/pragmaxim/zio-pass                • github.com/pragmaxim/scalapass-cli             Shared->AssetCustody Compare Centralized vs Decentralized Paradigm->Compare CEFI CEFI — Centralized Finance                SWIFT — connecting the global financial community             CentralBanking->CEFI ModernCore Modern Centralized Core Architecture in Scala                • CQRS — Scala/Akka has the framework built-in                  ◦ causality (action/reaction), FSM in-memory State                  ◦ real-time State, accessible directly                • Actors (entities) sharded across cluster nodes                • Each actor sources its own transactions                  ◦ builds account balance in-memory (fast)                • Each Tx feeds general Projections                  ◦ Projections are part of the design             CentralBanking->ModernCore CentralStandards Centralized Standards                Many specifications emerged over time:                                • ISO 20022 — unified messaging format                • FIX — real-time messaging format                • FpML — describes financial products                • CBPR+ — cross-border payments                  framework by CPMI & IOSCO                • ISDA — Swaps and Derivatives Association                • PCI DSS — payment-card data security             CEFI->CentralStandards CQRS CQRS — Command-Query-Responsibility-Segregation                • Ideal use-case for a distributed Actor System                  ◦ centralized on a single cluster                  ◦ akka-persistence + query                  ◦ actor per Account / Entity (in-memory State)                  ◦ not forced into message-driven architecture                • Inspired by Lagom & Aecor (both discontinued)                • ZIO Entity, EventSourced, EventStore — discontinued             ModernCore->CQRS CentralProblems Centralized problems                • Settlement layer — complex nightmare                  ◦ Visa Tx finality up to 3 days · ~2% fee                  ◦ new parties / banks cannot easily join                • Inconsistency                  ◦ rely on database ACID + thorough tests                  ◦ no cryptographic proofs                • A lot of State — bad for FP                • Privacy concerns             CQRS->CentralProblems UnbalancedCluster Unbalanced Cluster Distribution                 Problem                • Nodes carry different concentrations of whales & sharks                  ◦ pay-for-service transactions                  ◦ day trading                ⇒ performance issues, bottlenecks, replay-time variance                                 Solution                • rank-based cluster rebalancing             CQRS->UnbalancedCluster UnbalancedData Unbalanced Data Distribution                • PostgreSQL — custom optimisations / pagination                • Cassandra — hash / time / range partitioning                  + denormalisation                • Cloud storage at $: BigTable, BigQuery             CentralProblems->UnbalancedData DecentralCore Decentralized Core Architecture in Scala                • Peer-to-peer network & stateless nodes — ideal for ZIO                • Blockchain and Projections are separated                  ◦ Blockchain = TxLedger + AccountState (zio-chain)                  ◦ Projections = Blockchain Explorer (uexplorer)                • TxLedger + AccountState are provably correct                  and consistent across the whole p2p network             DecentralBanking->DecentralCore DApps Decentralized Apps                Smart-contracts as building blocks of finance                — composable, permissionless, auditable on-chain.             DecentralBanking->DApps Relay Relay & Para Chains                 How sustainability is achieved — through further decentralisation.             DecentralCore->Relay CryptoProofs Crypto proofs for fast consensus                • Merkelized Trie Database (Firewood)                • Patricia Merkle Trie on RocksDB (Trie-db)                • Authenticated Dynamic Dictionaries (AVL+ tree)             Relay->CryptoProofs Explorer Blockchain Explorer decentralization                • Indexes chain data, exposes HTTP API / GraphQL                • Often provides analytical insights                                 Centralized                • Powerful projection DB                • Hard to incentivise people to run it                                 Decentralized — The Graph                • Incentivisation model                • Inversion of control — index what you need                • Subgraphs over only relevant chain parts                                 Indexing challenges                • Forks, rollbacks, reverting data                • Various tx formats & assets                • Partition size (Cassandra), JOINs (RDBMS)             Relay->Explorer Advantages Advantages of decentralization                • Clean standards of Settlement / Consensus layer                  ◦ in a peer-to-peer network                  ◦ any party can join                  ◦ good for FP — only Mempool + Peers as State                • Fast finality — Solana, Avalanche                • Consistency — provably correct data structures                  ◦ Merkle-tree database (Firewood)                • Privacy                  ◦ users own the data                  ◦ ZK proofs, ring signatures             Relay->Advantages ChainStandards Blockchain Standards                 Global, open set of standards — reminds of democracy.             DApps->ChainStandards
Overview
0 / 0
Space next · prev · Home overview · End last · 19 jump · Z zoom out · H hide chrome · F fullscreen