Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Referee for TBR and TK #455

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open

Conversation

XDapps
Copy link
Collaborator

@XDapps XDapps commented Oct 13, 2024

Ticket

Updated current Referee to be compatible with time based rewards.

  1. Updated Referee9 to use Referee Calculations for emissions calculation based on time between challenges.
  2. Added Referee10 to retain logic for Bulk Submissions.
  3. Updated Node License & Pool Factory Contract Upgrades to point at Referee10.

Testing: tests updated and passing in this PR #456 which should be merged into this branch before this PR is Approved/Merged.

Copy link
Collaborator

@CryptITAustria CryptITAustria left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test helper function in Referee9 need to be commented out, the rest is ready to merge.

Comment on lines 860 to 914
function updateMaxStakePerLicense(uint256 newAmount) external onlyRole(DEFAULT_ADMIN_ROLE) {
require(newAmount != 0, "31");
uint256 prevAmount = maxStakeAmountPerLicense;
maxStakeAmountPerLicense = newAmount;
emit UpdateMaxStakeAmount(prevAmount, newAmount);
}

/**
* @dev Admin update the maximum number of NodeLicense staked in a pool
* @param newAmount The new maximum amount per NodeLicense
*/
function updateMaxKeysPerPool(uint256 newAmount) external onlyRole(DEFAULT_ADMIN_ROLE) {
require(newAmount != 0, "32");
uint256 prevAmount = maxKeysPerPool;
maxKeysPerPool = newAmount;
emit UpdateMaxKeysPerPool(prevAmount, newAmount);
}

/**
* @dev Admin update the tier thresholds and the corresponding reward chance boost
* @param index The index if the tier to update
* @param newThreshold The new threshold of the tier
* @param newBoostFactor The new boost factor for the tier
*/
function updateStakingTier(uint256 index, uint256 newThreshold, uint256 newBoostFactor) external onlyRole(DEFAULT_ADMIN_ROLE) {

require(newBoostFactor > 0 && newBoostFactor <= 10000, "33");

uint256 lastIndex = stakeAmountTierThresholds.length - 1;
if (index == 0) {
require(stakeAmountTierThresholds[1] > newThreshold, "34");
} else if (index == lastIndex) {
require(stakeAmountTierThresholds[lastIndex - 1] < newThreshold, "35");
} else {
require(stakeAmountTierThresholds[index + 1] > newThreshold && stakeAmountTierThresholds[index - 1] < newThreshold, "36");
}

stakeAmountTierThresholds[index] = newThreshold;
stakeAmountBoostFactors[index] = newBoostFactor;
}

/**
* @dev Admin add a new staking tier to the end of the tier array
* @param newThreshold The new threshold of the tier
* @param newBoostFactor The new boost factor for the tier
*/
function addStakingTier(uint256 newThreshold, uint256 newBoostFactor) external onlyRole(DEFAULT_ADMIN_ROLE) {
require(newBoostFactor > 0 && newBoostFactor <= 10000, "37");

uint256 lastIndex = stakeAmountTierThresholds.length - 1;
require(stakeAmountTierThresholds[lastIndex] < newThreshold, "38");

stakeAmountTierThresholds.push(newThreshold);
stakeAmountBoostFactors.push(newBoostFactor);
}
Copy link
Collaborator

@CryptITAustria CryptITAustria Oct 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need them in version 9 do we ?

Copy link
Collaborator Author

@XDapps XDapps Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These have been removed, however, I do need the other PR #456 to be reviewed/approved and merged into this branch before converting this from Draft

Comment on lines 1122 to 1005
// Leaving these functions in the contract for test coverage purposes
// In the future these can be removed if size becomes an issue
function toggleAssertionChecking() public {
isCheckingAssertions = !isCheckingAssertions;
emit AssertionCheckingToggled(isCheckingAssertions);
}

//TEST FUNCTION this is used only for test coverage
// function setRollupAddress(address newRollupAddress) public {
// rollupAddress = newRollupAddress;
// emit RollupAddressChanged(newRollupAddress);
// }
} No newline at end of file
function setRollupAddress(address newRollupAddress) public {
rollupAddress = newRollupAddress;
emit RollupAddressChanged(newRollupAddress);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These need to be commented out in version 9 too !

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we comment these out if we can fit them in the contract size?

We can always still remove in the future, but this would allow us to run the tests without having to manually uncomment every time?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we leave them they need restricted access control.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These have been removed. Once the test case PR is approved, I can merge it into this branch before merging this into develop.

@XDapps XDapps marked this pull request as ready for review October 17, 2024 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants