-
Notifications
You must be signed in to change notification settings - Fork 409
fix: add destination base token asset id to bundle #2042
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
Changes from all commits
9aa6a08
b52ff6b
579508f
8444089
1d2971f
2518a85
63d1f8a
d1776cc
7eafa08
7811336
b16795a
bd57aea
2c33e67
15f59d5
687e5c5
1ac68df
6cc63ea
945f9e5
c0c9d7a
2fdae9a
9686aa7
56e963d
59ca009
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,13 +4,13 @@ pragma solidity ^0.8.24; | |
|
|
||
| import {InteroperableAddress} from "../vendor/draft-InteroperableAddress.sol"; | ||
|
|
||
| import {L2_BASE_TOKEN_SYSTEM_CONTRACT, L2_INTEROP_CENTER_ADDR, L2_MESSAGE_VERIFICATION, L2_TO_L1_MESSENGER_SYSTEM_CONTRACT, L2_SYSTEM_CONTEXT_SYSTEM_CONTRACT, L2_COMPLEX_UPGRADER_ADDR} from "../common/l2-helpers/L2ContractInterfaces.sol"; | ||
| import {L2_BASE_TOKEN_SYSTEM_CONTRACT, L2_INTEROP_CENTER_ADDR, L2_NATIVE_TOKEN_VAULT, L2_MESSAGE_VERIFICATION, L2_TO_L1_MESSENGER_SYSTEM_CONTRACT, L2_SYSTEM_CONTEXT_SYSTEM_CONTRACT, L2_COMPLEX_UPGRADER_ADDR} from "../common/l2-helpers/L2ContractInterfaces.sol"; | ||
| import {IInteropHandler} from "./IInteropHandler.sol"; | ||
| import {BUNDLE_IDENTIFIER, INTEROP_BUNDLE_VERSION, INTEROP_CALL_VERSION, BundleStatus, CallStatus, InteropBundle, InteropCall, MessageInclusionProof} from "../common/Messaging.sol"; | ||
| import {IERC7786Recipient} from "./IERC7786Recipient.sol"; | ||
| import {ReentrancyGuard} from "../common/ReentrancyGuard.sol"; | ||
| import {InteropDataEncoding} from "./InteropDataEncoding.sol"; | ||
| import {BundleAlreadyProcessed, CallAlreadyExecuted, CallNotExecutable, CanNotUnbundle, ExecutingNotAllowed, MessageNotIncluded, UnauthorizedMessageSender, UnbundlingNotAllowed, WrongCallStatusLength, WrongDestinationChainId, WrongSourceChainId, InvalidInteropBundleVersion, InvalidInteropCallVersion} from "./InteropErrors.sol"; | ||
| import {BundleAlreadyProcessed, CallAlreadyExecuted, CallNotExecutable, CanNotUnbundle, ExecutingNotAllowed, MessageNotIncluded, UnauthorizedMessageSender, UnbundlingNotAllowed, WrongCallStatusLength, WrongDestinationChainId, WrongDestinationBaseTokenAssetId, WrongSourceChainId, InvalidInteropBundleVersion, InvalidInteropCallVersion} from "./InteropErrors.sol"; | ||
| import {InvalidSelector, Unauthorized} from "../common/L1ContractErrors.sol"; | ||
| import {NotInGatewayMode} from "../core/bridgehub/L1BridgehubErrors.sol"; | ||
|
|
||
|
|
@@ -62,6 +62,13 @@ contract InteropHandler is IInteropHandler, ReentrancyGuard { | |
| WrongDestinationChainId(bundleHash, interopBundle.destinationChainId, block.chainid) | ||
| ); | ||
|
|
||
| // Verify that the destination base token asset ID of the bundle is equal to the base token asset ID of the chain | ||
| bytes32 baseTokenAssetId = L2_NATIVE_TOKEN_VAULT.BASE_TOKEN_ASSET_ID(); | ||
| require( | ||
| interopBundle.destinationBaseTokenAssetId == baseTokenAssetId, | ||
| WrongDestinationBaseTokenAssetId(bundleHash, baseTokenAssetId, interopBundle.destinationBaseTokenAssetId) | ||
| ); | ||
|
|
||
| // If the execution address is not specified then the execution is permissionless. | ||
| if (interopBundle.bundleAttributes.executionAddress.length != 0) { | ||
| (uint256 executionChainId, address executionAddress) = InteroperableAddress.parseEvmV1( | ||
|
|
@@ -137,6 +144,13 @@ contract InteropHandler is IInteropHandler, ReentrancyGuard { | |
| WrongDestinationChainId(bundleHash, interopBundle.destinationChainId, block.chainid) | ||
| ); | ||
|
|
||
| // Verify that the destination base token asset ID of the bundle is equal to the base token asset ID of the chain | ||
| bytes32 baseTokenAssetId = L2_NATIVE_TOKEN_VAULT.BASE_TOKEN_ASSET_ID(); | ||
| require( | ||
| interopBundle.destinationBaseTokenAssetId == baseTokenAssetId, | ||
| WrongDestinationBaseTokenAssetId(bundleHash, baseTokenAssetId, interopBundle.destinationBaseTokenAssetId) | ||
| ); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stylistic, but repeated fromlines 65-70 Moving to a separate function won't add much, as variables will have to be passed, but might remove repetition
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is some level of code duplication on InteropHandler (eg, checks above this one), probably worth to refactor it but imo better to do so on a separate PR. |
||
|
|
||
| // If the bundle was already fully executed or unbundled, we revert stating that it was processed already. | ||
| require(status == BundleStatus.Unreceived, BundleAlreadyProcessed(bundleHash)); | ||
|
|
||
|
|
@@ -150,6 +164,8 @@ contract InteropHandler is IInteropHandler, ReentrancyGuard { | |
| bytes memory _bundle, | ||
| CallStatus[] calldata _providedCallStatus | ||
| ) public { | ||
| require(L2_SYSTEM_CONTEXT_SYSTEM_CONTRACT.currentSettlementLayerChainId() != L1_CHAIN_ID, NotInGatewayMode()); | ||
|
|
||
| // Decode the bundle data, calculate its hash and get the current status of the bundle. | ||
| (InteropBundle memory interopBundle, bytes32 bundleHash, BundleStatus status) = _getBundleData( | ||
| _bundle, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.