Documentation ¶
Index ¶
- Variables
- func AssertMsgResult(r Reporter, expected *schema.Receipt, actual *vm.Ret, label string)
- func BaseFeeOrDefault(basefee *gobig.Int) abi.TokenAmount
- func CircSupplyOrDefault(circSupply *gobig.Int) abi.TokenAmount
- func ExecuteMessageVector(r Reporter, v string, vector *schema.TestVector, variant *schema.Variant)
- func ExecuteTipsetVector(r Reporter, v string, vector *schema.TestVector, variant *schema.Variant)
- func LoadVectorCAR(vectorCAR schema.Base64EncodedBytes) (blockstoreutil.Blockstore, error)
- func NewFixedRand() vmcontext.HeadChainRandomness
- type Driver
- type DriverOpts
- type ExecuteMessageParams
- type ExecuteTipsetResult
- type LogReporter
- func (l *LogReporter) Errorf(format string, args ...interface{})
- func (*LogReporter) FailNow()
- func (l *LogReporter) Failed() bool
- func (l *LogReporter) Fatalf(format string, args ...interface{})
- func (*LogReporter) Helper()
- func (*LogReporter) Log(args ...interface{})
- func (*LogReporter) Logf(format string, args ...interface{})
- type RecordingRand
- func (r *RecordingRand) GetBeaconEntry(ctx context.Context, round abi.ChainEpoch) (*types.BeaconEntry, error)
- func (r *RecordingRand) GetBeaconRandomness(ctx context.Context, round abi.ChainEpoch) ([32]byte, error)
- func (r *RecordingRand) GetChainRandomness(ctx context.Context, round abi.ChainEpoch) ([32]byte, error)
- func (r *RecordingRand) Recorded() schema.Randomness
- type ReplayingRand
- func (r *ReplayingRand) GetBeaconEntry(ctx context.Context, round abi.ChainEpoch) (*types.BeaconEntry, error)
- func (r *ReplayingRand) GetBeaconRandomness(ctx context.Context, round abi.ChainEpoch) ([32]byte, error)
- func (r *ReplayingRand) GetChainRandomness(ctx context.Context, round abi.ChainEpoch) ([32]byte, error)
- type Reporter
Constants ¶
This section is empty.
Variables ¶
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) )
Functions ¶
func AssertMsgResult ¶
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 ¶
ExecuteMessageVector executes a message-class test vector.
func ExecuteTipsetVector ¶
ExecuteTipsetVector executes a tipset-class test vector.
func LoadVectorCAR ¶
func LoadVectorCAR(vectorCAR schema.Base64EncodedBytes) (blockstoreutil.Blockstore, error)
func NewFixedRand ¶
func NewFixedRand() vmcontext.HeadChainRandomness
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 (*Driver) ExecuteMessage ¶
func (d *Driver) ExecuteMessage(bs blockstoreutil.Blockstore, params ExecuteMessageParams) (*vm.Ret, cid.Cid, error)
ExecuteMessage executes a conformance test vector message in a temporary LegacyVM.
func (*Driver) ExecuteTipset ¶
func (d *Driver) ExecuteTipset(bs blockstoreutil.Blockstore, chainDs ds.Batching, preroot cid.Cid, parentEpoch abi.ChainEpoch, tipset *schema.Tipset, execEpoch abi.ChainEpoch) (*ExecuteTipsetResult, error)
ExecuteTipset executes the supplied tipset on top of the state represented by the preroot 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.
This method returns the receipts root, the poststate root, and the LegacyVM 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 LegacyVM.Flush(), forces a blockstore // recursive copy, from the temporary buffer blockstore, to the real // system's blockstore. Disabling LegacyVM 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 LegacyVM 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 Timestamp uint64 Message *types.Message CircSupply abi.TokenAmount BaseFee abi.TokenAmount NetworkVersion network.Version Rand vmcontext.HeadChainRandomness // 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 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.Ret }
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 v1api.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) GetBeaconEntry ¶ added in v1.17.0
func (r *RecordingRand) GetBeaconEntry(ctx context.Context, round abi.ChainEpoch) (*types.BeaconEntry, error)
func (*RecordingRand) GetBeaconRandomness ¶ added in v1.14.0
func (r *RecordingRand) GetBeaconRandomness(ctx context.Context, round abi.ChainEpoch) ([32]byte, error)
func (*RecordingRand) GetChainRandomness ¶ added in v1.14.0
func (r *RecordingRand) GetChainRandomness(ctx context.Context, round abi.ChainEpoch) ([32]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) GetBeaconEntry ¶ added in v1.17.0
func (r *ReplayingRand) GetBeaconEntry(ctx context.Context, round abi.ChainEpoch) (*types.BeaconEntry, error)
func (*ReplayingRand) GetBeaconRandomness ¶ added in v1.14.0
func (r *ReplayingRand) GetBeaconRandomness(ctx context.Context, round abi.ChainEpoch) ([32]byte, error)
func (*ReplayingRand) GetChainRandomness ¶ added in v1.14.0
func (r *ReplayingRand) GetChainRandomness(ctx context.Context, round abi.ChainEpoch) ([32]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.