-
Notifications
You must be signed in to change notification settings - Fork 44
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
Forbid contract reentry #513
Conversation
I haven't bumped the env version because I haven't figured out how to make the sdk changes (proc-macro) in order to regen the wasm tests. |
Reentry
flag to contract invocationThere 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 looks good to me, but I'm a little confused by the comment that has been added, since it is incorrect in the context of testing.
I don't think it makes sense to couple reentry as a capability with error handling, as there are disconnected reasons to choose one and the other. In the SDK I hope to add support for "invocation options" on functions that call both call and try_call, and it will muddy the SDK API if these options are inconsistent between the two functions. At the moment these options will only include the reentry flag, but I imagine them including other options in the future. cc @graydon |
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.
LGTM! Thanks!
Got it. This was not meant to be set-in-stone, rather it was just one of the options. The main reason it was proposed was to differentiate an "straightforward and safe" route ( |
@jayz22 I think we should add new call and try_call functions that take the additional option. I think we can simply call them |
I've reopened the issue so that we can continue discuss there. |
What
Partially resolves #336.
Add areentry: RawVal
argument to thetry_call
function. If set, it checks the host context for frames with the same contract id.Disallow contract reentry by checking the host context for frames with the same contract id.
In a later follow up, we will add a
reentry: RawVal
flag to thetry_call
function and use that.Why
try_call
? Thecall
host function is the recommended (safe) path of invocation, where any failure will results in an host error. Thetry_call
is the more loose version that allows failure to be returned as a status. It makes sense to only enable re-entry in thetry_call
invocation path since that is a further loosening feature (@graydon has suggested it).Known limitations
[TODO or N/A]