Actors
srml::system
LockableCurrency
Membership
The storage staking module is the gatekeeper for entry and orderly exit of platform members into and out of the Storage Provider
role.
Entry is achieved through staking funds. Storage providers are rewarded periodically with new funds as incentive to maintain operational status. Storage providers can choose to stop offering their services by un-staking. System sudo account can forcefully remove storage providers from active participation, and optionally punish provider by slashing staked funds.
The module is used to configure the storage tranches available in the storage system, and for updating operational parameters associated with each tranche, such as minimum stake and storage capacity.
Tranches must always aim to maintain a minimum number of providers MinSlots
.
The module will prevent un-staking when it would result in MinSlots
no longer being filled. Once tranches are created they cannot be destroyed, however their operational parameters can be adjusted. If at anytime the maximum number of slots MaxSlots
for a tranche is update to be less than the number of active providers N
in the tranche, no new providers can be allowed to join until the number drops below MaxSlots
again.
Members will utilize a separate account, referred to as the role account, which will be associated with their membership, to hold the staked funds. This corresponding key, is referred to as the role key. The role key is also used to sign a extrinsics sent by the storage provider software when interacting with the chain. A role account may only only be associated with a single member at any given time. A role account can only be used to stake into a single tranche at any given time.
Staking is achieved by locking funds in the role account. The amount locked will be equal to the StakeAmount
parameter for the tranche the storage provider is participating in. The storage provider may transfer funds out of the role account only that are in excess of the locked amount.
For convenience, the locked funds can still be used to pay for transactions fees. This means the balance may fall below the locked amount.
Entering a tranche is a multi-step process:
There must be an available slot in a tranche to enter. All providers stake the same amount of funds, this means it's not possible for a new storage provider to displace an existing provider.
At regular intervals defined by tranche parameters, a fixed award is distributed to distributors. The reward amount is a configurable parameter.
The reward will go to the member account, unless the balance in the role account is below the StakeAmount
, in which case it
will go to the role account. This forces storage providers to gradually add funds to their role account in order to maintain their commitment of staking a certain amount.
When a storage provider decides to leave a tranche, they can initiate the process by un-staking. If the platform allows it, the provider goes immediately out of service. An un-bonding period follows after which the funds in the role account become transferable.
StorageProviderInfo
: Represents when the provider joined a tranche, the member identifier they are associated with, and their role account identifier.EntryRequest
: Represents intent to join a specific tranche, with a certain role account and member identity. Requests have a lifetime RequestLifeTime
. If not approved before expiry they are cleared from state.TrancheCount
: Number of tranches created.RoleAccountIds
: List of currently staked role accounts.StorageProviderInfoByRoleAccount
: Map of RoleAccount to StorageProviderInfoRoleAccountsByTrancheId
: Map of tranche identifier to list of role accountsRoleAccountIdsByMemberId
: Map of member identifier to list of role accountsEntryRequests
: List of pending requests to enter storage provider roleRequestLifeTime
: Duration of time before a role entry request expiresTrancheIdsByDataObjectTypeId
: Mapping of tranches available for a DataObjectType
Tranche Operational Parameters
StakeAmount
: Map of tranche identifier to Optional Stake AmountMinSlots
: Map of tranche identifier to Optional Minimum Number of slotsMaxSlots
: Map of tranche identifier to Optional Maximum Number of slotsFixedReward
: Map of tranche identifier to Optional Reward AmountFixedRewardPeriod
: Map of tranche identifier to Optional BlockNumberUnbondingPeriod
: Map of tranche identifier to Optional BlockNumberEntryRequestFee
: Map of tranche identifier to Optional Fee AmountDataObjectTypeId
: The DataObjectType
for which this tranche is created.Tranche identifier starts at 0. So if TrancheCount = 4, the identifiers of the created tranches are 0, 1, 2, and 3.
Note: Currently, tranches are not limited in size. When good tooling for monitoring and creating tranches is available, the intend is to limit tranches in size, and add new ones before storage space runs out.
Each event has payload as sublist
TrancheCreated
: A new tranche was created
TrancheUpdated
: Some tranche parameters were changed
EntryRequested
: A new role key
ProviderJoined
: A new storage provider joined a tranche
ProviderLeft
: A storage provider un-staked
ProviderEjected
: A storage provider was forcefully removed
origin
: call originparameters
: List of operational parameters
stake_amount
min_providers
max_providers
fixed_reward
fixed_reward_period
unbonding_period
entry_request_fee
data_object_type_id
Creates a new tranche with provided parameters.
DataObjectType
.TrancheCount
increased by oneTranche operational parameter values set in each corresponding parameter map
TrancheCreated
origin
stake_amount
min_providers
max_providers
fixed_reward
fixed_reward_period
unbonding_period
entry_request_fee
Change tranche operational parameters
TrancheUpdated
origin
: role accountMember creating request to join a tranche
EntryRequests
List has new requestEntryRequested
Member approves a pending request to stake and join a tranche using the role account.
RoleAccountIds
StorageProviderInfoByRoleAccount
mapRoleAccountsByTrancheId
RoleAccountIdsByMemberId
EntryRequests
ProviderJoined
Member chooses to un-stake and stop providing service.
RoleAccountsByTrancheId
, RoleAccounts
, RoleAccountIdsByMemberId
, StorageProviderInfoByRoleAccount
Forcefully remove a storage provider from service. And optionally slash staked balance.
RoleAccountsByTrancheId
, RoleAccounts
, RoleAccountIdsByMemberId
, StorageProviderInfoByRoleAccount
punish
is true, slash stake amount from role accountClear expired entry requests.
Make reward payouts.
A tranche that has MinSlots = 0, where content is not guaranteed to persist. Suitable for short lived data?