Tom Mellan
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Optimal disk replacement policy under crypto economic failure penalisation constraints ## Problem statement Being a storage provider relies on having operational hard disks. Sometimes disks fail. The probability of failure typically follows what's known in reliability engineering as a *bathtub curve*: ![](https://i.imgur.com/ByJ185y.png) When a disk fails the storage provider pays for its replacement, but since the failure is unpredictable, it carries risk of missing the winning PoST giving a block-reward opportunity cost and missing window PoST with faulted sectors resulting in collateral slashing. These costs can be mitigated by planning a sufficiently early replacement date, but of course it's too early, that's also suboptimal. Furthermore disks typically come with a 1, 2 or 3 year warranty. Then the question then arises --- given these factors, and distributional assumption about disk lifetime --- what's the optimal policy to replace the disk? ## Approach Optimal policy means the time $\tau$ when it's best replace the disk. To define what best means, we can note that the problem is a *renewal-reward process*. Whereas a *renewal process* is a generalization of Poisson arrival process to arbitrary non-negative arrival times, a *renewal-reward process* introduces additional structure, placing rewards (or costs) on top of arrivals. This is precisely what is happening with disk replacement --- disks fail at random times, with time-dependent costs, then disks are renewed. To proceed we'll use the renewal-reward theorem. This relates the asymptotic limit of the process to the ratio of expected rewards and disk lifetimes. The expected reward per unit time will gives us an expression to optimize to find the most cost-effective replacement time. ## Solution Let $R(t)$ be a renewal-reward process for disk replacement and $t$ be chronological time. The expected renewal-reward theorem states \begin{align*} \mathbb{E}\left[R(t)\right]=\underset{t\to\infty}{\text{lim}}\frac{t\,\mathbb{E}\left[C(t)\right]}{\mathbb{E}\left[\Lambda(t)\right]} \end{align*} where $C$ is a stochastic process for cost of replacement and $\Lambda$ is a stochastic process for the lifetime of the disk. To find optimal time $\tau$ we optimize for the expected reward per unit time: \begin{align*} \tau=\underset{t}{\text{argmin}}\frac{\mathbb{E}\left[C(t)\right]}{\mathbb{E}\left[\Lambda(t)\right]}\,. \end{align*} The expectations must be defined over appropriate distributions. For the probability of disk failure, like the bathtub curve above, we can model this as a generalized Beta distribution. Let the probability of failure at time $t$ be Beta distributed but on an arbitrary finite interval $[0,T]$, where $T$ is maximum retirement time. For this distribution (instead of the usual one on $[0,1]$), the pdf is given by \begin{align*} p\left(\text{fail}(t)\right)=T^{1-\alpha-\beta}\left(T-t\right)^{\beta-1}\left(t\right)^{\alpha-1}\frac{\Gamma(\alpha+\beta)}{\Gamma(\alpha)\Gamma(\beta)}\,. \end{align*} By the tower property of total expectation we can expand the expected disk lifetime over different modes ($m_{\Lambda}$) of failure: \begin{align*} \mathbb{E}\left[\Lambda\right] & =\mathbb{E}\left[\mathbb{E}\left[\Lambda|\text{fail}_{i}\right]\right]\\ & =\sum_{i\in m_{\Lambda}}\mathbb{E}\left[\Lambda|\text{fail}_{i}\right]p\left(\text{fail}_{i}\right) \end{align*} For the disk lifetime, we consider two failure modes. The disk fails at time $t$ before we replace it, or we replace it preemptively: \begin{align*} m_{\Lambda}=\begin{cases} m_{\Lambda}(t<\tau) & \text{unplanned failure}\\ m_{\Lambda}(t\ge\tau) & \text{replaced before failure} \end{cases}\,. \end{align*} The probability of each scenario, the $p\left(\text{fail}_{i}\right)$ in each case, is given by \begin{align*} p\left(\text{fail}_{t<\tau}\right) & =\int_{0}^{\tau}p\left(\text{fail}(t)\right)dt\\ & =\text{B}(\frac{\tau}{T},\alpha,\beta)\frac{\Gamma(\alpha+\beta)}{\Gamma(\alpha)\Gamma(\beta)} \end{align*} where $\text{B}(\frac{\tau}{5},\alpha,\beta)$ is the incomplete beta function, and \begin{align*} p\left(\text{fail}_{\tau>t}\right) & =\int_{\tau}^{T}p\left(\text{fail}(t)\right)dt\\ & =\frac{\Gamma(\alpha)\Gamma(\beta)-\text{B}(\frac{\tau}{T},\alpha,\beta)\Gamma(\alpha+\beta)}{\Gamma(\alpha)\Gamma(\beta)}\,. \end{align*} The expectation of disk lifetime given failure before retirement is \begin{align*} \mathbb{E}\left[\Lambda|\text{fail}_{t<\tau}\right] & =\int_{0}^{\tau}t\,p\left(\text{fail}(t)\right)dt\\ & =T\text{B}(\frac{\tau}{T},1+\alpha,\beta)\frac{\Gamma(\alpha+\beta)}{\Gamma(\alpha)\Gamma(\beta)}\,\,. \end{align*} If failure happens after the disk is retired, the expected lifetime is simply $\tau$. For costs, we can similarly expand over different modes $m_{C}$ of cost realization: \begin{align*} \mathbb{E}\left[C\right] & =\mathbb{E}\left[\mathbb{E}\left[C|\text{fail}_{i}\right]\right]\\ & =\sum_{i\in m_{C}}\mathbb{E}\left[C|\text{fail}_{i}\right]p\left(\text{fail}_{i}\right) \end{align*} The ways cost can vary with failure time depend on the warranty time period $W$ and the replacement policy time $\tau$, and the potential cost of disk replacement $D$, slashing incurred $S$, and block reward opportunity cost $B$. In this model, three scenarios are considered: * Disk failure during warranty, at time $t$ where $t<W<\tau$, in which case the $\mathbb{E}\left[C|\text{fail}_{i}\right]$ cost is given by slashing $S$ $+$ block-reward $B$. * Failure after warranty, at time $t$ where $W<t<\tau$, giving an $\mathbb{E}\left[C|\text{fail}_{i}\right]$ cost of disk replacement $D$ $+$ slashing $S$ $+$ block-reward $B$. * Disk is retired, i.e. $t$ where $W<\tau<t$, for which the cost is just disk replacement $D$ since unpredictable slashing etc isn't a factor. For each of the $\mathbb{E}\left[C|\text{fail}_{i}\right]p\left(\text{fail}_{i}\right)$ terms in $\mathbb{E}\left[C\right]$, analytic expressions are available but omitted here for brevity. ## Computation If we assume the lifetime distribution is generalized Beta with maximum retirement time of $T=5$ years, and shape parameters $\alpha=0.99$ and $\beta=0.98$, i.e. $\text{gBeta}(0.99,0.98,5)$, then our bathtub curve looks like ![](https://i.imgur.com/6YCRi2W.png) If: * the warranty is $W=3$ years * disk replacement cost is $D=$\$500 * slashing cost from unplanned failure is $S=$\$200 * block reward opportunity cost is $B=$\$100 then our optimisation problem is to find the minimum of $\frac{\mathbb{E}\left[C(t)\right]}{\mathbb{E}\left[\Lambda(t)\right]}$ setting these specific parameters. This cost function looks like: ![](https://i.imgur.com/MfWbFdq.png) The optimal cost policy is to replace the disk at time $\tau=3.3$ years --- that is, slightly after the warranty $3$ year warranty. ## Next Improvements * using a lifetime distribution parameters $\alpha$ and $\beta$ actually based on data for the types of disks SPs are using * use the actual cost of disk replacement instead of placeholder \$$500$ * work out actual numbers for the cost asscoated with slashing and missing blockrewards from having disk failure Furthermore this type of optimal policy model can potentially be fed into other research regarding long-term storage e.g. pricing perpetual storage.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully