openwallet-foundation / acapy

ACA-Py is a foundation for building decentralized identity applications and services running in non-mobile environments.
https://aca-py.org
Apache License 2.0
421 stars 515 forks source link

Caching/Processing known JSON-LD Contexts #1733

Closed acuderman closed 3 months ago

acuderman commented 2 years ago

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?

swcurran commented 2 years ago

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.

acuderman commented 2 years ago

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.

TimoGlastra commented 2 years ago

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.

swcurran commented 2 years ago

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.

MajdT51 commented 1 year ago

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