feat: Polygon ZKevm v2 hook and ism#4547
feat: Polygon ZKevm v2 hook and ism#4547iamzubin wants to merge 6 commits intohyperlane-xyz:mainfrom
Conversation
|
| * @notice Message hook to inform the {Polygon zkEVM chain Ism} of messages published through | ||
| * the native Polygon zkEVM bridge bridge. | ||
| */ | ||
| contract PolygonZkevmHook is IPostDispatchHook, MailboxClient { |
There was a problem hiding this comment.
can you inherit from AbstractMessageIdAuthHook here, it'll mean less code duplication?
| bytes calldata, | ||
| bytes calldata | ||
| ) external pure override returns (uint256) { | ||
| return 0; |
There was a problem hiding this comment.
But I imagine there's still some additional overhead for the relayer to submit the tx on the destination chain. You can follow using a childHook which is effectively an IGP:
aroralanuk
left a comment
There was a problem hiding this comment.
It's a good start, take a look at the comments. It'll be easier to separate this into two PRs for v1 and v2.
| ); | ||
| bytes32 messageId = message.id(); | ||
|
|
||
| zkEvmBridge.bridgeMessage{value: msg.value}( |
There was a problem hiding this comment.
Only send the metadata.msgValue(0) and refund the rest
| * @notice Message hook to inform the {Polygon zkEVM chain Ism} of messages published through | ||
| * the native Polygon zkEVM bridge bridge. | ||
| */ | ||
| contract PolygonZkevmV2Hook is IPostDispatchHook, MailboxClient { |
There was a problem hiding this comment.
inherit from AbstractMessageIdAuthHook here instead too
| "PolygonzkEVMv2Hook: invalid destination domain" | ||
| ); | ||
| require( | ||
| _zkEvmBridgeDestinationNetId <= 1, |
There was a problem hiding this comment.
this can only be 0 or 1 then?
| bytes calldata | ||
| ) external view override returns (uint256) { | ||
| return | ||
| interchainGasPaymaster.quoteGasPayment( |
| bytes calldata _message | ||
| ) external payable override { | ||
| bytes32 messageId = keccak256(_message); | ||
| uint256 gasPayment = interchainGasPaymaster.quoteGasPayment( |
There was a problem hiding this comment.
childHook.quoteDispatch()
| VERIFIED_MASK_INDEX | ||
| ); | ||
| if (_msgValue > 0) { | ||
| verifiedMessages[messageId] -= _msgValue; |
There was a problem hiding this comment.
send extra msgValue (via the metadata) so we don't have leftover here
| * @dev off-chain verification information for a given message. | ||
| * @param _message The message for which off-chain verification information is requested. | ||
| */ | ||
| function getOffchainVerifyInfo( |
There was a problem hiding this comment.
why do we need CCIP here, the relayer will be calling the verify function, no?
There was a problem hiding this comment.
maybe helpful to make a quick mermaid diagram.
There was a problem hiding this comment.
@curlypoint did make a diagram for v1, v2 also follows similar flow.
There was a problem hiding this comment.
yeah, that's something that was needed to be discussed as bridge needs to generate a proof to claim. the ccip call was for the hyperlane relayer to get that proof using PolygonZKevm api (tho that does not follow the ccip spec.
| * @notice Polygon zkEVM chain Ism that uses the Polygon zkEVM bridge to verify messages | ||
| */ | ||
| contract PolygonZkevmV2Ism is | ||
| ICcipReadIsm, |
| * @inheritdoc AbstractMessageIdAuthorizedIsm | ||
| */ | ||
| function _isAuthorized() internal view override returns (bool) { | ||
| bytes32 originSender = abi.decode(msg.data[4:], (bytes32)); |
There was a problem hiding this comment.
don't we need to access control msg.sender since msg.data[4:] can be arbitrarily set by the caller?
| @@ -0,0 +1,25 @@ | |||
| // SPDX-License-Identifier: MIT OR Apache-2.0 | |||
There was a problem hiding this comment.
we already have TestInterchainGasPaymaster
Description
This PR adds a hook and ISM contract for Polygon's zkEVM v2 bridge.
The contracts tap into the Polygon zkEVM bridge to ensure cross-chain messages come from a trusted source. This works by using the zkEVM bridge's exit nodes, which handle verifying the message integrity.
This PR also includes code from PR #3136
PR for docs : PR 40
Drive-by changes
None
Related issues
Fixes #2848
Backward compatibility
Yes