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 typeAt function for inspecting the type of objects in storage #1254

Merged
merged 10 commits into from
Nov 26, 2021

Conversation

dsainati1
Copy link
Contributor

Closes #1246

Description

Adds a method to AuthAccounts to inspect the type of an object in storage:

cadence•fun typeAt(_ path: StoragePath): Type?

if the storage path is empty, the function returns nil. Otherwise, it returns the type of the value stored there.


  • 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

@github-actions
Copy link

github-actions bot commented Nov 18, 2021

Cadence Benchstat comparison

This branch with compared with the base branch onflow:master commit 0e7825d
The command go test ./... -run=XXX -bench=. -shuffle=on -count N was used.
Bench tests were run a total of 7 times on each branch.

Results

old.txtnew.txt
time/opdelta
InterpretRecursionFib-22.62ms ± 1%2.83ms ± 7%+8.31%(p=0.001 n=6+7)
NewInterpreter/new_interpreter-21.15µs ± 2%1.18µs ± 3%+2.91%(p=0.014 n=6+7)
CheckContractInterfaceFungibleTokenConformance-2164µs ± 2%168µs ± 5%+2.64%(p=0.035 n=6+7)
RuntimeStorageWriteCached-2153µs ±42%133µs ± 1%~(p=0.805 n=7+7)
RuntimeResourceDictionaryValues-216.0ms ± 3%15.9ms ± 4%~(p=0.710 n=7+7)
RuntimeFungibleTokenTransfer-21.19ms ± 1%1.40ms ±25%~(p=0.456 n=7+7)
ParseArray-221.7ms ± 3%21.5ms ± 2%~(p=0.456 n=7+7)
ParseFungibleToken-2443µs ± 3%442µs ± 2%~(p=1.000 n=7+7)
ParseDeploy/decode_hex-21.42ms ± 3%1.41ms ± 3%~(p=0.535 n=7+7)
QualifiedIdentifierCreation/One_level-23.11ns ± 1%3.10ns ± 1%~(p=0.945 n=7+6)
QualifiedIdentifierCreation/Three_levels-2163ns ± 1%162ns ± 2%~(p=0.234 n=6+7)
ContractInterfaceFungibleToken-246.9µs ± 4%47.6µs ± 5%~(p=0.535 n=7+7)
NewInterpreter/new_sub-interpreter-22.07µs ± 2%2.12µs ± 3%~(p=0.073 n=7+7)
ParseInfix-223.2µs ± 2%22.8µs ± 1%−1.76%(p=0.022 n=7+6)
ParseDeploy/byte_array-232.8ms ± 3%32.0ms ± 1%−2.50%(p=0.002 n=7+7)
 
alloc/opdelta
RuntimeFungibleTokenTransfer-2231kB ± 0%232kB ± 0%+0.37%(p=0.001 n=7+7)
RuntimeResourceDictionaryValues-24.34MB ± 0%4.34MB ± 0%+0.02%(p=0.001 n=7+7)
RuntimeStorageWriteCached-283.7kB ± 0%83.7kB ± 0%~(all equal)
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%~(p=0.592 n=7+7)
ContractInterfaceFungibleToken-226.5kB ± 0%26.5kB ± 0%~(p=0.385 n=6+7)
InterpretRecursionFib-21.21MB ± 0%1.21MB ± 0%~(all equal)
NewInterpreter/new_interpreter-2680B ± 0%680B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-21.06kB ± 0%1.06kB ± 0%~(all equal)
 
allocs/opdelta
RuntimeResourceDictionaryValues-2108k ± 0%108k ± 0%+0.00%(p=0.008 n=7+6)
RuntimeStorageWriteCached-21.42k ± 0%1.42k ± 0%~(all equal)
RuntimeFungibleTokenTransfer-24.40k ± 0%4.40k ± 0%~(p=0.604 n=6+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-231.0 ± 0%31.0 ± 0%~(all equal)
 

@codecov-commenter
Copy link

codecov-commenter commented Nov 23, 2021

Codecov Report

Merging #1254 (c802694) into master (0e7825d) will increase coverage by 0.01%.
The diff coverage is 92.00%.

❗ Current head c802694 differs from pull request most recent head 1fc91ca. Consider uploading reports for the commit 1fc91ca to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1254      +/-   ##
==========================================
+ Coverage   77.31%   77.32%   +0.01%     
==========================================
  Files         274      274              
  Lines       35347    35372      +25     
==========================================
+ Hits        27327    27350      +23     
- Misses       6941     6943       +2     
  Partials     1079     1079              
Flag Coverage Δ
unittests 77.32% <92.00%> (+0.01%) ⬆️

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

Impacted Files Coverage Δ
runtime/interpreter/interpreter.go 89.11% <87.50%> (-0.02%) ⬇️
runtime/interpreter/account.go 93.16% <100.00%> (+0.17%) ⬆️
runtime/sema/authaccount_type.go 100.00% <100.00%> (ø)

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 0e7825d...1fc91ca. Read the comment docs.

@dsainati1 dsainati1 requested a review from turbolent November 23, 2021 19:53
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.

Nice! Just one small issue in the documentation, but should be good to merge after

Co-authored-by: Bastian Müller <[email protected]>
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.

add a typeAt function to get the type of stored data
3 participants