owned this note
owned this note
Published
Linked with GitHub
# Reviewing Termination Fee
###### tags: `filecoin-pl` `Protocol Review`
:::info
Up to date by December 2022
:::
*Date: 15 December 2022*
*Speaker: Danilo Lessa Bernardineli (BlockScience)*
*[Recording Link](https://drive.google.com/file/d/1cZZ1mTylCJvb_saViw6SuGHEdb93hbYr/view?usp=share_link)*
## What is
**According to the [Filecoin Spec](https://spec.filecoin.io/)**, the Sector Termination Fee is an dynamical fee that can be paid
- pro-actively by the miner
- due to fault termination, which happens when the sector is faulty for more than `42 consecutive days`
The **proposed** initial form as per section 4.7.1 of the is as it follows:
`Sector Termination Fee = max(Earned Rewards, 90d of Sector Rewards)`
Also, it is important to pinpoint the form of Sector Fault Fee, which are made of two:
- Sector Fault Fee, which is defined as 2.14 BR of an sector
- Sector Fault Detection Fee, which is defined as 1.5 BR of an sector.
Those interact with the Storage Pledge as it's value is defined as being at **minimum** 7 days worth of Fault Fees and 1 Sector Detection Fee. The sum of those gives an total of 16.48 BR of an sector.
___
The **Code Implementation** for the **Fee Calculation** is given by the `actors/builtin/miner/monies.go::PledgePenaltyForTermination` function on the `specs-actors` repo. [(link)](https://github.com/filecoin-project/specs-actors/blob/d8d9867f68a3c299295efdc6d1b3421c9b63df57/actors/builtin/miner/monies.go#L117), which can be simplified into:
- `Sector Termination Fee = max(Sector Penalization, Base Termination Fee)`
- `Sector Penalization = 3.5 days of Sector Expected Rewards`
- `Base Termination Fee = Sector Storage Pledge + (expectedReward) / (2 * Days)`
- `expectedReward = dayReward * cappedSectorAge + replacedDayReward * relevantReplacedAge`
- `cappedSectorAge = min(sectorAge, 140 Days)`:
- `replacedDayReward `: the day reward of the sector being replaced in a capacity upgrade
- `relevantReplacedAge`: the age of the sector being reaplced in a capacity upgrade
**Assuming no Capacity Upgrades**, the Code Implementation gives the following form:
- `Sector Termination Fee = max(Sector Penalization, Base Termination Fee)`
- `Sector Penalization = 3.5 days of Sector Daily Expected Rewards on the Termination Time`
- `Base Termination Fee = Sector Storage Pledge + min(0.5 * Sector Days, 70 Days) * Sector Daily Expected Rewards on the Activation Time`
- Alternatively, `Base Termination Fee = Sector Storage Pledge + Half of Earned Rewards, with an ceiling on 70 days worth of expected rewards`
___
The **Code Implementation** for the penalty processing is given by the `actors/builtin/miner/miner_actor.go::processEarlyTerminations` function on the `specs-actors` repo [(link)](https://github.com/filecoin-project/specs-actors/blob/3c87d38a4829460c92a084465521f649d7613796/actors/builtin/miner/miner_actor.go#L2406), and the Maximum Faulty period is located at `actors/builtin/miner/policy.go::FaultMaxAge`, which is set as of now to 42 days.
___
## Pitfalls
- The Termination Fee is not properly documented on the spec, and there are divergences vs what's actually on the code.
- There were some updates on the Network without changes on the Storage Pledge requirements (eg. consecutive faults are now 6w rather than 2w). This can make the Termination Fee comparatively cheap vs repairing the sector if onboarding costs are relatively low.
- The Termination Fee have multiple dependences on the network state at the `Activation Time`. This can be an tricky situation, as for an fixed QAP, we can expect the Sector Storage Pledge and Expected Day Rewards for a sector being onboarded / upgraded to go down over time.
- The Termination CAN depend on the Sector Expected Rewards on the Termination Time (3.5d of the current expected s-BR), however we should expect it be an extreme event, as it would require `3.5d of current BR > 20d of activation BR + at most 70d of expected earnt rewards`. For an old sector, we can assume `3.5d of current daily BR > 90d of activation daily BR`, which means that the current daily BR should be ~25x bigger than the activation daily BR.
- There's an risk on that case that the Miner will not have enough collateral for paying the Termination Fee
- Although we expect the Termination Fee to be payable for new sectors, the risk of the miner not having enough to pay it increases as the sector gets older. This is because the expected rewards at activation time tends to be higher than the actual rewards as time goes on.
## Historical Context
The termination fee was initially proposed in the [Slash the World document](https://docs.google.com/document/d/1m9NU-NfaFqg8SdwMm9hf-1wzPHnFC-9PJSub8ho9R2E/edit#) around April 2020, and its form was being defined as:
- `TerminationFee[t] := max(StoragePledge[t], BaseTerminationFee[t])`
- `BaseTerminationFee[t] := InitialPledge * (1 + min[Sector Age, 180 Days] / 20 days)`
- Or eq.: `BaseTerminationFee[t] := InitialPledge * (1 + min[Sector Age / 20 Days, 9 Days])`
One limiting factor back then was associated with how much data was acessible. Computing the Locked Rewards associated an Sector was not trivial technically, so the formulation did require assuming how much collateral the miner would have.
Also, Termination Fee would be triggered when the sector is in the faulted state for "14 consecutive proving periods" rather than the current `42 consecutive days`. Note that those are way higher than the slack that the Storage Pledge provides (20 days worth of Block Reward)
![Termination Fee per Sector Definition on the Slash the World document](https://hackmd.io/_uploads/SJZvWS8dj.png)
![](https://hackmd.io/_uploads/HywS1_D_s.png)
___
A modelling concern initially was related to the rationality of recovering sectors in cause of faults - [FilSim Planning Doc, May 2020](https://docs.google.com/document/d/1NXOXFrGiwgtIhW6iGZAxOPyNV0S16hvuD9UinyqdDpk/edit#heading=h.zgzhwh14lhe0).
On the time between the design, testnet and mainnet, the Fee form did change a couple of times, namely:
- `TerminationFee[t] := max(SectorPenalization[t], BaseTerminationFee[t])`
- Before Testnet:
- `BaseTerminationFee[t] = InitialPledge + BlockReward(t_start) * min[Sector Age, 180 days]`
- `SectorPenalization: 5 days of Sector BR at Penalty Time`
- Testnet Recommendations:
- `BaseTerminationFee[t] = BlockReward(t_start) * (20 + min[Sector Age, 70 days])`
- `SectorPenalization: 5 days of Sector BR at Penalty Time`
- Mainnet Recommendations
- `BaseTerminationFee[t] = BlockReward(t_start) * (20 + min[0.5 * Sector Age, 70 days])`
- `SectorPenalization: 3.5 days of Sector BR at Penalty Time`
It's possible that the introduction of the `0.5x` multipler on the `Sector Age` was one of the concessions in response to the pushbacks associated with the introduction of an `30% Target Locked Supply`.
[FIL Cryptoecon Recommendations](https://docs.google.com/spreadsheets/d/1whGnDKztmjsQvuVQILtkJx3t0N0tDNta2TPwCAKHnWk/edit#gid=0)
![](https://hackmd.io/_uploads/HkSHGB8ds.png)
___
In Sep 2021, there was an [network update](https://github.com/filecoin-project/community/discussions/74#discussioncomment-1398542) through [FIP-0026](https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0026.md) that increased the Faulty Period in order to be terminated from 14 days to 42 days.
Upgrading the Termination Fee was considered during FIP 17/FIP 17, and some discussion back then can be found at the [Qualitative Analysis, FIP 17/FIP 19](/t69zej6-Td6OfKW_WgUbkQ), [Meso Research Plan for Termination Fee](/uhwH00C1SB6u_W3Ar-TIdw) and the [Termination fee governance surface and functional form](/bZr6bPMXQa-Vm3867SdTgg) documents