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

[DRAFT] MpcContract using yields #1133

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

saketh-are
Copy link
Contributor

No description provided.

@saketh-are saketh-are changed the title [DO NOT MERGE] draft a toy contract using yields [DRAFT] MpcContract using yields Jan 18, 2024
Copy link
Contributor

@mikedotexe mikedotexe left a comment

Choose a reason for hiding this comment

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

Excited to see this example, or something very similar merged into this SDK.
Great to have a reference in the examples directory for this, which is an intriguing update to the protocol

@DavidM-D
Copy link
Contributor

@saketh-are what still needs to be done to this before it can be merged in?

@saketh-are
Copy link
Contributor Author

@DavidM-D #1183 merges the imports for the host functions which is enough to unblock you. It is pending a review by a code owner.

@gagdiez
Copy link

gagdiez commented May 21, 2024

Very interesting addition @saketh-are ! I am missing only one piece of the puzzle in the code:

How is the resume on pub fn sign_respond

env::promise_yield_resume(&data_id, &serde_json::to_vec(&signature).unwrap());

linked back to the yield_create in pub fn sign

        let yield_promise = env::promise_yield_create(
            "sign_on_finish",
            &serde_json::to_vec(&(index,)).unwrap(),
            SIGN_ON_FINISH_CALL_GAS,
            GasWeight(0),
            DATA_ID_REGISTER,
        );

Because multiple users will call sign, and they will want to get the Signature for their specific payloads

@gagdiez
Copy link

gagdiez commented May 21, 2024

@saketh-are @DavidM-D I am working on a blogpost here:

Will try to complete the first draft tomorrow

@saketh-are
Copy link
Contributor Author

@gagdiez The way the example is written the sign function will give back the signature as its return value.

@gagdiez
Copy link

gagdiez commented May 21, 2024

@saketh-are that part I get it, what I don't get is:

  • saketh calls sign and a yield is created, now saketh is waiting for a reply
  • gagdiez calls sign and a yield is created, now gagdiez is waiting for a reply
  • The service calls sign_respond and provides a signature for gagdiez

Which part of the sign_respond code says: "please now resume computation for gagdiez"

@saketh-are
Copy link
Contributor Author

saketh-are commented May 21, 2024

sign_respond accepts an argument data_id which is used to identify the yield which is being resumed. It is a unique token produced by the host function promise_yield_create (it is written to a data register indicated by DATA_ID_REGISTER) and later expected as an argument to the host function promise_yield_resume.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: NEW❗
Development

Successfully merging this pull request may close these issues.

4 participants