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

Add safety checks for go casts in the interpreter #1331

Merged
merged 9 commits into from
Jan 5, 2022

Conversation

dsainati1
Copy link
Contributor

Description

This adds more graceful go handling for some type assertions in the runtime/sema directory, which previously were unhandled. This should not result in any behavioral differences. Part of https://github.com/dapperlabs/cadence-private-issues/issues/4


  • 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-commenter
Copy link

Codecov Report

Merging #1331 (0e213e7) into master (834f5f1) will decrease coverage by 0.26%.
The diff coverage is 44.01%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1331      +/-   ##
==========================================
- Coverage   75.57%   75.30%   -0.27%     
==========================================
  Files         279      279              
  Lines       37813    37934     +121     
==========================================
- Hits        28578    28568      -10     
- Misses       7958     8030      +72     
- Partials     1277     1336      +59     
Flag Coverage Δ
unittests 75.30% <44.01%> (-0.27%) ⬇️

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

Impacted Files Coverage Δ
runtime/interpreter/value.go 68.44% <39.13%> (-0.52%) ⬇️
runtime/interpreter/interpreter.go 88.01% <39.62%> (-1.60%) ⬇️
runtime/interpreter/interpreter_expression.go 81.78% <48.48%> (-9.40%) ⬇️
runtime/interpreter/interpreter_statement.go 86.44% <53.84%> (-2.26%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 834f5f1...0e213e7. Read the comment docs.

@github-actions
Copy link

github-actions bot commented Jan 4, 2022

Cadence Benchstat comparison

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

Results

old.txtnew.txt
time/opdelta
RuntimeResourceDictionaryValues-213.6ms ± 2%13.4ms ± 7%~(p=0.165 n=7+7)
RuntimeFungibleTokenTransfer-21.12ms ±20%1.16ms ±18%~(p=1.000 n=7+7)
ParseDeploy/byte_array-233.5ms ± 3%33.2ms ± 1%~(p=0.534 n=7+6)
ParseDeploy/decode_hex-21.16ms ± 1%1.16ms ± 0%~(p=0.268 n=7+5)
ParseArray-222.5ms ± 3%22.1ms ± 2%~(p=0.053 n=7+7)
ParseFungibleToken-2439µs ± 4%436µs ± 2%~(p=0.710 n=7+7)
ParseInfix-223.6µs ± 4%23.7µs ± 2%~(p=0.456 n=7+7)
QualifiedIdentifierCreation/One_level-22.83ns ± 2%2.81ns ± 0%~(p=0.803 n=6+6)
QualifiedIdentifierCreation/Three_levels-2120ns ± 2%120ns ± 1%~(p=0.472 n=6+7)
CheckContractInterfaceFungibleTokenConformance-2129µs ± 1%128µs ± 2%~(p=0.234 n=6+7)
ContractInterfaceFungibleToken-240.0µs ± 1%39.6µs ± 1%~(p=0.132 n=6+6)
InterpretRecursionFib-22.53ms ± 4%2.48ms ± 1%~(p=0.534 n=7+6)
NewInterpreter/new_interpreter-2967ns ± 1%965ns ± 1%~(p=0.699 n=6+6)
NewInterpreter/new_sub-interpreter-22.11µs ± 5%2.05µs ± 1%−2.63%(p=0.019 n=7+7)
 
alloc/opdelta
RuntimeResourceDictionaryValues-24.04MB ± 0%4.04MB ± 0%~(p=0.383 n=7+7)
RuntimeFungibleTokenTransfer-2238kB ± 0%238kB ± 0%~(p=0.646 n=7+7)
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-265.7kB ± 0%65.7kB ± 0%~(all equal)
ContractInterfaceFungibleToken-226.5kB ± 0%26.5kB ± 0%~(all equal)
InterpretRecursionFib-21.24MB ± 0%1.24MB ± 0%~(p=0.972 n=6+7)
NewInterpreter/new_interpreter-2720B ± 0%720B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-21.18kB ± 0%1.18kB ± 0%~(all equal)
 
allocs/opdelta
RuntimeResourceDictionaryValues-2102k ± 0%102k ± 0%~(p=0.718 n=7+7)
RuntimeFungibleTokenTransfer-24.54k ± 0%4.54k ± 0%~(p=0.700 n=7+7)
QualifiedIdentifierCreation/One_level-20.00 0.00 ~(all equal)
QualifiedIdentifierCreation/Three_levels-22.00 ± 0%2.00 ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-21.07k ± 0%1.07k ± 0%~(all equal)
ContractInterfaceFungibleToken-2457 ± 0%457 ± 0%~(all equal)
InterpretRecursionFib-225.0k ± 0%25.0k ± 0%~(all equal)
NewInterpreter/new_interpreter-211.0 ± 0%11.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-236.0 ± 0%36.0 ± 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.

Looks good! 👍

@dsainati1 dsainati1 merged commit dbdcbc5 into master Jan 5, 2022
@dsainati1 dsainati1 deleted the interpreter-go-casts branch January 5, 2022 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants