-
Notifications
You must be signed in to change notification settings - Fork 90
Resolve issues with verifyDeposit and verifyBalances #2622
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
base: nicka/pectra
Are you sure you want to change the base?
Conversation
Added verifyBalancesWithDeposits that can only be called by the staking monitor
…ee proofs verifyDeposit now checks the first pending deposit is not to an exiting validator
Updated Natspec with maths on calculating the gen indexes Removed the staking monitor
Added amountWei to the DepositValidatorExiting event
// Verify the withdrawableEpoch on the validator of the strategy's deposit | ||
IBeaconProofs(BEACON_PROOFS).verifyValidatorWithdrawable( | ||
depositBlockRoot, | ||
validatorData.index, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we verify Index here do we have a need for a separate verifyValidator
function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function could promote a validator from STAKED to VERIFIED and add an entry to verifiedValidators
contracts/contracts/strategies/NativeStaking/CompoundingValidatorManager.sol
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments. Great job on these changes aside from 2 issues I think they are solid
bytes validatorPubKeyProof; | ||
} | ||
|
||
struct DepositValidatorData { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe name this DepositValidatorProofData
@@ -479,6 +493,22 @@ abstract contract CompoundingValidatorManager is Governable { | |||
emit ValidatorVerified(pubKeyHash, validatorIndex); | |||
} | |||
|
|||
struct FirstPendingDepositData { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe name this FirstPendingDepositProofData
contracts/contracts/strategies/NativeStaking/CompoundingValidatorManager.sol
Show resolved
Hide resolved
|
||
// Verify the withdrawableEpoch on the validator of the strategy's deposit | ||
IBeaconProofs(BEACON_PROOFS).verifyValidatorWithdrawable( | ||
depositBlockRoot, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 I think this should be validatorBlockRoot
instead of depositBlockRoot
// Store the exit epoch in the deposit data | ||
deposit.withdrawableEpoch = validatorData.withdrawableEpoch; | ||
|
||
emit DepositValidatorExiting( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super nit: maybe DepositToValidatorExiting
validatorData.pubKeyProof | ||
); | ||
|
||
// If the validator is exiting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment nit: maybe add this is most likely to validator being slashed
// If there are no deposits then we can skip the deposit verification | ||
// This section is after the validator balance verifications so an exited validator will be marked | ||
// as EXITED before the deposits are verified. If there was a deposit to an exited validator | ||
// then the deposit can only be removed once the validator is fully exited. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit comment addition:
... validator is fully exited. The ETH deposited to an exiting validator remains in the beaconState.pendingDeposits
as part of the beacon chain's deposits_to_postpone
array inside which the deposit remains as long as the validator has not fully exited from the beacon chain. Once the validator has fully exited the postponed deposit is credited back to the strategy contract.
// The verification of the validator the first pending deposit is for must be on or after when | ||
// `snapBalances` was called. | ||
require( | ||
balancesMem.timestamp <= validatorVerificationBlockTimestamp, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A thought: what if we remove the validatorVerificationBlockTimestamp
and just calculate it as: balancesMem.timestamp + SLOT_DURATION
. This would impose an extra limitation to verifyBalances
where 3 slots in succession are required to produce a block instead of 2.
// now has to wait until the validator's balance is verified to be zero. | ||
require( | ||
firstPendingDeposit.slot < depositData.slot || | ||
verificationEpoch < depositData.withdrawableEpoch || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 in StakeEth the depositData.withdrawableEpoch
is set to FAR_FUTURE_EPOCH. This means if verify deposit has not been called yet on a withdrawable validator the verificationEpoch < depositData.withdrawableEpoch
check will always be true and make this whole require pass.
I think this require should look like this:
require(
firstPendingDeposit.slot < depositData.slot ||
(
verificationEpoch < depositData.withdrawableEpoch &&
depositData.withdrawableEpoch != FAR_FUTURE_EPOCH
) ||
validatorState[depositData.pubKeyHash] ==
VALIDATOR_STATE.EXITED,
"Deposit likely processed"
);
Changes
verifyDeposit
:verifyBalances
:EXITED
Code Change Checklist
To be completed before internal review begins:
Internal review:
Deploy checklist
Two reviewers complete the following checklist: