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

Fix composite-typed argument passing #1235

Merged
merged 4 commits into from
Nov 15, 2021
Merged

Fix composite-typed argument passing #1235

merged 4 commits into from
Nov 15, 2021

Conversation

SupunS
Copy link
Member

@SupunS SupunS commented Nov 12, 2021

Closes onflow/flow-emulator#94

Description

When composite typed values are passed in as arguments, always get the field type info from the type-definition.


  • 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

@SupunS SupunS added the Bugfix label Nov 12, 2021
@SupunS SupunS self-assigned this Nov 12, 2021
@github-actions
Copy link

github-actions bot commented Nov 12, 2021

Cadence Benchstat comparison

This branch with compared with the base branch onflow:master commit c4c1392
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
RuntimeStorageWriteCached-2163µs ±30%146µs ± 1%~(p=0.710 n=7+7)
RuntimeFungibleTokenTransfer-21.19ms ± 1%1.34ms ±18%~(p=0.209 n=7+7)
ParseArray-224.9ms ± 1%25.0ms ± 2%~(p=0.620 n=7+7)
ParseDeploy/byte_array-237.4ms ± 3%37.0ms ± 2%~(p=0.209 n=7+7)
ParseFungibleToken-2505µs ± 2%504µs ± 2%~(p=0.710 n=7+7)
ParseInfix-226.4µs ± 1%26.3µs ± 1%~(p=0.731 n=7+6)
QualifiedIdentifierCreation/One_level-22.93ns ± 0%2.93ns ± 0%~(p=0.513 n=6+6)
QualifiedIdentifierCreation/Three_levels-2173ns ± 2%173ns ± 0%~(p=0.814 n=7+6)
ContractInterfaceFungibleToken-249.2µs ± 2%49.7µs ± 1%~(p=0.132 n=6+6)
NewInterpreter/new_sub-interpreter-22.21µs ± 2%2.21µs ± 1%~(p=0.976 n=7+6)
InterpretRecursionFib-22.88ms ± 2%2.84ms ± 3%~(p=0.053 n=7+7)
CheckContractInterfaceFungibleTokenConformance-2162µs ± 1%161µs ± 0%−0.63%(p=0.035 n=7+6)
NewInterpreter/new_interpreter-21.24µs ± 2%1.22µs ± 1%−1.86%(p=0.002 n=6+7)
ParseDeploy/decode_hex-21.51ms ± 3%1.48ms ± 1%−2.13%(p=0.011 n=7+7)
RuntimeResourceDictionaryValues-217.6ms ± 1%17.2ms ± 2%−2.68%(p=0.005 n=6+7)
 
alloc/opdelta
RuntimeStorageWriteCached-283.7kB ± 0%83.7kB ± 0%~(p=1.126 n=6+7)
RuntimeFungibleTokenTransfer-2225kB ± 0%225kB ± 0%~(p=0.779 n=7+7)
RuntimeResourceDictionaryValues-24.33MB ± 0%4.33MB ± 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)
ContractInterfaceFungibleToken-226.7kB ± 0%26.7kB ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-266.4kB ± 0%66.4kB ± 0%~(all equal)
NewInterpreter/new_interpreter-2680B ± 0%680B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-21.02kB ± 0%1.02kB ± 0%~(all equal)
InterpretRecursionFib-21.21MB ± 0%1.21MB ± 0%~(all equal)
 
allocs/opdelta
RuntimeStorageWriteCached-21.42k ± 0%1.42k ± 0%~(all equal)
RuntimeFungibleTokenTransfer-24.38k ± 0%4.38k ± 0%~(p=0.140 n=6+7)
RuntimeResourceDictionaryValues-2108k ± 0%108k ± 0%~(p=1.086 n=6+7)
QualifiedIdentifierCreation/One_level-20.00 0.00 ~(all equal)
QualifiedIdentifierCreation/Three_levels-22.00 ± 0%2.00 ± 0%~(all equal)
ContractInterfaceFungibleToken-2458 ± 0%458 ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-21.07k ± 0%1.07k ± 0%~(all equal)
NewInterpreter/new_interpreter-211.0 ± 0%11.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-230.0 ± 0%30.0 ± 0%~(all equal)
InterpretRecursionFib-225.0k ± 0%25.0k ± 0%~(all equal)
 

@codecov-commenter
Copy link

Codecov Report

Merging #1235 (11f734c) into master (c4c1392) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1235   +/-   ##
=======================================
  Coverage   77.53%   77.54%           
=======================================
  Files         274      274           
  Lines       35085    35083    -2     
=======================================
  Hits        27204    27204           
+ Misses       6801     6799    -2     
  Partials     1080     1080           
Flag Coverage Δ
unittests 77.54% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
runtime/common/location.go 74.19% <100.00%> (+2.76%) ⬆️
runtime/convertValues.go 76.85% <100.00%> (+0.25%) ⬆️
runtime/interpreter/interpreter.go 89.05% <100.00%> (+<0.01%) ⬆️
runtime/interpreter/statictype.go 69.33% <100.00%> (-0.54%) ⬇️

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 c4c1392...11f734c. Read the comment docs.

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! Thank you for fixing this 👍

@@ -3817,7 +3817,11 @@ func (interpreter *Interpreter) GetContractComposite(contractLocation common.Add
return contractValue, nil
}

func (interpreter *Interpreter) getCompositeType(location common.Location, qualifiedIdentifier string, typeID common.TypeID) (*sema.CompositeType, error) {
func (interpreter *Interpreter) GetCompositeType(
Copy link
Member

Choose a reason for hiding this comment

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

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.

Unable to pass certain structures as arguments to scripts / transactions
3 participants