gas

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: Apache-2.0, MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EnableGasTracing = os.Getenv("VENUS_VM_ENABLE_GAS_TRACING_VERY_SLOW") == "1"

EnableGasTracing, if true, outputs gas tracing in execution traces.

Functions

func ComputeGasOverestimationBurn

func ComputeGasOverestimationBurn(gasUsed, gasLimit int64) (int64, int64)

ComputeGasOverestimationBurn computes amount of gas to be refunded and amount of gas to be burned Result is (refund, burn)

Types

type GasCharge

type GasCharge struct {
	Name  string
	Extra interface{}

	ComputeGas int64
	StorageGas int64

	VirtualCompute int64
	VirtualStorage int64
}

GasCharge amount of gas consumed at one time

func NewGasCharge

func NewGasCharge(name string, computeGas int64, storageGas int64) GasCharge

func (GasCharge) Total

func (g GasCharge) Total() int64

Total return all gas in one time

func (GasCharge) WithExtra

func (g GasCharge) WithExtra(extra interface{}) GasCharge

func (GasCharge) WithVirtual

func (g GasCharge) WithVirtual(compute, storage int64) GasCharge

type GasOutputs

type GasOutputs struct {
	BaseFeeBurn        abi.TokenAmount
	OverEstimationBurn abi.TokenAmount

	MinerPenalty abi.TokenAmount
	MinerTip     abi.TokenAmount
	Refund       abi.TokenAmount

	GasRefund int64
	GasBurned int64
}

GasOutputs detail of gas after message executed

func ComputeGasOutputs

func ComputeGasOutputs(gasUsed, gasLimit int64, baseFee, feeCap, gasPremium abi.TokenAmount, chargeNetworkFee bool) GasOutputs

ComputeGasOutputs compute gas outputs base on message gas parameters and gasUsed after executed

func ZeroGasOutputs

func ZeroGasOutputs() GasOutputs

ZeroGasOutputs returns a logically zeroed GasOutputs.

type GasTracker

type GasTracker struct {
	GasAvailable int64
	GasUsed      int64

	ExecutionTrace    types.ExecutionTrace
	NumActorsCreated  uint64    //nolint
	AllowInternal     bool      //nolint
	CallerValidated   bool      //nolint
	LastGasChargeTime time.Time //nolint
	LastGasCharge     *types.GasTrace
}

GasTracker maintains the stateView of gas usage throughout the execution of a message.

func NewGasTracker

func NewGasTracker(limit int64) *GasTracker

NewGasTracker initializes a new empty gas tracker

func (*GasTracker) Charge

func (t *GasTracker) Charge(gas GasCharge, msg string, args ...interface{})

Charge will add the gas charge To the current Method gas context.

WARNING: this Method will panic if there is no sufficient gas left.

func (*GasTracker) TryCharge

func (t *GasTracker) TryCharge(gasCharge GasCharge) bool

TryCharge charges `amount` or `RemainingGas()“, whichever is smaller.

Returns `True` if the there was enough gas To pay for `amount`.

type Pricelist

type Pricelist interface {
	// OnChainMessage returns the gas used for storing a message of a given size in the chain.
	OnChainMessage(msgSize int) GasCharge
	// OnChainReturnValue returns the gas used for storing the response of a message in the chain.
	OnChainReturnValue(dataSize int) GasCharge

	// OnMethodInvocation returns the gas used when invoking a method.
	OnMethodInvocation(value abi.TokenAmount, methodNum abi.MethodNum) GasCharge

	// OnIpldGet returns the gas used for storing an object
	OnIpldGet() GasCharge
	// OnIpldPut returns the gas used for storing an object
	OnIpldPut(dataSize int) GasCharge

	// OnCreateActor returns the gas used for creating an actor
	OnCreateActor() GasCharge
	// OnDeleteActor returns the gas used for deleting an actor
	OnDeleteActor() GasCharge

	OnVerifySignature(sigType crypto.SigType, planTextSize int) (GasCharge, error)
	OnHashing(dataSize int) GasCharge
	OnComputeUnsealedSectorCid(proofType abi.RegisteredSealProof, pieces []abi.PieceInfo) GasCharge
	OnVerifySeal(info proof7.SealVerifyInfo) GasCharge
	OnVerifyAggregateSeals(aggregate proof7.AggregateSealVerifyProofAndInfos) GasCharge
	OnVerifyReplicaUpdate(update proof7.ReplicaUpdateInfo) GasCharge
	OnVerifyPost(info proof7.WindowPoStVerifyInfo) GasCharge
	OnVerifyConsensusFault() GasCharge
}

Pricelist provides prices for operations in the VM.

Note: this interface should be APPEND ONLY since last chain checkpoint

type PricesSchedule

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

PricesSchedule schedule gas prices for different network version

func NewPricesSchedule

func NewPricesSchedule(forkParams *config.ForkUpgradeConfig) *PricesSchedule

NewPricesSchedule new gasprice schedule from forkParams parameters

func (*PricesSchedule) PricelistByEpoch

func (schedule *PricesSchedule) PricelistByEpoch(epoch abi.ChainEpoch) Pricelist

PricelistByEpoch finds the latest prices for the given epoch

func (*PricesSchedule) SetPricelist added in v1.2.0

func (schedule *PricesSchedule) SetPricelist(newPrices map[abi.ChainEpoch]Pricelist)

SetPricelist set new prices, for test

Jump to

Keyboard shortcuts

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