Skip to content
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

Transaction pre-conditions must also be view #2171

Merged

Conversation

dsainati1
Copy link
Contributor

While reading over onflow/flips#41 I realized that we did not properly enforce that transaction pre-conditions were view. This refactors the checking to push the purity scope in all condition checking locations, covering the missed case.


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

@codecov
Copy link

codecov bot commented Nov 30, 2022

Codecov Report

Merging #2171 (cfce557) into feature/stable-cadence (df5b469) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@                   Coverage Diff                   @@
##           feature/stable-cadence    #2171   +/-   ##
=======================================================
  Coverage                   78.20%   78.20%           
=======================================================
  Files                         309      309           
  Lines                       64709    64716    +7     
=======================================================
+ Hits                        50603    50610    +7     
  Misses                      12316    12316           
  Partials                     1790     1790           
Flag Coverage Δ
unittests 78.20% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
runtime/interpreter/interpreter_statement.go 92.14% <100.00%> (+0.15%) ⬆️
runtime/sema/check_conditions.go 100.00% <100.00%> (ø)
runtime/sema/check_function.go 99.39% <100.00%> (-0.01%) ⬇️

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

@github-actions
Copy link

Cadence Benchstat comparison

This branch with compared with the base branch onflow:feature/stable-cadence commit 3a0c7b1
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-2178µs ± 3%175µs ± 3%~(p=0.209 n=7+7)
ContractInterfaceFungibleToken-258.4µs ± 5%60.2µs ±15%~(p=0.805 n=7+7)
InterpretRecursionFib-23.05ms ± 8%2.88ms ± 2%−5.37%(p=0.001 n=7+7)
NewInterpreter/new_interpreter-21.38µs ± 2%1.43µs ±12%~(p=1.000 n=6+7)
NewInterpreter/new_sub-interpreter-2784ns ±11%737ns ± 4%−5.94%(p=0.026 n=7+7)
ParseArray-29.75ms ± 4%9.72ms ± 5%~(p=0.620 n=7+7)
ParseDeploy/byte_array-214.9ms ± 5%14.8ms ± 3%~(p=0.710 n=7+7)
ParseDeploy/decode_hex-21.60ms ± 5%1.58ms ± 4%~(p=0.710 n=7+7)
ParseFungibleToken/With_memory_metering-2249µs ± 8%248µs ± 3%~(p=1.000 n=7+7)
ParseFungibleToken/Without_memory_metering-2189µs ± 4%195µs ± 5%~(p=0.097 n=7+7)
ParseInfix-28.38µs ± 4%8.29µs ± 1%~(p=1.000 n=7+7)
QualifiedIdentifierCreation/One_level-23.07ns ± 3%3.12ns ± 2%~(p=0.165 n=7+7)
QualifiedIdentifierCreation/Three_levels-2180ns ± 3%185ns ± 1%+2.82%(p=0.002 n=6+6)
RuntimeFungibleTokenTransfer-2899µs ±24%690µs ± 3%~(p=0.051 n=7+6)
RuntimeResourceDictionaryValues-26.71ms ± 3%6.75ms ± 1%~(p=0.620 n=7+7)
RuntimeScriptNoop-233.2µs ±37%31.1µs ±39%~(p=0.710 n=7+7)
SuperTypeInference/arrays-2400ns ± 3%400ns ± 2%~(p=0.902 n=7+7)
SuperTypeInference/composites-2153ns ± 5%155ns ± 3%~(p=0.318 n=7+7)
SuperTypeInference/integers-2110ns ± 2%112ns ± 3%~(p=0.111 n=6+7)
ValueIsSubtypeOfSemaType-2121ns ± 5%121ns ± 4%~(p=1.000 n=7+6)
 
alloc/opdelta
CheckContractInterfaceFungibleTokenConformance-252.5kB ± 0%52.5kB ± 0%~(all equal)
ContractInterfaceFungibleToken-225.4kB ± 0%25.4kB ± 0%~(all equal)
InterpretRecursionFib-21.00MB ± 0%1.00MB ± 0%~(p=0.303 n=6+7)
NewInterpreter/new_interpreter-2752B ± 0%752B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-2200B ± 0%200B ± 0%~(all equal)
ParseArray-22.68MB ± 3%2.74MB ± 6%~(p=0.091 n=7+7)
ParseDeploy/byte_array-24.25MB ± 4%4.24MB ± 4%~(p=0.259 n=7+7)
ParseDeploy/decode_hex-2214kB ± 0%214kB ± 0%~(p=0.871 n=7+7)
ParseFungibleToken/With_memory_metering-229.5kB ± 0%29.4kB ± 0%~(p=0.883 n=7+7)
ParseFungibleToken/Without_memory_metering-229.5kB ± 0%29.4kB ± 0%~(p=0.808 n=7+7)
ParseInfix-21.92kB ± 0%1.92kB ± 0%~(p=1.000 n=7+7)
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
RuntimeFungibleTokenTransfer-2103kB ± 0%103kB ± 1%~(p=0.456 n=7+7)
RuntimeResourceDictionaryValues-22.29MB ± 0%2.28MB ± 0%−0.25%(p=0.035 n=6+7)
RuntimeScriptNoop-28.61kB ± 0%8.62kB ± 1%~(p=0.401 n=7+7)
SuperTypeInference/arrays-296.0B ± 0%96.0B ± 0%~(all equal)
SuperTypeInference/composites-20.00B 0.00B ~(all equal)
SuperTypeInference/integers-20.00B 0.00B ~(all equal)
ValueIsSubtypeOfSemaType-248.0B ± 0%48.0B ± 0%~(all equal)
 
allocs/opdelta
CheckContractInterfaceFungibleTokenConformance-2922 ± 0%922 ± 0%~(all equal)
ContractInterfaceFungibleToken-2444 ± 0%444 ± 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-259.6k ± 0%59.6k ± 0%~(p=0.767 n=6+7)
ParseDeploy/byte_array-289.4k ± 0%89.4k ± 0%~(p=0.592 n=7+7)
ParseDeploy/decode_hex-264.0 ± 0%64.0 ± 0%~(all equal)
ParseFungibleToken/With_memory_metering-2789 ± 0%789 ± 0%~(all equal)
ParseFungibleToken/Without_memory_metering-2789 ± 0%789 ± 0%~(all equal)
ParseInfix-248.0 ± 0%48.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.00k ± 0%2.00k ± 0%+0.04%(p=0.033 n=7+6)
RuntimeResourceDictionaryValues-237.0k ± 0%37.0k ± 0%~(p=0.073 n=7+7)
RuntimeScriptNoop-2139 ± 0%139 ± 0%~(all equal)
SuperTypeInference/arrays-23.00 ± 0%3.00 ± 0%~(all equal)
SuperTypeInference/composites-20.00 0.00 ~(all equal)
SuperTypeInference/integers-20.00 0.00 ~(all equal)
ValueIsSubtypeOfSemaType-21.00 ± 0%1.00 ± 0%~(all equal)
 

Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@dsainati1 dsainati1 merged commit 5b0ba3c into feature/stable-cadence Nov 30, 2022
@dsainati1 dsainati1 deleted the sainati/transaction-view-preconditions branch November 30, 2022 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants