validator

package
v0.41.1-data-migration... Latest Latest
Warning

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

Go to latest
Published: May 21, 2025 License: AGPL-3.0 Imports: 20 Imported by: 2

Documentation

Index

Constants

View Source
const DefaultSealedIndexedHeightThreshold = 30

DefaultSealedIndexedHeightThreshold is the default number of blocks between sealed and indexed height this sets a limit on how far into the past the payer validator will allow for checking the payer's balance.

Variables

View Source
var ErrUnknownReferenceBlock = errors.New("unknown reference block")

ErrUnknownReferenceBlock indicates that a transaction references an unknown block.

View Source
var IndexReporterNotInitialized = errors.New("index reported not initialized")

IndexReporterNotInitialized is returned when indexReporter is nil because execution data syncing and indexing is disabled

Functions

func IsInsufficientBalanceError

func IsInsufficientBalanceError(err error) bool

Types

type Blocks

type Blocks interface {
	HeaderByID(id flow.Identifier) (*flow.Header, error)
	FinalizedHeader() (*flow.Header, error)
	SealedHeader() (*flow.Header, error)
	IndexedHeight() (uint64, error)
}

type DuplicatedSignatureError

type DuplicatedSignatureError struct {
	Address  flow.Address
	KeyIndex uint32
}

DuplicatedSignatureError indicates that two signatures havs been provided for a key (combination of account and key index)

func (DuplicatedSignatureError) Error

func (e DuplicatedSignatureError) Error() string

type ExpiredTransactionError

type ExpiredTransactionError struct {
	RefHeight, FinalHeight uint64
}

ExpiredTransactionError indicates that a transaction has expired.

func (ExpiredTransactionError) Error

func (e ExpiredTransactionError) Error() string

type IncompleteTransactionError

type IncompleteTransactionError struct {
	MissingFields []string
}

IncompleteTransactionError indicates that a transaction is missing one or more required fields.

func (IncompleteTransactionError) Error

type IndexedHeightFarBehindError

type IndexedHeightFarBehindError struct {
	SealedHeight  uint64
	IndexedHeight uint64
}

IndexedHeightFarBehindError indicates that a node is far behind on indexing.

func (IndexedHeightFarBehindError) Error

type InsufficientBalanceError

type InsufficientBalanceError struct {
	Payer           flow.Address
	RequiredBalance cadence.UFix64
}

func (InsufficientBalanceError) Error

func (e InsufficientBalanceError) Error() string

type InvalidAddressError

type InvalidAddressError struct {
	Address flow.Address
}

InvalidAddressError indicates that a transaction references an invalid flow Address in either the Authorizers or Payer field.

func (InvalidAddressError) Error

func (e InvalidAddressError) Error() string

type InvalidGasLimitError

type InvalidGasLimitError struct {
	Maximum uint64
	Actual  uint64
}

InvalidGasLimitError indicates that a transaction specifies a gas limit that exceeds the maximum.

func (InvalidGasLimitError) Error

func (e InvalidGasLimitError) Error() string

type InvalidScriptError

type InvalidScriptError struct {
	ParserErr error
}

InvalidScriptError indicates that a transaction contains an invalid Cadence script.

func (InvalidScriptError) Error

func (e InvalidScriptError) Error() string

func (InvalidScriptError) Unwrap

func (e InvalidScriptError) Unwrap() error

type InvalidSignatureError

type InvalidSignatureError struct {
	Signature flow.TransactionSignature
}

InvalidSignatureError indicates that a transaction contains a signature with a wrong format.

func (InvalidSignatureError) Error

func (e InvalidSignatureError) Error() string

type InvalidTxByteSizeError

type InvalidTxByteSizeError struct {
	Maximum uint64
	Actual  uint64
}

InvalidTxByteSizeError indicates that a transaction byte size exceeds the maximum.

func (InvalidTxByteSizeError) Error

func (e InvalidTxByteSizeError) Error() string

type InvalidTxRateLimitedError

type InvalidTxRateLimitedError struct {
	Payer flow.Address
}

func (InvalidTxRateLimitedError) Error

type PayerBalanceMode

type PayerBalanceMode int

PayerBalanceMode represents the mode for checking the payer's balance when validating transactions. It controls whether and how the balance check is performed during transaction validation.

There are few modes available:

  • `Disabled` - Balance checking is completely disabled. No checks are performed to verify if the payer has sufficient balance to cover the transaction fees.
  • `WarnCheck` - Balance is checked, and a warning is logged if the payer does not have enough balance. The transaction is still accepted and processed regardless of the check result.
  • `EnforceCheck` - Balance is checked, and the transaction is rejected if the payer does not have sufficient balance to cover the transaction fees.
const (
	// Disabled indicates that payer balance checking is turned off.
	Disabled PayerBalanceMode = iota

	// WarnCheck logs a warning if the payer's balance is insufficient, but does not prevent the transaction from being accepted.
	WarnCheck

	// EnforceCheck prevents the transaction from being accepted if the payer's balance is insufficient to cover transaction fees.
	EnforceCheck
)

func ParsePayerBalanceMode

func ParsePayerBalanceMode(s string) (PayerBalanceMode, error)

func (PayerBalanceMode) String

func (m PayerBalanceMode) String() string

type ProtocolStateBlocks

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

func NewProtocolStateBlocks

func NewProtocolStateBlocks(state protocol.State, indexReporter state_synchronization.IndexReporter) *ProtocolStateBlocks

func (*ProtocolStateBlocks) FinalizedHeader

func (b *ProtocolStateBlocks) FinalizedHeader() (*flow.Header, error)

func (*ProtocolStateBlocks) HeaderByID

func (b *ProtocolStateBlocks) HeaderByID(id flow.Identifier) (*flow.Header, error)

func (*ProtocolStateBlocks) IndexedHeight

func (b *ProtocolStateBlocks) IndexedHeight() (uint64, error)

IndexedHeight returns the highest indexed height by calling corresponding function of indexReporter. Expected errors during normal operation: - access.IndexReporterNotInitialized - indexed reporter was not initialized.

func (*ProtocolStateBlocks) SealedHeader

func (b *ProtocolStateBlocks) SealedHeader() (*flow.Header, error)

type TransactionValidationOptions

type TransactionValidationOptions struct {
	Expiry                       uint
	ExpiryBuffer                 uint
	AllowEmptyReferenceBlockID   bool
	AllowUnknownReferenceBlockID bool
	MaxGasLimit                  uint64
	CheckScriptsParse            bool
	MaxTransactionByteSize       uint64
	MaxCollectionByteSize        uint64
	CheckPayerBalanceMode        PayerBalanceMode
}

type TransactionValidator

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

func NewTransactionValidator

func NewTransactionValidator(
	blocks Blocks,
	chain flow.Chain,
	transactionValidationMetrics module.TransactionValidationMetrics,
	options TransactionValidationOptions,
	executor execution.ScriptExecutor,
) (*TransactionValidator, error)

func NewTransactionValidatorWithLimiter

func NewTransactionValidatorWithLimiter(
	blocks Blocks,
	chain flow.Chain,
	options TransactionValidationOptions,
	transactionValidationMetrics module.TransactionValidationMetrics,
	rateLimiter ratelimit.RateLimiter,
) *TransactionValidator

func (*TransactionValidator) Validate

func (v *TransactionValidator) Validate(ctx context.Context, tx *flow.TransactionBody) (err error)

type ValidationStep

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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