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 CharacterValue type #1392

Merged
merged 20 commits into from
Feb 3, 2022
Merged

Add CharacterValue type #1392

merged 20 commits into from
Feb 3, 2022

Conversation

dsainati1
Copy link
Contributor

@dsainati1 dsainati1 commented Jan 31, 2022

Closes #1373

Description

Cadence previously lacked a runtime character value, causing some inconsistency between the static Character type and values with that type at runtime. This adds runtime Character values, which are produced by indexing into a string and by creating a character variable like so: let x: Character = "a".


  • 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

@dsainati1 dsainati1 added Language Breaking Change Breaks Cadence contracts deployed on Mainnet Improvement labels Jan 31, 2022
@dsainati1 dsainati1 requested review from turbolent and SupunS January 31, 2022 21:14
@dsainati1 dsainati1 self-assigned this Jan 31, 2022
@github-actions
Copy link

github-actions bot commented Jan 31, 2022

Cadence Benchstat comparison

This branch with compared with the base branch onflow:master commit d3124c5
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.7ms ± 4%14.0ms ± 4%~(p=0.165 n=7+7)
RuntimeFungibleTokenTransfer-21.10ms ±30%1.14ms ±27%~(p=0.902 n=7+7)
ParseDeploy/byte_array-219.5ms ± 2%19.8ms ± 6%~(p=0.383 n=7+7)
ParseFungibleToken-2175µs ± 5%174µs ± 6%~(p=0.710 n=7+7)
ParseInfix-29.25µs ± 3%9.15µs ± 5%~(p=0.945 n=6+7)
ParseArray-212.2ms ± 3%12.1ms ± 4%~(p=0.699 n=6+6)
QualifiedIdentifierCreation/Three_levels-2132ns ± 4%131ns ± 4%~(p=0.402 n=7+7)
CheckContractInterfaceFungibleTokenConformance-2128µs ± 5%125µs ± 3%~(p=0.731 n=7+6)
NewInterpreter/new_interpreter-21.03µs ± 2%1.00µs ± 5%~(p=0.175 n=7+6)
NewInterpreter/new_sub-interpreter-22.01µs ± 3%2.01µs ± 6%~(p=0.805 n=7+7)
ParseDeploy/decode_hex-21.12ms ± 4%1.08ms ± 4%−3.62%(p=0.038 n=7+7)
InterpretRecursionFib-22.39ms ± 6%2.28ms ± 4%−4.73%(p=0.007 n=7+7)
ContractInterfaceFungibleToken-239.5µs ± 6%37.5µs ± 3%−5.25%(p=0.026 n=7+7)
QualifiedIdentifierCreation/One_level-22.23ns ± 7%2.07ns ± 0%−7.01%(p=0.050 n=7+7)
 
alloc/opdelta
CheckContractInterfaceFungibleTokenConformance-265.7kB ± 0%66.0kB ± 0%+0.44%(p=0.002 n=6+6)
ContractInterfaceFungibleToken-226.5kB ± 0%26.6kB ± 0%+0.30%(p=0.001 n=7+7)
RuntimeFungibleTokenTransfer-2277kB ± 0%277kB ± 0%+0.10%(p=0.003 n=5+7)
RuntimeResourceDictionaryValues-24.05MB ± 0%4.05MB ± 0%~(p=0.318 n=7+7)
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
NewInterpreter/new_interpreter-2768B ± 0%768B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-21.24kB ± 0%1.24kB ± 0%~(all equal)
InterpretRecursionFib-21.24MB ± 0%1.24MB ± 0%~(p=1.168 n=6+7)
 
allocs/opdelta
ContractInterfaceFungibleToken-2457 ± 0%458 ± 0%+0.22%(p=0.001 n=7+7)
CheckContractInterfaceFungibleTokenConformance-21.07k ± 0%1.07k ± 0%+0.19%(p=0.001 n=7+7)
RuntimeFungibleTokenTransfer-24.62k ± 0%4.62k ± 0%+0.04%(p=0.017 n=7+7)
RuntimeResourceDictionaryValues-2102k ± 0%102k ± 0%~(p=0.906 n=7+7)
QualifiedIdentifierCreation/One_level-20.00 0.00 ~(all equal)
QualifiedIdentifierCreation/Three_levels-22.00 ± 0%2.00 ± 0%~(all equal)
NewInterpreter/new_interpreter-212.0 ± 0%12.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-238.0 ± 0%38.0 ± 0%~(all equal)
InterpretRecursionFib-225.0k ± 0%25.0k ± 0%~(all equal)
 

@dsainati1 dsainati1 marked this pull request as ready for review February 1, 2022 15:42
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, great work!

@codecov-commenter
Copy link

codecov-commenter commented Feb 2, 2022

Codecov Report

Merging #1392 (eacabaa) into master (d3124c5) will decrease coverage by 2.76%.
The diff coverage is 74.79%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1392      +/-   ##
==========================================
- Coverage   75.81%   73.05%   -2.77%     
==========================================
  Files         279      280       +1     
  Lines       38780    38900     +120     
==========================================
- Hits        29402    28419     -983     
- Misses       8016     9038    +1022     
- Partials     1362     1443      +81     
Flag Coverage Δ
unittests 73.05% <74.79%> (-2.77%) ⬇️

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

Impacted Files Coverage Δ
runtime/interpreter/dynamictype.go 66.66% <0.00%> (-1.91%) ⬇️
runtime/interpreter/hashablevalue.go 100.00% <ø> (ø)
runtime/interpreter/visitor.go 8.33% <0.00%> (-0.22%) ⬇️
runtime/interpreter/decode.go 44.50% <30.76%> (-0.20%) ⬇️
values.go 71.09% <50.00%> (-0.39%) ⬇️
encoding/json/decode.go 71.08% <66.66%> (-0.05%) ⬇️
runtime/interpreter/encode.go 65.72% <66.66%> (+0.01%) ⬆️
runtime/interpreter/value.go 55.95% <75.00%> (-15.34%) ⬇️
encoding/json/encode.go 93.50% <100.00%> (+0.08%) ⬆️
runtime/convertValues.go 77.41% <100.00%> (+0.14%) ⬆️
... and 12 more

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 d3124c5...eacabaa. 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 work! Just a couple minor things and then ready to get merged 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Language Breaking Change Breaks Cadence contracts deployed on Mainnet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing dedicated CharacterValue leads to incorrect run-time type value
3 participants