Storage Module
The storage module in Gitopia blockchain is responsible for managing storage providers, handling storage challenges, and distributing rewards. This section explains the key components and functionality of the storage module.
Provider Management
Storage providers are registered on the blockchain and must stake tokens to participate in the network. The module provides the following functionality for provider management:
- Registration: New providers can register by providing their URL, description, and staking tokens
- Updates: Providers can update their URL and description
- Unregistration: Providers can initiate the process of leaving the network
- Staking: Providers must stake a minimum amount of tokens to participate
Storage Challenges
The module implements a challenge-response system to verify that providers are maintaining the data properly. For a detailed explanation of the challenge system, see the Storage Challenge System documentation.
- Challenge Generation: Challenges are automatically generated at regular intervals (every
challenge_interval_blocks
) - Challenge Types: Two types of challenges are supported:
- Packfile challenges: Verify storage of Git repository packfiles
- Release asset challenges: Verify storage of release assets
- Challenge Response: Providers must submit proofs within the
challenge_period
- Rewards and Penalties:
- Successful responses are rewarded with tokens
- Failed or missed challenges result in slashing of staked tokens
Data Management
The module tracks various types of data stored in the network:
- Packfiles: Git repository packfiles with their CID, root hash, and size
- Release Assets: Release assets with their CID, root hash, size, and SHA256 hash
Module Parameters
The storage module has several configurable parameters:
min_stake_amount
: Minimum amount of tokens required to become a providerchallenge_interval_blocks
: Number of blocks between challengeschallenge_period
: Time window for providers to respond to challengesreward_per_day
: Total reward per day for a provider. This is distributed to providers via storage challengeschallenge_slash_amount
: Amount slashed for failed challenges before consecutive_fails_thresholdconsecutive_fails_threshold
: Number of consecutive failures for additional slashingconsecutive_fails_slash_percentage
: Percentage of stake slashed for consecutive failuresunstake_cooldown_blocks
: Number of blocks to wait before completing unstakingstorage_price_per_mb
: Price per MB for storage updates beyond free_storage_mbfree_storage_mb
: Free storage in MB per usermax_providers
: Maximum number of providers allowed in the networkenable_storage_challenges
: Enable storage challenges
Transaction Messages
The module supports the following transaction messages:
MsgRegisterProvider
: Register as a new storage providerMsgUpdateProvider
: Update provider informationMsgUpdateRepositoryPackfile
: Update repository packfile informationMsgUpdateReleaseAsset
: Update release asset informationMsgDeleteReleaseAsset
: Delete release asset informationMsgSubmitChallengeResponse
: Submit proof for a storage challengeMsgWithdrawProviderRewards
: Withdraw accumulated rewardsMsgUnregisterProvider
: Initiate provider unregistrationMsgCompleteUnstake
: Complete the unstaking processMsgUpdateParams
: Update module parameters (governance)
This blockchain integration ensures the reliability and security of the storage network by incentivizing proper data maintenance and penalizing misbehavior.