cadence icon indicating copy to clipboard operation
cadence copied to clipboard

Add support for Fx prefix for addresses

Open robert-e-davidson3 opened this issue 2 years ago • 2 comments

Closes #398

Description

Addresses can start with Fx.

Lexer reads tokens starting with Fx as hexadecimals if followed by a valid hex rune. So Fx0123456789abcdef is a valid number.

Related changes to treat Fx as a valid beginning to hex numbers.


WIP:

  • [ ] Revert altered test to use 0x prefix for import.
  • [ ] Add tests that use Fx prefix for addresses.

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

robert-e-davidson3 avatar Mar 20 '22 19:03 robert-e-davidson3

Cadence Benchstat comparison

This branch with compared with the base branch onflow:master commit f615beac3761d79dd829d408a635b502ae15e676 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
QualifiedIdentifierCreation/One_level-22.34ns ± 0%2.68ns ± 0%+14.32%(p=0.001 n=7+7)
ParseDeploy/decode_hex-21.14ms ± 0%1.17ms ± 2%+1.77%(p=0.014 n=6+7)
RuntimeResourceDictionaryValues-26.24ms ± 4%6.28ms ± 1%~(p=0.366 n=7+6)
RuntimeFungibleTokenTransfer-21.26ms ±31%1.14ms ±26%~(p=0.259 n=7+7)
Transfer-284.0ns ± 2%83.7ns ± 1%~(p=1.000 n=7+7)
ParseFungibleToken-2181µs ± 1%186µs ± 7%~(p=0.456 n=7+7)
ParseInfix-28.39µs ± 2%8.41µs ± 1%~(p=0.535 n=7+7)
ParseDeploy/byte_array-219.3ms ± 2%20.1ms ±10%~(p=0.101 n=6+7)
ParseArray-212.8ms ± 8%12.4ms ± 3%~(p=0.710 n=7+7)
QualifiedIdentifierCreation/Three_levels-2138ns ± 0%140ns ± 3%~(p=0.099 n=6+7)
CheckContractInterfaceFungibleTokenConformance-2131µs ± 2%133µs ± 6%~(p=0.731 n=6+7)
ContractInterfaceFungibleToken-239.1µs ± 1%39.4µs ± 0%~(p=0.432 n=7+5)
InterpretRecursionFib-22.67ms ± 3%2.66ms ± 3%~(p=0.710 n=7+7)
NewInterpreter/new_interpreter-21.13µs ± 1%1.14µs ± 1%~(p=0.141 n=6+6)
NewInterpreter/new_sub-interpreter-22.20µs ± 1%2.22µs ± 2%~(p=0.084 n=6+6)
 
alloc/opdelta
RuntimeResourceDictionaryValues-22.25MB ± 0%2.25MB ± 0%~(p=0.383 n=7+7)
RuntimeFungibleTokenTransfer-2273kB ± 0%273kB ± 0%~(p=0.176 n=7+7)
Transfer-248.0B ± 0%48.0B ± 0%~(all equal)
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-266.3kB ± 0%66.3kB ± 0%~(p=0.245 n=7+6)
ContractInterfaceFungibleToken-226.7kB ± 0%26.7kB ± 0%~(p=0.538 n=7+6)
InterpretRecursionFib-21.14MB ± 0%1.14MB ± 0%~(p=0.767 n=6+7)
NewInterpreter/new_interpreter-2848B ± 0%848B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-21.34kB ± 0%1.34kB ± 0%~(all equal)
 
allocs/opdelta
RuntimeResourceDictionaryValues-237.6k ± 0%37.6k ± 0%~(p=0.073 n=7+7)
RuntimeFungibleTokenTransfer-24.58k ± 0%4.58k ± 0%~(p=0.209 n=7+7)
Transfer-21.00 ± 0%1.00 ± 0%~(all equal)
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-2460 ± 0%460 ± 0%~(all equal)
InterpretRecursionFib-223.8k ± 0%23.8k ± 0%~(all equal)
NewInterpreter/new_interpreter-213.0 ± 0%13.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-240.0 ± 0%40.0 ± 0%~(all equal)
 

github-actions[bot] avatar Mar 20 '22 19:03 github-actions[bot]

Codecov Report

Merging #1518 (be23c56) into master (f615bea) will decrease coverage by 0.06%. The diff coverage is 52.50%.

:exclamation: Current head be23c56 differs from pull request most recent head 8a3cdd6. Consider uploading reports for the commit 8a3cdd6 to get more accurate results

@@            Coverage Diff             @@
##           master    #1518      +/-   ##
==========================================
- Coverage   74.73%   74.66%   -0.07%     
==========================================
  Files         288      289       +1     
  Lines       55340    55641     +301     
==========================================
+ Hits        41357    41543     +186     
- Misses      12489    12600     +111     
- Partials     1494     1498       +4     
Flag Coverage Δ
unittests 74.66% <52.50%> (-0.07%) :arrow_down:

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

Impacted Files Coverage Δ
encoding/json/decode.go 74.31% <0.00%> (ø)
runtime/parser2/lexer/state.go 93.42% <43.75%> (-6.58%) :arrow_down:
runtime/common/address.go 94.00% <100.00%> (+0.12%) :arrow_up:
runtime/parser2/lexer/lexer.go 95.95% <100.00%> (ø)
runtime/sema/ordered_map_member_struct.go 42.25% <0.00%> (-7.05%) :arrow_down:
runtime/interpreter/primitivestatictype.go 72.93% <0.00%> (-6.89%) :arrow_down:
runtime/interpreter/statictype.go 70.58% <0.00%> (-3.27%) :arrow_down:
runtime/sema/checker.go 89.47% <0.00%> (-1.01%) :arrow_down:
runtime/runtime.go 85.87% <0.00%> (-1.01%) :arrow_down:
runtime/interpreter/variable_activations.go 61.36% <0.00%> (-0.86%) :arrow_down:
... and 36 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 f615bea...8a3cdd6. Read the comment docs.

codecov-commenter avatar Mar 20 '22 22:03 codecov-commenter