From 1ecf35ce2d16f344d653e41deb6534409dd0a0e4 Mon Sep 17 00:00:00 2001 From: Faye Amacker <33205765+fxamacker@users.noreply.github.com> Date: Thu, 9 Nov 2023 17:37:37 -0600 Subject: [PATCH] Add `atRoot` parameter to Value.Transfer() This commit adds a new parameter atRoot to Transfer(). Atree storage is validated only if both remove and atRoot parameters are true in ArrayValue.Transfer(), DictionaryValue.Transfer(), and CompositeValue.Transfer(). Currently in ArrayValue.Transfer(), DictionaryValue.Transfer(), and CompositeValue.Transfer() if remove parameter is true: - atree storage is validated - container slab is removed However, when transferring nested ArrayValue, DictionaryValue, and CompositeValue with remove flag, atree storage validation can fail because child slab is removed while parent container is not reset completely yet. This validation problem is similar to the previously fixed atree storage validation problem during nested DeepRemove(). --- runtime/interpreter/interpreter.go | 3 + runtime/interpreter/interpreter_expression.go | 1 + runtime/interpreter/interpreter_invocation.go | 1 + runtime/interpreter/interpreter_statement.go | 1 + runtime/interpreter/simplecompositevalue.go | 1 + runtime/interpreter/storage_test.go | 1 + runtime/interpreter/value.go | 82 +++++++++++++++++-- .../value_accountcapabilitycontroller.go | 1 + runtime/interpreter/value_accountreference.go | 1 + runtime/interpreter/value_function.go | 3 + runtime/interpreter/value_placeholder.go | 1 + runtime/interpreter/value_publickey.go | 1 + .../value_storagecapabilitycontroller.go | 1 + runtime/interpreter/value_test.go | 3 + runtime/stdlib/account.go | 6 ++ runtime/tests/interpreter/interpreter_test.go | 2 + runtime/tests/interpreter/reference_test.go | 1 + runtime/tests/interpreter/resources_test.go | 4 + runtime/tests/interpreter/values_test.go | 7 ++ 19 files changed, 115 insertions(+), 6 deletions(-) diff --git a/runtime/interpreter/interpreter.go b/runtime/interpreter/interpreter.go index 29956e6037..6df7db3d0b 100644 --- a/runtime/interpreter/interpreter.go +++ b/runtime/interpreter/interpreter.go @@ -1706,6 +1706,7 @@ func (interpreter *Interpreter) transferAndConvert( false, nil, nil, + true, ) result := interpreter.ConvertAndBox( @@ -3924,6 +3925,7 @@ func (interpreter *Interpreter) authAccountSaveFunction(addressValue AddressValu true, nil, nil, + true, ) // Write new value @@ -4048,6 +4050,7 @@ func (interpreter *Interpreter) authAccountReadFunction(addressValue AddressValu false, nil, nil, + false, ) // Remove the value from storage, diff --git a/runtime/interpreter/interpreter_expression.go b/runtime/interpreter/interpreter_expression.go index f570abeab4..18097e279d 100644 --- a/runtime/interpreter/interpreter_expression.go +++ b/runtime/interpreter/interpreter_expression.go @@ -1359,6 +1359,7 @@ func (interpreter *Interpreter) VisitAttachExpression(attachExpression *ast.Atta false, nil, nil, + true, ).(*CompositeValue) // we enforce this in the checker diff --git a/runtime/interpreter/interpreter_invocation.go b/runtime/interpreter/interpreter_invocation.go index d0d18d39ea..b1c56e9665 100644 --- a/runtime/interpreter/interpreter_invocation.go +++ b/runtime/interpreter/interpreter_invocation.go @@ -101,6 +101,7 @@ func (interpreter *Interpreter) invokeFunctionValue( false, nil, nil, + true, ) } } diff --git a/runtime/interpreter/interpreter_statement.go b/runtime/interpreter/interpreter_statement.go index dd6090c68c..ea9cf54b2f 100644 --- a/runtime/interpreter/interpreter_statement.go +++ b/runtime/interpreter/interpreter_statement.go @@ -326,6 +326,7 @@ func (interpreter *Interpreter) VisitForStatement(statement *ast.ForStatement) S false, nil, nil, + true, ) iterable, ok := transferredValue.(IterableValue) diff --git a/runtime/interpreter/simplecompositevalue.go b/runtime/interpreter/simplecompositevalue.go index 9ea6c64dc0..9a8a23fcb8 100644 --- a/runtime/interpreter/simplecompositevalue.go +++ b/runtime/interpreter/simplecompositevalue.go @@ -262,6 +262,7 @@ func (v *SimpleCompositeValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { // TODO: actually not needed, value is not storable if remove { diff --git a/runtime/interpreter/storage_test.go b/runtime/interpreter/storage_test.go index 725e0b89bc..71dcfa9bfb 100644 --- a/runtime/interpreter/storage_test.go +++ b/runtime/interpreter/storage_test.go @@ -629,6 +629,7 @@ func TestNestedContainerMutationAfterMove(t *testing.T) { false, nil, map[atree.ValueID]struct{}{}, + true, ).(*CompositeValue) containerValue1.Append(inter, EmptyLocationRange, childValue1) diff --git a/runtime/interpreter/value.go b/runtime/interpreter/value.go index dcc8e30213..cad03b09ef 100644 --- a/runtime/interpreter/value.go +++ b/runtime/interpreter/value.go @@ -134,6 +134,7 @@ type Value interface { remove bool, storable atree.Storable, preventTransfer map[atree.ValueID]struct{}, + atRoot bool, ) Value DeepRemove(interpreter *Interpreter, atRoot bool) // Clone returns a new value that is equal to this value. @@ -484,6 +485,7 @@ func (v TypeValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -604,6 +606,7 @@ func (v VoidValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -777,6 +780,7 @@ func (v BoolValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -951,6 +955,7 @@ func (v CharacterValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -1432,6 +1437,7 @@ func (v *StringValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -1609,6 +1615,7 @@ func NewArrayValue( true, nil, nil, + true, ) return value @@ -1916,6 +1923,7 @@ func (v *ArrayValue) Concat(interpreter *Interpreter, locationRange LocationRang false, nil, nil, + false, ) }, ) @@ -2005,6 +2013,7 @@ func (v *ArrayValue) Set(interpreter *Interpreter, locationRange LocationRange, map[atree.ValueID]struct{}{ v.ValueID(): {}, }, + true, ) existingStorable, err := v.array.Set(uint64(index), element) @@ -2081,6 +2090,7 @@ func (v *ArrayValue) Append(interpreter *Interpreter, locationRange LocationRang map[atree.ValueID]struct{}{ v.ValueID(): {}, }, + true, ) err := v.array.Append(element) @@ -2149,6 +2159,7 @@ func (v *ArrayValue) Insert(interpreter *Interpreter, locationRange LocationRang map[atree.ValueID]struct{}{ v.ValueID(): {}, }, + true, ) err := v.array.Insert(uint64(index), element) @@ -2207,6 +2218,7 @@ func (v *ArrayValue) Remove(interpreter *Interpreter, locationRange LocationRang true, storable, nil, + true, ) } @@ -2676,6 +2688,7 @@ func (v *ArrayValue) Transfer( remove bool, storable atree.Storable, preventTransfer map[atree.ValueID]struct{}, + atRoot bool, ) Value { baseUsage, elementUsage, dataSlabs, metaDataSlabs := common.NewArrayMemoryUsages(v.array.Count(), v.elementSize) common.UseMemory(interpreter, baseUsage) @@ -2744,7 +2757,7 @@ func (v *ArrayValue) Transfer( } element := MustConvertStoredValue(interpreter, value). - Transfer(interpreter, locationRange, address, remove, nil, preventTransfer) + Transfer(interpreter, locationRange, address, remove, nil, preventTransfer, false) return element, nil }, @@ -2762,7 +2775,9 @@ func (v *ArrayValue) Transfer( } interpreter.maybeValidateAtreeValue(v.array) - interpreter.maybeValidateAtreeStorage() + if atRoot { + interpreter.maybeValidateAtreeStorage() + } interpreter.RemoveReferencedSlab(storable) } @@ -3006,6 +3021,7 @@ func (v *ArrayValue) Slice( false, nil, nil, + false, ) }, ) @@ -3038,6 +3054,7 @@ func (v *ArrayValue) Reverse( false, nil, nil, + false, ) }, ) @@ -3111,6 +3128,7 @@ func (v *ArrayValue) Filter( false, nil, nil, + false, ) }, ) @@ -3190,6 +3208,7 @@ func (v *ArrayValue) Map( false, nil, nil, + false, ) }, ) @@ -3913,6 +3932,7 @@ func (v IntValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -4553,6 +4573,7 @@ func (v Int8Value) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -5195,6 +5216,7 @@ func (v Int16Value) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -5837,6 +5859,7 @@ func (v Int32Value) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -6471,6 +6494,7 @@ func (v Int64Value) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -7215,6 +7239,7 @@ func (v Int128Value) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -7956,6 +7981,7 @@ func (v Int256Value) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -8585,6 +8611,7 @@ func (v UIntValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -9171,6 +9198,7 @@ func (v UInt8Value) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -9712,6 +9740,7 @@ func (v UInt16Value) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -10254,6 +10283,7 @@ func (v UInt32Value) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -10825,6 +10855,7 @@ func (v UInt64Value) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -11500,6 +11531,7 @@ func (v UInt128Value) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -12174,6 +12206,7 @@ func (v UInt256Value) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -12611,6 +12644,7 @@ func (v Word8Value) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -13049,6 +13083,7 @@ func (v Word16Value) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -13488,6 +13523,7 @@ func (v Word32Value) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -13953,6 +13989,7 @@ func (v Word64Value) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -14533,6 +14570,7 @@ func (v Word128Value) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -15114,6 +15152,7 @@ func (v Word256Value) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -15691,6 +15730,7 @@ func (v Fix64Value) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -16225,6 +16265,7 @@ func (v UFix64Value) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -16808,6 +16849,7 @@ func (v *CompositeValue) RemoveMember( true, existingValueStorable, nil, + true, ) } @@ -16852,6 +16894,7 @@ func (v *CompositeValue) SetMember( map[atree.ValueID]struct{}{ v.ValueID(): {}, }, + true, ) existingStorable, err := v.dictionary.Set( @@ -17200,6 +17243,7 @@ func (v *CompositeValue) Transfer( remove bool, storable atree.Storable, preventTransfer map[atree.ValueID]struct{}, + atRoot bool, ) Value { baseUse, elementOverhead, dataUse, metaDataUse := common.NewCompositeMemoryUsages(v.dictionary.Count(), 0) @@ -17303,6 +17347,7 @@ func (v *CompositeValue) Transfer( remove, nil, preventTransfer, + false, ) return atreeKey, value, nil @@ -17322,7 +17367,9 @@ func (v *CompositeValue) Transfer( } interpreter.maybeValidateAtreeValue(v.dictionary) - interpreter.maybeValidateAtreeStorage() + if atRoot { + interpreter.maybeValidateAtreeStorage() + } interpreter.RemoveReferencedSlab(storable) } @@ -18355,6 +18402,7 @@ func (v *DictionaryValue) GetMember( false, nil, nil, + false, ) }, ) @@ -18392,6 +18440,7 @@ func (v *DictionaryValue) GetMember( false, nil, nil, + false, ) }) @@ -18560,6 +18609,7 @@ func (v *DictionaryValue) Remove( true, existingValueStorable, nil, + true, ) return NewSomeValueNonCopying(interpreter, existingValue) @@ -18603,6 +18653,7 @@ func (v *DictionaryValue) Insert( true, nil, preventTransfer, + true, ) value = value.Transfer( @@ -18612,6 +18663,7 @@ func (v *DictionaryValue) Insert( true, nil, preventTransfer, + true, ) valueComparator := newValueComparator(interpreter, locationRange) @@ -18649,6 +18701,7 @@ func (v *DictionaryValue) Insert( true, existingValueStorable, nil, + true, ) return NewSomeValueNonCopying(interpreter, existingValue) @@ -18809,6 +18862,7 @@ func (v *DictionaryValue) Transfer( remove bool, storable atree.Storable, preventTransfer map[atree.ValueID]struct{}, + atRoot bool, ) Value { baseUse, elementOverhead, dataUse, metaDataUse := common.NewDictionaryMemoryUsages( v.dictionary.Count(), @@ -18891,10 +18945,10 @@ func (v *DictionaryValue) Transfer( } key := MustConvertStoredValue(interpreter, atreeKey). - Transfer(interpreter, locationRange, address, remove, nil, preventTransfer) + Transfer(interpreter, locationRange, address, remove, nil, preventTransfer, false) value := MustConvertStoredValue(interpreter, atreeValue). - Transfer(interpreter, locationRange, address, remove, nil, preventTransfer) + Transfer(interpreter, locationRange, address, remove, nil, preventTransfer, false) return key, value, nil }, @@ -18913,7 +18967,9 @@ func (v *DictionaryValue) Transfer( } interpreter.maybeValidateAtreeValue(v.dictionary) - interpreter.maybeValidateAtreeStorage() + if atRoot { + interpreter.maybeValidateAtreeStorage() + } interpreter.RemoveReferencedSlab(storable) } @@ -19238,6 +19294,7 @@ func (v NilValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -19569,6 +19626,7 @@ func (v *SomeValue) Transfer( remove bool, storable atree.Storable, preventTransfer map[atree.ValueID]struct{}, + _ bool, ) Value { config := interpreter.SharedState.Config @@ -19590,6 +19648,7 @@ func (v *SomeValue) Transfer( remove, nil, preventTransfer, + false, ) if remove { @@ -20055,6 +20114,7 @@ func (v *StorageReferenceValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -20390,6 +20450,7 @@ func (v *EphemeralReferenceValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -20607,6 +20668,7 @@ func (v AddressValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -20893,6 +20955,7 @@ func (v PathValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -21111,6 +21174,7 @@ func (v *PathCapabilityValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { v.DeepRemove(interpreter, true) @@ -21313,6 +21377,7 @@ func (v *IDCapabilityValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { v.DeepRemove(interpreter, true) @@ -21462,6 +21527,7 @@ func (v PathLinkValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) @@ -21599,6 +21665,7 @@ func (v *PublishedValue) Transfer( remove bool, storable atree.Storable, preventTransfer map[atree.ValueID]struct{}, + _ bool, ) Value { // NB: if the inner value of a PublishedValue can be a resource, // we must perform resource-related checks here as well @@ -21612,6 +21679,7 @@ func (v *PublishedValue) Transfer( remove, nil, preventTransfer, + false, ).(CapabilityValue) addressValue := v.Recipient.Transfer( @@ -21621,6 +21689,7 @@ func (v *PublishedValue) Transfer( remove, nil, preventTransfer, + false, ).(AddressValue) if remove { @@ -21761,6 +21830,7 @@ func (v AccountLinkValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) diff --git a/runtime/interpreter/value_accountcapabilitycontroller.go b/runtime/interpreter/value_accountcapabilitycontroller.go index 28111d19ca..8bb4643ca8 100644 --- a/runtime/interpreter/value_accountcapabilitycontroller.go +++ b/runtime/interpreter/value_accountcapabilitycontroller.go @@ -178,6 +178,7 @@ func (v *AccountCapabilityControllerValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) diff --git a/runtime/interpreter/value_accountreference.go b/runtime/interpreter/value_accountreference.go index f236543adb..69e959d55e 100644 --- a/runtime/interpreter/value_accountreference.go +++ b/runtime/interpreter/value_accountreference.go @@ -277,6 +277,7 @@ func (v *AccountReferenceValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) diff --git a/runtime/interpreter/value_function.go b/runtime/interpreter/value_function.go index c04fb0d779..f79e36963e 100644 --- a/runtime/interpreter/value_function.go +++ b/runtime/interpreter/value_function.go @@ -153,6 +153,7 @@ func (f *InterpretedFunctionValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { // TODO: actually not needed, value is not storable if remove { @@ -302,6 +303,7 @@ func (f *HostFunctionValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { // TODO: actually not needed, value is not storable if remove { @@ -429,6 +431,7 @@ func (f BoundFunctionValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { // TODO: actually not needed, value is not storable if remove { diff --git a/runtime/interpreter/value_placeholder.go b/runtime/interpreter/value_placeholder.go index b809e5e922..8f0648e0a9 100644 --- a/runtime/interpreter/value_placeholder.go +++ b/runtime/interpreter/value_placeholder.go @@ -88,6 +88,7 @@ func (f placeholderValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { // TODO: actually not needed, value is not storable if remove { diff --git a/runtime/interpreter/value_publickey.go b/runtime/interpreter/value_publickey.go index 9193ed3253..df2e0f30b9 100644 --- a/runtime/interpreter/value_publickey.go +++ b/runtime/interpreter/value_publickey.go @@ -72,6 +72,7 @@ func NewPublicKeyValue( false, nil, nil, + true, ) }, } diff --git a/runtime/interpreter/value_storagecapabilitycontroller.go b/runtime/interpreter/value_storagecapabilitycontroller.go index 23223bed26..9bf6140f69 100644 --- a/runtime/interpreter/value_storagecapabilitycontroller.go +++ b/runtime/interpreter/value_storagecapabilitycontroller.go @@ -202,6 +202,7 @@ func (v *StorageCapabilityControllerValue) Transfer( remove bool, storable atree.Storable, _ map[atree.ValueID]struct{}, + _ bool, ) Value { if remove { interpreter.RemoveReferencedSlab(storable) diff --git a/runtime/interpreter/value_test.go b/runtime/interpreter/value_test.go index c264640e78..68baae3ee5 100644 --- a/runtime/interpreter/value_test.go +++ b/runtime/interpreter/value_test.go @@ -176,6 +176,7 @@ func TestOwnerArrayDeepCopy(t *testing.T) { false, nil, nil, + true, ) array = arrayCopy.(*ArrayValue) @@ -570,6 +571,7 @@ func TestOwnerDictionaryCopy(t *testing.T) { false, nil, nil, + true, ) dictionaryCopy := copyResult.(*DictionaryValue) @@ -874,6 +876,7 @@ func TestOwnerCompositeCopy(t *testing.T) { false, nil, nil, + true, ).(*CompositeValue) value = composite.GetMember( diff --git a/runtime/stdlib/account.go b/runtime/stdlib/account.go index 1577c34c9e..ab6d4e88bc 100644 --- a/runtime/stdlib/account.go +++ b/runtime/stdlib/account.go @@ -1032,6 +1032,7 @@ func newAuthAccountInboxPublishFunction( true, nil, nil, + true, ) storageMapKey := interpreter.StringStorageMapKey(nameValue.Str) @@ -1099,6 +1100,7 @@ func newAuthAccountInboxUnpublishFunction( true, nil, nil, + false, ) inter.WriteStored( @@ -1185,6 +1187,7 @@ func newAuthAccountInboxClaimFunction( true, nil, nil, + false, ) inter.WriteStored( @@ -3166,6 +3169,7 @@ func newAuthAccountCapabilitiesPublishFunction( true, nil, nil, + true, ).(*interpreter.IDCapabilityValue) if !ok { panic(errors.NewUnreachableError()) @@ -3236,6 +3240,7 @@ func newAuthAccountCapabilitiesUnpublishFunction( true, nil, nil, + false, ).(*interpreter.IDCapabilityValue) if !ok { panic(errors.NewUnreachableError()) @@ -3383,6 +3388,7 @@ func newAuthAccountCapabilitiesMigrateLinkFunction( true, nil, nil, + true, ).(*interpreter.IDCapabilityValue) if !ok { panic(errors.NewUnreachableError()) diff --git a/runtime/tests/interpreter/interpreter_test.go b/runtime/tests/interpreter/interpreter_test.go index d0a35a80aa..37226c34b5 100644 --- a/runtime/tests/interpreter/interpreter_test.go +++ b/runtime/tests/interpreter/interpreter_test.go @@ -5225,6 +5225,7 @@ func TestInterpretReferenceFailableDowncasting(t *testing.T) { true, nil, nil, + true, ) domain := storagePath.Domain.Identifier() @@ -8093,6 +8094,7 @@ func TestInterpretResourceMovingAndBorrowing(t *testing.T) { false, nil, nil, + true, ) r1Type := checker.RequireGlobalType(t, inter.Program.Elaboration, "R1") diff --git a/runtime/tests/interpreter/reference_test.go b/runtime/tests/interpreter/reference_test.go index 34abede312..995e2a997c 100644 --- a/runtime/tests/interpreter/reference_test.go +++ b/runtime/tests/interpreter/reference_test.go @@ -744,6 +744,7 @@ func TestInterpretReferenceUseAfterShiftStatementMove(t *testing.T) { false, nil, nil, + true, ) r1Type := checker.RequireGlobalType(t, inter.Program.Elaboration, "R1") diff --git a/runtime/tests/interpreter/resources_test.go b/runtime/tests/interpreter/resources_test.go index cd7f20e49d..8ac401baf9 100644 --- a/runtime/tests/interpreter/resources_test.go +++ b/runtime/tests/interpreter/resources_test.go @@ -196,6 +196,7 @@ func TestInterpretImplicitResourceRemovalFromContainer(t *testing.T) { false, nil, nil, + true, ) r1Type := checker.RequireGlobalType(t, inter.Program.Elaboration, "R1") @@ -325,6 +326,7 @@ func TestInterpretImplicitResourceRemovalFromContainer(t *testing.T) { false, nil, nil, + true, ) r1Type := checker.RequireGlobalType(t, inter.Program.Elaboration, "R1") @@ -449,6 +451,7 @@ func TestInterpretImplicitResourceRemovalFromContainer(t *testing.T) { false, nil, nil, + true, ) r1Type := checker.RequireGlobalType(t, inter.Program.Elaboration, "R1") @@ -578,6 +581,7 @@ func TestInterpretImplicitResourceRemovalFromContainer(t *testing.T) { false, nil, nil, + true, ) r1Type := checker.RequireGlobalType(t, inter.Program.Elaboration, "R1") diff --git a/runtime/tests/interpreter/values_test.go b/runtime/tests/interpreter/values_test.go index 84dcd9733b..815ccc799d 100644 --- a/runtime/tests/interpreter/values_test.go +++ b/runtime/tests/interpreter/values_test.go @@ -153,6 +153,7 @@ func TestRandomMapOperations(t *testing.T) { false, nil, nil, + true, ).(*interpreter.DictionaryValue) require.Equal(t, entries.size(), copyOfTestMap.Count()) @@ -493,6 +494,7 @@ func TestRandomMapOperations(t *testing.T) { true, nil, nil, + true, ).(*interpreter.DictionaryValue) require.Equal(t, entries.size(), movedDictionary.Count()) @@ -608,6 +610,7 @@ func TestRandomArrayOperations(t *testing.T) { false, nil, nil, + true, ).(*interpreter.ArrayValue) require.Equal(t, len(elements), copyOfTestArray.Count()) @@ -864,6 +867,7 @@ func TestRandomArrayOperations(t *testing.T) { true, nil, nil, + true, ).(*interpreter.ArrayValue) require.Equal(t, len(elements), movedArray.Count()) @@ -955,6 +959,7 @@ func TestRandomCompositeValueOperations(t *testing.T) { false, nil, nil, + true, ).(*interpreter.CompositeValue) for name, orgValue := range orgFields { @@ -996,6 +1001,7 @@ func TestRandomCompositeValueOperations(t *testing.T) { false, nil, nil, + true, ).(*interpreter.CompositeValue) require.NoError(t, err) @@ -1021,6 +1027,7 @@ func TestRandomCompositeValueOperations(t *testing.T) { true, nil, nil, + true, ).(*interpreter.CompositeValue) // Cleanup the slab of original composite.