Closed timothee-haudebourg closed 1 year ago
@sbihel the ssi_json_ld::json_to_dataset
is always called with the same options across ssi
. Should I remove those options to simplify the code or is it really used outside ssi
with different options?
Also I have a few clippy warnings in ssi-ucan
, but I don't think they were introduced by my changes so I won't fix them here (unless I'm wrong).
warning: the borrowed expression implements the required traits
--> ssi-ucan/src/lib.rs:160:21
|
160 | &DagJsonCodec.encode(&to_ipld(&self.header).map_err(IpldError::new)?)?,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `DagJsonCodec.encode(&to_ipld(&self.header).map_err(IpldError::new)?)?`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
= note: `#[warn(clippy::needless_borrow)]` on by default
warning: the borrowed expression implements the required traits
--> ssi-ucan/src/lib.rs:164:21
|
164 | &DagJsonCodec.encode(&self.payload)?,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `DagJsonCodec.encode(&self.payload)?`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
warning: the borrowed expression implements the required traits
--> ssi-ucan/src/lib.rs:296:21
|
296 | &DagJsonCodec.encode(&to_ipld(&header).map_err(IpldError::new)?)?,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `DagJsonCodec.encode(&to_ipld(&header).map_err(IpldError::new)?)?`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
warning: the borrowed expression implements the required traits
--> ssi-ucan/src/lib.rs:299:39
|
299 | base64::encode_config(&DagJsonCodec.encode(&self)?, base64::URL_SAFE_NO_PAD),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `DagJsonCodec.encode(&self)?`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
warning: `ssi-ucan` (lib) generated 4 warnings
Edit: well it prevents me from passing the CI, so I'll fix it anyway.
Everything seems to work except for the presentation_from_credential_issue_verify
test in ssi-vc
that runs out of memory during some JSON-LD document expansion.
Async function seem to consume a lot of memory, and I've checked, less than a megabyte of stack remains when the expansion algorithm is called. I'm not sure how that can be solved without increasing the stack size. I've tried in another context, with more stack and the expansion succeeded.
I solved the stack size issue by increasing the minimum stack size to 3MB. This is done by defining the RUST_MIN_STACK
environment variable in .cargo/config.toml
.
@sbihel the ssi_json_ld::json_to_dataset is always called with the same options across ssi. Should I remove those options to simplify the code or is it really used outside ssi with different options?
I would be in favour. I don't think it's used by anyone and we can always re-introduce them later.
The LinkedDataDocument::get_contexts returns a (optional) string representing a JSON-LD context. The implementer is expected to convert its context to a string, and the caller then re-parse the context before calling the json-ld lib. Instead the function could directly return a json_ld::syntax::context::Value or even better jsonld::RemoteDocumentReference<, _, json_ld::syntax::context::Value> directly. Then no need to parse anything, but I'm not sure of the impact on ssi, it may involve greater changes.
This is probably a issue for later but I agree with you, it's a bit too funky. After a quick glance, I wonder why it's not directly returning Contexts
. Because that's really the only use we have for it
This PR upgrades the
json-ld
dependency.Implementation
ssi-json-ld
json-ld
.rdf
module for therdf-types
crate.rdf-types
.ssi-dids
did-ethr
did-jwk
did-key
did-pkh
did-sol
did-tezos
did-webkey
ssi-ldp
ssi-vc
ssi-zcap-ld
Added dependencies
rdf-types
to represent RDF concepts (triples, subject, predicate, object, etc.), compatible withjson-ld
.grdf
to represent RDF datasets, compatible withrdf-types
Possible improvements
ssi_json_ld::json_to_dataset
is always called with the same options acrossssi
. Maybe we could simplify it a bit.LinkedDataDocument::get_contexts
returns a (optional) string representing a JSON-LD context. The implementer is expected to convert its context to a string, and the caller then re-parse the context before calling thejson-ld
lib. Instead the function could directly return ajson_ld::syntax::context::Value
or even betterjson_ld::RemoteDocumentReference<_, _, json_ld::syntax::context::Value>
directly. Then no need to parse anything, but I'm not sure of the impact onssi
, it may involve greater changes.