cadence icon indicating copy to clipboard operation
cadence copied to clipboard

Invalidate resource references when the referenced resource is moved

Open SupunS opened this issue 3 years ago • 2 comments

Description

This is the draft implementation of the FLIP: https://github.com/onflow/flow/pull/1043

Adds a run-time check to invalidate references, if the pointed resource is being moved.

Note: This PR doesn't invalidate the references upon stack-to-stack moves. Adding that is subjected to the final verdict on the proposed FLIP.


  • [ ] Targeted PR against master branch
  • [x] Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • [x] Code follows the standards mentioned here
  • [x] Updated relevant documentation
  • [x] Re-reviewed Files changed in the Github PR explorer
  • [x] Added appropriate labels

SupunS avatar Sep 23 '22 15:09 SupunS

Codecov Report

Merging #1999 (6bfa821) into feature/stable-cadence (0e3bc7b) will increase coverage by 0.03%. The diff coverage is 86.36%.

:exclamation: Current head 6bfa821 differs from pull request most recent head cb06d74. Consider uploading reports for the commit cb06d74 to get more accurate results

@@                    Coverage Diff                     @@
##           feature/stable-cadence    #1999      +/-   ##
==========================================================
+ Coverage                   77.89%   77.93%   +0.03%     
==========================================================
  Files                         304      304              
  Lines                       63759    63757       -2     
==========================================================
+ Hits                        49667    49689      +22     
+ Misses                      12347    12323      -24     
  Partials                     1745     1745              
Flag Coverage Δ
unittests 77.93% <86.36%> (+0.03%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
runtime/interpreter/value.go 70.50% <79.31%> (+0.05%) :arrow_up:
runtime/interpreter/errors.go 57.20% <100.00%> (+1.25%) :arrow_up:
runtime/interpreter/interpreter.go 89.01% <100.00%> (+0.04%) :arrow_up:
runtime/interpreter/storage.go 69.04% <0.00%> (-1.59%) :arrow_down:
runtime/interpreter/statictype.go 82.03% <0.00%> (-0.65%) :arrow_down:
runtime/sema/checker.go 92.33% <0.00%> (+0.01%) :arrow_up:
runtime/sema/check_conditional.go 95.36% <0.00%> (+0.06%) :arrow_up:
runtime/sema/resources.go 88.44% <0.00%> (+0.54%) :arrow_up:
... and 2 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Sep 23 '22 15:09 codecov[bot]

Cadence Benchstat comparison

This branch with compared with the base branch onflow:feature/stable-cadence commit b0c0e27409b809d97a89d4c2372b8ae8cf5d9768 The command for i in {1..N}; do go test ./... -run=XXX -bench=. -benchmem -shuffle=on; done was used. Bench tests were run a total of 7 times on each branch.

Collapsed results for better readability

old.txtnew.txt
time/opdelta
CheckContractInterfaceFungibleTokenConformance-2123µs ± 3%119µs ± 1%−2.54%(p=0.015 n=6+6)
ContractInterfaceFungibleToken-242.1µs ± 3%41.2µs ± 1%−2.22%(p=0.011 n=7+7)
InterpretRecursionFib-22.55ms ± 2%2.51ms ± 1%−1.65%(p=0.011 n=7+7)
NewInterpreter/new_interpreter-21.17µs ± 1%1.16µs ± 3%−0.87%(p=0.045 n=7+6)
NewInterpreter/new_sub-interpreter-2622ns ± 3%613ns ± 1%~(p=0.128 n=7+7)
ParseArray-28.33ms ± 3%8.12ms ± 1%−2.42%(p=0.014 n=7+6)
ParseDeploy/byte_array-212.6ms ± 2%12.3ms ± 2%−2.59%(p=0.011 n=7+7)
ParseDeploy/decode_hex-21.22ms ± 1%1.21ms ± 0%−1.03%(p=0.026 n=6+6)
ParseFungibleToken/With_memory_metering-2194µs ± 1%192µs ± 3%~(p=0.181 n=6+7)
ParseFungibleToken/Without_memory_metering-2154µs ± 2%151µs ± 1%−2.11%(p=0.004 n=7+7)
ParseInfix-27.26µs ± 1%7.10µs ± 0%−2.23%(p=0.002 n=6+6)
QualifiedIdentifierCreation/One_level-22.35ns ± 0%2.35ns ± 0%~(p=0.293 n=7+6)
QualifiedIdentifierCreation/Three_levels-2139ns ± 2%139ns ± 3%~(p=0.279 n=6+7)
RuntimeFungibleTokenTransfer-2685µs ±21%613µs ±27%~(p=0.165 n=7+7)
RuntimeResourceDictionaryValues-25.14ms ± 3%5.00ms ± 1%−2.62%(p=0.008 n=7+6)
RuntimeScriptNoop-215.2µs ± 2%18.3µs ±32%~(p=0.945 n=6+7)
ValueIsSubtypeOfSemaType-290.1ns ± 2%91.9ns ± 3%~(p=0.128 n=7+7)
 
alloc/opdelta
CheckContractInterfaceFungibleTokenConformance-251.6kB ± 0%51.6kB ± 0%~(all equal)
ContractInterfaceFungibleToken-224.9kB ± 0%24.9kB ± 0%~(all equal)
InterpretRecursionFib-21.00MB ± 0%1.00MB ± 0%~(all equal)
NewInterpreter/new_interpreter-2800B ± 0%800B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-2216B ± 0%216B ± 0%~(all equal)
ParseArray-22.75MB ± 3%2.71MB ± 2%~(p=0.456 n=7+7)
ParseDeploy/byte_array-24.21MB ± 3%4.18MB ± 3%~(p=0.383 n=7+7)
ParseDeploy/decode_hex-2214kB ± 0%214kB ± 0%~(p=1.000 n=7+7)
ParseFungibleToken/With_memory_metering-229.8kB ± 0%29.8kB ± 0%~(p=0.470 n=7+7)
ParseFungibleToken/Without_memory_metering-229.8kB ± 0%29.8kB ± 0%~(p=0.805 n=7+7)
ParseInfix-21.93kB ± 0%1.93kB ± 0%~(p=0.848 n=6+7)
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
RuntimeFungibleTokenTransfer-2103kB ± 1%103kB ± 1%~(p=0.301 n=7+7)
RuntimeResourceDictionaryValues-22.27MB ± 0%2.27MB ± 0%~(p=0.620 n=7+7)
RuntimeScriptNoop-28.83kB ± 1%8.85kB ± 1%~(p=0.710 n=7+7)
ValueIsSubtypeOfSemaType-248.0B ± 0%48.0B ± 0%~(all equal)
 
allocs/opdelta
CheckContractInterfaceFungibleTokenConformance-2905 ± 0%905 ± 0%~(all equal)
ContractInterfaceFungibleToken-2435 ± 0%435 ± 0%~(all equal)
InterpretRecursionFib-218.9k ± 0%18.9k ± 0%~(all equal)
NewInterpreter/new_interpreter-213.0 ± 0%13.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-24.00 ± 0%4.00 ± 0%~(all equal)
ParseArray-269.6k ± 0%69.6k ± 0%~(p=1.000 n=7+7)
ParseDeploy/byte_array-2104k ± 0%104k ± 0%~(p=1.000 n=7+7)
ParseDeploy/decode_hex-275.0 ± 0%75.0 ± 0%~(all equal)
ParseFungibleToken/With_memory_metering-21.00k ± 0%1.00k ± 0%~(all equal)
ParseFungibleToken/Without_memory_metering-21.00k ± 0%1.00k ± 0%~(all equal)
ParseInfix-260.0 ± 0%60.0 ± 0%~(all equal)
QualifiedIdentifierCreation/One_level-20.00 0.00 ~(all equal)
QualifiedIdentifierCreation/Three_levels-22.00 ± 0%2.00 ± 0%~(all equal)
RuntimeFungibleTokenTransfer-22.05k ± 0%2.05k ± 0%~(all equal)
RuntimeResourceDictionaryValues-236.9k ± 0%36.9k ± 0%~(p=0.237 n=7+7)
RuntimeScriptNoop-2143 ± 0%143 ± 0%~(all equal)
ValueIsSubtypeOfSemaType-21.00 ± 0%1.00 ± 0%~(all equal)
 

github-actions[bot] avatar Sep 23 '22 16:09 github-actions[bot]