migrations

package
v0.33.36-atree-util Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: AGPL-3.0 Imports: 30 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TestnetAccountsWithBrokenSlabReferences = func() map[common.Address]struct{} {
	testnetAddresses := map[common.Address]struct{}{
		mustHexToAddress("434a1f199a7ae3ba"): {},
		mustHexToAddress("454c9991c2b8d947"): {},
		mustHexToAddress("48602d8056ff9d93"): {},
		mustHexToAddress("5d63c34d7f05e5a4"): {},
		mustHexToAddress("5e3448b3cffb97f2"): {},
		mustHexToAddress("7d8c7e050c694eaa"): {},
		mustHexToAddress("ba53f16ede01972d"): {},
		mustHexToAddress("c843c1f5a4805c3a"): {},
		mustHexToAddress("48d3be92e6e4a973"): {},
	}

	for address := range testnetAddresses {
		if !flow.Testnet.Chain().IsValid(flow.Address(address)) {
			panic(fmt.Sprintf("invalid testnet address: %s", address.Hex()))
		}
	}

	return testnetAddresses
}()

Functions

func CheckDomainPayloads

func CheckDomainPayloads(accountRegisters *registers.AccountRegisters) error

func MigrateByAccount added in v0.29.0

func MigrateByAccount(
	log zerolog.Logger,
	nWorker int,
	registersByAccount *registers.ByAccount,
	migrations []AccountBasedMigration,
) error

MigrateByAccount takes migrations and all the registers, grouped by account, and returns the migrated registers.

func MigrateGroupConcurrently added in v0.29.0

func MigrateGroupConcurrently(
	log zerolog.Logger,
	migrations []AccountBasedMigration,
	registersByAccount *registers.ByAccount,
	nWorker int,
) error

MigrateGroupConcurrently migrate the registers in the given account groups. The registers in each account are processed sequentially by the given migrations in order.

func NoOpMigration

func NoOpMigration(p []ledger.Payload) ([]ledger.Payload, error)

func PruneMigration added in v0.16.2

func PruneMigration(payload []ledger.Payload) ([]ledger.Payload, error)

PruneMigration removes all the payloads with empty value this prunes the trie for values that has been deleted

Types

type AccountBasedMigration added in v0.33.1

type AccountBasedMigration interface {
	InitMigration(
		log zerolog.Logger,
		registersByAccount *registers.ByAccount,
		nWorkers int,
	) error
	MigrateAccount(
		ctx context.Context,
		address common.Address,
		accountRegisters *registers.AccountRegisters,
	) error
	io.Closer
}

AccountBasedMigration is an interface for migrations that migrate account by account concurrently getting all the payloads for each account at a time.

type AccountUsageMigration added in v0.33.30

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

AccountUsageMigration iterates through each payload, and calculate the storage usage and update the accounts status with the updated storage usage

func (*AccountUsageMigration) Close added in v0.33.30

func (m *AccountUsageMigration) Close() error

func (*AccountUsageMigration) InitMigration added in v0.33.30

func (m *AccountUsageMigration) InitMigration(
	log zerolog.Logger,
	_ *registers.ByAccount,
	_ int,
) error

func (*AccountUsageMigration) MigrateAccount added in v0.33.30

func (m *AccountUsageMigration) MigrateAccount(
	_ context.Context,
	address common.Address,
	accountRegisters *registers.AccountRegisters,
) error

type AtreeRegisterMigrator added in v0.35.4

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

AtreeRegisterMigrator is a migrator that converts the storage of an account from the old atree format to the new atree format. Account "storage used" should be correctly updated after the migration.

func NewAtreeRegisterMigrator added in v0.35.4

func NewAtreeRegisterMigrator(
	rwf reporters.ReportWriterFactory,
	validateMigratedValues bool,
	logVerboseValidationError bool,
	continueMigrationOnValidationError bool,
	checkStorageHealthBeforeMigration bool,
	checkStorageHealthAfterMigration bool,
) *AtreeRegisterMigrator

func (*AtreeRegisterMigrator) Close added in v0.35.4

func (m *AtreeRegisterMigrator) Close() error

func (*AtreeRegisterMigrator) InitMigration added in v0.35.4

func (m *AtreeRegisterMigrator) InitMigration(
	log zerolog.Logger,
	_ *registers.ByAccount,
	nWorkers int,
) error

func (*AtreeRegisterMigrator) MigrateAccount added in v0.35.4

func (m *AtreeRegisterMigrator) MigrateAccount(
	_ context.Context,
	address common.Address,
	accountRegisters *registers.AccountRegisters,
) error

type AtreeRegisterMigratorRuntime added in v0.35.4

type AtreeRegisterMigratorRuntime struct {
	TransactionState    state.NestedTransactionPreparer
	Interpreter         *interpreter.Interpreter
	Storage             *runtime.Storage
	Address             common.Address
	AccountsAtreeLedger *util.AccountsAtreeLedger
}

func NewAtreeRegisterMigratorRuntime added in v0.35.4

func NewAtreeRegisterMigratorRuntime(
	address common.Address,
	regs registers.Registers,
) (
	*AtreeRegisterMigratorRuntime,
	error,
)

NewAtreeRegisterMigratorRuntime returns a new runtime to be used with the AtreeRegisterMigrator.

type DeduplicateContractNamesMigration added in v0.33.1

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

DeduplicateContractNamesMigration checks if the contract names have been duplicated and removes the duplicate ones.

This migration de-syncs storage used, so it should be run before the StorageUsedMigration.

func (*DeduplicateContractNamesMigration) Close added in v0.33.1

func (*DeduplicateContractNamesMigration) InitMigration added in v0.33.1

func (*DeduplicateContractNamesMigration) MigrateAccount added in v0.33.1

func (d *DeduplicateContractNamesMigration) MigrateAccount(
	ctx context.Context,
	address common.Address,
	accountRegisters *registers.AccountRegisters,
) error

type FilterUnreferencedSlabsMigration added in v0.33.30

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

func NewFilterUnreferencedSlabsMigration added in v0.33.30

func NewFilterUnreferencedSlabsMigration(
	outputDir string,
	rwf reporters.ReportWriterFactory,
) *FilterUnreferencedSlabsMigration

func (*FilterUnreferencedSlabsMigration) Close added in v0.33.30

func (*FilterUnreferencedSlabsMigration) InitMigration added in v0.33.30

func (m *FilterUnreferencedSlabsMigration) InitMigration(
	log zerolog.Logger,
	_ *registers.ByAccount,
	nWorkers int,
) error

func (*FilterUnreferencedSlabsMigration) MigrateAccount added in v0.33.30

func (m *FilterUnreferencedSlabsMigration) MigrateAccount(
	_ context.Context,
	address common.Address,
	accountRegisters *registers.AccountRegisters,
) error

type FixSlabsWithBrokenReferencesMigration added in v0.33.30

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

func NewFixBrokenReferencesInSlabsMigration added in v0.33.30

func NewFixBrokenReferencesInSlabsMigration(
	outputDir string,
	rwf reporters.ReportWriterFactory,
	accountsToFix map[common.Address]struct{},
) *FixSlabsWithBrokenReferencesMigration

func (*FixSlabsWithBrokenReferencesMigration) Close added in v0.33.30

func (*FixSlabsWithBrokenReferencesMigration) InitMigration added in v0.33.30

func (m *FixSlabsWithBrokenReferencesMigration) InitMigration(
	log zerolog.Logger,
	_ *registers.ByAccount,
	nWorkers int,
) error

func (*FixSlabsWithBrokenReferencesMigration) MigrateAccount added in v0.33.30

func (m *FixSlabsWithBrokenReferencesMigration) MigrateAccount(
	_ context.Context,
	address common.Address,
	accountRegisters *registers.AccountRegisters,
) error

type RegistersMigration added in v0.33.30

type RegistersMigration func(registersByAccount *registers.ByAccount) error

func CreateAccountBasedMigration added in v0.33.1

func CreateAccountBasedMigration(
	log zerolog.Logger,
	nWorker int,
	migrations []AccountBasedMigration,
) RegistersMigration

CreateAccountBasedMigration creates a migration function that migrates the payloads account by account using the given migrations accounts are processed concurrently using the given number of workers but each account is processed sequentially by the given migrations in order. The migrations InitMigration function is called once before the migration starts And the Close function is called once after the migration finishes if the migration is a finisher.

Jump to

Keyboard shortcuts

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