Expand description
§Rialo Workflow Macro (V2 - syngen-generated parser)
This crate provides the rialo! procedural macro for generating Solana program interfaces and implementations
from high-level workflow definitions. The macro follows a classic compiler architecture pattern:
Parse → Model → Transform → Generate
§Architecture Overview
The compilation pipeline consists of four main phases:
- Parse (
parsemodule): Converts macro input tokens into an internal data model using syngen-generated parser - Model (
modelmodule): Provides the internal representation of workflow components - Transform (
transformmodule): Analyzes and transforms the model for code generation - Generate (
generatemodule): Produces Solana program code from the transformed model
§Key Concepts
- Workflow State: Persistent data structure that survives across async operations
- Workflow Program: Collection of functions that define the workflow’s behavior
- Function Types: Different categories of functions (initiating, handler, control, terminating, internal)
- Async Operations: Venus DSL syntax (AFTER, EVERY, ON, SEND, START) that are transformed into Solana program calls
- Resource Analysis: Automatic calculation of required Solana accounts based on async operations
§Input Format
ⓘ
rialo! {
state {
// Persistent state fields
field_name: Type,
}
program {
// Use statements and function definitions
use some_crate::SomeType;
initiating fn entry_point(&mut self, param: Type) -> ProgramResult {
// Function body with Venus DSL async syntax
}
handler fn async_callback(&mut self, data: Type) -> ProgramResult {
// Handler function body
}
}
}§Generated Code Structure
The macro generates two main modules:
interface: Instruction definitions and constructors (always generated)implementation: Program logic, state struct, and Solana entrypoint (feature-gated)
§Example Usage
ⓘ
use crate::workflow;
rialo! {
state {
counter: u64,
next_timestamp: u64,
}
program {
use rialo_s_program::entrypoint::ProgramResult;
initiating fn start(&mut self, frequency: u64) -> ProgramResult {
self.next_timestamp = self.unix_timestamp() as u64 + frequency;
AFTER self.next_timestamp seconds CALL self.tick();
Ok(())
}
handler fn tick(&mut self, _now: u64) -> ProgramResult {
self.counter += 1;
Ok(())
}
}
}Re-exports§
pub use model::Model;pub use model::WorkflowBlock;
Modules§
- generate
- generate_
client - Client crate generation for Venus programs.
- generate_
manifest - Venus Manifest generation for workflow testing
- generate_
rex_ wasm - Generate WASM component source code from rex block functions.
- generate_
server_ wit - Server-side WIT generation for Venus workflows
- model
- Model Module
- parse
- Parse Module
- transform
Functions§
- generate
- Generate Solana program code from a workflow model.
- parse_
from_ str - Parse a Venus DSL program from a string