Service Structure
Jade currently supports two types of services: authorizer service and general service, there is also corevm service supported in our toolkit but it has not been
official integrated in JAM implementations yet.
[no_std]: we need to avoid standard rust library on buildingriscv64services for making our compiled binaries compatible with the JAM virtual machines.#[jade::is_authorized]: the entrypoint of theis_authorizedlogic.#[jade::refine]: the entrypoint of therefinelogic.#[jade::accumulate]: the entrypoint of theaccumulatelogic.
Note that authorizer service and general service are different service types, you cannot declare both
#[jade::is_authorized]and#[jade::refine](or#[jade::accumulate]) in the same service.
Authorizer Service
#![allow(unused)] #![cfg_attr(target_arch = "riscv64", no_std)] fn main() { use jade::prelude::{AuthTrace, CoreIndex}; #[jade::is_authorized] fn is_authorized(_core_index: CoreIndex) -> AuthTrace { Default::default() } }
General Service
#![allow(unused)] #![cfg_attr(target_arch = "riscv64", no_std)] fn main() { use jade::prelude::{AuthTrace, CoreIndex}; #[jade::refine] fn refine( core: u16, index: u16, id: u32, payload: Vec<u8>, package_hash: OpaqueHash, ) -> Vec<u8> { // ... refine logic here } #[jade::accumulate] fn accumulate(now: u32, id: u32, results: Vec<Operand>) -> Option<OpaqueHash> { // ... accumulate logic here } }