Skip to main content
Version: dev

Data Bus

The data bus is an optimization that the backend can use to make recursion more efficient. In order to use it, you must define some inputs of the program entry points (usually the main() function) with the call_data modifier, and the return values with the return_data modifier. These modifiers are incompatible with pub and mut modifiers.

Example

fn main(mut x: u32, y: call_data(0) u32, z: call_data(0) [u32; 4]) -> return_data u32 {
let a = z[x];
a + y
}

Each call_data parameter takes an identifier (call_data(<id>) T) which groups parameters into the same call-data array — parameters sharing an identifier end up in the same read-only array, while different identifiers produce independent ones.

As a result, both call_data and return_data will be treated as private inputs and encapsulated into a read-only array each, for the backend to process.