-
Notifications
You must be signed in to change notification settings - Fork 370
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
Arb l1 to l2 hook and ISM #3106
base: main
Are you sure you want to change the base?
Conversation
|
function _dispatch() private { | ||
vm.createSelectFork("sepolia"); | ||
vm.startBroadcast(sk); | ||
bytes memory metadata = StandardHookMetadata.formatMetadata( | ||
TEST_MSG_VALUE, | ||
GAS_LIMIT, | ||
sender, | ||
abi.encodePacked(MAX_FEE_PER_GAS) | ||
); | ||
uint256 deposit = ArbitrumOrbitHook(ARBHOOK).quoteDispatch( | ||
metadata, | ||
TEST_MESSAGE | ||
); | ||
IMailbox(MAILBOX).dispatch{ | ||
value: deposit + MAX_FEE_PER_GAS * GAS_LIMIT | ||
}( | ||
ARBITRUM_DOMAIN, | ||
TypeCasts.addressToBytes32(address(testRecipient)), | ||
TEST_MESSAGE, | ||
metadata, | ||
ArbitrumOrbitHook(ARBHOOK) | ||
); | ||
vm.stopBroadcast(); | ||
} |
Check warning
Code scanning / Slither
Unused return Medium
function _dispatch() private { | ||
vm.createSelectFork("sepolia"); | ||
vm.startBroadcast(sk); | ||
bytes memory metadata = StandardHookMetadata.formatMetadata( | ||
TEST_MSG_VALUE, | ||
GAS_LIMIT, | ||
sender, | ||
abi.encodePacked(MAX_FEE_PER_GAS) | ||
); | ||
uint256 deposit = ArbitrumOrbitHook(ARBHOOK).quoteDispatch( | ||
metadata, | ||
TEST_MESSAGE | ||
); | ||
IMailbox(MAILBOX).dispatch{ | ||
value: deposit + MAX_FEE_PER_GAS * GAS_LIMIT | ||
}( | ||
ARBITRUM_DOMAIN, | ||
TypeCasts.addressToBytes32(address(testRecipient)), | ||
TEST_MESSAGE, | ||
metadata, | ||
ArbitrumOrbitHook(ARBHOOK) | ||
); | ||
vm.stopBroadcast(); | ||
} |
Check warning
Code scanning / Slither
Unused return Medium
function run() external { | ||
vm.createSelectFork("sepolia_arb"); | ||
string memory seed = vm.envString("SEEDPHRASE"); | ||
vm.startBroadcast(vm.deriveKey(seed, 0)); | ||
new ArbitrumOrbitIsm(); | ||
vm.stopBroadcast(); | ||
} |
Check warning
Code scanning / Slither
Unused return Medium
function run() external { | ||
vm.createSelectFork("sepolia_arb"); | ||
vm.startBroadcast(sk); | ||
testRecipient = new TestRecipient(); | ||
ArbitrumOrbitIsm(ARBISM).setAuthorizedHook( | ||
TypeCasts.addressToBytes32(ARBHOOK) | ||
); | ||
vm.stopBroadcast(); | ||
_dispatch(); | ||
} |
Check warning
Code scanning / Slither
Unused return Medium
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.
great start! I like how you reused the existing abstractions
* [2:34] msg.value | ||
* [34:66] Gas limit for message | ||
* [66:86] Refund address for message | ||
* [86:117] Max fee per gas (custom) |
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.
it would be good to have a default here otherwise this is quite a breaking change for developers
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.
See comment below.
require( | ||
metadata.msgValue(0) < 2 ** 255, | ||
"ArbitrumOrbitHook: msgValue must be less than 2 ** 255" | ||
); | ||
// To make sure the default value for each meta datum IS NOT used. | ||
require( | ||
metadata.length >= MIN_METADATA_LENGTH, | ||
"ArbitrumOrbitHook: invalid metadata length" | ||
); |
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 wonder if we should just move these checks into the AbstractMessageIdAuthHook
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.
- Agreed, moved msg value check into
AbstractMessageIdAuthHook
and changed the OPStackhook as a drive-by change. - To make UX better, I made max fee per gas an optional metadata, defaulted to use IGP's gas price (like you suggested below) unless user provides max fee per gas through metadata. So the length check shouldn't be needed anymore.
uint256 ticketID = baseInbox.createRetryableTicket{value: msg.value}( | ||
TypeCasts.bytes32ToAddress(ism), | ||
metadata.msgValue(0), | ||
baseInbox.calculateRetryableSubmissionFee(PAYLOAD_LENGTH, 0), |
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.
should PAYLOAD_LENGTH
actually be derived from message.length
?
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.
and can we dedupe this with quoteDispatch
somehow
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.
- Ah if I understand correctly,
PAYLOAD_LENGTH
is always 36 bytes because the payload is theverifyMessageId
call to the ISM: the calldata has 4 bytes for method ID and 32 bytes for message ID. - Deduped, please take a look.
uint256 maxFeePerGas = abi.decode( | ||
metadata.getCustomMetadata(), | ||
(uint256) | ||
); |
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.
the InterchainGasPaymaster
has oracleized gas prices which maybe could be reused here, or added to the "standard metadata" shape
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.
See above.
hey @exp7l - as Yorke shared, this is a great start on a much needed hook. Are you stuck on anything? How can we help? |
@avious00 my apologies, I'm moving these few weeks and got distracted. I should be able to come back to this pr in the coming week. Thanks for the patience. |
Any updates here? |
looking now |
Added some changes and comments above, what do you think? @yorhodes |
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.
almost there, nice work!
hey @exp7l you're pretty close - would be great to push this over the line since a lot of people have been asking |
Co-authored-by: Yorke Rhodes <[email protected]>
This reverts commit 5381ff9 due to misconfigured yarn.lock
Description
fixes #2845:
This implements a hook that calls (L1) Arbitrum's Inbox's
createRetryableTicket
and provides a quoting method for message ID dispatching.This also implements an ISM that mostly follows
OPStackISM
. Specifically, provided the ISM is the message originator (i.e. the address that creates the Retryable ticket on L1), ISM escrows any ETH sent and verifies provided message ID. When relayer relays the message later, the escrowed ETH is released and message is relayed to recipient.Implementation includes deploy scripts for deploying to testnet or any network if you edit the network settings.
Testing
Mailbox
isn't deployed on Arbitrum Sepolia, I didn't try relaying the message. But because the ISM is almost the same asOpStackISM
, the dispatch call test should be enough.solidity/test/isms/ArbitrumOrbitIsm.t.sol