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

Improve state decoding tool #1232

Merged
merged 3 commits into from
Dec 9, 2021
Merged

Conversation

turbolent
Copy link
Member

Description

  • Handle slab not found errors gracefully (report them)
  • Ignore and report empty lines

  • 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-commenter commented Nov 10, 2021

Codecov Report

Merging #1232 (45a7a78) into master (141b10c) will increase coverage by 0.23%.
The diff coverage is n/a.

❗ Current head 45a7a78 differs from pull request most recent head 80d66a9. Consider uploading reports for the commit 80d66a9 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1232      +/-   ##
==========================================
+ Coverage   77.17%   77.41%   +0.23%     
==========================================
  Files         279      273       -6     
  Lines       35791    34823     -968     
==========================================
- Hits        27623    26957     -666     
+ Misses       7081     6791     -290     
+ Partials     1087     1075      -12     
Flag Coverage Δ
unittests 77.41% <ø> (+0.23%) ⬆️

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

Impacted Files Coverage Δ
runtime/format/string.go 89.28% <0.00%> (-10.72%) ⬇️
runtime/ast/expression.go 74.12% <0.00%> (-8.76%) ⬇️
runtime/common/location.go 71.42% <0.00%> (-2.77%) ⬇️
runtime/ast/block.go 87.50% <0.00%> (-2.50%) ⬇️
runtime/parser2/parser.go 94.58% <0.00%> (-0.99%) ⬇️
runtime/interpreter/errors.go 23.20% <0.00%> (-0.97%) ⬇️
runtime/interpreter/statictype.go 69.86% <0.00%> (-0.72%) ⬇️
runtime/ast/statement.go 77.56% <0.00%> (-0.70%) ⬇️
runtime/convertValues.go 76.60% <0.00%> (-0.66%) ⬇️
runtime/sema/check_for.go 92.72% <0.00%> (-0.61%) ⬇️
... and 50 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 141b10c...80d66a9. Read the comment docs.

@github-actions
Copy link

github-actions bot commented Nov 10, 2021

Cadence Benchstat comparison

This branch with compared with the base branch onflow:master commit 141b10c
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
ContractInterfaceFungibleToken-248.5µs ± 2%50.4µs ± 5%+3.89%(p=0.005 n=6+7)
RuntimeResourceDictionaryValues-217.6ms ± 2%17.8ms ± 4%~(p=0.366 n=7+6)
RuntimeFungibleTokenTransfer-21.61ms ±18%1.57ms ±18%~(p=0.318 n=7+7)
ParseFungibleToken-2483µs ± 3%489µs ± 1%~(p=0.432 n=7+5)
ParseInfix-225.4µs ± 2%25.1µs ± 2%~(p=0.138 n=7+6)
ParseArray-223.8ms ± 6%23.7ms ± 4%~(p=1.000 n=7+7)
ParseDeploy/byte_array-235.7ms ± 3%36.0ms ± 5%~(p=0.456 n=7+7)
ParseDeploy/decode_hex-21.48ms ± 3%1.48ms ± 3%~(p=0.628 n=7+6)
QualifiedIdentifierCreation/One_level-23.33ns ± 3%3.29ns ± 2%~(p=0.301 n=7+7)
QualifiedIdentifierCreation/Three_levels-2169ns ± 3%167ns ± 7%~(p=0.456 n=7+7)
CheckContractInterfaceFungibleTokenConformance-2179µs ± 5%175µs ± 3%~(p=0.259 n=7+7)
NewInterpreter/new_interpreter-21.21µs ± 4%1.24µs ± 3%~(p=0.137 n=7+7)
NewInterpreter/new_sub-interpreter-22.22µs ± 3%2.27µs ± 6%~(p=0.080 n=7+7)
InterpretRecursionFib-22.73ms ± 1%2.81ms ± 5%~(p=0.097 n=7+7)
 
alloc/opdelta
RuntimeResourceDictionaryValues-24.34MB ± 0%4.34MB ± 0%~(p=0.902 n=7+7)
RuntimeFungibleTokenTransfer-2238kB ± 0%238kB ± 0%~(p=0.659 n=7+6)
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
ContractInterfaceFungibleToken-226.5kB ± 0%26.5kB ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-265.7kB ± 0%65.7kB ± 0%~(all equal)
NewInterpreter/new_interpreter-2720B ± 0%720B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-21.11kB ± 0%1.11kB ± 0%~(all equal)
InterpretRecursionFib-21.24MB ± 0%1.24MB ± 0%~(p=0.140 n=7+6)
 
allocs/opdelta
RuntimeResourceDictionaryValues-2108k ± 0%108k ± 0%~(p=0.970 n=7+7)
RuntimeFungibleTokenTransfer-24.53k ± 0%4.53k ± 0%~(p=0.755 n=7+7)
QualifiedIdentifierCreation/One_level-20.00 0.00 ~(all equal)
QualifiedIdentifierCreation/Three_levels-22.00 ± 0%2.00 ± 0%~(all equal)
ContractInterfaceFungibleToken-2457 ± 0%457 ± 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-232.0 ± 0%32.0 ± 0%~(all equal)
InterpretRecursionFib-225.0k ± 0%25.0k ± 0%~(all equal)
 

Comment on lines +273 to +277
err := loadStorageKey(key, address, data, inter, slabStorage)
var slabNotFoundErr *atree.SlabNotFoundError
if errors.As(err, &slabNotFoundErr) {
slabNotFoundErrCount++
}
Copy link
Member

Choose a reason for hiding this comment

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

I think atree.SlabNotFoundError might not be returned from loadStorageKey.

Copy link
Member Author

@turbolent turbolent Nov 19, 2021

Choose a reason for hiding this comment

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

loadStorageKey calls StoredValue on the decoded slab, which in turn might read more slabs (e.g. if it is an atree value like an array or dictionary). The decoded state might be corrupt, which might cause atree to load a slab which does not exist, resulting in a SlabNotFoundError

@turbolent turbolent merged commit aaf0a50 into master Dec 9, 2021
@turbolent turbolent deleted the bastian/improve-state-decoding-tool branch December 9, 2021 13:08
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