Documentation
¶
Index ¶
- func LogicSigSanityCheck(gi int, groupCtx *GroupContext) error
- func MakeSigVerifyJobProcessor(ledger LedgerForStreamVerifier, cache VerifiedTransactionCache, ...) (svp execpool.BatchProcessor, err error)
- func PaysetGroups(ctx context.Context, payset [][]transactions.SignedTxn, ...) (err error)
- type GroupContext
- func PrepareGroupContext(group []transactions.SignedTxn, contextHdr *bookkeeping.BlockHeader, ...) (*GroupContext, error)
- func TxnGroup(stxs []transactions.SignedTxn, contextHdr *bookkeeping.BlockHeader, ...) (groupCtx *GroupContext, err error)
- func TxnGroupWithTracer(stxs []transactions.SignedTxn, contextHdr *bookkeeping.BlockHeader, ...) (groupCtx *GroupContext, err error)
- type LedgerForStreamVerifier
- type NewBlockWatcher
- type TxGroupError
- type TxGroupErrorReason
- type TxnGroupBatchSigVerifier
- type UnverifiedTxnSigJob
- type VerificationResult
- type VerifiedTransactionCache
- type VerifiedTxnCacheError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LogicSigSanityCheck ¶
func LogicSigSanityCheck(gi 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 MakeSigVerifyJobProcessor ¶
func MakeSigVerifyJobProcessor( ledger LedgerForStreamVerifier, cache VerifiedTransactionCache, resultChan chan<- *VerificationResult, droppedChan chan<- *UnverifiedTxnSigJob, ) (svp execpool.BatchProcessor, err error)
MakeSigVerifyJobProcessor returns the object implementing the stream verifier Helper interface
func PaysetGroups ¶
func PaysetGroups(ctx context.Context, payset [][]transactions.SignedTxn, blkHeader bookkeeping.BlockHeader, verificationPool execpool.BacklogPool, cache VerifiedTransactionCache, ledger logic.LedgerForSignature) (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.
Types ¶
type GroupContext ¶
type GroupContext struct {
// contains filtered or unexported fields
}
GroupContext holds values used to evaluate the LogicSigs in a group. The first set are the parameters external to a transaction which could potentially change the result of LogicSig evaluation. Example: If the consensusVersion changes, a rule might change that matters. Certainly this is _very_ rare, but we don't want to use the result of a LogicSig evaluation across a protocol upgrade boundary.
The second set are derived from the first set and from the transaction data. They are stored here only for efficiency, not for correctness, so they are not checked in Equal()
func PrepareGroupContext ¶
func PrepareGroupContext(group []transactions.SignedTxn, contextHdr *bookkeeping.BlockHeader, ledger logic.LedgerForSignature, evalTracer logic.EvalTracer) (*GroupContext, error)
PrepareGroupContext prepares a GroupCtx for a given transaction group.
func TxnGroup ¶
func TxnGroup(stxs []transactions.SignedTxn, contextHdr *bookkeeping.BlockHeader, cache VerifiedTransactionCache, ledger logic.LedgerForSignature) (groupCtx *GroupContext, err error)
TxnGroup verifies a []SignedTxn as being signed and having no obviously inconsistent data.
func TxnGroupWithTracer ¶
func TxnGroupWithTracer(stxs []transactions.SignedTxn, contextHdr *bookkeeping.BlockHeader, cache VerifiedTransactionCache, ledger logic.LedgerForSignature, evalTracer logic.EvalTracer) (groupCtx *GroupContext, err error)
TxnGroupWithTracer verifies a []SignedTxn as being signed and having no obviously inconsistent data, while using a tracer.
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 LedgerForStreamVerifier ¶
type LedgerForStreamVerifier interface { logic.LedgerForSignature RegisterBlockListeners([]ledgercore.BlockListener) Latest() basics.Round BlockHdr(rnd basics.Round) (blk bookkeeping.BlockHeader, err error) }
LedgerForStreamVerifier defines the ledger methods used by the StreamVerifier.
type NewBlockWatcher ¶
type NewBlockWatcher struct {
// contains filtered or unexported fields
}
NewBlockWatcher is a struct used to provide a new block header to the stream verifier
func MakeNewBlockWatcher ¶
func MakeNewBlockWatcher(blkHdr bookkeeping.BlockHeader) (nbw *NewBlockWatcher)
MakeNewBlockWatcher construct a new block watcher with the initial blkHdr
func (*NewBlockWatcher) OnNewBlock ¶
func (nbw *NewBlockWatcher) OnNewBlock(block bookkeeping.Block, delta ledgercore.StateDelta)
OnNewBlock implements the interface to subscribe to new block notifications from the ledger
type TxGroupError ¶
type TxGroupError struct { // GroupIndex is the index of the transaction in the group that failed. NOTE: this will be -1 if // the error is not specific to a single transaction. GroupIndex int Reason TxGroupErrorReason // contains filtered or unexported fields }
TxGroupError is an error from txn pre-validation (well form-ness, signature format, etc). It can be unwrapped into underlying error, as well as has a specific failure reason code.
func (*TxGroupError) Error ¶
func (e *TxGroupError) Error() string
Error returns an error message from the underlying error
func (*TxGroupError) Unwrap ¶
func (e *TxGroupError) Unwrap() error
Unwrap returns an underlying error
type TxGroupErrorReason ¶
type TxGroupErrorReason int
TxGroupErrorReason is reason code for ErrTxGroupError
const ( // TxGroupErrorReasonGeneric is a generic (not tracked) reason code TxGroupErrorReasonGeneric TxGroupErrorReason = iota // TxGroupErrorReasonNotWellFormed is txn.WellFormed failure or malformed logic signature TxGroupErrorReasonNotWellFormed // TxGroupErrorReasonInvalidFee is invalid fee pooling in transaction group TxGroupErrorReasonInvalidFee // TxGroupErrorReasonHasNoSig is for transaction without any signature TxGroupErrorReasonHasNoSig // TxGroupErrorReasonSigNotWellFormed defines signature format errors TxGroupErrorReasonSigNotWellFormed // TxGroupErrorReasonMsigNotWellFormed defines multisig format errors TxGroupErrorReasonMsigNotWellFormed // TxGroupErrorReasonLogicSigFailed defines logic sig validation errors TxGroupErrorReasonLogicSigFailed // TxGroupErrorReasonNumValues is number of enum values TxGroupErrorReasonNumValues )
type TxnGroupBatchSigVerifier ¶
type TxnGroupBatchSigVerifier struct {
// contains filtered or unexported fields
}
TxnGroupBatchSigVerifier provides Verify method to synchronously verify a group of transactions It starts a new block listener to receive latests block headers for the sig verification
func MakeSigVerifier ¶
func MakeSigVerifier(ledger LedgerForStreamVerifier, cache VerifiedTransactionCache) (TxnGroupBatchSigVerifier, error)
MakeSigVerifier creats a new TxnGroupBatchSigVerifier for synchronous verification of transactions
func (*TxnGroupBatchSigVerifier) Verify ¶
func (sv *TxnGroupBatchSigVerifier) Verify(stxs []transactions.SignedTxn) error
Verify synchronously verifies the signatures of the transactions in the group
type UnverifiedTxnSigJob ¶
type UnverifiedTxnSigJob struct { TxnGroup []transactions.SignedTxn BacklogMessage interface{} }
UnverifiedTxnSigJob is the sig verification job passed to the Stream verifier It represents an unverified txn whose signatures will be verified BacklogMessage is a *txBacklogMsg from data/txHandler.go which needs to be passed back to that context Implements UnverifiedSigJob
func (UnverifiedTxnSigJob) GetNumberOfBatchableItems ¶
func (ue UnverifiedTxnSigJob) GetNumberOfBatchableItems() (batchSigs uint64, err error)
GetNumberOfBatchableItems returns the number of batchable signatures in the txn group
type VerificationResult ¶
type VerificationResult struct { TxnGroup []transactions.SignedTxn BacklogMessage interface{} Err error }
VerificationResult is the result of the txn group verification BacklogMessage is the reference associated with the txn group which was initially passed to the stream verifier
type VerifiedTransactionCache ¶
type VerifiedTransactionCache interface { // Add adds a given transaction group and its 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) // GetUnverifiedTransactionGroups compares the provided payset against the currently cached transactions and figure which transaction groups aren't fully cached. GetUnverifiedTransactionGroups(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 designed to 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 identify 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 access to the underlying error