Skip to content
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

Example presets #2

Merged
merged 5 commits into from
Jul 11, 2023
Merged

Example presets #2

merged 5 commits into from
Jul 11, 2023

Conversation

samtay
Copy link

@samtay samtay commented Jul 11, 2023

The PIR FHE example is still the default, but now the user can choose other examples (currently just PIR FHE and Sudoku ZKP). You can also link to an example, e.g. playground.sunscreen.tech/?example=sudoku.

Also, take a look at the explanation in this commit msg. One unfortunate side effect is that if you have navigated to a particular example (or followed a link with an example set), so that &example=_ is present in the URL, refreshing your browser will now refresh the example code. Previously local storage would take precedent. But I don't see a great way around that...

screenshots

2023-07-11-122208_2256x1324_scrot
2023-07-11-122302_2256x1328_scrot

We dont support gists, and the rust user form is too general for the sunscreen playground
This is necessary to link out to FHE vs ZKP examples. There's a little
bit of an awkward dance around the initial page load, since the
playground holds configuration state in query params and relies on these
params when navigating routes (e.g. going to /help then back to index
and keeping the users options for debug/release etc.).
Naively adding the example state would mean that such a navigation would
clobber any edits the user made to the code.

Instead, we only update the code based on the example query param _once_
and then the operation is a no-op. After this initial page load, the
only way to change the example code is through the example drop down
menu. In particular, navigating to help and back will _not_ reload the
example code. But, importantly, it will keep the last selected example
in the dropdown selected.
@ryanorendorff
Copy link

I wasn't a big fan of the local storage on the standard rust playground because I often want to open it up and try something random. For an example I think it is especially ok if it resets, since then the URL will point to a known state.


return (
<Fragment>
<Copied href={permalink}>Permalink to the playground</Copied>
<Copied href={gistUrl}>Direct link to the gist</Copied>
{/*<Copied href={permalink}>Permalink to the playground</Copied>*/}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[question]: Is this disabled because the local storage does not take precedent?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I commented this out because we don't currently support the GitHub Gist integration that the playground offers. I do think this would probably just mean making a GH token and passing it through upon deployment, but we're not doing that. So, I'd rather remove these links than keep them broken. (You can see this in our current playground - try sharing via gist.)

@@ -162,20 +166,141 @@ fn main() -> Result<(), Error> {
}
`;

const SUDOKU: State = `use sunscreen::{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[question]: Is there a way we can ensure this stays in sync with the checked in rust code running the example? It would be convenient to have one source of truth for the example (that can be built in CI); I'm not familiar enough with frontend to know if loading a github blob URL like https://github.com/Sunscreen-tech/Sunscreen/blob/main/examples/sudoku_zkp/src/main.rs would work.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, going through GH is an interesting idea. We'd just have to specify the version e.g. https://raw.githubusercontent.com/Sunscreen-tech/Sunscreen/v0.7.0/examples/pir/src/main.rs. I thought GH put raw content behind an expiring token, but maybe they stopped doing that.

It might require loading from the backend rather than frontend, but doesn't sound unreasonable.

@samtay samtay merged commit 362efb0 into sunscreen Jul 11, 2023
@samtay samtay deleted the samtay/presets branch July 11, 2023 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants