-
Notifications
You must be signed in to change notification settings - Fork 140
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
Fix erroneous report of resource invalidation when executing a pre-condition #1625
Conversation
Cadence Benchstat comparisonThis branch with compared with the base branch onflow:master commit f615bea Results
|
Codecov Report
@@ Coverage Diff @@
## master #1625 +/- ##
==========================================
+ Coverage 74.73% 74.76% +0.02%
==========================================
Files 288 288
Lines 55340 55382 +42
==========================================
+ Hits 41357 41404 +47
+ Misses 12489 12483 -6
- Partials 1494 1495 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@@ -4163,3 +4163,837 @@ transaction(recipient: Address, amount: UFix64) { | |||
) | |||
require.NoError(t, err) | |||
} | |||
|
|||
func TestRuntimeMissingMemberExampleMarketplace(t *testing.T) { |
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 test currently reports "no value for member" as detailed in #1539
The issue with resource invalidation was originally discovered as it was preventing reproducing this behavior. I have added this test here to document this behavior, with a comment indicating that its behavior is not ideal. I will work on another PR to fix the issue here.
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 work here @dsainati1, both the analysis of the root problem and the solution are 👌
Like you described, in addition to the inner function body, also the condition wrapper functions bind the arguments, which leads to multiple variables being associated with the same resource.
Temporarily un-tracking the resource-kinded arguments and restoring the tracking makes sense.
Co-authored-by: Bastian Müller <[email protected]>
Co-authored-by: Bastian Müller <[email protected]>
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 work!
@SupunS can you please also have a look, as you authored the run-time resource tracking facility 🙏
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.
Nice! 👌
Fixes issue reported in Discord
Description
The safety analysis for resource validation, which was introduced in #1464, was not properly handling pre and post conditions for functions in composites that implemented interfaces. In order to implement this behavior, we "wrap" the composite function in another "function" that contains the code for the pre and post conditions, and redeclare all the parameters. If one of the parameters is given a resource-kinded argument, this tricks the analysis into thinking this resource is being duplicated, when it is not.
To handle this, we invalidate any resources that are parameters to the precondition before executing the body, then re-validate them after the body, before executing the post condition.
master
branchFiles changed
in the Github PR explorer