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

Account type #2648

Merged
merged 118 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from 112 commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
80b646d
rename files
turbolent Jul 7, 2023
2ad4058
Merge branch 'feature/mutability-restrictions' into bastian/account-type
turbolent Jul 7, 2023
6693995
replace AuthAccount type with Account type; use workaround for missin…
turbolent Jul 7, 2023
45cb536
add support for entitlement mapping declarations to code generator
turbolent Jul 7, 2023
0d492ec
fix Account type
turbolent Jul 7, 2023
4a2670b
add helper function to construct entitlement set access or entitlemen…
turbolent Jul 7, 2023
a63d425
change convenience constructors for fields and functions to take any …
turbolent Jul 7, 2023
1fc6bfb
add support generating map and set access, improve nested type genera…
turbolent Jul 7, 2023
9b5dc27
add support for generating entitlement map relations
turbolent Jul 7, 2023
35124d8
remove public account type definition
turbolent Jul 7, 2023
16b4df3
replace generated code for AuthAccount with Account type
turbolent Jul 7, 2023
1db6219
replace uses of AuthAccount and PublicAccount with Account type
turbolent Jul 7, 2023
7438e07
add back recently added check function
turbolent Jul 8, 2023
4fd7ea2
refactor interpreter
turbolent Jul 8, 2023
099af40
Merge branch 'feature/stable-cadence' into bastian/account-type
turbolent Aug 9, 2023
9b0b942
add missing authorization to AccountReferenceType, add fully entitled…
turbolent Aug 9, 2023
b28eb93
fix primitive static types
turbolent Aug 9, 2023
8801268
update majority of account implementation in stdlib
turbolent Aug 9, 2023
758fe1a
update tests to new account API
turbolent Aug 9, 2023
59f5448
addjust more account checker tests to new Account API
turbolent Aug 9, 2023
6bf6066
adjust more tests
turbolent Aug 10, 2023
dc77474
improve error message
turbolent Aug 10, 2023
f9eb762
adjust remaining account tests
turbolent Aug 10, 2023
9d1cd42
remove account check helper
turbolent Aug 10, 2023
cfaec19
Merge branch 'feature/stable-cadence' into bastian/account-type
turbolent Aug 10, 2023
b7200cb
add view annotations
turbolent Aug 10, 2023
3bb936f
allow coarse grained entitlements
turbolent Aug 10, 2023
784cda6
fix entitlement access constuction
turbolent Aug 10, 2023
213b414
improve error message
turbolent Aug 10, 2023
feb9593
adjust more tests
turbolent Aug 10, 2023
1ef6800
fix entitlements tests
turbolent Aug 10, 2023
bc1c3b5
adjust resource owner field tests
turbolent Aug 10, 2023
1f5da6f
adjust purity tests
turbolent Aug 10, 2023
0c52f10
allow references in events
turbolent Aug 10, 2023
48e1423
adjust Never tests
turbolent Aug 10, 2023
7bddf2c
adjust transaction tests
turbolent Aug 10, 2023
aaaf6b0
use account's storage field
turbolent Aug 10, 2023
69cb41f
improve orimitive static types and related tests
turbolent Aug 10, 2023
6c0ce93
fix test
turbolent Aug 10, 2023
29085ff
add missing identity rules
turbolent Aug 10, 2023
46a2304
rename
turbolent Aug 10, 2023
9a86ef6
fix static types
turbolent Aug 10, 2023
efbfd1e
replace last use of PublicAccount in checker tests
turbolent Aug 10, 2023
3f49588
cleanup
turbolent Aug 10, 2023
de923ab
remove account reference value, use ephemeral reference value
turbolent Aug 10, 2023
4684488
merge auth and public account handlers
turbolent Aug 10, 2023
59ac442
adjust expected primitive static type count
turbolent Aug 10, 2023
d1d8b4c
adjust interpreter tests
turbolent Aug 10, 2023
47643b3
get interpreter tests compiling again, buy stubbing out test account …
turbolent Aug 11, 2023
62c9a4c
fix test names
turbolent Aug 11, 2023
c9298e0
adjust tests
turbolent Aug 11, 2023
fccfd09
bring back balance fields
turbolent Aug 11, 2023
ed79460
move account storage functions to separate value
turbolent Aug 11, 2023
9062489
add test implementation of stdlib AccountHandler
turbolent Aug 11, 2023
0beb881
construct proper account storage handler
turbolent Aug 11, 2023
888df28
use stdlib to construct account value
turbolent Aug 11, 2023
1134437
fix various issues (wrong types, typos)
turbolent Aug 11, 2023
0b77625
return reference
turbolent Aug 11, 2023
16e9730
adjust getAuthAccount, use new type argument
turbolent Aug 11, 2023
2607c6e
get interpreter tests passing again
turbolent Aug 11, 2023
e0a0d80
remove tests which got accidentally re-introduced during merge
turbolent Aug 11, 2023
2cdd343
improve newEntitlementAccess helper
turbolent Aug 11, 2023
2474ca8
Merge branch 'feature/mutability-restrictions' into bastian/account-type
turbolent Aug 11, 2023
e084bfb
adjust environment, provide fully-entitled Account access globaly
turbolent Aug 11, 2023
469872d
prevent type clash: rename test framework's Account type to TestAccount
turbolent Aug 11, 2023
7161367
adjust transaction executor
turbolent Aug 11, 2023
5aec082
adjust contract invocation executor
turbolent Aug 11, 2023
46c9a01
stub out account related types in CCF and JSON encoding to get them t…
turbolent Aug 12, 2023
8ac41a6
replace AuthAccount signer types in transaction prepare parameter lists
turbolent Aug 12, 2023
429895b
replace and add missing types
turbolent Aug 12, 2023
5f5c0c8
replace use of AuthAccount
turbolent Aug 12, 2023
1575612
remove unused code
turbolent Aug 12, 2023
2011d85
adjust runtime tests, get them to compile and run again
turbolent Aug 12, 2023
752f508
adjust account tests
turbolent Aug 12, 2023
d3c757f
adjust tests to new Account type
turbolent Aug 12, 2023
7059b30
fix string formatting for account value and associated metering
turbolent Aug 12, 2023
da1c49c
adjust tests
turbolent Aug 12, 2023
06f45fa
adjust parser test
turbolent Aug 12, 2023
123feb7
improve error messages
turbolent Aug 12, 2023
6a701e9
improve getAuthAccount type definition
turbolent Aug 12, 2023
6395c0f
adjusts more tests
turbolent Aug 12, 2023
d8973df
adjust more tests
turbolent Aug 12, 2023
09d4b62
adjust more tests
turbolent Aug 14, 2023
cd4716c
adjust more tests
turbolent Aug 14, 2023
4dab90e
use thread safe data structures for entitlement maps
dsainati1 Aug 14, 2023
4bcc861
adjust tests
turbolent Aug 14, 2023
18ec2a2
fix test
turbolent Aug 14, 2023
f219964
fix tests, provide authorization to pay for new accounts
turbolent Aug 14, 2023
9a3b536
bring back Account constructor
turbolent Aug 14, 2023
adfbd49
adjust tests
turbolent Aug 14, 2023
a9df97b
fix type
turbolent Aug 14, 2023
f0d8449
adjust test
turbolent Aug 14, 2023
bce5d83
simplify definition, reuse existing authorization
turbolent Aug 14, 2023
7d02d18
Merge branch 'feature/stable-cadence' into bastian/account-type
turbolent Aug 15, 2023
5f93672
refactor, and add new and missing types
turbolent Aug 15, 2023
a733765
clean up
turbolent Aug 15, 2023
9d81d7b
Merge pull request #2716 from onflow/sainati/entitlement-map-data-race
dsainati1 Aug 15, 2023
bcc3422
iimprove CCF simple types, find and add missing tests
turbolent Aug 15, 2023
810a5e6
add support for any primitive type
turbolent Aug 15, 2023
8960ec5
Merge branch 'feature/stable-cadence' into bastian/account-type
turbolent Aug 15, 2023
27a2fab
test resource owner field type
turbolent Aug 15, 2023
fe519ba
adjust test
turbolent Aug 15, 2023
8008105
fix test names
turbolent Aug 15, 2023
b0b6c23
adjust test
turbolent Aug 15, 2023
5aea0c1
bring back support for decoding "Bytes" kind
turbolent Aug 15, 2023
8c56d2d
Update runtime/account_test.go
turbolent Aug 22, 2023
1748c68
Merge branch 'feature/stable-cadence' into bastian/account-type
turbolent Aug 23, 2023
4796b0f
adjust tests
turbolent Aug 23, 2023
dbe69dc
clean up
turbolent Aug 24, 2023
0470315
simplify
turbolent Aug 24, 2023
cbbd45c
add tests for event emission with reference-typed parameter
turbolent Aug 24, 2023
0fe78e8
Merge branch 'feature/stable-cadence' into bastian/account-type
turbolent Aug 25, 2023
ff83742
improve naming
turbolent Aug 25, 2023
28ee8ad
Merge branch 'bastian/sync-stable-cadence-6' into bastian/account-type
turbolent Aug 29, 2023
990fe05
revert type ID calculation
turbolent Aug 29, 2023
f197038
Merge branch 'bastian/sync-stable-cadence-6' into bastian/account-type
turbolent Aug 29, 2023
4590571
Merge branch 'feature/stable-cadence' into bastian/account-type
turbolent Aug 29, 2023
8d8f5ff
entitlements got renamed
turbolent Aug 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
543 changes: 301 additions & 242 deletions encoding/ccf/ccf_test.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions encoding/ccf/ccf_type_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func simpleStructType() *cadence.StructType {
Fields: []cadence.Field{
{
Identifier: "a",
Type: cadence.IntType{},
Type: cadence.IntType,
},
},
}
Expand All @@ -135,11 +135,11 @@ func simpleStructType2() *cadence.StructType {
Fields: []cadence.Field{
{
Identifier: "a",
Type: cadence.IntType{},
Type: cadence.IntType,
},
{
Identifier: "b",
Type: cadence.StringType{},
Type: cadence.StringType,
},
},
}
Expand Down
52 changes: 27 additions & 25 deletions encoding/ccf/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,10 @@ func (d *Decoder) decodeValue(t cadence.Type, types *cadenceTypeByCCFTypeID) (ca
// If type t for the value to be decoded is a concrete type (e.g. IntType),
// value MUST NOT be ccf-type-and-value-message.

switch t := t.(type) {
switch t {
case cadence.VoidType:
return d.decodeVoid()

case *cadence.OptionalType:
return d.decodeOptional(t, types)

case cadence.BoolType:
return d.decodeBool()

Expand Down Expand Up @@ -495,27 +492,6 @@ func (d *Decoder) decodeValue(t cadence.Type, types *cadenceTypeByCCFTypeID) (ca
case cadence.UFix64Type:
return d.decodeUFix64()

case *cadence.VariableSizedArrayType:
return d.decodeArray(t, false, 0, types)

case *cadence.ConstantSizedArrayType:
return d.decodeArray(t, true, uint64(t.Size), types)

case *cadence.DictionaryType:
return d.decodeDictionary(t, types)

case *cadence.ResourceType:
return d.decodeResource(t, types)

case *cadence.StructType:
return d.decodeStruct(t, types)

case *cadence.EventType:
return d.decodeEvent(t, types)

case *cadence.ContractType:
return d.decodeContract(t, types)

case cadence.StoragePathType:
return d.decodePath()

Expand All @@ -536,6 +512,32 @@ func (d *Decoder) decodeValue(t cadence.Type, types *cadenceTypeByCCFTypeID) (ca
return nil, err
}
return cadence.NewMeteredTypeValue(d.gauge, typeValue), nil
}

switch t := t.(type) {
case *cadence.OptionalType:
return d.decodeOptional(t, types)

case *cadence.VariableSizedArrayType:
return d.decodeArray(t, false, 0, types)

case *cadence.ConstantSizedArrayType:
return d.decodeArray(t, true, uint64(t.Size), types)

case *cadence.DictionaryType:
return d.decodeDictionary(t, types)

case *cadence.ResourceType:
return d.decodeResource(t, types)

case *cadence.StructType:
return d.decodeStruct(t, types)

case *cadence.EventType:
return d.decodeEvent(t, types)

case *cadence.ContractType:
return d.decodeContract(t, types)

case *cadence.CapabilityType:
return d.decodeCapability(t, types)
Expand Down
171 changes: 4 additions & 167 deletions encoding/ccf/decode_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,175 +109,12 @@ func (d *Decoder) decodeSimpleTypeID() (cadence.Type, error) {
return nil, err
}

switch simpleTypeID {
case TypeBool:
return cadence.TheBoolType, nil

case TypeString:
return cadence.TheStringType, nil

case TypeCharacter:
return cadence.TheCharacterType, nil

case TypeAddress:
return cadence.TheAddressType, nil

case TypeInt:
return cadence.TheIntType, nil

case TypeInt8:
return cadence.TheInt8Type, nil

case TypeInt16:
return cadence.TheInt16Type, nil

case TypeInt32:
return cadence.TheInt32Type, nil

case TypeInt64:
return cadence.TheInt64Type, nil

case TypeInt128:
return cadence.TheInt128Type, nil

case TypeInt256:
return cadence.TheInt256Type, nil

case TypeUInt:
return cadence.TheUIntType, nil

case TypeUInt8:
return cadence.TheUInt8Type, nil

case TypeUInt16:
return cadence.TheUInt16Type, nil

case TypeUInt32:
return cadence.TheUInt32Type, nil

case TypeUInt64:
return cadence.TheUInt64Type, nil

case TypeUInt128:
return cadence.TheUInt128Type, nil

case TypeUInt256:
return cadence.TheUInt256Type, nil

case TypeWord8:
return cadence.TheWord8Type, nil

case TypeWord16:
return cadence.TheWord16Type, nil

case TypeWord32:
return cadence.TheWord32Type, nil

case TypeWord64:
return cadence.TheWord64Type, nil

case TypeWord128:
return cadence.TheWord128Type, nil

case TypeWord256:
return cadence.TheWord256Type, nil

case TypeFix64:
return cadence.TheFix64Type, nil

case TypeUFix64:
return cadence.TheUFix64Type, nil

case TypePath:
return cadence.ThePathType, nil

case TypeCapabilityPath:
return cadence.TheCapabilityPathType, nil

case TypeStoragePath:
return cadence.TheStoragePathType, nil

case TypePublicPath:
return cadence.ThePublicPathType, nil

case TypePrivatePath:
return cadence.ThePrivatePathType, nil

case TypeAuthAccount:
return cadence.TheAuthAccountType, nil

case TypePublicAccount:
return cadence.ThePublicAccountType, nil

case TypeAuthAccountKeys:
return cadence.TheAuthAccountKeysType, nil

case TypePublicAccountKeys:
return cadence.ThePublicAccountKeysType, nil

case TypeAuthAccountContracts:
return cadence.TheAuthAccountContractsType, nil

case TypePublicAccountContracts:
return cadence.ThePublicAccountContractsType, nil

case TypeDeployedContract:
return cadence.TheDeployedContractType, nil

case TypeAccountKey:
return cadence.TheAccountKeyType, nil

case TypeBlock:
return cadence.TheBlockType, nil

case TypeAny:
return cadence.TheAnyType, nil

case TypeAnyStruct:
return cadence.TheAnyStructType, nil

case TypeAnyResource:
return cadence.TheAnyResourceType, nil

case TypeMetaType:
return cadence.TheMetaType, nil

case TypeNever:
return cadence.TheNeverType, nil

case TypeNumber:
return cadence.TheNumberType, nil

case TypeSignedNumber:
return cadence.TheSignedNumberType, nil

case TypeInteger:
return cadence.TheIntegerType, nil

case TypeSignedInteger:
return cadence.TheSignedIntegerType, nil

case TypeFixedPoint:
return cadence.TheFixedPointType, nil

case TypeSignedFixedPoint:
return cadence.TheSignedFixedPointType, nil

case TypeBytes:
return cadence.TheBytesType, nil

case TypeVoid:
return cadence.TheVoidType, nil

case TypeAnyStructAttachmentType:
return cadence.TheAnyStructAttachmentType, nil

case TypeAnyResourceAttachmentType:
return cadence.TheAnyResourceAttachmentType, nil

default:
ty := typeBySimpleTypeID(SimpleType(simpleTypeID))
if ty == nil {
return nil, fmt.Errorf("unsupported encoded simple type ID %d", simpleTypeID)
}

return ty, nil
}

// decodeOptionalType decodes optional-type or optional-type-value as
Expand Down
7 changes: 4 additions & 3 deletions encoding/ccf/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -1305,9 +1305,9 @@ func (e *Encoder) encodeTypeValueRef(id ccfTypeID) error {
//
// ; cbor-tag-simple-type-value
// #6.185(simple-type-id)
func (e *Encoder) encodeSimpleTypeValue(id uint64) error {
func (e *Encoder) encodeSimpleTypeValue(id SimpleType) error {
rawTagNum := []byte{0xd8, CBORTagSimpleTypeValue}
return e.encodeSimpleTypeWithRawTag(id, rawTagNum)
return e.encodeSimpleTypeWithRawTag(uint64(id), rawTagNum)
}

// encodeOptionalTypeValue encodes cadence.OptionalType as
Expand Down Expand Up @@ -2015,9 +2015,10 @@ func isOptionalNeverType(t cadence.Type) bool {
return false
}

if ot.Type.Equal(cadence.NewNeverType()) {
if ot.Type.Equal(cadence.NeverType) {
return true
}

t = ot.Type
}
}
Expand Down
6 changes: 3 additions & 3 deletions encoding/ccf/encode_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (e *Encoder) encodeInlineType(typ cadence.Type, tids ccfTypeIDByCadenceType
return e.encodeCapabilityType(typ, tids)

case *cadence.FunctionType:
return e.encodeSimpleType(TypeFunction)
return e.encodeSimpleType(SimpleTypeFunction)

default:
panic(cadenceErrors.NewUnexpectedError("unsupported type %s (%T)", typ.ID(), typ))
Expand All @@ -99,9 +99,9 @@ func (e *Encoder) encodeNullableInlineType(typ cadence.Type, tids ccfTypeIDByCad
//
// ; cbor-tag-simple-type
// #6.137(simple-type-id)
func (e *Encoder) encodeSimpleType(id uint64) error {
func (e *Encoder) encodeSimpleType(id SimpleType) error {
rawTagNum := []byte{0xd8, CBORTagSimpleType}
return e.encodeSimpleTypeWithRawTag(id, rawTagNum)
return e.encodeSimpleTypeWithRawTag(uint64(id), rawTagNum)
}

// encodeSimpleTypeWithRawTag encodes simple type with given tag number as
Expand Down
Loading
Loading