Skip to content

Commit

Permalink
Merge pull request #33 from vechain/feat/endorsement-cooldown
Browse files Browse the repository at this point in the history
Feat/endorsement cooldown
  • Loading branch information
Agilulfo1820 authored Dec 20, 2024
2 parents f463f13 + f317227 commit 2557822
Show file tree
Hide file tree
Showing 46 changed files with 8,039 additions and 378 deletions.
70 changes: 51 additions & 19 deletions CONTRACTS_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,60 @@ This document provides a detailed log of upgrades to the smart contract suite, e

## Version History

| Date | Contract(s) | Summary |
| ------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| 29th November 2024 | `VeBetterPassport` version `3`, `GalaxyMember` version `3`, and `VoterRewards` version 4 | Added GM level as personhood check in VeBetter passport. |
| 28th November 2024 | `NodeManagement` version `2` | Added new functions to check node delegation status and improved node management capabilities. |
| 15th November 2024 | `GalaxyMember` version `2`, `VoterRewards` version `3`, `B3TRGovernor` version `5` | Added Vechain Node Binding with Galaxy Member feature |
| 15th November 2024 | `X2EarnApps` version `2` | Added X2Earn Apps Vechain Node Endorsement feature |
| 21th October 2024 | `VeBetterPassport` version `2` | Check if the entity is a delegatee when request is created |
| 11th October 2024 | `XAllocationVoting` version `2` | Check isPerson when casting vote & fixed weight during vote |
| 11th October 2024 | `B3TRGovernor` version `4` | Check isPerson when casting vote |
| 11th October 2024 | `X2EarnRewardsPool` version `3` | Register action in VeBetter Passport contract |
| 27th September 2024 | `Emissions` version `2` | Aligned emissions with the expected schedule |
| 13th September 2024 | `B3TRGovernor` version `3`, `XAllocationPool` version `2` | - Added toggling of quadratic voting and funding |
| 4th September 2024 | `X2EarnRewardsPool` version `2` | - Added impact key management and proof building |
| 31st August 2024 | `VoterRewards` version `2` | - Added quadratic rewarding features |
| 29th August 2024 | `B3TRGovernor` version `2` | Updated access control modifiers |
| Date | Contract(s) | Summary |
| ------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| 4th December 2024 | `X2EarnApps` version `3`, `XAllocationVoting` version `4`, `XAllocationPool` version `4`, and `X2EarnRewardsPool` version `5` | Added endorsement cooldown feature to X2Earn contracts. |
| 29th November 2024 | `VeBetterPassport` version `3`, `GalaxyMember` version `3`, and `VoterRewards` version 4 | Added GM level as personhood check in VeBetter passport. |
| 28th November 2024 | `NodeManagement` version `2` | Added new functions to check node delegation status and improved node management capabilities. |
| 15th November 2024 | `GalaxyMember` version `2`, `VoterRewards` version `3`, `B3TRGovernor` version `5` | Added Vechain Node Binding with Galaxy Member feature |
| 15th November 2024 | `X2EarnApps` version `2` | Added X2Earn Apps Vechain Node Endorsement feature |
| 21th October 2024 | `VeBetterPassport` version `2` | Check if the entity is a delegatee when request is created |
| 11th October 2024 | `XAllocationVoting` version `2` | Check isPerson when casting vote & fixed weight during vote |
| 11th October 2024 | `B3TRGovernor` version `4` | Check isPerson when casting vote |
| 11th October 2024 | `X2EarnRewardsPool` version `3` | Register action in VeBetter Passport contract |
| 27th September 2024 | `Emissions` version `2` | Aligned emissions with the expected schedule |
| 13th September 2024 | `B3TRGovernor` version `3`, `XAllocationPool` version `2` | - Added toggling of quadratic voting and funding |
| 4th September 2024 | `X2EarnRewardsPool` version `2` | - Added impact key management and proof building |
| 31st August 2024 | `VoterRewards` version `2` | - Added quadratic rewarding features |
| 29th August 2024 | `B3TRGovernor` version `2` | Updated access control modifiers |

---

## Upgrade `VeBetterPassport` to Version 3, `GalaxyMember` to Version 3, and `VoterRewards` version 4
## Upgrade `X2EarnApps` to Version 3, `XAllocationVoting` to version `4`, `XAllocationPool` to version `4`, and `X2EarnRewardsPool` to version `5`

Added new endorsement cooldown feature to X2EarnApps, in which vechain nodes enter a cooldown period after endorsing an XApp.
<br>
Updated `XAllocationVoting`, `XAllocationPool` and `X2EarnRewardsPool` to use version `3` of `X2EarnApps` interface.

### Changes 🚀

- **Upgraded Contract(s):**
- `X2EarnApps.sol` to version `3`
- `XAllocationVoting.sol` to version `4`
- `XAllocationPool.sol` to version `4`
- `X2EarnRewardsPool.sol` to version `5`

### Storage Changes 📦
- **`X2EarnApps`**:
- Added `_endorsementRound` to store latest round Vechain Node endorsed an XApp.
- Added `_cooldownPeriod` to store cooldown period in terms of rounds.
- Added `_xAllocationVotingGovernor` to store `XAllocationVoting` address.

### New Features 🚀
- **`X2EarnApps`**:
- Added `checkCooldown()` to check if a vechain node is currently in cooldown period, this is a public function that is also used inside `endorseApp()` and `unendorseApp()`.
- Added `getXAllocationVotingGovernor()` to get the address of the `XAllocationVoting` contract.
- Added `cooldownPeriod()` to get the cooldown period in rounds.
- Added `setXAllocationVotingGovernor()` to set `XAllocationVoting` address.
- Added `updateCooldownPeriod()` to update cooldown period.

### Bug Fixes 🐛

- None.

---

## Upgrade `VeBetterPassport` to Version 3, and `GalaxyMember` to Version 3

Added new personhood check in VeBetter passport, if a user owns a GM with a level greater than 1 they are considered a person.
<br>
Expand All @@ -38,12 +73,10 @@ Updated `VoterRewards` to use version `3` of `GalaxyMember` interface.
- `VoterRewards.sol` to version `4`

### Storage Changes 📦

- **`GalaxyMember`**:
- Added `_selectedTokenIDCheckpoints` to store checkpoints for selected GM token ID of the user.

### New Features 🚀

- **`VeBetterPassport`**:
- Updated `PassportPersonhoodLogic.sol` library's function `_checkPassport()` to include check for GM level.
- **`GalaxyMember`**:
Expand Down Expand Up @@ -72,7 +105,6 @@ Added new functions to check node delegation status and improved node management
- None.

### New Features 🚀

- **`NodeManagement`**:
- Added `isNodeDelegated()` to check if a specific node ID is delegated
- Added `isNodeDelegator()` to check if a user has delegated their node
Expand Down
4 changes: 4 additions & 0 deletions config/contracts/envs/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,9 @@ export function createLocalConfig() {
VEPASSPORT_DECAY_RATE: 0,

CREATOR_NFT_URI: "ipfs://bafybeie2onvzl3xsod5becuswpdmi63gtq7wgjqhqjecehytt7wdeg4py4/metadata/1.json",

//WARNING: Cooldown depends on the current round. If the current round is 1, the cooldown cannot be greater than 1. Otherwise the endorsement will fail.
//Check `EndorsementUtils.sol` `checkCooldown` method for more details.
X2EARN_NODE_COOLDOWN_PERIOD: 0, // 0 cycles
})
}
2 changes: 2 additions & 0 deletions config/contracts/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,6 @@ export type ContractsConfig = {
VEPASSPORT_DECAY_RATE: number

CREATOR_NFT_URI: string

X2EARN_NODE_COOLDOWN_PERIOD: number
}
48 changes: 31 additions & 17 deletions contracts/X2EarnApps.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { EndorsementUpgradeable } from "./x-2-earn-apps/modules/EndorsementUpgra
import { VechainNodesDataTypes } from "./libraries/VechainNodesDataTypes.sol";
import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import { IXAllocationVotingGovernor } from "./interfaces/IXAllocationVotingGovernor.sol";

/**
* @title X2EarnApps
Expand All @@ -41,6 +42,13 @@ import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/ac
* Only users with the DEFAULT_ADMIN_ROLE can add new apps, set the base URI and set the voting eligibility for an app.
* Admins can also control the app metadata and management.
* Each app has a set of admins and moderators that can manage the app and settings.
*
* -------------------- Version 2 --------------------
* - The contract has been upgraded to version 2 to include the X2Earn endorsement system.
* - Added libraries to reduce the contract size and improve readability.
*
* -------------------- Version 3 --------------------
* - The contract has been upgraded to version 3 to add node cooldown period.
*/
contract X2EarnApps is
X2EarnAppsUpgradeable,
Expand All @@ -63,24 +71,16 @@ contract X2EarnApps is
}

/**
* @notice Initialize the version 2 contract
* @param _gracePeriod the grace period to be reendorsed
* @param _nodeManagementContract the address of the vechain node management contract
* @param _veBetterPassportContract the address of the VeBetterPassport contract
* @notice Initialize the version 3 contract
* @param _cooldownPeriod the cooldown period for the endorsement
*
* @dev This function is called only once during the contract deployment
* @dev This function is called only once during the contract upgrade
*/
function initializeV2(
uint48 _gracePeriod,
address _nodeManagementContract,
address _veBetterPassportContract,
address _x2EarnCreatorContract
) public reinitializer(2) {
require(_nodeManagementContract != address(0), "X2EarnApps: Invalid Node Managementcontract address");
require(_veBetterPassportContract != address(0), "X2EarnApps: Invalid VeBetterPassport contract address");
require(_x2EarnCreatorContract != address(0), "X2EarnApps: Invalid X2EarnCreator contract address");
__Endorsement_init(_gracePeriod, _nodeManagementContract, _veBetterPassportContract);
__Administration_init_v2(_x2EarnCreatorContract);
function initializeV3(
uint48 _cooldownPeriod,
address _xAllocationVotingGovernor
) public reinitializer(3) {
__Endorsement_init_v3(_cooldownPeriod, _xAllocationVotingGovernor);
}

// ---------- Modifiers ------------ //
Expand Down Expand Up @@ -122,7 +122,7 @@ contract X2EarnApps is
* @return sting The version of the contract
*/
function version() public pure virtual returns (string memory) {
return "2";
return "3";
}

// ---------- Overrides ------------ //
Expand Down Expand Up @@ -269,6 +269,13 @@ contract X2EarnApps is
_setGracePeriod(_newGracePeriod);
}

/**
* @dev See {IX2EarnApps-updateCooldownPeriod}.
*/
function updateCooldownPeriod(uint256 _newCooldownPeriod) public virtual onlyRole(GOVERNANCE_ROLE) {
_setCooldownPeriod(_newCooldownPeriod);
}

/**
* @dev See {IX2EarnApps-updateNodeEndorsementScores}.
*/
Expand Down Expand Up @@ -323,6 +330,13 @@ contract X2EarnApps is
_setVeBetterPassportContract(_veBetterPassportContract);
}

/**
* @dev See {IX2EarnApps-setXAllocationVotingGovernor}.
*/
function setXAllocationVotingGovernor(address _xAllocationVotingGovernor) public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
_setXAllocationVotingGovernor(_xAllocationVotingGovernor);
}

/**
* @dev See {IX2EarnApps-setX2EarnCreatorContract}.
*/
Expand Down
6 changes: 5 additions & 1 deletion contracts/X2EarnRewardsPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ import { IVeBetterPassport } from "./interfaces/IVeBetterPassport.sol";
* - Added onchain proof and impact tracking
* ----- Version 3 -----
* - Added VeBetterPassport integration
* ----- Version 4 -----
* - Updated the X2EarnApps interface to support node endorsement feature
* ----- Version 5 -----
* - Updated the X2EarnApps interface to support node cooldown functionality
*/
contract X2EarnRewardsPool is
IX2EarnRewardsPool,
Expand Down Expand Up @@ -492,7 +496,7 @@ contract X2EarnRewardsPool is
* @dev See {IX2EarnRewardsPool-version}
*/
function version() external pure virtual returns (string memory) {
return "4";
return "5";
}

/**
Expand Down
4 changes: 3 additions & 1 deletion contracts/XAllocationPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ import { IX2EarnRewardsPool } from "./interfaces/IX2EarnRewardsPool.sol";
* - Added the abilty to toggle quadratic funding on and off.
* ---------------------- Version 3 ----------------------------------------
* - Use new interface IX2EarnApps that supports endorsement.
* ---------------------- Version 4 ----------------------------------------
* - Updated the X2EarnApps interface to support node cooldown functionality
*/
contract XAllocationPool is IXAllocationPool, AccessControlUpgradeable, ReentrancyGuardUpgradeable, UUPSUpgradeable {
using Checkpoints for Checkpoints.Trace208; // Checkpoints library for managing the voting mechanism used in the XAllocationVoting contract
Expand Down Expand Up @@ -642,7 +644,7 @@ contract XAllocationPool is IXAllocationPool, AccessControlUpgradeable, Reentran
* @return string The version of the contract
*/
function version() external pure virtual returns (string memory) {
return "3";
return "4";
}

/**
Expand Down
6 changes: 6 additions & 0 deletions contracts/XAllocationVoting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
* ----- Version 2 -----
* - Integrated VeBetterPassport
* - Added check to ensure that the vote weight for an XApp cast by a user is greater than the voting threshold
*
* ----- Version 3 -----
* - Updated the X2EarnApps interface to support node endorsement feature
*
* ----- Version 4 -----
* - Updated the X2EarnApps interface to support node cooldown functionality
*/
contract XAllocationVoting is
XAllocationVotingGovernor,
Expand Down
Loading

0 comments on commit 2557822

Please sign in to comment.