Skip to content

Commit

Permalink
Merge pull request #5987 from onflow/auto-update-onflow-cadence-v1.0.…
Browse files Browse the repository at this point in the history
…0-preview.30

Update to Cadence v1.0.0-preview.30
  • Loading branch information
turbolent authored May 29, 2024
2 parents 29bf6de + 66f4f59 commit 7d80c9d
Show file tree
Hide file tree
Showing 11 changed files with 167 additions and 148 deletions.
7 changes: 0 additions & 7 deletions cmd/util/ledger/migrations/cadence.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
_ "embed"
"fmt"

"github.com/onflow/cadence/migrations"
"github.com/onflow/cadence/migrations/capcons"
"github.com/onflow/cadence/migrations/statictypes"
"github.com/onflow/cadence/runtime/common"
Expand Down Expand Up @@ -227,11 +226,6 @@ func NewCadence1ValueMigrations(

errorMessageHandler := &errorMessageHandler{}

// As the proper migrated static type is computed for each old type,
// the entitlements migration will store that info in this cache to be
// reused across accounts for instances of the same types
staticTypeCache := migrations.NewDefaultStaticTypeCache()

// The value migrations are run as account-based migrations,
// i.e. the migrations are only given the payloads for the account to be migrated.
// However, the migrations need to be able to get the code for contracts of any account.
Expand Down Expand Up @@ -262,7 +256,6 @@ func NewCadence1ValueMigrations(
programs,
NewCadence1CompositeStaticTypeConverter(opts.ChainID),
NewCadence1InterfaceStaticTypeConverter(opts.ChainID),
staticTypeCache,
opts,
)
},
Expand Down
3 changes: 1 addition & 2 deletions cmd/util/ledger/migrations/cadence_values_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ func NewCadence1ValueMigration(
programs map[runtime.Location]*interpreter.Program,
compositeTypeConverter statictypes.CompositeTypeConverterFunc,
interfaceTypeConverter statictypes.InterfaceTypeConverterFunc,
staticTypeCache migrations.StaticTypeCache,
opts Options,
) *CadenceBaseMigration {

Expand All @@ -254,7 +253,7 @@ func NewCadence1ValueMigration(
statictypes.NewStaticTypeMigration().
WithCompositeTypeConverter(compositeTypeConverter).
WithInterfaceTypeConverter(interfaceTypeConverter),
entitlements.NewEntitlementsMigrationWithCache(inter, staticTypeCache),
entitlements.NewEntitlementsMigration(inter),
string_normalization.NewStringNormalizingMigration(),
}
},
Expand Down
6 changes: 3 additions & 3 deletions cmd/util/ledger/migrations/cadence_values_migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,17 +444,17 @@ func checkMigratedState(
{
storageKey: interpreter.StorageKey{Key: "cap_con", Address: address},
storageMapKey: interpreter.Uint64StorageMapKey(0x2),
value: "StorageCapabilityController(borrowType: auth(A.01cf0e2f2f715450.Test.E) &A.01cf0e2f2f715450.Test.R, capabilityID: /storage/r, target: 2)",
value: "StorageCapabilityController(borrowType: Type<auth(A.01cf0e2f2f715450.Test.E) &A.01cf0e2f2f715450.Test.R>(), capabilityID: 2, target: /storage/r)",
},
{
storageKey: interpreter.StorageKey{Key: "cap_con", Address: address},
storageMapKey: interpreter.Uint64StorageMapKey(0x1),
value: "StorageCapabilityController(borrowType: &A.0ae53cb6e3f42a79.FlowToken.Vault, capabilityID: /storage/flowTokenVault, target: 1)",
value: "StorageCapabilityController(borrowType: Type<&A.0ae53cb6e3f42a79.FlowToken.Vault>(), capabilityID: 1, target: /storage/flowTokenVault)",
},
{
storageKey: interpreter.StorageKey{Key: "cap_con", Address: address},
storageMapKey: interpreter.Uint64StorageMapKey(0x3),
value: "StorageCapabilityController(borrowType: &A.0ae53cb6e3f42a79.FlowToken.Vault, capabilityID: /storage/flowTokenVault, target: 3)",
value: "StorageCapabilityController(borrowType: Type<&A.0ae53cb6e3f42a79.FlowToken.Vault>(), capabilityID: 3, target: /storage/flowTokenVault)",
},
},
visitMigration.visits,
Expand Down
57 changes: 29 additions & 28 deletions fvm/meter/memory_meter.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,34 +68,35 @@ var (

// Cadence Values

common.MemoryKindCadenceVoidValue: 1,
common.MemoryKindCadenceOptionalValue: 17,
common.MemoryKindCadenceBoolValue: 8,
common.MemoryKindCadenceStringValue: 16,
common.MemoryKindCadenceCharacterValue: 16,
common.MemoryKindCadenceAddressValue: 8,
common.MemoryKindCadenceIntValue: 50,
common.MemoryKindCadenceNumberValue: 1,
common.MemoryKindCadenceArrayValueBase: 41,
common.MemoryKindCadenceArrayValueLength: 16,
common.MemoryKindCadenceDictionaryValue: 41,
common.MemoryKindCadenceKeyValuePair: 33,
common.MemoryKindCadenceStructValueBase: 33,
common.MemoryKindCadenceStructValueSize: 16,
common.MemoryKindCadenceResourceValueBase: 33,
common.MemoryKindCadenceResourceValueSize: 16,
common.MemoryKindCadenceEventValueBase: 33,
common.MemoryKindCadenceEventValueSize: 16,
common.MemoryKindCadenceContractValueBase: 33,
common.MemoryKindCadenceContractValueSize: 16,
common.MemoryKindCadenceEnumValueBase: 33,
common.MemoryKindCadenceEnumValueSize: 16,
common.MemoryKindCadencePathValue: 33,
common.MemoryKindCadenceTypeValue: 17,
common.MemoryKindCadenceCapabilityValue: 1, // TODO: update with proper weight
common.MemoryKindCadenceFunctionValue: 1,
common.MemoryKindCadenceAttachmentValueBase: 33,
common.MemoryKindCadenceAttachmentValueSize: 16,
common.MemoryKindCadenceVoidValue: 1,
common.MemoryKindCadenceOptionalValue: 17,
common.MemoryKindCadenceBoolValue: 8,
common.MemoryKindCadenceStringValue: 16,
common.MemoryKindCadenceCharacterValue: 16,
common.MemoryKindCadenceAddressValue: 8,
common.MemoryKindCadenceIntValue: 50,
common.MemoryKindCadenceNumberValue: 1,
common.MemoryKindCadenceArrayValueBase: 41,
common.MemoryKindCadenceArrayValueLength: 16,
common.MemoryKindCadenceDictionaryValue: 41,
common.MemoryKindCadenceKeyValuePair: 33,
common.MemoryKindCadenceStructValueBase: 33,
common.MemoryKindCadenceStructValueSize: 16,
common.MemoryKindCadenceResourceValueBase: 33,
common.MemoryKindCadenceResourceValueSize: 16,
common.MemoryKindCadenceEventValueBase: 33,
common.MemoryKindCadenceEventValueSize: 16,
common.MemoryKindCadenceContractValueBase: 33,
common.MemoryKindCadenceContractValueSize: 16,
common.MemoryKindCadenceEnumValueBase: 33,
common.MemoryKindCadenceEnumValueSize: 16,
common.MemoryKindCadencePathValue: 33,
common.MemoryKindCadenceTypeValue: 17,
common.MemoryKindCadenceCapabilityValue: 1, // TODO: update with proper weight
common.MemoryKindCadenceDeprecatedPathCapabilityType: 1, // TODO: remove, deprecated. Also has a wrong name
common.MemoryKindCadenceFunctionValue: 1,
common.MemoryKindCadenceAttachmentValueBase: 33,
common.MemoryKindCadenceAttachmentValueSize: 16,

// Cadence Types

Expand Down
24 changes: 12 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
cloud.google.com/go/profiler v0.3.0
cloud.google.com/go/storage v1.36.0
github.com/antihax/optional v1.0.0
github.com/aws/aws-sdk-go-v2/config v1.27.11
github.com/aws/aws-sdk-go-v2/config v1.27.15
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.5.1
github.com/aws/aws-sdk-go-v2/service/s3 v1.15.0
github.com/btcsuite/btcd/btcec/v2 v2.2.1
Expand Down Expand Up @@ -47,12 +47,12 @@ require (
github.com/multiformats/go-multiaddr-dns v0.3.1
github.com/multiformats/go-multihash v0.2.3
github.com/onflow/atree v0.7.0-rc.2
github.com/onflow/cadence v1.0.0-preview.29
github.com/onflow/cadence v1.0.0-preview.30
github.com/onflow/crypto v0.25.1
github.com/onflow/flow v0.3.4
github.com/onflow/flow-core-contracts/lib/go/contracts v1.1.0
github.com/onflow/flow-core-contracts/lib/go/templates v1.0.0
github.com/onflow/flow-go-sdk v1.0.0-preview.30
github.com/onflow/flow-go-sdk v1.0.0-preview.31
github.com/onflow/flow/protobuf/go/flow v0.4.4
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58
github.com/pierrec/lz4 v2.6.1+incompatible
Expand Down Expand Up @@ -125,18 +125,18 @@ require (
github.com/SaveTheRbtz/mph v0.1.1-0.20240117162131-4166ec7869bc // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
github.com/aws/aws-sdk-go-v2 v1.26.1 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.11 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.1 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.5 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.5 // indirect
github.com/aws/aws-sdk-go-v2 v1.27.0 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.15 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.3 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.7 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.7 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.2 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.7 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.9 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.7.0 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.20.5 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.4 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.28.6 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.20.8 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.24.2 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.28.9 // indirect
github.com/aws/smithy-go v1.20.2 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand Down
Loading

0 comments on commit 7d80c9d

Please sign in to comment.