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

263 go over smart contracts functions and review things #77

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions contracts/HydraChain/HydraChain.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ contract HydraChain is
using ArraysUpgradeable for uint256[];

uint256 public currentEpochId;
/// @notice Epoch data linked with the epoch id
mapping(uint256 => Epoch) public epochs;
/// @notice Array with epoch ending blocks
uint256[] public epochEndBlocks;
/// @notice Epoch data linked with the epoch id
mapping(uint256 => Epoch) public epochs;

mapping(uint256 => uint256) internal _commitBlockNumbers;

Expand Down Expand Up @@ -112,8 +112,8 @@ contract HydraChain is
}

epochs[newEpochId] = epoch;
_commitBlockNumbers[newEpochId] = block.number;
epochEndBlocks.push(epoch.endBlock);
_commitBlockNumbers[newEpochId] = block.number;

// Update participations
uint256 uptimesCount = uptime.length;
Expand All @@ -140,12 +140,12 @@ contract HydraChain is
uint256 withdrawableRewards,
uint256 votingPower,
ValidatorStatus status,
bool isbanInitiated
bool isBanInitiated
)
{
(blsKey, stake, totalStake, commission, withdrawableRewards, status) = _getValidator(validatorAddress);
votingPower = validatorPower[validatorAddress];
isbanInitiated = bansInitiated[validatorAddress] != 0;
isBanInitiated = bansInitiated[validatorAddress] != 0;
}

// _______________ Public functions _______________
Expand Down
3 changes: 2 additions & 1 deletion contracts/HydraChain/IHydraChain.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ interface IHydraChain is IInspector, IValidatorManager, IDaoIncentive, IValidato
* @return withdrawableRewards withdrawable rewards
* @return votingPower voting power of the validator
* @return status status of the validator
* @return isBanInitiated is ban initiated for validator
*/
function getValidator(
address validator
Expand All @@ -71,6 +72,6 @@ interface IHydraChain is IInspector, IValidatorManager, IDaoIncentive, IValidato
uint256 withdrawableRewards,
uint256 votingPower,
ValidatorStatus status,
bool isbanInitiated
bool isBanInitiated
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ abstract contract AccessControl is IAccessControl, Ownable2StepUpgradeable {

// _______________ Initializer _______________

// TODO: We must be able to enable/disable this feature
// solhint-disable-next-line func-name-mixedcase
function __AccessControl_init(address _governance) internal onlyInitializing {
__AccessControl_init_unchained(_governance);
Expand Down
4 changes: 2 additions & 2 deletions contracts/HydraChain/modules/DaoIncentive/DaoIncentive.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ abstract contract DaoIncentive is
RewardWalletConnector,
HydraStakingConnector
{
address public daoIncentiveVaultAddr;
uint256 public lastDistribution;
Vitomir2 marked this conversation as resolved.
Show resolved Hide resolved
SamBorisov marked this conversation as resolved.
Show resolved Hide resolved
uint256 public vaultDistribution;
uint256 public lastDistribution; // timestamp of the last distribution
address public daoIncentiveVaultAddr;

// _______________ Initializer _______________

Expand Down
4 changes: 2 additions & 2 deletions contracts/HydraChain/modules/Inspector/Inspector.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ abstract contract Inspector is IInspector, ValidatorManager {

// solhint-disable-next-line func-name-mixedcase
function __Inspector_init_unchained() internal onlyInitializing {
initiateBanThreshold = 18000; // in blocks => 1 hour minimum
validatorPenalty = 700 ether;
reporterReward = 300 ether;
banThreshold = 24 hours;
initiateBanThreshold = 18000; // in blocks => 1 hour minimum
}

// _______________ Modifiers _______________
Expand Down Expand Up @@ -68,8 +68,8 @@ abstract contract Inspector is IInspector, ValidatorManager {
}

bansInitiated[msg.sender] = 0;
hydraStakingContract.recoverEjectedValidator(msg.sender);
_updateParticipation(msg.sender);
hydraStakingContract.recoverEjectedValidator(msg.sender);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ interface IValidatorManager {
event NewValidator(address indexed validator, uint256[4] blsKey);
event PowerExponentUpdated(uint256 newPowerExponent);

error InvalidSignature(address signer);
error MaxValidatorsReached();
error InvalidCommission(uint256 commission);
error InvalidPowerExponent();
error InvalidSignature(address signer);

/**
* @notice Retruns bool indicating if validator is Active.
Expand Down
54 changes: 28 additions & 26 deletions contracts/HydraDelegation/IDelegation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,39 @@ interface IDelegation is IWithdrawal {

error InvalidMinDelegation();

/**
* @notice Changes the minimum delegation amount
* @dev Only callable by the admin
* @param newMinDelegation New minimum delegation amount
*/
function changeMinDelegation(uint256 newMinDelegation) external;
SamBorisov marked this conversation as resolved.
Show resolved Hide resolved

/**
* @notice Returns the total delegation amount
*/
function totalDelegation() external view returns (uint256);

/**
* @notice Claims rewards for delegator for staker
* @param staker Address of the validator
*/
function claimDelegatorReward(address staker) external;
Vitomir2 marked this conversation as resolved.
Show resolved Hide resolved

/**
* @notice Undelegates amount from staker for sender and claims rewards.
* @param staker Validator to undelegate from
* @param amount The amount to undelegate
*/
function undelegate(address staker, uint256 amount) external;

// _______________ Public functions _______________

/**
* @notice Delegates sent amount to staker and claims rewards.
* @param staker Validator to delegate to
*/
function delegate(address staker) external payable;

/**
* @notice Returns the total amount of delegation for a staker
* @param staker Address of the validator
Expand Down Expand Up @@ -44,30 +72,4 @@ interface IDelegation is IWithdrawal {
* @return Delegator's unclaimed rewards per staker (in HYDRA wei)
*/
function getDelegatorReward(address staker, address delegator) external view returns (uint256);

/**
* @notice Delegates sent amount to staker and claims rewards.
* @param staker Validator to delegate to
*/
function delegate(address staker) external payable;

/**
* @notice Undelegates amount from staker for sender and claims rewards.
* @param staker Validator to undelegate from
* @param amount The amount to undelegate
*/
function undelegate(address staker, uint256 amount) external;

/**
* @notice Claims rewards for delegator for staker
* @param staker Address of the validator
*/
function claimDelegatorReward(address staker) external;

/**
* @notice Changes the minimum delegation amount
* @dev Only callable by the admin
* @param newMinDelegation New minimum delegation amount
*/
function changeMinDelegation(uint256 newMinDelegation) external;
}
Loading
Loading