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: OWR V2 #153

Open
wants to merge 12 commits into
base: release/v0.2
Choose a base branch
from
Open

feat: OWR V2 #153

wants to merge 12 commits into from

Conversation

pinebit
Copy link
Contributor

@pinebit pinebit commented Jan 22, 2025

Summary

In according to the design doc we reviewed internally, introduced the new version of OWR contracts that respect Pectra changes.

Details

Please refer to the internal design doc for further details.

Note: most of the existing code has been copied from V1 (audited version) and remained intact as it has been audited and tested already.

How to test it

forge test

ticket: #152

@pinebit pinebit requested a review from OisinKyne January 22, 2025 13:55
@@ -158,16 +158,17 @@ contract ObolLidoSplitTest is ObolLidoSplitTestHelper, Test {

function testFuzz_CanDistributeWithFee(
address anotherSplit,
uint256 amountToDistribute,
uint8 amountToDistributeEth,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fuzzing was failing for this test reliably, hence reduced the ranges.

Copy link
Contributor

Choose a reason for hiding this comment

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

is 8bit very low if this is measured in wei? We should maybe figure out if there could actuall be something amiss at like <=uint96. not worried about uint256.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is in ETH. We multiply it below uint256(amountToDistributeEth) * 1 ether;.

@pinebit pinebit marked this pull request as ready for review January 23, 2025 07:47
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.

Looking great so far!

Then main question that arises for me is whether/why is there not an issue with storage variable layouts with the clone with immutable args behaviour. Everything else is mostly nits, tweaks, or questions for my understanding.

src/owr/OptimisticWithdrawalRecipientV2Factory.sol Outdated Show resolved Hide resolved
src/owr/OptimisticWithdrawalRecipientV2Factory.sol Outdated Show resolved Hide resolved
/// principal recipient (multiple of 32 ETH)
/// (reward recipient has no threshold & receives all residual flows)
/// it cannot be greater than uint96
/// @param owner Owner of the new OptimisticWithdrawalRecipientV2 clone
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 say this address is the admin for the rbac system? (is that the case even or is there a roleAdmin role?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The term corresponds to onlyOwnerOrRoles attribute logic and OwnableRoles design which is not under our control. It is sort of Admin role but without explicitly defined "ADMIN_ROLE".

@@ -158,16 +158,17 @@ contract ObolLidoSplitTest is ObolLidoSplitTestHelper, Test {

function testFuzz_CanDistributeWithFee(
address anotherSplit,
uint256 amountToDistribute,
uint8 amountToDistributeEth,
Copy link
Contributor

Choose a reason for hiding this comment

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

is 8bit very low if this is measured in wei? We should maybe figure out if there could actuall be something amiss at like <=uint96. not worried about uint256.

src/owr/OptimisticWithdrawalRecipientV2.sol Outdated Show resolved Hide resolved
// +--------+--------+
// | 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.

Okay if this is official and amounts are only 64 bit, maybe they're not wei? and disregard my other comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like the amount is in GWEI
Sample withdrawal tx: https://explorer.pectra-devnet-5.ethpandaops.io/tx/0xcae1a4da5202658d57ae5daca8cfa1afb24200f3d70aa62747228706026929dc?tab=index
1 ETH is encoded as 0x000000003b9aca00, so it must be GWEI...

Copy link
Contributor

@OisinKyne OisinKyne Jan 24, 2025

Choose a reason for hiding this comment

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

okay, if i'm not mistaken, the EVM native eth is handled in wei, we might want to be careful as we manage the two variations (or at least flag explicitly on the @ dev docs that requestWithdrawals is in gwei as opposed to wei.

Comment on lines +7 to +11
contract OWRV2Reentrancy is Test {
receive() external payable {
if (address(this).balance <= 1 ether) OptimisticWithdrawalRecipientV2(msg.sender).distributeFunds();
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a test to see what happens during re-entrancy, or is there a non-re-entrant modifier i didn't spot somewhere? I like to be careful of re-entrancy, but hope we can handle it rather than slapping a modifier on things to prevent it :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah it is a test helper, can ignore ^

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The initial test was borrowed from V1 with all necessary helpers adjusted to V2.

src/test/owr/OptimisticWithdrawalRecipientV2.t.sol Outdated Show resolved Hide resolved
}

function testCan_OWRIsPayable() public {
owrETH.distributeFunds{value: 2 ether}();
Copy link
Contributor

Choose a reason for hiding this comment

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

Weird, is this insta-adding and distributing msg.value? I guess it works? 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This part came from V1 test, I did not examine it in details.

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