Skip to content

Commit d2da31f

Browse files
committed
Merge branch 'master' into bastian/sync-feature-compiler
2 parents acefeb8 + 04e30bd commit d2da31f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+6146
-9852
lines changed

.github/workflows/compatibility-check.yml

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ on:
2121
# Feature branches would get checked when they are going to get merged into the `master` anyway.
2222
- master
2323
- 'v**'
24+
# We want to check the compatibility of the entitlements refactor
25+
- 'feature/entitlements-refactor'
2426

2527
env:
2628
GO_VERSION: '1.23'

encoding/ccf/decode.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ func (esm EnforceSortMode) valid() bool {
138138

139139
// DecOptions specifies CCF decoding options which can be used to create immutable DecMode.
140140
type DecOptions struct {
141-
// EnforceSortCompositeFields specifies how decoder should enforce sort order of compsite fields.
141+
// EnforceSortCompositeFields specifies how decoder should enforce sort order of composite fields.
142142
EnforceSortCompositeFields EnforceSortMode
143143

144-
// EnforceSortIntersectionTypes specifies how decoder should enforce sort order of restricted types.
144+
// EnforceSortIntersectionTypes specifies how decoder should enforce sort order of intersection types.
145145
EnforceSortIntersectionTypes EnforceSortMode
146146

147147
// EnforceSortEntitlementTypes specifies how decoder should enforce sort order of entitlement types.

encoding/json/encoding_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2591,7 +2591,7 @@ func TestEncodeType(t *testing.T) {
25912591
"staticType": {
25922592
"kind": "Function",
25932593
"purity": "",
2594-
"typeID": "fun<T>(String):Int",
2594+
"typeID": "fun<T:AnyStruct>(String):Int",
25952595
"return": {
25962596
"kind": "Int"
25972597
},

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ require (
66
github.com/bits-and-blooms/bitset v1.5.0
77
github.com/c-bata/go-prompt v0.2.6
88
github.com/dave/dst v0.27.2
9-
github.com/fxamacker/cbor/v2 v2.4.1-0.20230228173756-c0c9f774e40c
9+
github.com/fxamacker/cbor/v2 v2.8.1-0.20250402194037-6f932b086829
1010
github.com/itchyny/gojq v0.12.14
1111
github.com/k0kubun/pp/v3 v3.2.0
1212
github.com/kr/pretty v0.3.1
1313
github.com/leanovate/gopter v0.2.9
1414
github.com/logrusorgru/aurora/v4 v4.0.0
15-
github.com/onflow/atree v0.9.0
15+
github.com/onflow/atree v0.10.0
1616
github.com/rivo/uniseg v0.4.4
1717
github.com/schollz/progressbar/v3 v3.13.1
1818
github.com/stretchr/testify v1.10.0

go.sum

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
1616
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1717
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1818
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
19-
github.com/fxamacker/cbor/v2 v2.4.1-0.20230228173756-c0c9f774e40c h1:5tm/Wbs9d9r+qZaUFXk59CWDD0+77PBqDREffYkyi5c=
20-
github.com/fxamacker/cbor/v2 v2.4.1-0.20230228173756-c0c9f774e40c/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo=
19+
github.com/fxamacker/cbor/v2 v2.8.1-0.20250402194037-6f932b086829 h1:qOglMkJ5YBwog/GU/NXhP9gFqxUGMuqnmCkbj65JMhk=
20+
github.com/fxamacker/cbor/v2 v2.8.1-0.20250402194037-6f932b086829/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
2121
github.com/fxamacker/circlehash v0.3.0 h1:XKdvTtIJV9t7DDUtsf0RIpC1OcxZtPbmgIH7ekx28WA=
2222
github.com/fxamacker/circlehash v0.3.0/go.mod h1:3aq3OfVvsWtkWMb6A1owjOQFA+TLsD5FgJflnaQwtMM=
2323
github.com/goccy/go-yaml v1.17.1 h1:LI34wktB2xEE3ONG/2Ar54+/HJVBriAGJ55PHls4YuY=
@@ -74,8 +74,8 @@ github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2Em
7474
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw=
7575
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
7676
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
77-
github.com/onflow/atree v0.9.0 h1:M+Z/UPwzv0/Yy7ChI5T1ZIHD3YN1cs/hxGEs/HWhzaY=
78-
github.com/onflow/atree v0.9.0/go.mod h1:FT6udJF9Q7VQTu3wknDhFX+VV4D44ZGdqtTAE5iztck=
77+
github.com/onflow/atree v0.10.0 h1:LFYlRgb0fjs8vezBW/N/tzi+ijLMssjHwIwoV4RwYaA=
78+
github.com/onflow/atree v0.10.0/go.mod h1:aqnnE8Os77JiBIeC7UcbeM7N1V3Ys5XWH0CykeMpym0=
7979
github.com/onflow/crypto v0.25.0 h1:BeWbLsh3ZD13Ej+Uky6kg1PL1ZIVBDVX+2MVBNwqddg=
8080
github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI=
8181
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
@@ -188,6 +188,6 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
188188
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
189189
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
190190
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
191-
lukechampine.com/blake3 v1.3.0 h1:sJ3XhFINmHSrYCgl958hscfIa3bw8x4DqMP3u1YvoYE=
192-
lukechampine.com/blake3 v1.3.0/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k=
191+
lukechampine.com/blake3 v1.4.0 h1:xDbKOZCVbnZsfzM6mHSYcGRHZ3YrLDzqz8XnV4uaD5w=
192+
lukechampine.com/blake3 v1.4.0/go.mod h1:MQJNQCTnR+kwOP/JEZSxj3MaQjp80FOFSNMMHXcSeX0=
193193
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=

interpreter/account_storagemap_test.go

+17-51
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ func TestAccountStorageMapDomainExists(t *testing.T) {
4949
storage := runtime.NewStorage(
5050
ledger,
5151
nil,
52-
runtime.StorageConfig{
53-
StorageFormatV2Enabled: true,
54-
},
52+
runtime.StorageConfig{},
5553
)
5654

5755
accountStorageMap := interpreter.NewAccountStorageMap(nil, storage, atree.Address(address))
@@ -75,9 +73,7 @@ func TestAccountStorageMapDomainExists(t *testing.T) {
7573
storage := runtime.NewStorage(
7674
ledger,
7775
nil,
78-
runtime.StorageConfig{
79-
StorageFormatV2Enabled: true,
80-
},
76+
runtime.StorageConfig{},
8177
)
8278

8379
// Turn off AtreeStorageValidationEnabled and explicitly check atree storage health at the end of test.
@@ -119,9 +115,7 @@ func TestAccountStorageMapGetDomain(t *testing.T) {
119115
storage := runtime.NewStorage(
120116
ledger,
121117
nil,
122-
runtime.StorageConfig{
123-
StorageFormatV2Enabled: true,
124-
},
118+
runtime.StorageConfig{},
125119
)
126120

127121
// Turn off AtreeStorageValidationEnabled and explicitly check atree storage health at the end of test.
@@ -158,9 +152,7 @@ func TestAccountStorageMapGetDomain(t *testing.T) {
158152
storage := runtime.NewStorage(
159153
ledger,
160154
nil,
161-
runtime.StorageConfig{
162-
StorageFormatV2Enabled: true,
163-
},
155+
runtime.StorageConfig{},
164156
)
165157

166158
// Turn off AtreeStorageValidationEnabled and explicitly check atree storage health at the end of test.
@@ -206,9 +198,7 @@ func TestAccountStorageMapCreateDomain(t *testing.T) {
206198
storage := runtime.NewStorage(
207199
ledger,
208200
nil,
209-
runtime.StorageConfig{
210-
StorageFormatV2Enabled: true,
211-
},
201+
runtime.StorageConfig{},
212202
)
213203

214204
// Turn off AtreeStorageValidationEnabled and explicitly check atree storage health at the end of test.
@@ -259,9 +249,7 @@ func TestAccountStorageMapCreateDomain(t *testing.T) {
259249
storage := runtime.NewStorage(
260250
ledger,
261251
nil,
262-
runtime.StorageConfig{
263-
StorageFormatV2Enabled: true,
264-
},
252+
runtime.StorageConfig{},
265253
)
266254

267255
// Turn off AtreeStorageValidationEnabled and explicitly check atree storage health at the end of test.
@@ -319,9 +307,7 @@ func TestAccountStorageMapSetAndUpdateDomain(t *testing.T) {
319307
storage := runtime.NewStorage(
320308
ledger,
321309
nil,
322-
runtime.StorageConfig{
323-
StorageFormatV2Enabled: true,
324-
},
310+
runtime.StorageConfig{},
325311
)
326312

327313
// Turn off AtreeStorageValidationEnabled and explicitly check atree storage health at the end of test.
@@ -375,9 +361,7 @@ func TestAccountStorageMapSetAndUpdateDomain(t *testing.T) {
375361
storage := runtime.NewStorage(
376362
ledger,
377363
nil,
378-
runtime.StorageConfig{
379-
StorageFormatV2Enabled: true,
380-
},
364+
runtime.StorageConfig{},
381365
)
382366

383367
// Turn off AtreeStorageValidationEnabled and explicitly check atree storage health at the end of test.
@@ -433,9 +417,7 @@ func TestAccountStorageMapRemoveDomain(t *testing.T) {
433417
storage := runtime.NewStorage(
434418
ledger,
435419
nil,
436-
runtime.StorageConfig{
437-
StorageFormatV2Enabled: true,
438-
},
420+
runtime.StorageConfig{},
439421
)
440422

441423
// Turn off AtreeStorageValidationEnabled and explicitly check atree storage health at the end of test.
@@ -482,9 +464,7 @@ func TestAccountStorageMapRemoveDomain(t *testing.T) {
482464
storage := runtime.NewStorage(
483465
ledger,
484466
nil,
485-
runtime.StorageConfig{
486-
StorageFormatV2Enabled: true,
487-
},
467+
runtime.StorageConfig{},
488468
)
489469

490470
// Turn off AtreeStorageValidationEnabled and explicitly check atree storage health at the end of test.
@@ -537,9 +517,7 @@ func TestAccountStorageMapIterator(t *testing.T) {
537517
storage := runtime.NewStorage(
538518
ledger,
539519
nil,
540-
runtime.StorageConfig{
541-
StorageFormatV2Enabled: true,
542-
},
520+
runtime.StorageConfig{},
543521
)
544522

545523
// Turn off AtreeStorageValidationEnabled and explicitly check atree storage health at the end of test.
@@ -583,9 +561,7 @@ func TestAccountStorageMapIterator(t *testing.T) {
583561
storage := runtime.NewStorage(
584562
ledger,
585563
nil,
586-
runtime.StorageConfig{
587-
StorageFormatV2Enabled: true,
588-
},
564+
runtime.StorageConfig{},
589565
)
590566

591567
// Turn off AtreeStorageValidationEnabled and explicitly check atree storage health at the end of test.
@@ -650,9 +626,7 @@ func TestAccountStorageMapDomains(t *testing.T) {
650626
storage := runtime.NewStorage(
651627
ledger,
652628
nil,
653-
runtime.StorageConfig{
654-
StorageFormatV2Enabled: true,
655-
},
629+
runtime.StorageConfig{},
656630
)
657631

658632
accountStorageMap := interpreter.NewAccountStorageMap(nil, storage, atree.Address(address))
@@ -674,9 +648,7 @@ func TestAccountStorageMapDomains(t *testing.T) {
674648
storage := runtime.NewStorage(
675649
ledger,
676650
nil,
677-
runtime.StorageConfig{
678-
StorageFormatV2Enabled: true,
679-
},
651+
runtime.StorageConfig{},
680652
)
681653

682654
// Turn off automatic AtreeStorageValidationEnabled and explicitly check atree storage health directly.
@@ -719,9 +691,7 @@ func TestAccountStorageMapLoadFromRootSlabID(t *testing.T) {
719691
storage := runtime.NewStorage(
720692
ledger,
721693
nil,
722-
runtime.StorageConfig{
723-
StorageFormatV2Enabled: true,
724-
},
694+
runtime.StorageConfig{},
725695
)
726696

727697
inter := NewTestInterpreterWithStorage(t, storage)
@@ -755,9 +725,7 @@ func TestAccountStorageMapLoadFromRootSlabID(t *testing.T) {
755725
storage := runtime.NewStorage(
756726
ledger,
757727
nil,
758-
runtime.StorageConfig{
759-
StorageFormatV2Enabled: true,
760-
},
728+
runtime.StorageConfig{},
761729
)
762730

763731
// Turn off automatic AtreeStorageValidationEnabled and explicitly check atree storage health directly.
@@ -857,9 +825,7 @@ func checkAccountStorageMapDataWithRawData(
857825
storage := runtime.NewStorage(
858826
ledger,
859827
nil,
860-
runtime.StorageConfig{
861-
StorageFormatV2Enabled: true,
862-
},
828+
runtime.StorageConfig{},
863829
)
864830

865831
inter := NewTestInterpreterWithStorage(tb, storage)

interpreter/account_test.go

+77-3
Original file line numberDiff line numberDiff line change
@@ -441,12 +441,43 @@ func (n NoOpReferenceCreationContext) MeterMemory(usage common.MemoryUsage) erro
441441
return nil
442442
}
443443

444+
func (n NoOpReferenceCreationContext) ReadStored(storageAddress common.Address, domain common.StorageDomain, identifier interpreter.StorageMapKey) interpreter.Value {
445+
// NO-OP
446+
return nil
447+
}
448+
449+
func (n NoOpReferenceCreationContext) GetEntitlementType(typeID interpreter.TypeID) (*sema.EntitlementType, error) {
450+
// NO-OP
451+
return nil, nil
452+
}
453+
454+
func (n NoOpReferenceCreationContext) GetEntitlementMapType(typeID interpreter.TypeID) (*sema.EntitlementMapType, error) {
455+
// NO-OP
456+
return nil, nil
457+
}
458+
459+
func (n NoOpReferenceCreationContext) GetInterfaceType(location common.Location, qualifiedIdentifier string, typeID interpreter.TypeID) (*sema.InterfaceType, error) {
460+
// NO-OP
461+
return nil, nil
462+
}
463+
464+
func (n NoOpReferenceCreationContext) GetCompositeType(location common.Location, qualifiedIdentifier string, typeID interpreter.TypeID) (*sema.CompositeType, error) {
465+
// NO-OP
466+
return nil, nil
467+
}
468+
469+
func (n NoOpReferenceCreationContext) IsTypeInfoRecovered(location common.Location) bool {
470+
// NO-OP
471+
return false
472+
}
473+
444474
type NoOpFunctionCreationContext struct {
445-
NoOpReferenceCreationContext
446475
//Just to make the compiler happy
447476
interpreter.ResourceDestructionContext
448477
}
449478

479+
var _ interpreter.FunctionCreationContext = NoOpFunctionCreationContext{}
480+
450481
func (n NoOpFunctionCreationContext) ClearReferencedResourceKindedValues(valueID atree.ValueID) {
451482
// NO-OP
452483
}
@@ -474,8 +505,6 @@ func (n NoOpFunctionCreationContext) MeterMemory(usage common.MemoryUsage) error
474505
return nil
475506
}
476507

477-
var _ interpreter.FunctionCreationContext = NoOpFunctionCreationContext{}
478-
479508
func testAccountWithErrorHandler(
480509
t *testing.T,
481510
address interpreter.AddressValue,
@@ -1546,3 +1575,48 @@ func TestInterpretAccountStorageFields(t *testing.T) {
15461575
}
15471576
}
15481577
}
1578+
1579+
func TestInterpretAccountStorageReadFunctionTypes(t *testing.T) {
1580+
1581+
t.Parallel()
1582+
1583+
address := interpreter.NewUnmeteredAddressValueFromBytes([]byte{42})
1584+
1585+
inter, _ := testAccount(t, address, true, nil, `
1586+
fun getLoadType(): Type {
1587+
return account.storage.load.getType()
1588+
}
1589+
1590+
fun getCopyType(): Type {
1591+
return account.storage.copy.getType()
1592+
}
1593+
1594+
fun areEqual(): Bool {
1595+
return getLoadType() == getCopyType()
1596+
}
1597+
`, sema.Config{})
1598+
1599+
loadType, err := inter.Invoke("getLoadType")
1600+
require.NoError(t, err)
1601+
require.IsType(t, interpreter.TypeValue{}, loadType)
1602+
assert.Equal(t,
1603+
interpreter.FunctionStaticType{
1604+
Type: sema.Account_StorageTypeLoadFunctionType,
1605+
},
1606+
loadType.(interpreter.TypeValue).Type,
1607+
)
1608+
1609+
copyType, err := inter.Invoke("getCopyType")
1610+
require.NoError(t, err)
1611+
require.IsType(t, interpreter.TypeValue{}, copyType)
1612+
assert.Equal(t,
1613+
interpreter.FunctionStaticType{
1614+
Type: sema.Account_StorageTypeCopyFunctionType,
1615+
},
1616+
copyType.(interpreter.TypeValue).Type,
1617+
)
1618+
1619+
areEqual, err := inter.Invoke("areEqual")
1620+
require.NoError(t, err)
1621+
require.Equal(t, interpreter.FalseValue, areEqual)
1622+
}

0 commit comments

Comments
 (0)