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

fix: Refactor Arbitrum_Adapter #214

Merged
merged 13 commits into from
Dec 23, 2022
Merged

fix: Refactor Arbitrum_Adapter #214

merged 13 commits into from
Dec 23, 2022

Conversation

nicholaspai
Copy link
Member

@nicholaspai nicholaspai commented Dec 21, 2022

We realized that we haven't updated the arbitrum adapter to use outboundTransferCustomRefund so this cleans up the adapter before updating it

We have noticed in practice that `outboundTransferCustomRefund` seems to be crediting the `to` address with the gas refund rather than the `l2RefundAddress`. While `outboundTransfer` at least refunds the caller's (aliased) address which means funds are recoverable
@nicholaspai nicholaspai requested review from mrice32 and pxrl December 21, 2022 20:28
@@ -64,10 +54,6 @@ contract Arbitrum_Adapter is AdapterInterface {
// L2 Gas price bid for immediate L2 execution attempt (queryable via standard eth*gasPrice RPC)
uint256 public immutable l2GasPrice = 5e9; // 5 gWei

// Gas limit for immediate L2 execution attempt (can be estimated via NodeInterface.estimateRetryableTicket).
// NodeInterface precompile interface exists at L2 address 0x00000000000000000000000000000000000000C8
uint32 public immutable l2GasLimit = 2_000_000;
Copy link
Member Author

Choose a reason for hiding this comment

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

Gas limit for sending tokens should be a lot lower than for sending messages

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: any reason not to make these both constants rather than hardcoding them?

Copy link
Member Author

Choose a reason for hiding this comment

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

you mean instead of uint256 public immutable do uint256 public constant? Is that a gas savings?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, yeah, that too (constant is better than immutable!), but I just meant giving them names, which you did!

Copy link
Contributor

@mrice32 mrice32 left a comment

Choose a reason for hiding this comment

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

Looks great! Each refund is pretty small, so I think we should wait to hear back from arbitrum so we understand what's going on before making any changes in production.

@@ -64,10 +54,6 @@ contract Arbitrum_Adapter is AdapterInterface {
// L2 Gas price bid for immediate L2 execution attempt (queryable via standard eth*gasPrice RPC)
uint256 public immutable l2GasPrice = 5e9; // 5 gWei

// Gas limit for immediate L2 execution attempt (can be estimated via NodeInterface.estimateRetryableTicket).
// NodeInterface precompile interface exists at L2 address 0x00000000000000000000000000000000000000C8
uint32 public immutable l2GasLimit = 2_000_000;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: any reason not to make these both constants rather than hardcoding them?

// refund address. This means that the excess ETH to pay for the L2 transaction will be sent to the aliased
// contract address on L2, which we'd have to retrieve via a custom adapter
// (i.e. the Arbitrum_RescueAdapter).
l1ERC20GatewayRouter.outboundTransfer{ value: requiredL1CallValue }(
Copy link
Contributor

Choose a reason for hiding this comment

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

Just double checking -- we have a confirmed DAI transfer where we see the refund working correctly (i.e. going to the hub pool alias address rather than the spoke pool)?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes i confirmed it by checking the hub pool alias ETH balance the blockbefore and after the DAI transfer

data
);
}
// Excess funds will be sent to this contract's aliased arbitrum address.
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 logic identical to the logic that was here in the initial version of this adapter? I want to make sure we're really tight on what's being changed in these adapters since this code would be running in the HubPool context.

Copy link
Member Author

Choose a reason for hiding this comment

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

yep exactly the same

Copy link
Member Author

Choose a reason for hiding this comment

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

ive checked against on-chain verified contract code here

@nicholaspai nicholaspai requested a review from mrice32 December 21, 2022 23:32
Copy link
Contributor

@mrice32 mrice32 left a comment

Choose a reason for hiding this comment

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

LGTM! As with the prev comment: #214 (review), I think we should wait to hear back before moving forward with any modifications.

Copy link
Contributor

@mrice32 mrice32 left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -64,10 +54,6 @@ contract Arbitrum_Adapter is AdapterInterface {
// L2 Gas price bid for immediate L2 execution attempt (queryable via standard eth*gasPrice RPC)
uint256 public immutable l2GasPrice = 5e9; // 5 gWei

// Gas limit for immediate L2 execution attempt (can be estimated via NodeInterface.estimateRetryableTicket).
// NodeInterface precompile interface exists at L2 address 0x00000000000000000000000000000000000000C8
uint32 public immutable l2GasLimit = 2_000_000;
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, yeah, that too (constant is better than immutable!), but I just meant giving them names, which you did!

@nicholaspai nicholaspai changed the title fix: Revert use of outboundTransferCustomRefund fix: Refactor Arbitrum_Adapter Dec 22, 2022
@nicholaspai nicholaspai merged commit 44a80dc into master Dec 23, 2022
@nicholaspai nicholaspai deleted the npai/arbitrumadapter branch December 23, 2022 15:41
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