inspection

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountChange

type AccountChange map[string]int64

type Inspector

type Inspector interface {
	// Inspect
	// - storage is the execution state before the procedure was executed.
	//    only the executionSnapshot.Reads, will be read
	// - executionSnapshot is the reads and writes of the procedure
	// - events are all of the events the procedure is emitting
	Inspect(
		logger zerolog.Logger,
		storage snapshot.StorageSnapshot,
		executionSnapshot *snapshot.ExecutionSnapshot,
		events []flow.Event,
	) (Result, error)

	// Name is the name of the inspector
	Name() string
}

Inspector is run after each procedure on the procedure output and the starting state of a procedure It will then fill out the ProcedureOutput.Inspection results

type Result

type Result interface {
	InspectionName() string
	AsLogEvent() (zerolog.Level, func(e *zerolog.Event))
}

Result is the result of a procedure inspector

type SearchToken

type SearchToken struct {
	ID         string
	GetBalance func(value *interpreter.CompositeValue) uint64
	// TODO: optimize by using decoded events
	SinksSources map[string]func(flow.Event) (int64, error)
}

type TokenChanges

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

func NewTokenChangesInspector

func NewTokenChangesInspector(searchedTokens TokenChangesSearchTokens, chain flow.ChainID) *TokenChanges

NewTokenChangesInspector return a TokenChanges inspector, that will be run after transaction execution and analyze if any unaccounted tokens were created or destroy.

func (*TokenChanges) Inspect

func (td *TokenChanges) Inspect(
	log zerolog.Logger,
	storage snapshot.StorageSnapshot,
	executionSnapshot *snapshot.ExecutionSnapshot,
	events []flow.Event,
) (diff Result, err error)

Inspect gets the token diff from a state diff - thread safe - not deterministic (iterates over maps)! So it should not be used to affect execution! - will not panic - might return an error, but it is safe to ignore since this for information/reporting

Inspect could technically be run on chunk data packs.

func (*TokenChanges) Name

func (td *TokenChanges) Name() string

func (*TokenChanges) SetSearchedTokens

func (td *TokenChanges) SetSearchedTokens(searchedTokens TokenChangesSearchTokens)

SetSearchedTokens are safe to replace whenever. The change will not affect the inspections already in progress. TODO: this can be tied into the admin commands

type TokenChangesSearchTokens

type TokenChangesSearchTokens map[string]SearchToken

func DefaultTokenDiffSearchTokens

func DefaultTokenDiffSearchTokens(chain flow.Chain, withoutMintingEvent bool) TokenChangesSearchTokens

DefaultTokenDiffSearchTokens returns the default settings for token inspection We temporarily want to handle all token mints as a warning. To do that set the `withoutMintingEvent` to true.

type TokenDiffResult

type TokenDiffResult struct {
	// Changes in token balances per account
	// parsed from the state changes
	Changes map[flow.Address]AccountChange

	// KnownSourcesSinks is a map (by token id) of
	// know mints/burns for the token parsed from predetermined events
	KnownSourcesSinks map[string]int64
}

TokenDiffResult is the result of the inspection

func (TokenDiffResult) AsLogEvent

func (r TokenDiffResult) AsLogEvent() (zerolog.Level, func(e *zerolog.Event))

func (TokenDiffResult) InspectionName

func (r TokenDiffResult) InspectionName() string

func (TokenDiffResult) UnaccountedTokens

func (r TokenDiffResult) UnaccountedTokens() map[string]int64

Jump to

Keyboard shortcuts

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