Skip to main content

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 provider
  • challenge_interval_blocks: Number of blocks between challenges
  • challenge_period: Time window for providers to respond to challenges
  • reward_per_day: Total reward per day for a provider. This is distributed to providers via storage challenges
  • challenge_slash_amount: Amount slashed for failed challenges before consecutive_fails_threshold
  • consecutive_fails_threshold: Number of consecutive failures for additional slashing
  • consecutive_fails_slash_percentage: Percentage of stake slashed for consecutive failures
  • unstake_cooldown_blocks: Number of blocks to wait before completing unstaking
  • storage_price_per_mb: Price per MB for storage updates beyond free_storage_mb
  • free_storage_mb: Free storage in MB per user
  • max_providers: Maximum number of providers allowed in the network
  • enable_storage_challenges: Enable storage challenges

Transaction Messages

The module supports the following transaction messages:

  • MsgRegisterProvider: Register as a new storage provider
  • MsgUpdateProvider: Update provider information
  • MsgUpdateRepositoryPackfile: Update repository packfile information
  • MsgUpdateReleaseAsset: Update release asset information
  • MsgDeleteReleaseAsset: Delete release asset information
  • MsgSubmitChallengeResponse: Submit proof for a storage challenge
  • MsgWithdrawProviderRewards: Withdraw accumulated rewards
  • MsgUnregisterProvider: Initiate provider unregistration
  • MsgCompleteUnstake: Complete the unstaking process
  • MsgUpdateParams: Update module parameters (governance)

This blockchain integration ensures the reliability and security of the storage network by incentivizing proper data maintenance and penalizing misbehavior.