-
Notifications
You must be signed in to change notification settings - Fork 23
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
[Cadence] FLIP - random function #120
Conversation
My only concern with this change is that I think it may communicate the wrong thing to Cadence users. I understand how from the protocol perspective our randomness is no longer "unsafe", but from the perspective of a Cadence user, I think they will probably not consider it to be such. As far as they are concerned, the randomness (used naively) is still "unsafe" because it is still exploitable by a transaction that reverts to postselect a favorable result. Changing the name of the function to remove the Users can use certain patterns to make their randomness truly safe, but they need to structure their code in a specific way for this to work, and I am worried that people won't realize they need to do this without the built-in warning that a name like |
Thanks @dsainati1 I see your point but I'll add counter-arguments to keep the discussion going:
|
Great points @dsainati1 and @tarakby! @tarakby Could you please incorporate the concerns and your feedback into the FLIP itself? That way the reasoning is not lost |
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.
Looks good, though it would be nice to provide a more convenient API (a combination of the alternatives?) which reduces potential misuse
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.
Looks good! I think I'm fine with accepting that developers need to know that random is revertible without reading the function name
Would it be better if FVM was injecting the |
@janezpodhostnik That could be an option. There's always the question what should be part of the built-in functionality / standard library, and what is only provided by a particular environment. So far, the random function is part of the built-in functionality (standard library). I feel like every implementation of Cadence should provide one, so developers can be assured the function is available and reason about the behaviour. For now I'd keep it that way, however, I don't feel strongly about it. (The same question / reasoning applies to other functions/APIs (like the block API). |
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.
Great improvements! Just some fixes for the examples, and some stylistic recommendations
Co-authored-by: Bastian Müller <bastian@axiomzen.co>
Co-authored-by: Bastian Müller <bastian@axiomzen.co>
Co-authored-by: Bastian Müller <bastian@axiomzen.co>
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.
thank you for this excellent write-up 👏
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.
👍
|
||
All the reasons above support dropping the `unsafe` prefix. | ||
|
||
#### Revertible randomness |
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.
This is a great explanation:ok_hand:
Once merged, we should put this into the documentation and an abridged version into the docstring.
The plan is to decide on this FLIP in the next Cadence Language Design Meeting on Tue 12th, Sep. So far there is positive sentiment. Unless there are any new insights or significant reasons to reject are brought forward, the plan is to approve the FLIP. |
@tarakby The FLIP got approved 🎉 Please update the status and merge :-) |
Proposes a FLIP to:
unsafeRandom
function name after the underlying implementation has been secured using Flow protocol native random beacon.