agent

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2020 License: Apache-2.0, MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputePowerTable

func ComputePowerTable(v *vm.VM, agents []Agent) (powerTable, error)

Types

type Agent

type Agent interface {
	Tick(v SimState) ([]message, error)
}

type MinerAgent

type MinerAgent struct {
	Config        MinerAgentConfig // parameters used to define miner prior to creation
	Owner         address.Address
	Worker        address.Address
	IDAddress     address.Address
	RobustAddress address.Address
	// contains filtered or unexported fields
}

func NewMinerAgent

func NewMinerAgent(owner address.Address, worker address.Address, idAddress address.Address, robustAddress address.Address,
	rndSeed int64, config MinerAgentConfig,
) *MinerAgent

func (*MinerAgent) Tick

func (ma *MinerAgent) Tick(v SimState) ([]message, error)

type MinerAgentConfig

type MinerAgentConfig struct {
	PrecommitRate   float64                 // average number of precommits per epoch
	ProofType       abi.RegisteredSealProof // seal proof type for this miner
	StartingBalance abi.TokenAmount         // initial actor balance for miner actor
}

type MinerGenerator

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

func NewMinerGenerator

func NewMinerGenerator(accounts []address.Address, config MinerAgentConfig, createMinerProbability float32, rndSeed int64) *MinerGenerator

func (*MinerGenerator) Tick

func (mg *MinerGenerator) Tick(v SimState) ([]message, error)

type Sim

type Sim struct {
	Config SimConfig
	Agents []Agent
	// contains filtered or unexported fields
}

Sim is a simulation framework to exercise actor code in a network-like environment. It's goal is to simulate realistic call sequences and interactions to perform invariant analysis and test performance assumptions prior to shipping actor code out to implementations. The model is that the simulation will "Tick" once per epoch. Within this tick: * It will first compute winning tickets from previous state for miners to simulate block mining. * It will create any agents it is configured to create and generate messages to create their associated actors. * It will call tick on all it agents. This call will return messages that will get added to the simulated "tipset". * Messages will be shuffled to simulate network entropy. * Messages will be applied and an new VM will be created from the resulting state tree for the next tick.

func NewSim

func NewSim(ctx context.Context, t testing.TB, store adt.Store, config SimConfig) *Sim

func (*Sim) AddAgent

func (s *Sim) AddAgent(a Agent)

func (*Sim) GetCallStats

func (s *Sim) GetCallStats() map[vm.MethodKey]*vm.CallStats

func (*Sim) GetEpoch

func (s *Sim) GetEpoch() abi.ChainEpoch

func (*Sim) GetState

func (s *Sim) GetState(addr address.Address, out cbor.Unmarshaler) error

func (*Sim) GetVM

func (s *Sim) GetVM() *vm.VM

func (*Sim) Rnd

func (s *Sim) Rnd() int64

func (*Sim) Store

func (s *Sim) Store() adt.Store

func (*Sim) Tick

func (s *Sim) Tick() error

func (*Sim) WinCount

func (s *Sim) WinCount(minerPower abi.StoragePower, totalPower abi.StoragePower) uint64

This is the Filecoin algorithm for winning a ticket within a block with the tickets replaced with random numbers. It lets miners win according to a Poisson distribution with rate proportional to the miner's fraction of network power.

type SimConfig

type SimConfig struct {
	AccountCount           int
	AccountInitialBalance  abi.TokenAmount
	Seed                   int64
	CreateMinerProbability float32
}

type SimState

type SimState interface {
	GetEpoch() abi.ChainEpoch
	GetState(addr address.Address, out cbor.Unmarshaler) error
	Store() adt.Store
	AddAgent(a Agent)
	Rnd() int64
}

Jump to

Keyboard shortcuts

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