Documentation
¶
Index ¶
- Variables
- func Eval(ctx context.Context, l LedgerForEvaluator, blk bookkeeping.Block, ...) (ledgercore.StateDelta, error)
- func MakeDebugBalances(l LedgerForCowBase, round basics.Round, proto protocol.ConsensusVersion, ...) apply.Balances
- type BlockEvaluator
- func (eval *BlockEvaluator) GenerateBlock(participating []basics.Address) (*ledgercore.UnfinishedBlock, error)
- func (eval *BlockEvaluator) PaySetSize() int
- func (eval *BlockEvaluator) ProcessBlockForIndexer(block *bookkeeping.Block) (ledgercore.StateDelta, []transactions.SignedTxnInBlock, error)
- func (eval *BlockEvaluator) ResetTxnBytes()
- func (eval *BlockEvaluator) Round() basics.Round
- func (eval *BlockEvaluator) SetGenerateForTesting(g bool)
- func (eval *BlockEvaluator) TestTransaction(txn transactions.SignedTxn) error
- func (eval *BlockEvaluator) TestTransactionGroup(txgroup []transactions.SignedTxn) error
- func (eval *BlockEvaluator) TestingTxnCounter() uint64
- func (eval *BlockEvaluator) Transaction(txn transactions.SignedTxn, ad transactions.ApplyData) error
- func (eval *BlockEvaluator) TransactionGroup(txgroup []transactions.SignedTxnWithAD) (err error)
- type EvaluatorOptions
- type LedgerForCowBase
- type LedgerForEvaluator
- type StateDeltaSubset
- type TxnGroupDeltaTracer
- func (tracer *TxnGroupDeltaTracer) AfterTxnGroup(ep *logic.EvalParams, deltas *ledgercore.StateDelta, evalError error)
- func (tracer *TxnGroupDeltaTracer) BeforeBlock(hdr *bookkeeping.BlockHeader)
- func (tracer *TxnGroupDeltaTracer) GetDeltaForID(id crypto.Digest) (StateDeltaSubset, error)
- func (tracer *TxnGroupDeltaTracer) GetDeltasForRound(rnd basics.Round) ([]TxnGroupDeltaWithIds, error)
- type TxnGroupDeltaWithIds
Constants ¶
This section is empty.
Variables ¶
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".
var ErrRoundZero = errors.New("cannot start evaluator for round 0")
ErrRoundZero is self-explanatory
Functions ¶
func Eval ¶
func Eval(ctx context.Context, l LedgerForEvaluator, blk bookkeeping.Block, validate bool, txcache verify.VerifiedTransactionCache, executionPool execpool.BacklogPool, tracer logic.EvalTracer) (ledgercore.StateDelta, error)
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 ¶
func StartEvaluator(l LedgerForEvaluator, hdr bookkeeping.BlockHeader, evalOpts EvaluatorOptions) (*BlockEvaluator, error)
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(participating []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.
A list of participating addresses is passed to GenerateBlock. This lets the BlockEvaluator know which of this node's participating addresses might be proposing this block. This information is used when:
- generating lists of absent accounts (don't suspend yourself)
- preparing a ledgercore.UnfinishedBlock, which contains the end-of-block state of each potential proposer. This allows for a final check in UnfinishedBlock.FinishBlock to ensure the proposer hasn't closed its account before setting the ProposerPayout header.
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 ¶
type LedgerForCowBase interface { BlockHdr(basics.Round) (bookkeeping.BlockHeader, error) GenesisHash() crypto.Digest CheckDup(config.ConsensusParams, basics.Round, basics.Round, basics.Round, transactions.Txid, ledgercore.Txlease) error LookupWithoutRewards(basics.Round, basics.Address) (ledgercore.AccountData, basics.Round, error) LookupAgreement(basics.Round, basics.Address) (basics.OnlineAccountData, error) GetKnockOfflineCandidates(basics.Round, config.ConsensusParams) (map[basics.Address]basics.OnlineAccountData, error) LookupAsset(basics.Round, basics.Address, basics.AssetIndex) (ledgercore.AssetResource, error) LookupApplication(basics.Round, basics.Address, basics.AppIndex) (ledgercore.AppResource, error) LookupKv(basics.Round, string) ([]byte, error) GetCreatorForRound(basics.Round, basics.CreatableIndex, basics.CreatableType) (basics.Address, bool, error) GetStateProofVerificationContext(stateProofLastAttestedRound basics.Round) (*ledgercore.StateProofVerificationContext, error) OnlineCirculation(basics.Round, basics.Round) (basics.MicroAlgos, error) }
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