spacejam_service/vm/
accumulate.rs

1//! Primitives for the accumulate invocation
2
3use crate::{BTreeMap, Gas, OpaqueHash, ServiceId, Vec, service::WorkExecResult};
4use serde::{Deserialize, Serialize};
5
6/// The commitment map
7pub type CommitmentMap = BTreeMap<ServiceId, OpaqueHash>;
8
9/// The accumulate params for the accumulation
10#[derive(Serialize, Deserialize, Debug)]
11pub struct AccumulateParams {
12    /// (N_t)  timeslot for the current accumulation
13    #[serde(with = "codec::compact")]
14    pub slot: u32,
15
16    /// (N_s)  the service id of the caller
17    #[serde(with = "codec::compact")]
18    pub id: u32,
19
20    /// (|o|) The count of operands
21    #[serde(with = "codec::compact")]
22    pub results: u32,
23}
24
25/// An operand of the accumulation
26///
27/// NOTE: we are currently following the order of jam-types instead
28/// of graypaper.
29///
30/// defined per GP (12.19)
31#[derive(Serialize, Deserialize, Debug, Clone)]
32pub struct Operand {
33    /// (p) The hash of the work package
34    pub package: OpaqueHash,
35
36    /// (e) The root of the segment tree which was generated by the work-package
37    /// in which the work-item which gave this result was placed.
38    pub exports_root: OpaqueHash,
39
40    /// (a) The hash of the authorizer which authorized the execution of the
41    /// work-package which generated this result.
42    pub authorizer_hash: OpaqueHash,
43
44    /// (y) The payload blob hash
45    pub payload: OpaqueHash,
46
47    // JAM_TYPES currently does not include this field
48    /// (g) The accumulate gas
49    #[serde(with = "codec::compact")]
50    pub gas: Gas,
51
52    /// (d) The work execution result
53    pub data: WorkExecResult,
54
55    /// (o) The output of the Is-Authorized logic which authorized the execution
56    /// of the work-package which generated this result.
57    pub auth_output: Vec<u8>,
58}