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

Value with Callback (auto unlocks) #24

Closed
wants to merge 9 commits into from
Closed

Conversation

evgenykuzyakov
Copy link
Contributor

No description provided.

@evgenykuzyakov
Copy link
Contributor Author

I was thinking about security of this and it still seems ok.

  • When a promise it attached to a callback, the predecessor_id doesn't change. So one contract can't fake a call to appear from a different predecessor.

@ilblackdragon ilblackdragon mentioned this pull request Nov 23, 2019
text/0000-value-with-callback-return.md Outdated Show resolved Hide resolved
text/0000-value-with-callback-return.md Outdated Show resolved Hide resolved
text/0000-value-with-callback-return.md Outdated Show resolved Hide resolved
text/0000-value-with-callback-return.md Outdated Show resolved Hide resolved
text/0000-value-with-callback-return.md Outdated Show resolved Hide resolved
text/0000-value-with-callback-return.md Show resolved Hide resolved
text/0000-value-with-callback-return.md Outdated Show resolved Hide resolved
text/0000-value-with-callback-return.md Show resolved Hide resolved
text/0000-value-with-callback-return.md Outdated Show resolved Hide resolved
text/0000-value-with-callback-return.md Show resolved Hide resolved
Evgeny Kuzyakov and others added 4 commits December 4, 2019 14:48
Co-Authored-By: Maksym Zavershynskyi <35039879+nearmax@users.noreply.github.com>
Co-Authored-By: Alexey <alexey@fckt.dev>
Co-Authored-By: Alexey <alexey@fckt.dev>
@evgenykuzyakov
Copy link
Contributor Author

Please take a look again. Added diagram, receipts and separated scenarios for better explanation.


Let's look at receipts (See [How runtime works](#how-runtime-work)):

```rust
Copy link
Contributor

Choose a reason for hiding this comment

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

The transition to specific receipts is unclear. This pseudocode here demonstrates how receipts are created and updated during the execution of exchange method on dex. I think this should be stated more explicitly.

text/0000-value-with-callback-return.md Outdated Show resolved Hide resolved
text/0000-value-with-callback-return.md Show resolved Hide resolved
predecessor_id: "dex",
input_data_ids: [],
output_data_receivers: [],
actions: [FunctionCall { method_name: "trasnferFrom", ... }],
Copy link
Contributor

Choose a reason for hiding this comment

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

We need an explanation on how locks are passed to the function calls, i.e. specify the args.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added args where it makes sense

text/0000-value-with-callback-return.md Outdated Show resolved Hide resolved
predecessor_id: "dex",
input_data_ids: ["data-id-1", "data-id-2"],
// 2 new data receivers we added for the received input data
output_data_receivers: [
Copy link
Contributor

Choose a reason for hiding this comment

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

This is confusing. It says we don't actually add them to output_data_receivers, but just account for them. Maybe comment out this field here to empathize that it is not actually added.

Copy link
Contributor

Choose a reason for hiding this comment

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

We need a different name for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What I meant, it the receipt would look like this if we append new output data receivers to the exiting output data receivers.


/// `dex` returns this callback (A7) using `return_promise`.
// This modifies A7, by redirecting output from A4.
ActionReceipt {
Copy link
Contributor

Choose a reason for hiding this comment

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

So this functionality is already implemented in the current runtime, when we use return_promise, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

id: "D5",
receiver_id: "fun",
predecessor_id: "dex",
data_id: "data-id-3",
Copy link
Contributor

Choose a reason for hiding this comment

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

Generating this receipt requires modification to the runtime, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. It's how it works. We always generate a data receipt.

text/0000-value-with-callback-return.md Outdated Show resolved Hide resolved
text/0000-value-with-callback-return.md Outdated Show resolved Hide resolved
}

/// `dex` returns this callback using `return_promise`.
// No receipts are modified, but execution outcome for A1 changes to reflect to wait for A4.
Copy link

Choose a reason for hiding this comment

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

but execution outcome for A1 changes

where I can see it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lexfrl lexfrl requested a review from k06a December 9, 2019 18:43
@evgenykuzyakov
Copy link
Contributor Author

evgenykuzyakov commented Dec 9, 2019

Going to write a new NEP (in short form first). Keeping this for eduction.

Spoiler: We'll use Safes which is similar to move operator

@evgenykuzyakov
Copy link
Contributor Author

WIP for the next version: #26

@frol frol deleted the delayed-promise branch December 20, 2022 18:47
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.

4 participants