chaos

package
v1.21.0-rpc-mirror-p01 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	MethodCallerValidation = builtin.MethodConstructor + iota
	MethodCreateActor
	MethodResolveAddress
	// MethodDeleteActor is the identifier for the method that deletes this actor.
	MethodDeleteActor
	// MethodSend is the identifier for the method that sends a message to another actor.
	MethodSend
	// MethodMutateState is the identifier for the method that attempts to mutate
	// a state value in the actor.
	MethodMutateState
	// MethodAbortWith is the identifier for the method that panics optionally with
	// a passed exit code.
	MethodAbortWith
	// MethodInspectRuntime is the identifier for the method that returns the
	// current runtime values.
	MethodInspectRuntime
	// MethodCreateState is the identifier for the method that creates the chaos actor's state.
	MethodCreateState
)

Variables

View Source
var Address = func() address.Address {

	addr, err := address.NewIDAddress(98)
	if err != nil {
		panic(err)
	}
	return addr
}()

Address is the singleton address of this actor. Its value is 98 (builtin.FirstNonSingletonActorId - 2), as 99 is reserved for the burnt funds singleton.

View Source
var ChaosActorCodeCID = func() cid.Cid {
	builder := cid.V1Builder{Codec: cid.Raw, MhType: multihash.IDENTITY}
	c, err := builder.Sum([]byte("fil/1/chaos"))
	if err != nil {
		panic(err)
	}
	return c
}()

ChaosActorCodeCID is the CID by which this kind of actor will be identified.

Functions

This section is empty.

Types

type AbortWithArgs added in v0.7.0

type AbortWithArgs struct {
	Code         exitcode.ExitCode
	Message      string
	Uncontrolled bool
}

AbortWithArgs are the arguments to the Actor.AbortWith method, specifying the exit code to (optionally) abort with and the message.

func (*AbortWithArgs) MarshalCBOR added in v0.7.0

func (t *AbortWithArgs) MarshalCBOR(w io.Writer) error

func (*AbortWithArgs) UnmarshalCBOR added in v0.7.0

func (t *AbortWithArgs) UnmarshalCBOR(r io.Reader) (err error)

type Actor

type Actor struct{}

Actor is a chaos actor. It implements a variety of illegal behaviours that trigger violations of VM invariants. These behaviours are not found in production code, but are important to test that the VM constraints are properly enforced.

The chaos actor is being incubated and its behaviour and ABI be standardised shortly. Its CID is ChaosActorCodeCID, and its singleton address is 98 (Address). It cannot be instantiated via the init actor, and its constructor panics.

Test vectors relying on the chaos actor being deployed will carry selector "chaos_actor:true".

func (Actor) AbortWith added in v0.7.0

func (a Actor) AbortWith(rt runtime2.Runtime, args *AbortWithArgs) *abi.EmptyValue

AbortWith simply causes a panic with the passed exit code.

func (Actor) CallerValidation

func (a Actor) CallerValidation(rt runtime2.Runtime, args *CallerValidationArgs) *abi.EmptyValue

CallerValidation violates VM call validation constraints.

CallerValidationBranchNone performs no validation.
CallerValidationBranchTwice validates twice.
CallerValidationBranchIsAddress validates caller against CallerValidationArgs.Addrs.
CallerValidationBranchIsType validates caller against CallerValidationArgs.Types.

func (Actor) Code added in v0.9.0

func (a Actor) Code() cid.Cid

func (Actor) Constructor

func (a Actor) Constructor(_ runtime2.Runtime, _ *abi.EmptyValue) *abi.EmptyValue

Constructor will panic because the Chaos actor is a singleton.

func (Actor) CreateActor

func (a Actor) CreateActor(rt runtime2.Runtime, args *CreateActorArgs) *abi.EmptyValue

CreateActor creates an actor with the supplied CID and Address.

func (Actor) CreateState added in v1.2.0

func (a Actor) CreateState(rt runtime2.Runtime, _ *abi.EmptyValue) *abi.EmptyValue

CreateState creates the chaos actor's state

func (Actor) DeleteActor

func (a Actor) DeleteActor(rt runtime2.Runtime, beneficiary *address.Address) *abi.EmptyValue

DeleteActor deletes the executing actor from the state tree, transferring any balance to beneficiary.

func (Actor) Exports

func (a Actor) Exports() []interface{}

Exports defines the methods this actor exposes publicly.

func (Actor) InspectRuntime added in v0.7.1

func (a Actor) InspectRuntime(rt runtime2.Runtime, _ *abi.EmptyValue) *InspectRuntimeReturn

InspectRuntime returns a copy of the serializable values available in the Runtime.

func (Actor) IsSingleton added in v0.9.0

func (a Actor) IsSingleton() bool

func (Actor) MutateState

func (a Actor) MutateState(rt runtime2.Runtime, args *MutateStateArgs) *abi.EmptyValue

MutateState attempts to mutate a state value in the actor.

func (Actor) ResolveAddress

func (a Actor) ResolveAddress(rt runtime2.Runtime, args *address.Address) *ResolveAddressResponse

func (Actor) Send

func (a Actor) Send(rt runtime2.Runtime, args *SendArgs) *SendReturn

Send requests for this actor to send a message to an actor with the passed parameters.

func (Actor) State added in v0.9.0

func (a Actor) State() cbor.Er

type CallerValidationArgs added in v0.7.2

type CallerValidationArgs struct {
	Branch CallerValidationBranch
	Addrs  []address.Address
	Types  []cid.Cid
}

CallerValidationArgs are the arguments to Actor.CallerValidation.

func (*CallerValidationArgs) MarshalCBOR added in v0.7.2

func (t *CallerValidationArgs) MarshalCBOR(w io.Writer) error

func (*CallerValidationArgs) UnmarshalCBOR added in v0.7.2

func (t *CallerValidationArgs) UnmarshalCBOR(r io.Reader) (err error)

type CallerValidationBranch

type CallerValidationBranch int64

CallerValidationBranch is an enum used to select a branch in the CallerValidation method.

const (
	// CallerValidationBranchNone causes no caller validation to take place.
	CallerValidationBranchNone CallerValidationBranch = iota
	// CallerValidationBranchTwice causes Runtime.ValidateImmediateCallerAcceptAny to be called twice.
	CallerValidationBranchTwice
	// CallerValidationBranchIsAddress causes caller validation against CallerValidationArgs.Addrs.
	CallerValidationBranchIsAddress
	// CallerValidationBranchIsType causes caller validation against CallerValidationArgs.Types.
	CallerValidationBranchIsType
)

type CreateActorArgs

type CreateActorArgs struct {
	// UndefActorCID instructs us to use cid.Undef; we can't pass cid.Undef
	// in ActorCID because it doesn't serialize.
	UndefActorCID bool
	ActorCID      cid.Cid

	// UndefAddress is the same as UndefActorCID but for Address.
	UndefAddress bool
	Address      address.Address
}

CreateActorArgs are the arguments to CreateActor.

func (*CreateActorArgs) MarshalCBOR

func (t *CreateActorArgs) MarshalCBOR(w io.Writer) error

func (*CreateActorArgs) UnmarshalCBOR

func (t *CreateActorArgs) UnmarshalCBOR(r io.Reader) (err error)

type InspectRuntimeReturn added in v0.7.1

type InspectRuntimeReturn struct {
	Caller         address.Address
	Receiver       address.Address
	ValueReceived  abi.TokenAmount
	CurrEpoch      abi.ChainEpoch
	CurrentBalance abi.TokenAmount
	State          State
}

InspectRuntimeReturn is the return value for the Actor.InspectRuntime method.

func (*InspectRuntimeReturn) MarshalCBOR added in v0.7.1

func (t *InspectRuntimeReturn) MarshalCBOR(w io.Writer) error

func (*InspectRuntimeReturn) UnmarshalCBOR added in v0.7.1

func (t *InspectRuntimeReturn) UnmarshalCBOR(r io.Reader) (err error)

type MutateStateArgs

type MutateStateArgs struct {
	Value  string
	Branch MutateStateBranch
}

MutateStateArgs specify the value to set on the state and the way in which it should be attempted to be set.

func (*MutateStateArgs) MarshalCBOR

func (t *MutateStateArgs) MarshalCBOR(w io.Writer) error

func (*MutateStateArgs) UnmarshalCBOR

func (t *MutateStateArgs) UnmarshalCBOR(r io.Reader) (err error)

type MutateStateBranch

type MutateStateBranch int64

MutateStateBranch is an enum used to select the type of state mutation to attempt.

const (
	// MutateInTransaction legally mutates state within a transaction.
	MutateInTransaction MutateStateBranch = iota
	// MutateReadonly ILLEGALLY mutates readonly state.
	MutateReadonly
	// MutateAfterTransaction ILLEGALLY mutates state after a transaction.
	MutateAfterTransaction
)

type ResolveAddressResponse

type ResolveAddressResponse struct {
	Address address.Address
	Success bool
}

ResolveAddressResponse holds the response of a call to runtime.ResolveAddress

func (*ResolveAddressResponse) MarshalCBOR

func (t *ResolveAddressResponse) MarshalCBOR(w io.Writer) error

func (*ResolveAddressResponse) UnmarshalCBOR

func (t *ResolveAddressResponse) UnmarshalCBOR(r io.Reader) (err error)

type SendArgs

type SendArgs struct {
	To     address.Address
	Value  abi.TokenAmount
	Method abi.MethodNum
	Params []byte
}

SendArgs are the arguments for the Send method.

func (*SendArgs) MarshalCBOR

func (t *SendArgs) MarshalCBOR(w io.Writer) error

func (*SendArgs) UnmarshalCBOR

func (t *SendArgs) UnmarshalCBOR(r io.Reader) (err error)

type SendReturn

type SendReturn struct {
	Return builtin2.CBORBytes
	Code   exitcode.ExitCode
}

SendReturn is the return values for the Send method.

func (*SendReturn) MarshalCBOR

func (t *SendReturn) MarshalCBOR(w io.Writer) error

func (*SendReturn) UnmarshalCBOR

func (t *SendReturn) UnmarshalCBOR(r io.Reader) (err error)

type State

type State struct {
	// Value can be updated by chaos actor methods to test illegal state
	// mutations when the state is in readonly mode for example.
	Value string
	// Unmarshallable is a sentinel value. If the slice contains no values, the
	// State struct will encode as CBOR without issue. If the slice is non-nil,
	// CBOR encoding will fail.
	Unmarshallable []*UnmarshallableCBOR
}

State is the state for the chaos actor used by some methods to invoke behaviours in the vm or runtime.

func (*State) MarshalCBOR

func (t *State) MarshalCBOR(w io.Writer) error

func (*State) UnmarshalCBOR

func (t *State) UnmarshalCBOR(r io.Reader) (err error)

type UnmarshallableCBOR

type UnmarshallableCBOR struct{}

UnmarshallableCBOR is a type that cannot be marshalled or unmarshalled to CBOR despite implementing the CBORMarshaler and CBORUnmarshaler interface.

func (*UnmarshallableCBOR) MarshalCBOR

func (t *UnmarshallableCBOR) MarshalCBOR(io.Writer) error

MarshalCBOR will fail to marshal the value to CBOR.

func (*UnmarshallableCBOR) UnmarshalCBOR

func (t *UnmarshallableCBOR) UnmarshalCBOR(io.Reader) error

UnmarshalCBOR will fail to unmarshal the value from CBOR.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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