util

package
v0.37.9-migration-mainnet Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: AGPL-3.0 Imports: 42 Imported by: 2

Documentation

Index

Constants

View Source
const (
	PayloadFileVersionV1 uint16 = 0x01
)

Variables

This section is empty.

Functions

func CheckStorageHealth added in v0.37.5

func CheckStorageHealth(
	address common.Address,
	storage *runtime.Storage,
	registers registers.Registers,
	domains []string,
	nWorkers int,
) error

func CreatePayloadFile added in v0.33.30

func CreatePayloadFile(
	logger zerolog.Logger,
	payloadFile string,
	payloads []*ledger.Payload,
	owners map[string]struct{},
	inputPayloadsFromPartialState bool,
) (int, error)

func IsPayloadAtreeInlined added in v0.33.30

func IsPayloadAtreeInlined(payload *ledger.Payload) (isAtreeSlab bool, isInlined bool, err error)

func IsPayloadFilePartialState added in v0.33.30

func IsPayloadFilePartialState(payloadFile string) (bool, error)

func IsRegisterAtreeInlined added in v0.33.30

func IsRegisterAtreeInlined(key string, value []byte) (isAtreeSlab bool, isInlined bool, err error)

func IsServiceLevelAddress

func IsServiceLevelAddress(address common.Address) bool

IsServiceLevelAddress returns true if the given address is the service level address. Which means it's not an actual account but instead holds service lever registers.

func LoadAtreeSlabsInStorage added in v0.37.5

func LoadAtreeSlabsInStorage(
	storage *runtime.Storage,
	registers registers.Registers,
	nWorkers int,
) error

func NewByAccountRegistersFromPayloadAccountGrouping added in v0.37.5

func NewByAccountRegistersFromPayloadAccountGrouping(
	payloadAccountGrouping *PayloadAccountGrouping,
	nWorker int,
) (
	*registers.ByAccount,
	error,
)

func ParseStateCommitment added in v0.33.30

func ParseStateCommitment(stateCommitmentHex string) flow.StateCommitment

func PayloadsAndAccountsFromEmulatorSnapshot added in v0.33.30

func PayloadsAndAccountsFromEmulatorSnapshot(db *sql.DB) (
	[]*ledger.Payload,
	map[flow.RegisterID]PayloadMetaInfo,
	[]common.Address,
	error,
)

func PayloadsFromEmulatorSnapshot added in v0.33.30

func PayloadsFromEmulatorSnapshot(snapshotPath string) ([]*ledger.Payload, error)

func ReadPayloadFile added in v0.33.30

func ReadPayloadFile(logger zerolog.Logger, payloadFile string) (bool, []*ledger.Payload, error)

func ReadTrie added in v0.33.30

func ReadTrie(dir string, targetHash flow.StateCommitment) ([]*ledger.Payload, error)

func SortPayloadsByAddress added in v0.33.30

func SortPayloadsByAddress(payloads []*ledger.Payload, nWorkers int) []*ledger.Payload

Types

type AccountsAtreeLedger

type AccountsAtreeLedger struct {
	Accounts environment.Accounts
}

func NewAccountsAtreeLedger

func NewAccountsAtreeLedger(accounts environment.Accounts) *AccountsAtreeLedger

func (*AccountsAtreeLedger) AllocateSlabIndex added in v0.37.1

func (a *AccountsAtreeLedger) AllocateSlabIndex(owner []byte) (atree.SlabIndex, error)

AllocateSlabIndex allocates new storage index under the owner accounts to store a new register

func (*AccountsAtreeLedger) GetValue

func (a *AccountsAtreeLedger) GetValue(owner, key []byte) ([]byte, error)

func (*AccountsAtreeLedger) SetValue

func (a *AccountsAtreeLedger) SetValue(owner, key, value []byte) error

func (*AccountsAtreeLedger) ValueExists

func (a *AccountsAtreeLedger) ValueExists(owner, key []byte) (exists bool, err error)

type GerOrLoadProgramListenerFunc added in v0.33.30

type GerOrLoadProgramListenerFunc func(
	location runtime.Location,
	program *interpreter.Program,
	err error,
)

type GetContractCodeFunc added in v0.33.30

type GetContractCodeFunc func(location common.AddressLocation) ([]byte, error)

type GetContractNamesFunc added in v0.33.30

type GetContractNamesFunc func(address flow.Address) ([]string, error)

type GetOrLoadProgramFunc added in v0.33.30

type GetOrLoadProgramFunc func(
	location runtime.Location,
	load func() (*interpreter.Program, error),
) (
	*interpreter.Program,
	error,
)

func NewProgramsGetOrLoadProgramFunc added in v0.33.30

func NewProgramsGetOrLoadProgramFunc(
	nestedTransactionPreparer state.NestedTransactionPreparer,
	accounts environment.Accounts,
) (GetOrLoadProgramFunc, error)

type MigrationRuntimeInterface

type MigrationRuntimeInterface struct {
	runtime.EmptyRuntimeInterface

	GetContractCodeFunc          GetContractCodeFunc
	GetContractNamesFunc         GetContractNamesFunc
	GetOrLoadProgramFunc         GetOrLoadProgramFunc
	GetOrLoadProgramListenerFunc GerOrLoadProgramListenerFunc
	// contains filtered or unexported fields
}

MigrationRuntimeInterface is a runtime interface that can be used in migrations. It only allows parsing and checking of contracts.

func NewMigrationRuntimeInterface added in v0.33.30

func NewMigrationRuntimeInterface(
	chainID flow.ChainID,
	getCodeFunc GetContractCodeFunc,
	getContractNamesFunc GetContractNamesFunc,
	getOrLoadProgramFunc GetOrLoadProgramFunc,
	getOrLoadProgramListenerFunc GerOrLoadProgramListenerFunc,
) *MigrationRuntimeInterface

func (*MigrationRuntimeInterface) GetAccountContractCode

func (m *MigrationRuntimeInterface) GetAccountContractCode(
	location common.AddressLocation,
) (code []byte, err error)

func (*MigrationRuntimeInterface) GetCode

func (m *MigrationRuntimeInterface) GetCode(location runtime.Location) ([]byte, error)

func (*MigrationRuntimeInterface) GetOrLoadProgram

func (m *MigrationRuntimeInterface) GetOrLoadProgram(
	location runtime.Location,
	load func() (*interpreter.Program, error),
) (
	program *interpreter.Program,
	err error,
)

func (*MigrationRuntimeInterface) RecoverProgram added in v0.37.1

func (m *MigrationRuntimeInterface) RecoverProgram(
	program *ast.Program,
	location common.Location,
) ([]byte, error)

func (*MigrationRuntimeInterface) ResolveLocation

func (m *MigrationRuntimeInterface) ResolveLocation(
	identifiers []runtime.Identifier,
	location runtime.Location,
) ([]runtime.ResolvedLocation, error)

type NopMeter

type NopMeter struct{}

NopMeter is a meter that does nothing. It can be used in migrations.

func (NopMeter) ComputationAvailable

func (n NopMeter) ComputationAvailable(_ common.ComputationKind, _ uint) bool

func (NopMeter) ComputationIntensities

func (n NopMeter) ComputationIntensities() meter.MeteredComputationIntensities

func (NopMeter) ComputationUsed

func (n NopMeter) ComputationUsed() (uint64, error)

func (NopMeter) InteractionUsed

func (n NopMeter) InteractionUsed() (uint64, error)

func (NopMeter) MemoryUsed

func (n NopMeter) MemoryUsed() (uint64, error)

func (NopMeter) MeterComputation

func (n NopMeter) MeterComputation(_ common.ComputationKind, _ uint) error

func (NopMeter) MeterEmittedEvent

func (n NopMeter) MeterEmittedEvent(_ uint64) error

func (NopMeter) MeterMemory

func (n NopMeter) MeterMemory(_ common.MemoryUsage) error

func (NopMeter) TotalEmittedEventBytes

func (n NopMeter) TotalEmittedEventBytes() uint64

type PayloadAccountGroup

type PayloadAccountGroup struct {
	Address  flow.Address
	Payloads []*ledger.Payload
}

PayloadAccountGroup is a grouping of payloads by account

type PayloadAccountGrouping

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

PayloadAccountGrouping is a grouping of payloads by account.

func GroupPayloadsByAccount

func GroupPayloadsByAccount(
	log zerolog.Logger,
	payloads []*ledger.Payload,
	nWorkers int,
) *PayloadAccountGrouping

GroupPayloadsByAccount takes a list of payloads and groups them by account. it uses nWorkers to sort the payloads by address and find the start and end indexes of each account.

func (*PayloadAccountGrouping) AllPayloadsCount

func (g *PayloadAccountGrouping) AllPayloadsCount() int

AllPayloadsCount the number of payloads

func (*PayloadAccountGrouping) Len

func (g *PayloadAccountGrouping) Len() int

Len returns the number of accounts

func (*PayloadAccountGrouping) Next

Next returns the next account group. If there is no more account group, it returns nil. The zero address is used for global Payloads and is not an actual account.

type PayloadMetaInfo added in v0.33.30

type PayloadMetaInfo struct {
	Height, Version uint64
}

type PayloadsLedger added in v0.33.30

type PayloadsLedger struct {
	Payloads map[flow.RegisterID]*ledger.Payload

	AllocateSlabIndexFunc func(owner []byte) (atree.SlabIndex, error)
}

PayloadsLedger is a simple read/write in-memory atree.Ledger implementation

func NewPayloadsLedger added in v0.33.30

func NewPayloadsLedger(payloads map[flow.RegisterID]*ledger.Payload) *PayloadsLedger

func (*PayloadsLedger) AllocateSlabIndex added in v0.37.1

func (p *PayloadsLedger) AllocateSlabIndex(owner []byte) (atree.SlabIndex, error)

func (*PayloadsLedger) GetValue added in v0.33.30

func (p *PayloadsLedger) GetValue(owner, key []byte) (value []byte, err error)

func (*PayloadsLedger) SetValue added in v0.33.30

func (p *PayloadsLedger) SetValue(owner, key, value []byte) (err error)

func (*PayloadsLedger) ValueExists added in v0.33.30

func (p *PayloadsLedger) ValueExists(owner, key []byte) (exists bool, err error)

type TopN added in v0.33.30

type TopN[T any] struct {
	Tree   []T
	N      int
	IsLess func(T, T) bool
}

TopN keeps track of the top N elements. Use Add to add elements to the list.

func NewTopN added in v0.33.30

func NewTopN[T any](n int, isLess func(T, T) bool) *TopN[T]

func (*TopN[T]) Add added in v0.33.30

func (h *TopN[T]) Add(value T) (popped T, didPop bool)

Add tries to add a value to the list. If the list is full, it will return the smallest value and true. If the list is not full, it will return the zero value and false.

func (*TopN[T]) Len added in v0.33.30

func (h *TopN[T]) Len() int

func (*TopN[T]) Less added in v0.33.30

func (h *TopN[T]) Less(i, j int) bool

func (*TopN[T]) Pop added in v0.33.30

func (h *TopN[T]) Pop() interface{}

func (*TopN[T]) Push added in v0.33.30

func (h *TopN[T]) Push(x interface{})

func (*TopN[T]) Swap added in v0.33.30

func (h *TopN[T]) Swap(i, j int)

type Trace added in v0.33.30

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

func NewTrace added in v0.33.30

func NewTrace(value string) *Trace

func (*Trace) Append added in v0.33.30

func (t *Trace) Append(value string) *Trace

func (*Trace) String added in v0.33.30

func (t *Trace) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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