apply

package
v0.0.0-...-d52e3dd Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStateProofTypeNotSupported       = errors.New("state proof type not supported")
	ErrExpectedDifferentStateProofRound = errors.New("expected different state proof round")
)

Errors for apply stateproof

Functions

func ApplicationCall

func ApplicationCall(ac transactions.ApplicationCallTxnFields, header transactions.Header, balances Balances, ad *transactions.ApplyData, gi int, evalParams *logic.EvalParams, txnCounter uint64) (err error)

ApplicationCall evaluates ApplicationCall transaction

func AssetConfig

AssetConfig applies an AssetConfig transaction using the Balances interface.

func AssetFreeze

AssetFreeze applies an AssetFreeze transaction using the Balances interface.

func AssetTransfer

AssetTransfer applies an AssetTransfer transaction using the Balances interface.

func FindChallenge

func FindChallenge(rules config.ProposerPayoutRules, current basics.Round, headers hdrProvider, period ChallengePeriod) challenge

FindChallenge returns the Challenge that was last issued if it's in the period requested.

func Heartbeat

func Heartbeat(hb transactions.HeartbeatTxnFields, header transactions.Header, balances Balances, provider hdrProvider, round basics.Round) error

Heartbeat applies a Heartbeat transaction using the Balances interface.

func Keyreg

Keyreg applies a KeyRegistration transaction using the Balances interface.

func Payment

Payment changes the balances according to this transaction. The ApplyData argument should reflect the changes made by apply(). It may already include changes made by the caller (i.e., Transaction.Apply), so apply() must update it rather than overwriting it. For example, Transaction.Apply() may have updated ad.SenderRewards, and this function should only add to ad.SenderRewards (if needed), but not overwrite it.

func Rekey

func Rekey(balances Balances, tx *transactions.Transaction) error

Rekey updates tx.Sender's AuthAddr to tx.RekeyTo, if provided

func StateProof

func StateProof(tx transactions.StateProofTxnFields, atRound basics.Round, sp StateProofsApplier, validate bool) error

StateProof applies the StateProof transaction and setting the next StateProof round

Types

type Balances

type Balances interface {
	// Get looks up the account data for an address, ignoring application and asset data
	// If the account is known to be empty, then err should be nil and the returned balance record should have the given address and empty AccountData
	// withPendingRewards specifies whether pending rewards should be applied.
	// A non-nil error means the lookup is impossible (e.g., if the database doesn't have necessary state anymore)
	Get(addr basics.Address, withPendingRewards bool) (ledgercore.AccountData, error)

	Put(basics.Address, ledgercore.AccountData) error

	// CloseAccount is used by payment.go to delete an account, after ensuring no balance, asset or app state remains.
	CloseAccount(basics.Address) error

	GetAppParams(addr basics.Address, aidx basics.AppIndex) (basics.AppParams, bool, error)
	PutAppParams(addr basics.Address, aidx basics.AppIndex, params basics.AppParams) error
	DeleteAppParams(addr basics.Address, aidx basics.AppIndex) error

	GetAppLocalState(addr basics.Address, aidx basics.AppIndex) (basics.AppLocalState, bool, error)
	HasAppLocalState(addr basics.Address, aidx basics.AppIndex) (bool, error)
	PutAppLocalState(addr basics.Address, aidx basics.AppIndex, state basics.AppLocalState) error
	DeleteAppLocalState(addr basics.Address, aidx basics.AppIndex) error

	GetAssetHolding(addr basics.Address, aidx basics.AssetIndex) (basics.AssetHolding, bool, error)
	PutAssetHolding(addr basics.Address, aidx basics.AssetIndex, data basics.AssetHolding) error
	DeleteAssetHolding(addr basics.Address, aidx basics.AssetIndex) error

	GetAssetParams(addr basics.Address, aidx basics.AssetIndex) (basics.AssetParams, bool, error)
	HasAssetParams(addr basics.Address, aidx basics.AssetIndex) (bool, error)
	PutAssetParams(addr basics.Address, aidx basics.AssetIndex, data basics.AssetParams) error
	DeleteAssetParams(addr basics.Address, aidx basics.AssetIndex) error

	// GetCreator gets the address of the account that created a given creatable
	GetCreator(cidx basics.CreatableIndex, ctype basics.CreatableType) (basics.Address, bool, error)

	// Allocate or deallocate either global or address-local app storage.
	//
	// Put(...) and then {AllocateApp/DeallocateApp}(..., ..., global=true)
	// creates/destroys an application.
	//
	// Put(...) and then {AllocateApp/DeallocateApp}(..., ..., global=false)
	// opts into/closes out of an application.
	AllocateApp(addr basics.Address, aidx basics.AppIndex, global bool, space basics.StateSchema) error
	DeallocateApp(addr basics.Address, aidx basics.AppIndex, global bool) error

	// Similar to above, notify COW that global/local asset state was created.
	AllocateAsset(addr basics.Address, index basics.AssetIndex, global bool) error
	DeallocateAsset(addr basics.Address, index basics.AssetIndex, global bool) error

	// StatefulEval executes a TEAL program in stateful mode on the balances.
	// It returns whether the program passed and its error.  It also returns
	// an EvalDelta that contains the changes made by the program.
	StatefulEval(gi int, params *logic.EvalParams, aidx basics.AppIndex, program []byte) (passed bool, evalDelta transactions.EvalDelta, err error)

	// Move MicroAlgos from one account to another, doing all necessary overflow checking (convenience method)
	// TODO: Does this need to be part of the balances interface, or can it just be implemented here as a function that calls Put and Get?
	Move(src, dst basics.Address, amount basics.MicroAlgos, srcRewards *basics.MicroAlgos, dstRewards *basics.MicroAlgos) error

	// Balances correspond to a Round, which mean that they also correspond
	// to a ConsensusParams.  This returns those parameters.
	ConsensusParams() config.ConsensusParams
}

Balances allow to move MicroAlgos from one address to another and to update balance records, or to access and modify individual balance records After a call to Put (or Move), future calls to Get or Move will reflect the updated balance record(s)

type ChallengePeriod

type ChallengePeriod int

ChallengePeriod indicates which part of the challenge period is under discussion.

const (
	// ChRisky indicates that a challenge is in effect, and the initial grace period is running out.
	ChRisky ChallengePeriod = iota
	// ChActive indicates that a challenege is in effect, and the grace period
	// has run out, so accounts can be suspended
	ChActive
)

type StateProofsApplier

type StateProofsApplier interface {
	GetStateProofNextRound() basics.Round
	SetStateProofNextRound(rnd basics.Round)
	GetStateProofVerificationContext(stateProofLastAttestedRound basics.Round) (*ledgercore.StateProofVerificationContext, error)
	ConsensusParams() config.ConsensusParams
	// contains filtered or unexported methods
}

StateProofsApplier allows fetching and updating state-proofs state on the ledger

Jump to

Keyboard shortcuts

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