Documentation
¶
Index ¶
- func PopRandom(list []uint64, rnd *rand.Rand) (uint64, []uint64)
- func WinCount(minerPower abi.StoragePower, totalPower abi.StoragePower, random float64) uint64
- type Agent
- type MinerAgent
- type MinerAgentConfig
- type MinerGenerator
- type RateIterator
- type Sim
- func (s *Sim) AddAgent(a Agent)
- func (s *Sim) GetCallStats() map[vm.MethodKey]*vm.CallStats
- func (s *Sim) GetEpoch() abi.ChainEpoch
- func (s *Sim) GetState(addr address.Address, out cbor.Unmarshaler) error
- func (s *Sim) GetVM() *vm.VM
- func (s *Sim) Rnd() int64
- func (s *Sim) Store() adt.Store
- func (s *Sim) Tick() error
- type SimConfig
- type SimState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WinCount ¶
func WinCount(minerPower abi.StoragePower, totalPower abi.StoragePower, random float64) 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.
Types ¶
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(s 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 FaultRate float64 // rate at which committed sectors go faulty (faults per committed sector per epoch) RecoveryRate float64 // rate at which faults are recovered (recoveries per fault per epoch) }
type MinerGenerator ¶
type MinerGenerator struct {
// contains filtered or unexported fields
}
func NewMinerGenerator ¶
func NewMinerGenerator(accounts []address.Address, config MinerAgentConfig, createMinerRate float64, rndSeed int64) *MinerGenerator
func (*MinerGenerator) Tick ¶
func (mg *MinerGenerator) Tick(_ SimState) ([]message, error)
type RateIterator ¶
type RateIterator struct {
// contains filtered or unexported fields
}
RateIterator can be used to model poisson process (a process with discreet events occurring at arbitrary times with a specified average rate). It's Tick function must be called at regular intervals with a function that will be called zero or more times to produce the event distribution at the correct rate.
func NewRateIterator ¶
func NewRateIterator(rate float64, seed int64) *RateIterator
func (*RateIterator) Tick ¶
func (ri *RateIterator) Tick(f func() error) error
simulate random occurrences by calling the given function once for each event that would land in this epoch. The function will be called `rate` times on average, but may be called zero or many times in any Tick.
func (*RateIterator) TickWithRate ¶
func (ri *RateIterator) TickWithRate(rate float64, f func() error) error
TickWithRate permits a variable rate. If the rate has changed, it will compute a new next occurrence before running tick. This prevents having to wait a long time to recognize a change from a very slow rate to a higher one.
type Sim ¶
type Sim struct { Config SimConfig Agents []Agent WinCount uint64 MessageCount uint64 // 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 (*Sim) GetEpoch ¶
func (s *Sim) GetEpoch() abi.ChainEpoch