cadence
cadence copied to clipboard
add a `clear` method to delete saved data in storage
Closes #1245
Adds a new method to the AuthAccount
object:
fun clear(_ path: Path): Bool
This function deletes whatever is present at the specified path, destroying any resources, and returns whether anything was present originally.
- [X] Targeted PR against
master
branch - [X] Linked to Github issue with discussion and accepted design OR link to spec that describes this work
- [X] Code follows the standards mentioned here
- [X] Updated relevant documentation
- [X] Re-reviewed
Files changed
in the Github PR explorer - [X] Added appropriate labels
Codecov Report
Merging #1253 (2ee3fb9) into master (81c63bf) will increase coverage by
0.01%
. The diff coverage is94.59%
.
@@ Coverage Diff @@
## master #1253 +/- ##
==========================================
+ Coverage 77.60% 77.61% +0.01%
==========================================
Files 274 274
Lines 35233 35261 +28
==========================================
+ Hits 27341 27369 +28
Misses 6805 6805
Partials 1087 1087
Flag | Coverage Δ | |
---|---|---|
unittests | 77.61% <94.59%> (+0.01%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
Impacted Files | Coverage Δ | |
---|---|---|
runtime/interpreter/interpreter.go | 89.19% <89.47%> (+0.06%) |
:arrow_up: |
runtime/interpreter/account.go | 93.16% <100.00%> (+0.17%) |
:arrow_up: |
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 81c63bf...2ee3fb9. Read the comment docs.
Cadence Benchstat comparison
This branch with compared with the base branch onflow:master commit 81c63bfef73cd4874d05b6274dbd2402a0a0b788
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.txt | new.txt | |||
---|---|---|---|---|
time/op | delta | |||
QualifiedIdentifierCreation/One_level-2 | 3.17ns ± 4% | 3.30ns ± 2% | +4.14% | (p=0.008 n=7+6) |
ParseArray-2 | 22.6ms ± 1% | 23.1ms ± 2% | +1.88% | (p=0.005 n=6+7) |
RuntimeStorageWriteCached-2 | 169µs ±43% | 143µs ± 2% | ~ | (p=0.731 n=7+6) |
RuntimeResourceDictionaryValues-2 | 16.7ms ± 3% | 16.4ms ± 3% | ~ | (p=0.534 n=7+6) |
RuntimeFungibleTokenTransfer-2 | 1.24ms ± 4% | 1.24ms ± 3% | ~ | (p=0.445 n=7+6) |
ParseFungibleToken-2 | 469µs ± 2% | 475µs ± 2% | ~ | (p=0.165 n=7+7) |
ParseInfix-2 | 24.6µs ± 2% | 24.9µs ± 4% | ~ | (p=0.456 n=7+7) |
ParseDeploy/decode_hex-2 | 1.44ms ± 4% | 1.43ms ± 3% | ~ | (p=1.000 n=7+7) |
QualifiedIdentifierCreation/Three_levels-2 | 161ns ± 2% | 163ns ± 4% | ~ | (p=0.386 n=6+7) |
CheckContractInterfaceFungibleTokenConformance-2 | 168µs ± 3% | 171µs ± 5% | ~ | (p=0.128 n=7+7) |
ContractInterfaceFungibleToken-2 | 47.4µs ± 1% | 47.8µs ± 2% | ~ | (p=0.318 n=7+7) |
InterpretRecursionFib-2 | 2.71ms ± 3% | 2.68ms ± 3% | ~ | (p=0.945 n=7+6) |
NewInterpreter/new_interpreter-2 | 1.16µs ± 5% | 1.16µs ± 2% | ~ | (p=0.781 n=7+7) |
NewInterpreter/new_sub-interpreter-2 | 2.11µs ± 3% | 2.10µs ± 3% | ~ | (p=0.779 n=7+7) |
ParseDeploy/byte_array-2 | 35.0ms ± 3% | 34.3ms ± 2% | −2.15% | (p=0.038 n=7+7) |
alloc/op | delta | |||
RuntimeFungibleTokenTransfer-2 | 233kB ± 0% | 234kB ± 0% | +0.40% | (p=0.001 n=7+7) |
RuntimeResourceDictionaryValues-2 | 4.34MB ± 0% | 4.34MB ± 0% | +0.02% | (p=0.001 n=7+7) |
RuntimeStorageWriteCached-2 | 83.7kB ± 0% | 83.7kB ± 0% | ~ | (p=0.294 n=6+7) |
QualifiedIdentifierCreation/One_level-2 | 0.00B | 0.00B | ~ | (all equal) |
QualifiedIdentifierCreation/Three_levels-2 | 64.0B ± 0% | 64.0B ± 0% | ~ | (all equal) |
CheckContractInterfaceFungibleTokenConformance-2 | 66.4kB ± 0% | 66.4kB ± 0% | ~ | (p=1.000 n=7+7) |
ContractInterfaceFungibleToken-2 | 26.7kB ± 0% | 26.7kB ± 0% | ~ | (all equal) |
InterpretRecursionFib-2 | 1.21MB ± 0% | 1.21MB ± 0% | ~ | (p=0.385 n=7+6) |
NewInterpreter/new_interpreter-2 | 680B ± 0% | 680B ± 0% | ~ | (all equal) |
NewInterpreter/new_sub-interpreter-2 | 1.06kB ± 0% | 1.06kB ± 0% | ~ | (all equal) |
allocs/op | delta | |||
RuntimeFungibleTokenTransfer-2 | 4.42k ± 0% | 4.43k ± 0% | +0.06% | (p=0.001 n=6+7) |
RuntimeResourceDictionaryValues-2 | 108k ± 0% | 108k ± 0% | +0.00% | (p=0.005 n=7+7) |
RuntimeStorageWriteCached-2 | 1.42k ± 0% | 1.42k ± 0% | ~ | (all equal) |
QualifiedIdentifierCreation/One_level-2 | 0.00 | 0.00 | ~ | (all equal) |
QualifiedIdentifierCreation/Three_levels-2 | 2.00 ± 0% | 2.00 ± 0% | ~ | (all equal) |
CheckContractInterfaceFungibleTokenConformance-2 | 1.07k ± 0% | 1.07k ± 0% | ~ | (all equal) |
ContractInterfaceFungibleToken-2 | 458 ± 0% | 458 ± 0% | ~ | (all equal) |
InterpretRecursionFib-2 | 25.0k ± 0% | 25.0k ± 0% | ~ | (all equal) |
NewInterpreter/new_interpreter-2 | 11.0 ± 0% | 11.0 ± 0% | ~ | (all equal) |
NewInterpreter/new_sub-interpreter-2 | 31.0 ± 0% | 31.0 ± 0% | ~ | (all equal) |
@dete Any thoughts?
@dsainati1 Should we maybe consider this change for Stable Cadence?
@dsainati1 Should we maybe consider this change for Stable Cadence?
Seems to me like based on the discussion on https://github.com/onflow/cadence/pull/1252, the sentiment is against these two methods, the argument being that any operation that destroys a resource should be explicit; having methods that can implicitly destroy resources is not a desirable feature for the language.
However I would be willing to put this to a FLIP if it's something we want to push for anyways.
@dsainati1 Sounds good! Added it to the agenda of the next LDM, maybe we can decide there together if we want to close this and the other related PR, or open a FLIP for them
Put on-hold for now, see https://github.com/onflow/cadence/blob/master/meetings/2022-10-11.md#additional-storage-api-functions
Seems like this feature is not wanted; closing.