Architecture Overview
Dolphin enables Python-to-Solana development through a sophisticated compilation pipeline that transforms Python code into native Solana programs. This page explains how Dolphin works under the hood.
Key Concepts
Dolphin's architecture is built around three main principles:
Python Frontend: Provide a clean, Pythonic interface for defining Solana programs
IR-Based Transformation: Use an Intermediate Representation (IR) as a bridge between languages
Native Compilation: Generate standard Solana BPF bytecode for optimal performance
High-Level Overview
Components
Parser & IR Gen
Python
Convert Python to IR
parser.py
, ir_gen.py
IR Definitions
Both
Cross-language data contract
ir.py
(Py), ir.rs
(Rust)
Code Generator
Rust
Convert IR to Solana code
codegen.rs
Compiler Driver
Rust
Build pipeline management
mod.rs
, generator/
How It Works
Python Parsing: The Python parser reads your code and identifies Dolphin-specific decorators, types, and structures
IR Generation: Your program is converted into a language-agnostic intermediate representation (IR)
Rust Generation: The IR is transformed into Solana-compatible Rust code
BPF Compilation: Standard Solana tooling compiles the Rust code to BPF bytecode
Common Misconceptions
❌ "PyO3 is used to run Python on Solana" ✅ Reality: PyO3 is only used during development time to share IR definitions between the Python-based frontend and Rust-based compiler
❌ "Python code is directly executed on-chain" ✅ Reality: Python is compiled to standard Solana programs through multiple transformation stages
Last updated