# Actor Spec: Cron [Back to Master Tracking Doc](https://hackmd.io/LOZjAsz-THelSD5lWqSVlw) ## Contents [TOC] ## At a Glance The Cron actor is a special actor invoked at the end of every Epoch. This is handled via an Implicit Message at the end of each Tipset, in which the System actor invokes Cron.EpochTick. **Actor Type:** - Singleton - Address: 3 **Exported Methods:** 1. Constructor 2. EpochTick ## State The Cron actor `State` is unique: it is completely static post-initialization. ```go= type State struct { Entries []Entry } type Entry struct { Receiver addr.Address MethodNum abi.MethodNum } ``` **`Entries`**: A slice of `Entry`s: method callbacks that will be invoked on the next call to `EpochTick`. * Each `Entry` defines: * `Receiver`: The destination actor of the callback. Uses an ID address. * `MethodNum`: The MethodNum of the method that will be invoked. The static values for `Entries` are listed below, and can also be found in `cron_state.BuiltInEntries`: ```go= st.Entries = []Entry{ Receiver: builtin.StoragePowerActorAddr, MethodNum: builtin.MethodsPower.OnEpochTickEnd, }, { Receiver: builtin.StorageMarketActorAddr, MethodNum: builtin.MethodsMarket.CronTick, }, ``` ## Exported Methods #### 1. Constructor ```go= func (a Actor) Constructor(rt vmr.Runtime, params *ConstructorParams) *adt.EmptyValue ``` The Cron constructor initializes the Cron actor's static `State` from its parameters: ```go= type ConstructorParams struct { Entries []Entry } ``` **`Entries`**: Will be equivalent to the specific `Entries` specified above. #### 2. EpochTick ```go= func (a Actor) EpochTick(rt vmr.Runtime, _ *adt.EmptyValue) *adt.EmptyValue ``` This method is invoked by the System actor as an Implicit Message at the end of each Tipset. Two method callbacks are invoked: 1. StoragePower.OnEpochTickEnd 2. StorageMarket.CronTick These invoked methods should not accept any parameters (except the `Runtime`). Also, they should both return `EmptyValue`. ##### Failure conditions Understanding potential failure conditions of the Cron actor is very important. Because the Cron actor is invoked as the final message in each Tipset, a failure within a Cron method callback could result in the Tipset being unable to be processed. **In a worst case scenario, this could lead to a total network halt.** Assuming Caller is the System actor, the following conditions will cause `EpochTick` to fail: * `panic` within an invoked callback * `Abortf` will simply be ignored, but `panic` will cause execution to halt. ## Questions * What entries will exist on constructor invocation? * zenground0: Only the values in `BuiltInEntries` * Is `st.Entries` cleared/deleted after `EpochTick`? * zenground0: No, state is static.