eos icon indicating copy to clipboard operation
eos copied to clipboard

EOS Storage Contract API

Open bytemaster opened this issue 9 years ago • 11 comments

This issue uses TOK to represent the native token of the blockchain:

The following messages are implemented by the storage contract:

tok::transfer( AccountName from, AccountName to, uint64_t amount )

This message handler is called anytime the @tok currency contract transfers TOK to or from the @storage contract. When tokens are received the producers will reserve space for the user based upon the current price of storage. When tokens are transferred away it will be rejected if it would reduce the user’s reserved space below the used space.

setlink( AccountName owner, string eosiopath, string ipfspath, uint32 size, bool store )

So long as eosiopath is unique and doesn’t start with a prefix of an existing eosiopath and the ipfspath is a valid IPFS path, then the link is created. If eosiopath already exists then it is updated to the new ipfspath. If the storage flag is set then block producers will attempt to cache the file.

This requires the authority and scope of the owner.

removelink( AccountName owner, string eosiopath )

The eosiopath must exist. After removing a path the user’s quota usage is reduced by the indicated file size.

This requires the authority and scope of the owner.

acceptstore( AccountName producer, AccountName owner, string eosiopath )

Any active block producer can call this method to claim they have successfully stored the file referenced by the ipfspath linked to by the eosiopath. At this time the used space

This requires the authority of the producer and the scope of the owner.

rejectstore( AccountName producer, AccountName owner, string eosiopath )

The eosiopath must exist. Any producer can use this to indicate that they have rejected the request to store a particular file. This may be called at any time and is intended for cases where a producer would be exposed to legal or criminal liability for continuing to store the file.

This requires the authority of the producer and the scope of the producer. It has no side effects or behaviors other than to notify the community that a particular producer has declined to store a file. This creates a database of files that may be suspicious and serves as an advisory for everyone. A block producer that does not publish a reject message is bound by contract to store and serve the file at eosiopath.

This requires the authority and scope of the producer.

bytemaster avatar Sep 14 '17 20:09 bytemaster

Waiting on https://github.com/EOSIO/eos/pull/274 to be merged.

pavybez avatar Sep 19 '17 02:09 pavybez

Here is my understanding of this assignment. Please correct me if I am wrong:

  1. transfer: Similar to currency contract implementation except we don't remove account if balance = 0.

  2. setlink: This will do following: a. Check the authorization of owner. b. Verify that it is a valid ipfs path. How do we do this without installing ipfs? c. Verify the validity of eosiopath (is it in right format). d. Verify that eosiopath is unique e. Verify that eosiopath does not start with a prefix of an existing eosiopath. This means that if eosiopath is /tmp/test and there is already a /tmp path we reject. f. Store the entire info (eosiopath, ipfspath, size, store) under account scope into db.

  3. removelink: This will do following: a. Check the authorization of owner. b. Check that file belongs to owner. c. Delete the link in database. d. Reduce quota usage (by how much? - 1 TOK = ? bytes) e. How do we inform producer to remove cached file?

  4. acceptstore: a. This is done by the producer; checks the authorization of producer and will notify whom?. b. Charge account for storage. what if store flag in setlink is false? c. Store anything or update database?

  5. rejectstore: a. Done by producer; checks authorization of producer and will notify whom? b. Store in a new table rejected links.

pavybez avatar Sep 20 '17 01:09 pavybez

@bytemaster Dan can you please review Pravin's list and comment on his understanding of the Storage API.

Thank you

ChristianDunst avatar Sep 22 '17 02:09 ChristianDunst

How would you prevent the price being 0 when the balance is 0 (ie. first message)

The storage whitepaper refers to Balance being the amount of space consumed, is this the same as the amount of space reserved?

michaeljyeates avatar Sep 23 '17 16:09 michaeljyeates

price is never 0 because price is based upon the post reseveration amount rather than the pre-reservation amount.

The String Key/value database has been merged.

bytemaster avatar Sep 24 '17 14:09 bytemaster

  1. transfer should remove if empty
  2. verification of IPFS paths is just verifying character subset and approximate length ranges
  3. accept store is only valid if store flag is set to true, no one is notified, database is updated to increase used quota and indicate the file has been accepted by both
  4. rejected links are just a flag on existing links, not a new table

bytemaster avatar Sep 24 '17 14:09 bytemaster

See pull request https://github.com/EOSIO/eos/pull/494 for base implementation without functionality.

pavybez avatar Sep 25 '17 08:09 pavybez

Blocked on https://github.com/EOSIO/eos/issues/493 and https://github.com/EOSIO/eos/issues/492

pavybez avatar Sep 26 '17 01:09 pavybez

Waiting for design approval.

pavybez avatar Sep 29 '17 09:09 pavybez

Design document reviewed and feedback was provided. Most of the questions were clarified except a few.

  • Implemented ABI
  • Requested for clarifications on the document

pavybez avatar Oct 04 '17 02:10 pavybez

This was written in light of the currency design that was multiple versions ago.

brianjohnson5972 avatar Oct 19 '18 19:10 brianjohnson5972