How regolith-labs/ore works
Main Components
• API Layer (located in the “api” directory):
• Contains modules such as consts, error, event, instruction, and a “state” sub-folder.
• Exposes model definitions and helpers (e.g., SDK to interact with the on-chain program) as well as state management.
• On-chain Program (located in the “program” directory):
• Implements individual instruction handlers that represent distinct operations (Claim, Close, Open, Mine, Reset, Update, and Initialize).
• State Accounts (in “api/src/state”):
• Bus: Tracks and limits the amount of mined ORE per epoch.
• Config: Singleton managing program-wide settings.
• Proof: Per-miner account tracking the hash and stake.
• Treasury: Singleton for minting ORE and holding user stakes.
• Security Audits:
• Though separate, the provided PDF audit documents serve as additional reference points for security considerations in your architecture.
• Testing & Deployment Tools:
• The project includes Cargo and toolchain configs for building and testing with Solana.
Understand the Relationships and Interactions
• The API layer acts as an interface or façade through which external clients can interact with the blockchain program. It encapsulates the program-level instructions and provides support functionality (constants, errors, events).
• The Program instructions (each in their separate module) are the actual on-chain handlers that execute core functions. They modify or read the state accounts.
• Each instruction has a clearly defined role (for example, “Mine” verifies a hash then increments a miner’s balance, whereas “Initialize” sets up global accounts). The interactions between these instructions and the state accounts need to be depicted.
Architectural Patterns & Design Principles
• The state account model is clearly central to the system – representing persistent blockchain data such as miner proofs and treasury balances.
• A modular design is used, with each instruction encapsulated in its own module.
• There is an emphasis on clarity and traceability of operations (e.g., from initializing the program to updating state).
○ A group labeled “State Accounts” containing Bus, Config, Proof, Treasury.
○ Illustrate data flow from the API layer to each Program instruction, indicating that external inputs (or client interactions via the SDK/API) trigger these instructions.
• Optionally, you could also include blocks for testing (e.g., “cargo test-sbf” process) and note security audits as external document review/validation points.
Final Checklist
• Clear and descriptive labels for each component (e.g., “API – SDK & Helper Functions”, “Program – Claim Instruction”, “State – Bus Account”).