eval

package
v0.0.0-...-5ac3edc Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: AGPL-3.0 Imports: 24 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotInCowCache = errors.New("can't find object in cow cache")

ErrNotInCowCache is returned when a lookup method requests a cached value, but it can't be found. the error is always being invoked by the roundCowBase object, but it would typically propage upstream through the roundCowState as a generic "missing object in cache".

View Source
var ErrRoundZero = errors.New("cannot start evaluator for round 0")

ErrRoundZero is self-explanatory

Functions

func Eval

Eval is the main evaluator entrypoint (in addition to StartEvaluator) used by Ledger.Validate() Ledger.AddBlock() Ledger.trackerEvalVerified()(accountUpdates.loadFromDisk())

Validate: Eval(ctx, l, blk, true, txcache, executionPool) AddBlock: Eval(context.Background(), l, blk, false, txcache, nil) tracker: Eval(context.Background(), l, blk, false, txcache, nil)

func MakeDebugBalances

func MakeDebugBalances(l LedgerForCowBase, round basics.Round, proto protocol.ConsensusVersion, prevTimestamp int64) apply.Balances

MakeDebugBalances creates a ledger suitable for dryrun and debugger

Types

type BlockEvaluator

type BlockEvaluator struct {
	Tracer logic.EvalTracer
	// contains filtered or unexported fields
}

BlockEvaluator represents an in-progress evaluation of a block against the ledger.

func StartEvaluator

StartEvaluator creates a BlockEvaluator, given a ledger and a block header of the block that the caller is planning to evaluate. If the length of the payset being evaluated is known in advance, a paysetHint >= 0 can be passed, avoiding unnecessary payset slice growth.

func (*BlockEvaluator) GenerateBlock

func (eval *BlockEvaluator) GenerateBlock(addrs []basics.Address) (*ledgercore.UnfinishedBlock, error)

GenerateBlock produces a complete block from the BlockEvaluator. This is used during proposal to get an actual block that will be proposed, after feeding in tentative transactions into this block evaluator.

After a call to GenerateBlock, the BlockEvaluator can still be used to accept transactions. However, to guard against reuse, subsequent calls to GenerateBlock on the same BlockEvaluator will fail.

func (*BlockEvaluator) PaySetSize

func (eval *BlockEvaluator) PaySetSize() int

PaySetSize returns the number of top-level transactions that have been added to the block evaluator so far.

func (*BlockEvaluator) ProcessBlockForIndexer

func (eval *BlockEvaluator) ProcessBlockForIndexer(block *bookkeeping.Block) (ledgercore.StateDelta, []transactions.SignedTxnInBlock, error)

ProcessBlockForIndexer ..

func (*BlockEvaluator) ResetTxnBytes

func (eval *BlockEvaluator) ResetTxnBytes()

ResetTxnBytes resets the number of bytes tracked by the BlockEvaluator to zero. This is a specialized operation used by the transaction pool to simulate the effect of putting pending transactions in multiple blocks.

func (*BlockEvaluator) Round

func (eval *BlockEvaluator) Round() basics.Round

Round returns the round number of the block being evaluated by the BlockEvaluator.

func (*BlockEvaluator) SetGenerateForTesting

func (eval *BlockEvaluator) SetGenerateForTesting(g bool)

SetGenerateForTesting is exported so that a ledger being used for testing can force a block evalator to create a block and compare it to another.

func (*BlockEvaluator) TestTransaction

func (eval *BlockEvaluator) TestTransaction(txn transactions.SignedTxn) error

TestTransaction performs basic duplicate detection and well-formedness checks on a single transaction, but does not actually add the transaction to the block evaluator, or modify the block evaluator state in any other visible way.

func (*BlockEvaluator) TestTransactionGroup

func (eval *BlockEvaluator) TestTransactionGroup(txgroup []transactions.SignedTxn) error

TestTransactionGroup performs basic duplicate detection and well-formedness checks on a transaction group, but does not actually add the transactions to the block evaluator, or modify the block evaluator state in any other visible way.

func (*BlockEvaluator) TestingTxnCounter

func (eval *BlockEvaluator) TestingTxnCounter() uint64

TestingTxnCounter - the method returns the current evaluator transaction counter. The method is used for testing purposes only.

func (*BlockEvaluator) Transaction

func (eval *BlockEvaluator) Transaction(txn transactions.SignedTxn, ad transactions.ApplyData) error

Transaction tentatively adds a new transaction as part of this block evaluation. If the transaction cannot be added to the block without violating some constraints, an error is returned and the block evaluator state is unchanged.

func (*BlockEvaluator) TransactionGroup

func (eval *BlockEvaluator) TransactionGroup(txgroup []transactions.SignedTxnWithAD) (err error)

TransactionGroup tentatively adds a new transaction group as part of this block evaluation. If the transaction group cannot be added to the block without violating some constraints, an error is returned and the block evaluator state is unchanged.

type EvaluatorOptions

type EvaluatorOptions struct {
	PaysetHint          int
	Validate            bool
	Generate            bool
	MaxTxnBytesPerBlock int
	ProtoParams         *config.ConsensusParams
	Tracer              logic.EvalTracer
}

EvaluatorOptions defines the evaluator creation options

type LedgerForCowBase

LedgerForCowBase represents subset of Ledger functionality needed for cow business

type LedgerForEvaluator

type LedgerForEvaluator interface {
	LedgerForCowBase
	GenesisHash() crypto.Digest
	GenesisProto() config.ConsensusParams
	LatestTotals() (basics.Round, ledgercore.AccountTotals, error)
	VotersForStateProof(basics.Round) (*ledgercore.VotersForRound, error)
	FlushCaches()
}

LedgerForEvaluator defines the ledger interface needed by the evaluator.

type StateDeltaSubset

type StateDeltaSubset struct {
	Accts      ledgercore.AccountDeltas
	KvMods     map[string]ledgercore.KvValueDelta
	Txids      map[transactions.Txid]ledgercore.IncludedTransactions
	Txleases   map[ledgercore.Txlease]basics.Round
	Creatables map[basics.CreatableIndex]ledgercore.ModifiedCreatable
	Hdr        *bookkeeping.BlockHeader
	// contains filtered or unexported fields
}

StateDeltaSubset exports a subset of ledgercore.StateDelta fields for a sparse encoding

type TxnGroupDeltaTracer

type TxnGroupDeltaTracer struct {

	// no-op methods we don't care about
	logic.NullEvalTracer
	// contains filtered or unexported fields
}

TxnGroupDeltaTracer collects groups of StateDelta objects covering groups of txns

func MakeTxnGroupDeltaTracer

func MakeTxnGroupDeltaTracer(lookback uint64) *TxnGroupDeltaTracer

MakeTxnGroupDeltaTracer creates a TxnGroupDeltaTracer

func (*TxnGroupDeltaTracer) AfterTxnGroup

func (tracer *TxnGroupDeltaTracer) AfterTxnGroup(ep *logic.EvalParams, deltas *ledgercore.StateDelta, evalError error)

AfterTxnGroup implements the EvalTracer interface for txn group boundaries

func (*TxnGroupDeltaTracer) BeforeBlock

func (tracer *TxnGroupDeltaTracer) BeforeBlock(hdr *bookkeeping.BlockHeader)

BeforeBlock implements the EvalTracer interface for pre-block evaluation

func (*TxnGroupDeltaTracer) GetDeltaForID

func (tracer *TxnGroupDeltaTracer) GetDeltaForID(id crypto.Digest) (StateDeltaSubset, error)

GetDeltaForID returns the StateDelta associated with the group of transaction executed for the supplied ID (txn or group)

func (*TxnGroupDeltaTracer) GetDeltasForRound

func (tracer *TxnGroupDeltaTracer) GetDeltasForRound(rnd basics.Round) ([]TxnGroupDeltaWithIds, error)

GetDeltasForRound supplies all StateDelta objects for txn groups in a given rnd

type TxnGroupDeltaWithIds

type TxnGroupDeltaWithIds struct {
	Ids   []string
	Delta StateDeltaSubset
	// contains filtered or unexported fields
}

TxnGroupDeltaWithIds associates all the Ids (group and Txn) with a single state delta object

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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