Function: callOutSignedAndBridge(bytes _params, DepositInput _dParams, GasParams _gParams, bool _hasFallbackToggled)
The function allows the execution of a cross-chain request, which involves locking funds into the localPort contract. On the Root chain, the Virtual Account contract associated with the caller will receive the _amount of global _hToken. Additionally, the caller can provide extra payload data to trigger functions of the Virtual Account on the Root chain.
Inputs
_paramsControl: Full control by the caller.
Constraints: N/A.
Impact: Contains additional data for
rootRouterAddress.executeSignedDepositSingle— can be empty.
_dParamsControl: Full control by the caller, who must own the corresponding amount of tokens.
Constraints: The
localPortcontract must be able to burn_dParams.hTokentokens and must have approval from the caller to transfer_dParams.token.Impact: It includes
_dParams.hToken,_dParams.token,_dParams.amount, and_dParams.deposit—_dParams.hTokenwill be burned by the localPort contract, and_dParams.tokenwill be transferred from the caller to the localPort contract.
_gParamsControl: Full control by the caller.
Constraints: There are no constraints.
Impact: These values are used to encode
AdapterParametersdata for the LayerZero relayer contract.
_hasFallbackToggledControl: Full control by the caller.
Constraints: N/A.
Impact: If true, a fallback call will be performed after receiving the message in the Root chain.
Branches and code coverage
Intended branches
Check that the deposit was successful.
Check that the fallback call was performed.
Function call analysis
this._createDeposit(True, _depositNonce, msg.sender, _dParams.hToken, _dParams.token, _dParams.amount, _dParams.deposit) -> IBranchPort(this.localPortAddress).bridgeOut(msg.sender, _hToken, _token, _amount, _deposit)What is controllable? The
_dParamsis controlled by the caller.If the return value is controllable, how is it used and how can it go wrong? There is no return value.
What happens if it reverts, reenters or does other unusual control flow? The function burns the
_dParams._amount - _dParams._depositamount of_dParams.hTokentokens from the caller's account. If_dParams.tokenis not the zero address, it transfers the_depositamount of_dParams.tokentokens from the caller to the localPortAddress contract address.
this._performCall(address payable(msg.sender), payload, _gParams, _hasFallbackToggled ? BridgeAgentConstants.BRANCH_BASE_CALL_OUT_SIGNED_DEPOSIT_SINGLE_GAS + BridgeAgentConstants.BASE_FALLBACK_GAS : BridgeAgentConstants.BRANCH_BASE_CALL_OUT_SIGNED_DEPOSIT_SINGLE_GAS) -> ILayerZeroEndpoint(this.lzEndpointAddress).send{value: msg.value}What is controllable? The payload is partly controlled; the caller controls
_dParams.hToken,_dParams.token,_dParams.amount, and_dParams.deposit.If the return value is controllable, how is it used and how can it go wrong? There is no return value.
What happens if it reverts, reenters or does other unusual control flow? The function can revert if the caller does not provide enough fee payment or if
rootChainIdis unknown. However, the caller does not controlrootChainId.
this._performCall(address payable(msg.sender), payload, _gParams, _hasFallbackToggled ? BridgeAgentConstants.BRANCH_BASE_CALL_OUT_SIGNED_DEPOSIT_SINGLE_GAS + BridgeAgentConstants.BASE_FALLBACK_GAS : BridgeAgentConstants.BRANCH_BASE_CALL_OUT_SIGNED_DEPOSIT_SINGLE_GAS) -> IRootBridgeAgent(this.rootBridgeAgentAddress).lzReceive{value: msg.value}What is controllable? The payload is partly controlled by the initial caller. The initial caller controls
_dParams.hToken,_dParams.token,_dParams.amount, and_dParams.deposit.If the return value is controllable, how is it used and how can it go wrong? There is no return value.
What happens if it reverts, reenters or does other unusual control flow? This function call is a part of the cross-chain--message transferring process, so it will be executed in a different transaction and on a different chain than the original call. Since all the logic for message processing is executed within the
excessivelySafeCallfunction, in case of a revert, the message will not be saved for resending and all native tokens from this contract will be transferred to the rootPortAddress contract. But if either transfers revert, the message will be saved for resending. However, it will also be possible to skip this message using theforceResumeReceivefunction. During payload processing, the function can revert if_dParams.hTokenis not set as a trusted local token in_srcChainIdand if_dParams.tokenis not set as the underlying token for_dParams.hTokenfrom_srcChainId.