-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: add support for fetching root keys automatically #569
base: main
Are you sure you want to change the base?
Conversation
Dear @rupansh, In order to potentially merge your code in this open-source repository and therefore proceed with your contribution, we need to have your approval on DFINITY's CLA. If you decide to agree with it, please visit this issue and read the instructions there. Once you have signed it, re-trigger the workflow on this PR to see if your code can be merged. — The DFINITY Foundation |
Why is this needed vs just calling fetch_root_key immediately after constructing the agent? |
This proposes a more ergonomic API,
Other than the ergonomic benefits, the construction of the agent becomes synchronous instead of requiring async. Imagine a global static agent, |
) -> Result<Vec<u8>, AgentError> { | ||
match delegation { | ||
None => Ok(self.read_root_key()), | ||
None => Ok(root_key), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for passing root_key
as a parameter here, rather than getting it from self
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verify_cert & check_delegation would become async and you have a recursive future. I wasn't able to unroll it into an iterator unfortunately, so I went with this
Only for lazy-init statics (e.g.
Do you have an example of this? |
Indeed
Sure, most of the code is written in a dual-environment style in leptos(i.e targeting both browser and server): A way to force async initialization would be by using I understand that this might be too specific to our use case which is why my main emphasis is on the ergonomics rather than better global statics |
Description
This change introduces a way to fetch root keys automatically on demand. This makes the construction of the agent a bit more ergonomic for local nodes.
Minor breakage to the API had to be introduced unfortunately. I also recommend deprecating the
fetch_root_keys
method.How Has This Been Tested?
I ran
cargo test
. Further, this version will also be used by the Yral fronend for testing our changes locally (https://github.com/go-bazzinga/hot-or-not-web-leptos-ssr/blob/rupansh/testcontainers/src/state/canisters.rs#L30)Checklist: