aries-cloudagent-python icon indicating copy to clipboard operation
aries-cloudagent-python copied to clipboard

Caching/Processing known JSON-LD Contexts

Open acuderman opened this issue 3 years ago • 4 comments

On 18.4 W3C servers had a downtime which caused the credentials could not be issued. Specifically https://www.w3.org/2018/credentials/v1 and https://w3id.org/security/bbs/v1 could not be resolved.

Since the contexts do not change would It make sense to hardcode them?

acuderman avatar Apr 19 '22 09:04 acuderman

Likely. This is one of the challenges of JSON-LD -- knowing how to handle contexts. AFAIK -- the recommendation is that code should NEVER dynamically load contexts, but should know about them. For something like ACA-Py, that means that the controller (the business component of an Aries Agent) should somehow be the source for dereferencing a JSON-LD context.

Any idea how that could work?

Admittedly, these two particular contexts could be pre-loaded by ACA-Py, since it does know about them. But the general problem is better handled with the controller handling the caching of contexts.

swcurran avatar Apr 19 '22 13:04 swcurran

I agree. I think that offloading context caching to the controller will require quite a big effort, so hardcoding them could be a good part-time solution.

acuderman avatar Apr 19 '22 15:04 acuderman

Agreed -- I think we should probably bundle the most commonly used context with ACA-Py.

In addition it may be easier to include a registry in ACA-Py of trusted contexts that can be configured add startup, possibly adding more through an endpoint later on.

TimoGlastra avatar Apr 21 '22 09:04 TimoGlastra

Sounds good. That puts the responsibility on the controller to define the set of allowed contexts (startup, loaded via API), but ACA-Py does the loading when needed. I like that.

I suggest that an issue be created that defines what is needed, referencing this issue and with a help wanted label on it.

swcurran avatar Apr 21 '22 14:04 swcurran

We talked about a similar point on the discord server ThreadId 1065643985646919740. I just want to document it here because it is very relevant. As swcurran said Loading context dynamically is not recommended. It is also harming the performance

For example, when I want to sign a Json-ld doc. AcaPy is sending many HTTP Request in the background ≈ 3 seconds

image

It would be great if these most used/known Json-ld contexts are cached or preloaded. But it will be also very very helpful to be able to import/cache/preload any other contexts

I took a quick look at Aries-framework-Go and they are solving it this way https://github.com/hyperledger/aries-framework-go/blob/main/docs/jsonld_context.md

MajdT51 avatar Jan 20 '23 15:01 MajdT51