feature(execution-engine): Canon data with CID (#419)

* Use CID values for tetraplets and `canon` vectors.

* Rename `cid_store` to `value_store`

It is consistent with the new `tetraplet_store` and `canon_store`
fields.

* Make canon data more typeful

The `CanonResult` doesn't take a JSON value anymore that is further
deserialized elsewhere, but is a struct that has all data deserialized.

* Typeful `CID` type

The `CID` type has a phantom type paramter defining its value's type.

* Group cid stores and trackers

Group cid stores into `CidInfo` struct, and trackers into `ExecutionCidState` struct.
This commit is contained in:
Ivan Boldyrev
2023-01-09 13:22:57 +07:00
committed by GitHub
parent f73e246a2e
commit 8f587b7803
28 changed files with 727 additions and 105 deletions

View File

@ -17,10 +17,12 @@
use super::GlobalStreamGens;
use super::RestrictedStreamGens;
use crate::cid_store::CidStore;
use crate::CanonCidAggregate;
use crate::ExecutionTrace;
use crate::JValue;
use air_utils::measure;
use polyplets::SecurityTetraplet;
use serde::Deserialize;
use serde::Serialize;
@ -57,8 +59,8 @@ pub struct InterpreterData {
/// Version of interpreter produced this data.
pub interpreter_version: semver::Version,
/// Map CID to values
pub cid_store: CidStore<JValue>,
/// CID-to-somethings mappings.
pub cid_info: CidInfo,
}
impl InterpreterData {
@ -70,20 +72,19 @@ impl InterpreterData {
last_call_request_id: 0,
restricted_streams: RestrictedStreamGens::new(),
interpreter_version,
cid_store: <_>::default(),
cid_info: <_>::default(),
}
}
#[allow(clippy::too_many_arguments)]
pub fn from_execution_result(
trace: ExecutionTrace,
streams: GlobalStreamGens,
restricted_streams: RestrictedStreamGens,
cid_store: impl Into<CidStore<JValue>>,
cid_info: CidInfo,
last_call_request_id: u32,
interpreter_version: semver::Version,
) -> Self {
let cid_store = cid_store.into();
Self {
trace,
global_streams: streams,
@ -91,7 +92,7 @@ impl InterpreterData {
last_call_request_id,
restricted_streams,
interpreter_version,
cid_store,
cid_info,
}
}
@ -114,6 +115,18 @@ impl InterpreterData {
}
}
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct CidInfo {
/// Map CID to value
pub value_store: CidStore<JValue>,
/// Map CID to a tetraplet
pub tetraplet_store: CidStore<SecurityTetraplet>,
/// Map CID to a canon value
pub canon_store: CidStore<CanonCidAggregate>,
}
#[cfg(test)]
mod tests {
use super::*;