conformance

package
v1.15.1-rc6 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: Apache-2.0, MIT Imports: 44 Imported by: 2

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 added in v0.8.1

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 added in v0.9.0

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 added in v0.9.0

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 added in v0.8.1

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

ExecuteMessageVector executes a message-class test vector.

func ExecuteTipsetVector added in v0.8.1

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

ExecuteTipsetVector executes a tipset-class test vector.

func LoadBlockstore added in v1.2.3

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

func NewFixedRand added in v0.9.0

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 added in v0.5.8

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 added in v0.8.1

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 added in v0.8.1

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
}

type ExecuteTipsetParams added in v1.2.3

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 added in v0.5.8

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 added in v1.14.0

type GasPricingRestoreFn func()

type LogReporter added in v0.8.1

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 added in v0.8.1

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

func (*LogReporter) FailNow added in v0.8.1

func (*LogReporter) FailNow()

func (*LogReporter) Failed added in v0.8.1

func (l *LogReporter) Failed() bool

func (*LogReporter) Fatalf added in v0.8.1

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

func (*LogReporter) Helper added in v0.8.1

func (*LogReporter) Helper()

func (*LogReporter) Log added in v0.8.1

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

func (*LogReporter) Logf added in v0.8.1

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

type RecordingRand added in v0.9.1

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

func NewRecordingRand added in v0.9.1

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 added in v0.9.1

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

func (*RecordingRand) GetChainRandomness added in v0.9.1

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

func (*RecordingRand) Recorded added in v0.9.1

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

type ReplayingRand added in v0.9.1

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

func NewReplayingRand added in v0.9.1

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 added in v0.9.1

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

func (*ReplayingRand) GetChainRandomness added in v0.9.1

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

type Reporter added in v0.8.1

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