migrations

package
v1.0.0-preview.29 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShouldFixBrokenCompositeKeyedDictionary

func ShouldFixBrokenCompositeKeyedDictionary(atreeValue atree.Value) bool

ShouldFixBrokenCompositeKeyedDictionary returns true if the given value is a dictionary with a composite key type.

It is useful for use with atree's PersistentSlabStorage.FixLoadedBrokenReferences.

NOTE: The intended use case is to enable migration programs in onflow/flow-go to fix broken references. As of April 2024, only 10 registers in testnet (not mainnet) were found to have broken references, and they seem to have resulted from a bug that was fixed 2 years ago by https://github.com/onflow/cadence/pull/1565.

Types

type AccountStorage

type AccountStorage struct {
	// contains filtered or unexported fields
}

func NewAccountStorage

func NewAccountStorage(storage *runtime.Storage, address common.Address) AccountStorage

NewAccountStorage constructs an `AccountStorage` for a given account.

func (*AccountStorage) MigrateStorageMap

func (i *AccountStorage) MigrateStorageMap(
	inter *interpreter.Interpreter,
	domain string,
	migrator StorageMapKeyMigrator,
	atreeKeyToStorageMapKey func(atree.Value) interpreter.StorageMapKey,
)

func (*AccountStorage) MigrateStringKeys

func (i *AccountStorage) MigrateStringKeys(
	inter *interpreter.Interpreter,
	key string,
	migrator StorageMapKeyMigrator,
)

func (*AccountStorage) MigrateUint64Keys

func (i *AccountStorage) MigrateUint64Keys(
	inter *interpreter.Interpreter,
	key string,
	migrator StorageMapKeyMigrator,
)

type CachedStaticType

type CachedStaticType struct {
	StaticType interpreter.StaticType
	Error      error
}

type DefaultStaticTypeCache

type DefaultStaticTypeCache struct {
	// contains filtered or unexported fields
}

func NewDefaultStaticTypeCache

func NewDefaultStaticTypeCache() *DefaultStaticTypeCache

func (*DefaultStaticTypeCache) Get

func (*DefaultStaticTypeCache) Set

func (c *DefaultStaticTypeCache) Set(
	typeID interpreter.TypeID,
	staticType interpreter.StaticType,
	err error,
)

type DomainMigration

type DomainMigration interface {
	Name() string
	Migrate(
		addressPath interpreter.AddressPath,
	)
}

type LegacyCharacterValue

type LegacyCharacterValue struct {
	interpreter.CharacterValue
}

LegacyCharacterValue simulates the old character-value which uses the un-normalized string for hashing.

func (*LegacyCharacterValue) Equal

func (v *LegacyCharacterValue) Equal(
	inter *interpreter.Interpreter,
	locationRange interpreter.LocationRange,
	other interpreter.Value,
) bool

func (*LegacyCharacterValue) HashInput

func (*LegacyCharacterValue) StoredValue

func (v *LegacyCharacterValue) StoredValue(_ atree.SlabStorage) (atree.Value, error)

func (*LegacyCharacterValue) Transfer

func (v *LegacyCharacterValue) Transfer(
	interpreter *interpreter.Interpreter,
	_ interpreter.LocationRange,
	_ atree.Address,
	remove bool,
	storable atree.Storable,
	_ map[atree.StorageID]struct{},
) interpreter.Value

type LegacyIntersectionType

type LegacyIntersectionType struct {
	*interpreter.IntersectionStaticType
}

LegacyIntersectionType simulates the old, incorrect restricted-type type-ID generation, which did not sort the type IDs of the interface types.

func (*LegacyIntersectionType) Equal

func (*LegacyIntersectionType) ID

type LegacyOptionalType

type LegacyOptionalType struct {
	*interpreter.OptionalStaticType
}

LegacyOptionalType simulates the old optional type with the old typeID generation.

func (*LegacyOptionalType) Equal

func (*LegacyOptionalType) ID

type LegacyPrimitiveStaticType

type LegacyPrimitiveStaticType struct {
	interpreter.PrimitiveStaticType
}

LegacyPrimitiveStaticType simulates the old primitive-static-type which uses the old type-ids for hashing.

func (LegacyPrimitiveStaticType) Equal

func (LegacyPrimitiveStaticType) ID

type LegacyReferenceType

type LegacyReferenceType struct {
	*interpreter.ReferenceStaticType
}

LegacyReferenceType simulates the old reference type with the old typeID generation.

func (*LegacyReferenceType) Encode

func (t *LegacyReferenceType) Encode(e *cbor.StreamEncoder) error

func (*LegacyReferenceType) Equal

func (*LegacyReferenceType) ID

type LegacyStringValue

type LegacyStringValue struct {
	*interpreter.StringValue
}

LegacyStringValue simulates the old string-value which uses the un-normalized string for hashing.

func (*LegacyStringValue) Equal

func (v *LegacyStringValue) Equal(
	inter *interpreter.Interpreter,
	locationRange interpreter.LocationRange,
	other interpreter.Value,
) bool

func (*LegacyStringValue) HashInput

func (v *LegacyStringValue) HashInput(_ *interpreter.Interpreter, _ interpreter.LocationRange, scratch []byte) []byte

func (*LegacyStringValue) StoredValue

func (v *LegacyStringValue) StoredValue(_ atree.SlabStorage) (atree.Value, error)

func (*LegacyStringValue) Transfer

func (v *LegacyStringValue) Transfer(
	interpreter *interpreter.Interpreter,
	_ interpreter.LocationRange,
	_ atree.Address,
	remove bool,
	storable atree.Storable,
	_ map[atree.StorageID]struct{},
) interpreter.Value

type Reporter

type Reporter interface {
	Migrated(
		storageKey interpreter.StorageKey,
		storageMapKey interpreter.StorageMapKey,
		migration string,
	)
	DictionaryKeyConflict(addressPath interpreter.AddressPath)
	Error(err error)
}

type StaticTypeCache

type StaticTypeCache interface {
	Get(typeID interpreter.TypeID) (CachedStaticType, bool)
	Set(
		typeID interpreter.TypeID,
		staticType interpreter.StaticType,
		err error,
	)
}

type StorageMapKeyMigrator

type StorageMapKeyMigrator interface {
	Migrate(
		inter *interpreter.Interpreter,
		storageKey interpreter.StorageKey,
		storageMap *interpreter.StorageMap,
		storageMapKey interpreter.StorageMapKey,
	)
	Domains() map[string]struct{}
}

func NewValueConverterPathMigrator

func NewValueConverterPathMigrator(
	domains map[string]struct{},
	convertValue ValueConverter,
) StorageMapKeyMigrator

type StorageMigration

type StorageMigration struct {
	// contains filtered or unexported fields
}

func NewStorageMigration

func NewStorageMigration(
	interpreter *interpreter.Interpreter,
	storage *runtime.Storage,
	name string,
	address common.Address,
) (
	*StorageMigration,
	error,
)

func (*StorageMigration) Commit

func (m *StorageMigration) Commit() error

func (*StorageMigration) DictionaryKeyConflictStorageMapKey

func (m *StorageMigration) DictionaryKeyConflictStorageMapKey(index int) interpreter.StringStorageMapKey

func (*StorageMigration) Migrate

func (m *StorageMigration) Migrate(migrator StorageMapKeyMigrator)

func (*StorageMigration) MigrateNestedValue

func (m *StorageMigration) MigrateNestedValue(
	storageKey interpreter.StorageKey,
	storageMapKey interpreter.StorageMapKey,
	value interpreter.Value,
	valueMigrations []ValueMigration,
	reporter Reporter,
	allowMutation bool,
) (migratedValue interpreter.Value)

func (*StorageMigration) NewValueMigrationsPathMigrator

func (m *StorageMigration) NewValueMigrationsPathMigrator(
	reporter Reporter,
	valueMigrations ...ValueMigration,
) StorageMapKeyMigrator

func (*StorageMigration) WithErrorStacktrace

func (m *StorageMigration) WithErrorStacktrace(stacktraceEnabled bool) *StorageMigration

type StorageMigrationError

type StorageMigrationError struct {
	StorageKey    interpreter.StorageKey
	StorageMapKey interpreter.StorageMapKey
	Migration     string
	Err           error
	Stack         []byte
}

func (StorageMigrationError) Error

func (e StorageMigrationError) Error() string

type ValueConverter

type ValueConverter func(
	storageKey interpreter.StorageKey,
	storageMapKey interpreter.StorageMapKey,
	value interpreter.Value,
) interpreter.Value

type ValueConverterPathMigrator

type ValueConverterPathMigrator struct {
	ConvertValue ValueConverter
	// contains filtered or unexported fields
}

func (ValueConverterPathMigrator) Domains

func (m ValueConverterPathMigrator) Domains() map[string]struct{}

func (ValueConverterPathMigrator) Migrate

func (m ValueConverterPathMigrator) Migrate(
	inter *interpreter.Interpreter,
	storageKey interpreter.StorageKey,
	storageMap *interpreter.StorageMap,
	storageMapKey interpreter.StorageMapKey,
)

type ValueMigration

type ValueMigration interface {
	Name() string
	Migrate(
		storageKey interpreter.StorageKey,
		storageMapKey interpreter.StorageMapKey,
		value interpreter.Value,
		interpreter *interpreter.Interpreter,
	) (newValue interpreter.Value, err error)
	CanSkip(valueType interpreter.StaticType) bool
	Domains() map[string]struct{}
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL