Allocations
Contract between the client and Züs System about storing their data
Introduction
To host your data on Züs system, there should be some kind of contract to agree on the terms of service, which are:
Size limit.
Expiration time.
Number of data shards and parity shards.
Write price range
Nominating the preferred blobbers to host your data.
We call this contract an Allocation. In this page we'll discuss operations related to the allocation and how the data related to the allocations flow through the system.
Allocation Structure
Allocation flow in Züs System
However, to manage your stored files that belong to the allocation, you need to communicate with the blobbers, thus the blobbers needs to know about the allocations they're involved in.
That's why the blobbers have a worker that synchronizes the allocation information with the blockchain periodically and store in the Blobber Metadata DB. The blobber uses the allocation data to authorize access and retrieve file references from the Blobber Metadata DB.
Allocation tokenomics
Allocation cost
Allocation cost is calculated as the write cost of the whole size of each data/parity shard on its corresponding blobber.
Cancelation Charge
Cancelation charge applies on the user in the following 2 cases:
At finalization/cancelation of the allocation.
At removal of a blobber from the allocation.
In case of total finalization/cancelation, a base cancelation charge is calculated as a globally configured percentage of the allocation cost mentioned above.
If this base cancelation charge is less than the amount of used tokens of the Write Pool of the allocation (mainly used to pay for challenges) then no fee is deducted. Otherwise, a cancelation reward is then calculated for each blobber of the allocation as a percentage of the base cancelation charge based on its passing rate and write price, and then sent to them. The total of these calculated rewards will be the total of the cancelation charge that will be deducted from the allocation Write Pool.
In case of blobber removal, the same calculation happens but taking into consideration just the blobber that is removed, not all allocation blobbers.
Operations on allocations
Creating an allocation
To create an allocation, you can use zboxcli newallocation
command.
What happens under the hood is simply that:
The smart contract function executes the following:
Validates the request:
Data and parity shards should be positive numbers.
Number of blobber ids provided should be equal to the sum of data and parity shards.
Price ranges (read/write) should be correct (min <= max).
Size of the allocation is not less than a globally configured allocation size minimum.
Checks all the blobbers are active.
Validating auth tokens for Restricted Blobbers, which are preferred blobbers that require authentication.
Adds the allocation size to the blobber offers, which is then when a new allocation is being requested.
Create a new write pool for the allocation and add the lock tokens amount to it.
Creates and saves a new Challenge Pool to the MPT. Challenge pool can be thought as a pool or container for tokens that will be used to pay challenge reward to the blobbers passing challenges.
Inserts the allocation to the MPT.
If the request is successful, the allocation ID is returned to the user, otherwise, the user will see the error. The allocation ID is set to the hash of the creation transaction.
Listing user's allocations
To list all your allocations, you can use zboxcli listalloctions
command.
What happens under the hood is:
Updating an allocation
To update the allocation settings, you can use zboxcli updateallocation
command.
The owner can update the following about the allocation settings:
Increase the size of the allocation, by setting the
Size
parameter of the transaction to a positive value.Change the file permissions options, by setting the
FileOptions
field of the transaction request.Make the allocation third-party-extendable, meaning non-owner clients can expand its size. You can do this by setting up
SetThirdPartyExtendable
of the transaction payload.Transfer allocation ownership (will be mentioned later).
Third party (non-owner) clients can also extend the size of an allocation if it's already set to be third-party-extendable by the owner.
Finalizing an allocation
When the transaction is expired, either the owner or one of the blobbers of the allocation can issue a transaction to finalize the allocation. To finalize the allocation, you can zbox alloc-fini
command:
Finalizing the allocation includes:
Settle all open challenges for the allocation, setting the unexpired ones to successful and the expired ones to failure, and updating the stats of the related blobbers.
Unlock the locked tokens for write operations on this allocation for all the stake pools of the involved blobbers.
Return all locked tokens in challenge pools to the owner's wallet.
Pays all pending reward/penalty for the settled challenges to the involved blobbers.
Update stats of the involved blobbers.
Canceling an allocation
Canceling is similar to finalization, with a couple of differences:
The cancelled allocation should NOT be expired, unlike finalization.
Only the allocation owner can issue cancellation transaction to the allocation.
To cancel the allocation, you can use the zbox alloc-cancel
command:
Canceling the allocation have exactly the same effect on blobber balances and token pools as finalization mentioned above.
Transfer an allocation to another account
For some use cases, users may need to exchange ownership of the allocation. Users can do this using the zbox transferallocation
command:
Last updated