conformance

package
v0.0.0-...-484cccf Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: Apache-2.0, MIT Imports: 50 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultCirculatingSupply is the fallback circulating supply returned by
	// the driver's CircSupplyCalculator function, used if the vector specifies
	// no circulating supply.
	DefaultCirculatingSupply = types.TotalFilecoinInt

	// DefaultBaseFee to use in the VM, if one is not supplied in the vector.
	DefaultBaseFee = abi.NewTokenAmount(100)
)
View Source
var FallbackBlockstoreGetter interface {
	ChainReadObj(context.Context, cid.Cid) ([]byte, error)
}

FallbackBlockstoreGetter is a fallback blockstore to use for resolving CIDs unknown to the test vector. This is rarely used, usually only needed when transplanting vectors across versions. This is an interface tighter than ChainModuleAPI. It can be backed by a FullAPI client.

View Source
var TipsetVectorOpts struct {
	// PipelineBaseFee pipelines the basefee in multi-tipset vectors from one
	// tipset to another. Basefees in the vector are ignored, except for that of
	// the first tipset. UNUSED.
	PipelineBaseFee bool

	// OnTipsetApplied contains callback functions called after a tipset has been
	// applied.
	OnTipsetApplied []func(bs blockstore.Blockstore, params *ExecuteTipsetParams, res *ExecuteTipsetResult)
}

Functions

func AssertMsgResult

func AssertMsgResult(r Reporter, expected *schema.Receipt, actual *vm.ApplyRet, label string)

AssertMsgResult compares a message result. It takes the expected receipt encoded in the vector, the actual receipt returned by Lotus, and a message label to log in the assertion failure message to facilitate debugging.

func BaseFeeOrDefault

func BaseFeeOrDefault(basefee *gobig.Int) abi.TokenAmount

BaseFeeOrDefault converts a basefee as passed in a test vector (go *big.Int type) to an abi.TokenAmount, or if nil it returns the DefaultBaseFee.

func CircSupplyOrDefault

func CircSupplyOrDefault(circSupply *gobig.Int) abi.TokenAmount

CircSupplyOrDefault converts a circulating supply as passed in a test vector (go *big.Int type) to an abi.TokenAmount, or if nil it returns the DefaultCirculatingSupply.

func ExecuteMessageVector

func ExecuteMessageVector(r Reporter, vector *schema.TestVector, variant *schema.Variant) (diffs []string, err error)

ExecuteMessageVector executes a message-class test vector.

func ExecuteTipsetVector

func ExecuteTipsetVector(r Reporter, vector *schema.TestVector, variant *schema.Variant) (diffs []string, err error)

ExecuteTipsetVector executes a tipset-class test vector.

func LoadBlockstore

func LoadBlockstore(vectorCAR schema.Base64EncodedBytes) (blockstore.Blockstore, error)

func NewFixedRand

func NewFixedRand() vm.Rand

NewFixedRand creates a test vm.Rand that always returns fixed bytes value of utf-8 string 'i_am_random_____i_am_random_____'.

Types

type Driver

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

func NewDriver

func NewDriver(ctx context.Context, selector schema.Selector, opts DriverOpts) *Driver

func (*Driver) ExecuteMessage

func (d *Driver) ExecuteMessage(bs blockstore.Blockstore, params ExecuteMessageParams) (*vm.ApplyRet, cid.Cid, error)

ExecuteMessage executes a conformance test vector message in a temporary VM.

func (*Driver) ExecuteTipset

func (d *Driver) ExecuteTipset(bs blockstore.Blockstore, ds ds.Batching, params ExecuteTipsetParams) (*ExecuteTipsetResult, error)

ExecuteTipset executes the supplied tipset on top of the state represented by the preroot CID.

This method returns the the receipts root, the poststate root, and the VM message results. The latter _include_ implicit messages, such as cron ticks and reward withdrawal per miner.

type DriverOpts

type DriverOpts struct {
	// DisableVMFlush, when true, avoids calling VM.Flush(), forces a blockstore
	// recursive copy, from the temporary buffer blockstore, to the real
	// system's blockstore. Disabling VM flushing is useful when extracting test
	// vectors and trimming state, as we don't want to force an accidental
	// deep copy of the state tree.
	//
	// Disabling VM flushing almost always should go hand-in-hand with
	// LOTUS_DISABLE_VM_BUF=iknowitsabadidea. That way, state tree writes are
	// immediately committed to the blockstore.
	DisableVMFlush bool
}

type ExecuteMessageParams

type ExecuteMessageParams struct {
	Preroot        cid.Cid
	Epoch          abi.ChainEpoch
	Message        *types.Message
	CircSupply     abi.TokenAmount
	BaseFee        abi.TokenAmount
	NetworkVersion network.Version

	// Rand is an optional vm.Rand implementation to use. If nil, the driver
	// will use a vm.Rand that returns a fixed value for all calls.
	Rand vm.Rand

	// Lookback is the LookbackStateGetter; returns the state tree at a given epoch.
	Lookback vm.LookbackStateGetter

	// TipSetGetter returns the tipset key at any given epoch.
	TipSetGetter vm.TipSetGetter
}

type ExecuteTipsetParams

type ExecuteTipsetParams struct {
	Preroot cid.Cid
	// ParentEpoch is the last epoch in which an actual tipset was processed. This
	// is used by Lotus for null block counting and cron firing.
	ParentEpoch abi.ChainEpoch
	Tipset      *schema.Tipset
	ExecEpoch   abi.ChainEpoch
	// Rand is an optional vm.Rand implementation to use. If nil, the driver
	// will use a vm.Rand that returns a fixed value for all calls.
	Rand vm.Rand
	// BaseFee if not nil or zero, will override the basefee of the tipset.
	BaseFee abi.TokenAmount
}

type ExecuteTipsetResult

type ExecuteTipsetResult struct {
	ReceiptsRoot  cid.Cid
	PostStateRoot cid.Cid

	// AppliedMessages stores the messages that were applied, in the order they
	// were applied. It includes implicit messages (cron, rewards).
	AppliedMessages []*types.Message
	// AppliedResults stores the results of AppliedMessages, in the same order.
	AppliedResults []*vm.ApplyRet

	// PostBaseFee returns the basefee after applying this tipset.
	PostBaseFee abi.TokenAmount
}

type GasPricingRestoreFn

type GasPricingRestoreFn func()

type LogReporter

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

LogReporter wires the Reporter methods to the log package. It is appropriate to use when calling the Execute* functions from a standalone CLI program.

func (*LogReporter) Errorf

func (l *LogReporter) Errorf(format string, args ...interface{})

func (*LogReporter) FailNow

func (*LogReporter) FailNow()

func (*LogReporter) Failed

func (l *LogReporter) Failed() bool

func (*LogReporter) Fatalf

func (l *LogReporter) Fatalf(format string, args ...interface{})

func (*LogReporter) Helper

func (*LogReporter) Helper()

func (*LogReporter) Log

func (*LogReporter) Log(args ...interface{})

func (*LogReporter) Logf

func (*LogReporter) Logf(format string, args ...interface{})

type RecordingRand

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

func NewRecordingRand

func NewRecordingRand(reporter Reporter, api v0api.FullNode) *RecordingRand

NewRecordingRand returns a vm.Rand implementation that proxies calls to a full Lotus node via JSON-RPC, and records matching rules and responses so they can later be embedded in test vectors.

func (*RecordingRand) GetBeaconRandomness

func (r *RecordingRand) GetBeaconRandomness(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error)

func (*RecordingRand) GetChainRandomness

func (r *RecordingRand) GetChainRandomness(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error)

func (*RecordingRand) Recorded

func (r *RecordingRand) Recorded() schema.Randomness

type ReplayingRand

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

func NewReplayingRand

func NewReplayingRand(reporter Reporter, recorded schema.Randomness) *ReplayingRand

NewReplayingRand replays recorded randomness when requested, falling back to fixed randomness if the value cannot be found; hence this is a safe backwards-compatible replacement for fixedRand.

func (*ReplayingRand) GetBeaconRandomness

func (r *ReplayingRand) GetBeaconRandomness(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error)

func (*ReplayingRand) GetChainRandomness

func (r *ReplayingRand) GetChainRandomness(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error)

type Reporter

type Reporter interface {
	Helper()

	Log(args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
	Logf(format string, args ...interface{})
	FailNow()
	Failed() bool
}

Reporter is a contains a subset of the testing.T methods, so that the Execute* functions in this package can be used inside or outside of go test runs.

Directories

Path Synopsis
gen

Jump to

Keyboard shortcuts

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