Skip to content

Latest commit

 

History

History
 
 

sminer

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Sminer Module

One of the core pallets of CESS, used to manage storage nodes.

Overview

In addition to registering and changing the basic information of storage nodes, this module also includes the work of rewarding and punishing storage nodes. If you want to know more details about storage nodes, you can view the wiki.

Terminology

  • beneficiary: The revenue account of the storage node is used to receive rewards from the storage node.
  • staking_val & collaterals: The pledge amount of the storage node affects the storage space that the storage node can currently provide.
  • pois_key: The secret key generated by the tee worker for calculating free space.
  • bloom filter: Bloom filter for service files. The hash of the service file is encoded and recorded in the Bloom filter to compare whether the file is missing.

Extrinsic

  • regnstk() - Storage node registration function. This function will initialize the meta information of the storage node after staking it, including the reward table.
  • register_pois_key() - This function is used to register the pois_key of the storage node. After completing this step, the storage node can start mining.
  • increase_collateral() - Storage nodes add pledge function.
  • update_beneficiary() - This function is used to update the revenue address of the storage node.
  • update_peer_id() - This function is used to update the peer_id field of the storage node.
  • receive_reward() - Used for storage nodes to receive rewards, and the rewards will be transferred to the income account.
  • miner_exit_prep() - Storage node pre-exit function. After calling this method, the storage node will enter the lock period and start a scheduler task.
  • miner_exit() - Triggered by the chain itself. It is the execution object of the scheduler task created in miner_exit_pre(). Some information processing required for storage node exit will be performed.
  • miner_withdraw() - Storage node redemption and pledge function. It can be called by the storage node after completing the exit process to redeem the current pledge.
  • faucet_top_up() - Testnet exclusive method. Recharge the faucet account.
  • faucet() - Faucet water function. An account can only be called once a day to receive 10,000 TCESS.
  • update_expender() - Can only be called by root privileges and is used to change the graph specification of idle files generated by storage nodes.

Interface

MinerControl

Used to update or check the information status of storage nodes, and also includes related functions for rewards and penalties for storage nodes.

Function

  • add_miner_idle_space() - Increase the free space of storage nodes.
  • delete_idle_update_accu() - Reduce idle files on storage nodes and update filters.
  • delete_idle_update_space() - Reduce idle space on storage nodes.
  • add_miner_service_space() - Increase the service space of storage nodes.
  • sub_miner_service_space() - Reduce the service space of storage nodes.
  • get_power() - Get storage node computing power.
  • miner_is_exist() - Determine whether the storage node exists.
  • get_miner_state() - Get storage node status.
  • get_all_miner() - Get a list of all storage node accounts.
  • insert_service_bloom() - Service file bloom filter inserts new files.
  • delete_service_bloom() - Remove specified files from service file bloom filter.
  • lock_space() - Lock the idle space of the storage node.
  • unlock_space() - Release the locked space of the storage node.
  • unlock_space_to_service() - Release the locked space of the storage node and increase the corresponding service space.
  • get_miner_idle_space() - Get the idle space of the storage node.
  • get_miner_count() - Get the number of storage nodes in the current network.
  • calculate_miner_reward() - Calculate storage node rewards and update its reward table.
  • clear_punish() - Clear punish the storage node.
  • idle_punish() - Implement idle punishment on storage nodes.
  • service_punish() - Implement service punishment on storage nodes.
  • force_miner_exit() - Force the storage node to be kicked out of the network.
  • update_restoral_target() - Update recovery target state.
  • restoral_target_is_exist() - Whether the recovery target exists.
  • is_positive() - Whether it is an positive storage node.
  • is_lock() - Whether it is an lock storage node.
  • update_miner_state() - Update storage node status.
  • get_expenders() - Get the current expander specification.
  • get_miner_snapshot() - Obtain the snapshot information of the storage node for random challenges.

Usage

in pallet::Config

pub trait Config:
		frame_system::Config + sp_std::fmt::Debug
    {
        //...
        type MinerControl: MinerControl<Self::AccountId, Self::BlockNumber>;
        //...
    }

in runtime.rs

impl pallet_audit::Config for Runtime {
    //...
    type MinerControl = Sminer;
    //...
}

Implementation Details

Reward Calculation

The reward of a storage node will be determined by the ratio of its service space and idle space to the total computing power of the entire network. The reward will be calculated based on the snapshot of the storage node recorded when the random challenge started, rather than the current state of the storage node. Read the wiki documentation to learn about the reward calculation formula and more reward details for storage nodes.