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

feat: added OWR pectra v0.1 #145

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

feat: added OWR pectra v0.1 #145

wants to merge 6 commits into from

Conversation

cosminobol
Copy link
Contributor

No description provided.


(bool ret,) = pectraConsolidationAddress.call{value: msg.value}(abi.encodePacked(source, target));
if (!ret) revert InvalidConsolidation_Failed();
emit ConsolidationRequested(msg.sender);
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's add source and destination pubkeys too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean ? Isn't the source and destination the pubKeys already?

src/owr/OptimisticWithdrawalRecipientPectra.sol Outdated Show resolved Hide resolved
/// Requests principal withdrawal
function requestPrincipalWithdrawal(bytes memory pubkey, uint8 amount) external payable onlyOwnerOrRoles(PRINCIPAL_WITHDRAWAL_ROLE) {
_requestWithdrawal(pubkey, amount, false);
emit PrincipalWithdrawalRequested(msg.sender);
Copy link
Collaborator

Choose a reason for hiding this comment

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

lets include amount here

}

/// Requests principal withdrawal
function requestPrincipalWithdrawal(bytes memory pubkey, uint8 amount) external payable onlyOwnerOrRoles(PRINCIPAL_WITHDRAWAL_ROLE) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this be an array given that multiple validators will use a OWR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can add a batchRequest method as well. For both, principal and rewards

Copy link
Contributor

@OisinKyne OisinKyne left a comment

Choose a reason for hiding this comment

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

Want to have a think about the contract name, and the name of the two system contracts. Concern about a uint8 knocking around. Think we potentially may need to get smart around the value handling aspect, to ensure we have enough msg.value to pay the basefee, but also don't overpay or get the eth stuck.

Let me know if the feedback is unclear :)

Comment on lines +93 to +94
address public immutable pectraWithdrawalAddress;
address public immutable pectraConsolidationAddress;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
address public immutable pectraWithdrawalAddress;
address public immutable pectraConsolidationAddress;
address public immutable executionLayerWithdrawalSystemContract;
address public immutable consolidationSystemContract;

People won't remember these by the hardfork they come in with. TBH we might come up with a better name for the contract too.

Comment on lines +164 to +165
// solhint-disable-next-line no-empty-blocks
/// clone implementation doesn't use constructor
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// solhint-disable-next-line no-empty-blocks
/// clone implementation doesn't use constructor
/// Sets the system contract addresses for execution layer withdrawals and consolidations.


/// emit event when receiving ETH
/// @dev implemented w/i clone bytecode
/* receive() external payable { */
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/* receive() external payable { */
/* receive() external payable { */

Do we not want this address to be payable? I see its commented in OWR too. Certainly no need to emit an event. But wonder would people try and transfer eth to this contract, maybe not having a payable receive or fallback prevents that, idk.

// ;; +--------+--------+
// ;; 48 48

(bool ret,) = pectraConsolidationAddress.call{value: msg.value}(abi.encodePacked(source, target));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
(bool ret,) = pectraConsolidationAddress.call{value: msg.value}(abi.encodePacked(source, target));
(bool ret,) = pectraConsolidationAddress.call{value: msg.value}(abi.encodePacked(source, target));

Its interesting that the fee will have to be passed as a value to the call, not as like gas costs. This might make it difficult to predict. Does the method return value if we overpay? it doesn't look like it to me. https://github.com/lightclient/sys-asm/blob/main/src/consolidations/main.eas#L51

So maybe we should do a read request of the fee (i think that's possible looking at the assembly), then send only that as msg.value? and then return the remainder to the caller?


import "forge-std/console.sol";

contract PectraWithdrawalMock {
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to other places, maybe this should be called an ExecutionLayerWithdrawalSystemContractMock

// +--------+--------+
// | pubkey | amount |
// +--------+--------+
// 48 8
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a stupid question but, are these measured in bits or bytes?

Because uint8, is 8 bits, representing a max number of 255. but is bytes memory pubkey also measured in bits? or is it measured in bytes? A validator pubkey is 96 hex chars, or 48 byte chars, or 384 bits.

Should amount be a uint64? which is 8*8bytes. That seems to make more sense for an amount to withdraw than a number from 0-> 255

Comment on lines +434 to +440
if (
(!_rewards && amount < BALANCE_CLASSIFICATION_THRESHOLD)
|| (_rewards && amount >= BALANCE_CLASSIFICATION_THRESHOLD)
) {
if (_rewards) revert InvalidPectraWithdrawal_Rewards();
else revert InvalidPectraWithdrawal_Principal();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What are we trying to achieve here? I feel like this could be simplified, I have a hard time parsing it with an if(and or and)(if/else).

/// @author Obol
/// @notice A factory contract for cheaply deploying
/// OptimisticWithdrawalRecipientPectra.
/// @dev This contract uses token = address(0) to refer to ETH.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// @dev This contract uses token = address(0) to refer to ETH.

This is a stale comment from when the OWRs supported erc20s, and native eth was indicated by using address(0) for the token address, right?

owr = OptimisticWithdrawalRecipientPectra(address(owrImpl).clone(data));
owr.initialize(owner);

emit CreateOWRecipient(address(owr), recoveryAddress, principalRecipient, rewardRecipient, amountOfPrincipalStake);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we log the owner? (how many things can we include in a log? i thought it was 4, 3 if named, but this has 5 and I'm suggesting a 6th

/// based on threshold to it's recipients
/// @dev Only ETH can be distributed for a given deployment. There is a
/// recovery method for tokens sent by accident.
contract OptimisticWithdrawalRecipientPectra is Clone, OwnableRoles {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
contract OptimisticWithdrawalRecipientPectra is Clone, OwnableRoles {
contract ControllableWithdrawalRecipient is Clone, OwnableRoles {
Suggested change
contract OptimisticWithdrawalRecipientPectra is Clone, OwnableRoles {
contract EditableWithdrawalRecipient is Clone, OwnableRoles {
Suggested change
contract OptimisticWithdrawalRecipientPectra is Clone, OwnableRoles {
contract ControllableOptimisticWithdrawalRecipient is Clone, OwnableRoles {

Trying to decide on what name might make the most sense, not convinced people will remember these features by the hardfork they are introduced in. Want to keep the withdrawal recipient suffix. Probably should keep the optimistic piece, to indicate that it optimistically assumes rewards are rewards not worst case slashing. Hoping to incorporate the 'exitable' and 'editable' aspects potentially.

Have a think and maybe run by me what option we go with before you make the changes.

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.

3 participants