Skip to content

Value with Callback (auto unlocks)#24

Closed
evgenykuzyakov wants to merge 9 commits intomasterfrom
delayed-promise
Closed

Value with Callback (auto unlocks)#24
evgenykuzyakov wants to merge 9 commits intomasterfrom
delayed-promise

Conversation

@evgenykuzyakov
Copy link
Copy Markdown
Contributor

No description provided.

@evgenykuzyakov
Copy link
Copy Markdown
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
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
Copy Markdown
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
Copy Markdown
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.

predecessor_id: "dex",
input_data_ids: [],
output_data_receivers: [],
actions: [FunctionCall { method_name: "trasnferFrom", ... }],
Copy link
Copy Markdown
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
Copy Markdown
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

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

}

/// `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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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