verify

package
v0.0.0-...-76c1feb Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogicSigSanityCheck

func LogicSigSanityCheck(txn *transactions.SignedTxn, groupIndex int, groupCtx *GroupContext) error

LogicSigSanityCheck checks that the signature is valid and that the program is basically well formed. It does not evaluate the logic.

func PaysetGroups

func PaysetGroups(ctx context.Context, payset [][]transactions.SignedTxn, blkHeader bookkeeping.BlockHeader, verificationPool execpool.BacklogPool, cache VerifiedTransactionCache) (err error)

PaysetGroups verifies that the payset have a good signature and that the underlying transactions are properly constructed. Note that this does not check whether a payset is valid against the ledger: a PaysetGroups may be well-formed, but a payset might contain an overspend.

This version of verify is performing the verification over the provided execution pool.

func Txn

func Txn(s *transactions.SignedTxn, txnIdx int, groupCtx *GroupContext) error

Txn verifies a SignedTxn as being signed and having no obviously inconsistent data. Block-assembly time checks of LogicSig and accounting rules may still block the txn.

Types

type GroupContext

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

GroupContext is the set of parameters external to a transaction which stateless checks are performed against.

For efficient caching, these parameters should either be constant or change slowly over time.

Group data are omitted because they are committed to in the transaction and its ID.

func PrepareGroupContext

func PrepareGroupContext(group []transactions.SignedTxn, contextHdr bookkeeping.BlockHeader) (*GroupContext, error)

PrepareGroupContext prepares a verification group parameter object for a given transaction group.

func TxnGroup

func TxnGroup(stxs []transactions.SignedTxn, contextHdr bookkeeping.BlockHeader, cache VerifiedTransactionCache) (groupCtx *GroupContext, err error)

TxnGroup verifies a []SignedTxn as being signed and having no obviously inconsistent data.

func (*GroupContext) Equal

func (g *GroupContext) Equal(other *GroupContext) bool

Equal compares two group contexts to see if they would represent the same verification context for a given transaction.

type VerifiedTransactionCache

type VerifiedTransactionCache interface {
	// Add adds a given transaction group and it's associated group context to the cache. If any of the transactions already appear
	// in the cache, the new entry overrides the old one.
	Add(txgroup []transactions.SignedTxn, groupCtx *GroupContext)
	// AddPayset works in a similar way to Add, but is intended for adding an array of transaction groups, along with their corresponding contexts.
	AddPayset(txgroup [][]transactions.SignedTxn, groupCtxs []*GroupContext) error
	// GetUnverifiedTranscationGroups compares the provided payset against the currently cached transactions and figure which transaction groups aren't fully cached.
	GetUnverifiedTranscationGroups(payset [][]transactions.SignedTxn, CurrSpecAddrs transactions.SpecialAddresses, CurrProto protocol.ConsensusVersion) [][]transactions.SignedTxn
	// UpdatePinned replaces the pinned entries with the one provided in the pinnedTxns map. This is typically expected to be a subset of the
	// already-pinned transactions. If a transaction is not currently pinned, and it's can't be found in the cache, a errMissingPinnedEntry error would be generated.
	UpdatePinned(pinnedTxns map[transactions.Txid]transactions.SignedTxn) error
	// Pin function would mark the given transaction group as pinned.
	Pin(txgroup []transactions.SignedTxn) error
}

VerifiedTransactionCache provides a cached store of recently verified transactions. The cache is desiged two have two separate "levels". On the bottom tier, the cache would be using a cyclic buffer, where old transactions would end up overridden by new ones. In order to support transactions that goes into the transaction pool, we have a higher tier of pinned cache. Pinned transactions would not be cycled-away by new incoming transactions, and would only get eliminated by updates to the transaction pool, which would inform the cache of updates to the pinned items.

func GetMockedCache

func GetMockedCache(alwaysVerified bool) VerifiedTransactionCache

GetMockedCache returns a mocked transaction cache implementation

func MakeVerifiedTransactionCache

func MakeVerifiedTransactionCache(cacheSize int) VerifiedTransactionCache

MakeVerifiedTransactionCache creates an instance of verifiedTransactionCache and returns it.

type VerifiedTxnCacheError

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

VerifiedTxnCacheError helps to identifiy the errors of a cache error and diffrenciate these from a general verification errors.

func (*VerifiedTxnCacheError) Error

func (e *VerifiedTxnCacheError) Error() string

Error formats the underlying error message

func (*VerifiedTxnCacheError) Unwrap

func (e *VerifiedTxnCacheError) Unwrap() error

Unwrap provides accesss to the underlying error

Jump to

Keyboard shortcuts

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