Skip to content

Latest commit

 

History

History
137 lines (99 loc) · 5.72 KB

v1.3.md

File metadata and controls

137 lines (99 loc) · 5.72 KB

v1.3

This update will introduce the feature of locking CFX to gain voting power for PoS mining pools. The voting power can be used to participate in Conflux's on-chain parameter voting and community governance voting. With this update, users can participate in voting by locking CFX and also receive PoS staking rewards.

This upgrade applies only to Core space mining pools, and CFX staked in eSpace space mining pools cannot be locked for voting participation.

This document primarily pertains to smart contracts. For information about UI updates, please refer to the corresponding documentation.

How to upgrade a contract.

First, please make sure that your current mining pool contract version is v1.2.0. If it's not, please upgrade to v1.2.0 first.

Then, update the contract code to v1.3.0 and follow this guide for the upgrade process, which is divided into two main steps:

Deploy the VotingEscrow contract.

The VotingEscrow contract is a newly introduced contract for managing the locking state. It provides the following functionalities:

  1. Locking Information Query
  2. Create, Add, Extend Locking
  3. On-chain Parameter Voting
  4. On-chain Parameter Voting Data Query

Deploy the VotingEscrow contract:

node bin/pool.js deployVotingEscrow

Upgrade PoSPool and configure it.

  1. Upgrade the PoSPool contract.
# Deploy a new PoSPool implementation contract.
node bin/pool.js deploy Pool
# Upgrade the PoSPool contract.
node bin/pool.js upgradePoolContract <new pool contract address>
  1. setVotingEscrow
# Set the VotingEscrow contract address.
node bin/pool.js Pool setVotingEscrow <voting escrow contract address>
  1. setParamsControl
# Set the parameter control contract address.
node bin/pool.js Pool setParamsControl

How to lock and participate in voting.

The 1.3 version upgrade of this project is mainly focused on mining pool contracts, and there won't be significant changes in the UI interface. It will only add a feature to display the user's current locking information.

Locking and voting with CFX need to be completed on confluxhub. For specific details, please refer to the confluxhub interface and instructions.

How to display the mining pool upgrade in ConfluxHub after the upgrade.

After your mining pool completes the upgrade, you need to submit a modification PR for the gov_pools.json file in the pos-pool project. In this file, add a mining pool information entry:

{
    "name": "test1",
    "address": "cfxtest:acgwa148z517jj15w9je5sdzn8p8j044kjrvjz92c1", 
    "icon": "https://confluxnetwork.org/favicon.ico", // your pool icon
    "website": "" // your pool website
}

If my mining pool is not using official code, how can I implement this feature and make it visible in ConfluxHub?

In this case, you will need to implement the functionality of PoSPool and VotingEscrow contracts on your own (ensuring that the contract interfaces are compatible) and register your mining pool information in ConfluxHub.

The core functionalities that the VotingEscrow contract needs to implement include:

  1. Recording user lockup information and acting as a proxy for users to perform CFX locking operations to acquire voting power.
  2. Recording user voting information and acting as a proxy for users to participate in on-chain parameter voting.

You can refer to the implementation of the VotingEscrow contract for specific logic.

The required interfaces to be implemented are as follows:

PoSPool

// Query the mining pool's APY (Annual Percentage Yield).
function poolAPY() external view returns (uint32);
// Retrieve the mining pool's name.
function poolName() external view returns (string memory);
// Retrieve a specific user's lockup information in the mining pool.
function userSummary(address user) external view returns (UserSummary memory);
// Retrieve the votingEscrow contract address for this mining pool.
function votingEscrow() external view returns (address);
// Retrieve the user's current lockup information: locked amount and locked block count.
function userLockInfo(address user) external view returns (IVotingEscrow.LockInfo memory);

VotingEscrow

interface IVotingEscrow {
    // Lockup Information: Locked Amount, Unlocked Block Count
    struct LockInfo {
        uint256 amount;
        uint256 unlockBlock;
    }

    // The user's current stake amount in the mining pool.
    function userStakeAmount(address user) external view returns (uint256);
    // Create Lockup (This method is only allowed to be called when the user is not currently locked up.)
    function createLock(uint256 amount, uint256 unlockBlock) external;
    // Increase Lockup Amount
    function increaseLock(uint256 amount) external;
    // Extend Lockup Duration
    function extendLockTime(uint256 unlockBlock) external;
    // Query the user's current lockup information.
    function userLockInfo(address user) external view returns (LockInfo memory);
    // Retrieve the user's lockup information for a specific block.
    function userLockInfo(address user, uint256 blockNumber) external view returns (LockInfo memory);
    // Query the user's current voting power.
    function userVotePower(address user) external view returns (uint256);
    // Retrieve the user's specified voting power.
    function userVotePower(address user, uint256 blockNumber) external view returns (uint256);
    // Participate in on-chain parameter voting: Voting round, Voting subject index, Number of votes for each option.
    function castVote(uint64 vote_round, uint16 topic_index, uint256[3] memory votes) external;
    // Retrieve on-chain parameter voting information.
    function readVote(address addr, uint16 topicIndex) external view returns (ParamsControl.Vote memory);
}

FAQs