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

Solid IStakingModule interface #574

Conversation

Psirex
Copy link
Contributor

@Psirex Psirex commented Feb 8, 2023

Main changes in the IStakingModule interface:

  • Solidity's structs are used for return values. In the contracts with the 0.4.24 Solidity version returned struct is encoded using assembly. (Back to tuples)
  • the __Keys__ suffix in the method and variable names was removed.

activeValidatorsKeysCount = depositedSigningKeysCount - exitedValidatorsCount;
readyToDepositValidatorsKeysCount = vettedSigningKeysCount - depositedSigningKeysCount;
bytes memory validatorsReportEncoded = abi.encode(
uint256(totalSigningKeysStats.exitedSigningKeysCount),
Copy link
Member

Choose a reason for hiding this comment

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

the cast is prob not needed here as ABI encoder pads anything to 32 bytes anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the encoding a bit. Now it just returns the struct from the memory instead of slicing it from the abi.encode() result.

// uint256 totalStuck;
// uint256 totalRefunded;
// uint256 targetLimit;
// uint256 excessCount;
Copy link
Member

Choose a reason for hiding this comment

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

what is excessCount? can it be calc from the other values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a new field introduced by #557 PR. According to the description: "excess validators count for operator that will be forced to exit"

Copy link
Member

Choose a reason for hiding this comment

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

I thought it's done via targetLimit, prob I'm misunderstanding smth

// struct ValidatorsReport {
// uint256 totalExited;
// uint256 totalDeposited;
// uint256 totalVetted;
Copy link
Member

Choose a reason for hiding this comment

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

I see an inconsistency in naming totalVetted vs targetLimit. maybe currentLimit and targetLimit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Such naming was introduced in the #557 PR and was preserved for consistency.

0 // targetLimit
);
assembly {
return(add(validatorsReportEncoded, 32), mul(32, 7))
Copy link
Member

Choose a reason for hiding this comment

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

a comment explaining the magic is needed here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comment with an explanation of what data is returned

0 // targetLimit
);
assembly {
return(add(validatorsReportEncoded, 32), mul(32, 7))
Copy link
Member

Choose a reason for hiding this comment

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

a comment explaining the magic is needed here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comment with an explanation of what data is returned

/// 4. a node operator was activated/deactivated
function getValidatorsKeysNonce() external view returns (uint256) {
/// 5. a node operator's validator(s) is used for the deposit
function getDepositsDataNonce() external view returns (uint256) {
Copy link
Member

Choose a reason for hiding this comment

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

the commonly used term is "deposit data", in the singular form

Copy link
Member

Choose a reason for hiding this comment

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

I'd rename to getDepositNonce()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to getDepositNonce()

/// 1. a node operator's key(s) is added
/// 2. a node operator's key(s) is removed
/// 3. a node operator's ready to deposit keys count is changed
/// 1. a node operator's validator(s) is added
Copy link
Member

Choose a reason for hiding this comment

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

validator => deposit data

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@Psirex Psirex marked this pull request as ready for review February 9, 2023 03:23
/// 5. a node operator's key(s) is used for the deposit
function getValidatorsKeysNonce() external view returns (uint256);
/// 5. a node operator's deposit data is used for the deposit
function getDepositNonce() external view returns (uint256);
Copy link
Member

Choose a reason for hiding this comment

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

getNonce()

Copy link
Member

Choose a reason for hiding this comment

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

Nonce MUST change in any changes in validator deposit data set

uint256 totalExited;
uint256 totalDeposited;
uint256 totalVetted;
uint256 totalStuck;
Copy link
Member

Choose a reason for hiding this comment

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

stuck

uint256 totalDeposited;
uint256 totalVetted;
uint256 totalStuck;
uint256 totalRefunded;
Copy link
Member

Choose a reason for hiding this comment

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

refunded

uint256 totalStuck;
uint256 totalRefunded;
uint256 targetLimit;
uint256 excessCount;
Copy link
Member

Choose a reason for hiding this comment

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

overlimit?

Copy link
Member

Choose a reason for hiding this comment

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

I thought it's over-limit but from what I've been told it cannot be calculated as deposited - targetLimit (which the overLimit name would imply). and if I'm wrong and it can I'd remove the field altogether

/// @return number of exited validators across all node operators
function updateExitedValidatorsKeysCount(
function updateExitedValidatorsCount(
Copy link
Member

Choose a reason for hiding this comment

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

also add updateRefundedValidators

/// @notice Called by StakingRouter after oracle finishes updating exited keys counts for all operators.
function finishUpdatingExitedValidatorsKeysCount() external;
/// @notice Called by StakingRouter after oracle finishes updating exited validators counts for all operators.
function finishUpdatingExitedValidatorsCount() external;
Copy link
Member

Choose a reason for hiding this comment

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

finishUpdatingNodeOperatorsData()
onNodeOperatorsDataFinalized()

/// @notice Invalidates all unused validators keys for all node operators
function invalidateReadyToDepositKeys() external;
/// @notice Invalidates all unused validators for all node operators
function invalidateDepositData() external;
Copy link
Member

Choose a reason for hiding this comment

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

rename somehow

bytes memory signatures
);

event DepositNonceChanged(uint256 depositNonce);
Copy link
Member

Choose a reason for hiding this comment

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

event StakingModuleNonceChanged(uint256 depositNonce);

struct ValidatorsReport {
uint256 totalExited;
uint256 totalDeposited;
uint256 totalVetted;
Copy link
Member

Choose a reason for hiding this comment

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

depositable

Copy link
Member

@skozin skozin Feb 9, 2023

Choose a reason for hiding this comment

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

that's not correct, though. a key that's already deposited is counted towards totalVetted but is not depositable

/// @param _refundedValidatorsCount New number of refunded validators of the node operator
function updateRefundedValidatorsCount(uint256 _nodeOperatorId, uint256 _refundedValidatorsCount) external {
_onlyExistedNodeOperator(_nodeOperatorId);
_auth(STAKING_ROUTER_ROLE);
Copy link
Contributor

Choose a reason for hiding this comment

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

need a lever from StakingRouter

@@ -507,7 +505,8 @@ contract NodeOperatorsRegistry is AragonApp, Versioned {
emit RefundedValidatorsCountChanged(_nodeOperatorId, _refundedValidatorsCount);
}

function invalidateReadyToDepositKeys() external {
/// @notice Invalidates all unused validators for all node operators
function onWithdrawalCredentialsChanged() external {
uint256 operatorsCount = getNodeOperatorsCount();
if (operatorsCount > 0) {
invalidateReadyToDepositKeysRange(0, operatorsCount - 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

DepositData?


// FIXME: get current value from the staking module
uint256 nodeOpStuckKeysCount;
(,,uint256 stuckValidatorsCount,,,uint256 totalExitedValidatorsCount,,) =
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add /* varName */ placeholders

Copy link
Contributor

@TheDZhon TheDZhon left a comment

Choose a reason for hiding this comment

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

hooray 👍

@TheDZhon TheDZhon merged commit f34273c into feature/shapella-upgrade Feb 10, 2023
@TheDZhon TheDZhon deleted the feature/shapella-upgrade-staking-module-interface branch February 10, 2023 15:01
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.

4 participants