Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an interface to publish the cost (in ZKAPs) of stored data, as observed during the last lease crawl #76

Closed
exarkun opened this issue Feb 24, 2020 · 0 comments · Fixed by #81

Comments

@exarkun
Copy link
Collaborator

exarkun commented Feb 24, 2020

To allow users to plan their storage usage and their purchasing of new ZKAPs, it would be helpful for them to know what it costs to maintain the data they currently have stored.

The lease renewal process defines the cost of this maintenance. As currently implemented, it periodically visits all files reachable from a root capability and renews leases of all objects found if they don't already have a lease of at least some configurable duration.

Lease renewal costs a number of ZKAPs proportional to the size of the object, with quantization. This makes the total cost of maintaining objects for one period equal to:

maintenanceCost = sum 
  [ quantizedSize(object) / ZKAPValue 
  | object <- reachableObjects(rootCap) 
  ]

And this value should be exposed in the HTTP API somewhere. A client UX can then estimate time to ZKAP depletion by dividing the number of ZKAPs left by the cost to maintain objects:

estimatedDepletion = remainingZKAPs / maintenanceCost * leasePeriod

The HTTP API should present the information like so:

GET /v1/unblinded-token

200 OK
Content-Type: application/json

{ ...
, "lease-maintenance-spending": {
    "when": <ISO8601 timestamp>
  , "amount": <integer ZKAP count>
  }
}

where "when" gives an approximate timestamp when the spending took place and "amount" gives the number ZKAPs which were spent on lease maintenance.

If lease maintenance has never been performed then the value for lease-maintenance-spending will be null instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant