diff --git a/contracts/interfaces/ISocket.sol b/contracts/interfaces/ISocket.sol index bf2108d7..58fa8dab 100644 --- a/contracts/interfaces/ISocket.sol +++ b/contracts/interfaces/ISocket.sol @@ -16,13 +16,13 @@ interface ISocket { * @notice emits the status of payload after external call * @param payloadId payload id which is executed */ - event ExecutionSuccess(bytes32 payloadId, bytes returnData); + event ExecutionSuccess(bytes32 payloadId, bool exceededMaxCopy, bytes returnData); /** * @notice emits the status of payload after external call * @param payloadId payload id which is executed */ - event ExecutionFailed(bytes32 payloadId, bytes returnData); + event ExecutionFailed(bytes32 payloadId, bool exceededMaxCopy, bytes returnData); /** * @notice emits the config set by a plug for a remoteChainSlug @@ -35,14 +35,14 @@ interface ISocket { /** * @notice emits the payload details when a new payload arrives at outbound * @param triggerId trigger id - * @param chainSlug local chain slug + * @param switchboard switchboard address * @param plug local plug address * @param overrides params, for specifying details like fee pool chain, fee pool token and max fees if required * @param payload the data which will be used by contracts on chain */ event AppGatewayCallRequested( bytes32 triggerId, - uint32 chainSlug, + address switchboard, address plug, bytes overrides, bytes payload @@ -54,7 +54,7 @@ interface ISocket { function execute( ExecuteParams memory executeParams_, TransmissionParams memory transmissionParams_ - ) external payable returns (bytes memory); + ) external payable returns (bool, bool, bytes memory); /** * @notice sets the config specific to the plug diff --git a/contracts/interfaces/ISocketBatcher.sol b/contracts/interfaces/ISocketBatcher.sol index 647e481f..aba5a990 100644 --- a/contracts/interfaces/ISocketBatcher.sol +++ b/contracts/interfaces/ISocketBatcher.sol @@ -18,9 +18,10 @@ interface ISocketBatcher { */ function attestAndExecute( ExecuteParams calldata executeParams_, + address switchboard_, bytes32 digest_, bytes calldata proof_, bytes calldata transmitterSignature_, address refundAddress_ - ) external payable returns (bytes memory); + ) external payable returns (bool, bool, bytes memory); } diff --git a/contracts/protocol/payload-delivery/app-gateway/RequestQueue.sol b/contracts/protocol/payload-delivery/app-gateway/RequestQueue.sol index 419cc5c8..0729e35a 100644 --- a/contracts/protocol/payload-delivery/app-gateway/RequestQueue.sol +++ b/contracts/protocol/payload-delivery/app-gateway/RequestQueue.sol @@ -134,7 +134,7 @@ abstract contract RequestQueue is DeliveryUtils { IContractFactoryPlug.deployContract.selector, queuePayloadParams_.isPlug, salt, - queuePayloadParams_.appGateway, + bytes32(uint256(uint160(queuePayloadParams_.appGateway))), queuePayloadParams_.switchboard, queuePayloadParams_.payload, queuePayloadParams_.initCallData diff --git a/contracts/protocol/socket/Socket.sol b/contracts/protocol/socket/Socket.sol index ced0edf4..5564153b 100644 --- a/contracts/protocol/socket/Socket.sol +++ b/contracts/protocol/socket/Socket.sol @@ -12,6 +12,15 @@ import "./SocketUtils.sol"; contract Socket is SocketUtils { using LibCall for address; + // @notice mapping of payload id to execution status + mapping(bytes32 => ExecutionStatus) public payloadExecuted; + + // @notice mapping of payload id to execution status + mapping(bytes32 => bytes32) public payloadIdToDigest; + + // @notice buffer to account for gas used by current contract execution + uint256 public constant GAS_LIMIT_BUFFER = 105; + //////////////////////////////////////////////////////// ////////////////////// ERRORS ////////////////////////// //////////////////////////////////////////////////////// @@ -39,6 +48,10 @@ contract Socket is SocketUtils { * @dev Error emitted when the message value is insufficient */ error InsufficientMsgValue(); + /** + * @dev Error emitted when the call type is read + */ + error ReadOnlyCall(); /** * @notice Constructor for the Socket contract @@ -58,13 +71,15 @@ contract Socket is SocketUtils { function execute( ExecuteParams memory executeParams_, TransmissionParams memory transmissionParams_ - ) external payable returns (bytes memory) { + ) external payable returns (bool, bool, bytes memory) { // check if the deadline has passed if (executeParams_.deadline < block.timestamp) revert DeadlinePassed(); + // check if the call type is valid + if (executeParams_.callType == CallType.READ) revert ReadOnlyCall(); PlugConfig memory plugConfig = _plugConfigs[executeParams_.target]; // check if the plug is disconnected - if (plugConfig.appGatewayId == bytes32(0)) revert PlugDisconnected(); + if (plugConfig.appGatewayId == bytes32(0)) revert PlugNotFound(); if (msg.value < executeParams_.value + transmissionParams_.socketFees) revert InsufficientMsgValue(); @@ -88,6 +103,7 @@ contract Socket is SocketUtils { plugConfig.appGatewayId, executeParams_ ); + payloadIdToDigest[payloadId] = digest; // verify the digest _verify(digest, payloadId, plugConfig.switchboard); @@ -115,20 +131,23 @@ contract Socket is SocketUtils { bytes32 payloadId_, ExecuteParams memory executeParams_, TransmissionParams memory transmissionParams_ - ) internal returns (bytes memory) { + ) internal returns (bool, bool, bytes memory) { // check if the gas limit is sufficient - if (gasleft() < executeParams_.gasLimit) revert LowGasLimit(); + // bump by 5% to account for gas used by current contract execution + if (gasleft() < (executeParams_.gasLimit * GAS_LIMIT_BUFFER) / 100) revert LowGasLimit(); // NOTE: external un-trusted call - (bool success, , bytes memory returnData) = executeParams_.target.tryCall( - executeParams_.value, - executeParams_.gasLimit, - maxCopyBytes, - executeParams_.payload - ); + (bool success, bool exceededMaxCopy, bytes memory returnData) = executeParams_ + .target + .tryCall( + executeParams_.value, + executeParams_.gasLimit, + maxCopyBytes, + executeParams_.payload + ); if (success) { - emit ExecutionSuccess(payloadId_, returnData); + emit ExecutionSuccess(payloadId_, exceededMaxCopy, returnData); if (address(socketFeeManager) != address(0)) { socketFeeManager.payAndCheckFees{value: transmissionParams_.socketFees}( executeParams_, @@ -137,13 +156,15 @@ contract Socket is SocketUtils { } } else { payloadExecuted[payloadId_] = ExecutionStatus.Reverted; - address receiver = transmissionParams_.refundAddress == address(0) ? msg.sender : transmissionParams_.refundAddress; + address receiver = transmissionParams_.refundAddress == address(0) + ? msg.sender + : transmissionParams_.refundAddress; SafeTransferLib.forceSafeTransferETH(receiver, msg.value); - - emit ExecutionFailed(payloadId_, returnData); + + emit ExecutionFailed(payloadId_, exceededMaxCopy, returnData); } - return returnData; + return (success, exceededMaxCopy, returnData); } function _validateExecutionStatus(bytes32 payloadId_) internal { @@ -157,33 +178,31 @@ contract Socket is SocketUtils { //////////////////////////////////////////////////////// /** * @notice To trigger to a connected remote chain. Should only be called by a plug. - * @param payload_ bytes to be delivered on EVMx - * @param overrides_ a bytes param to add details for execution, for eg: fees to be paid for execution */ - function _triggerAppGateway( - address plug_, - bytes memory overrides_, - bytes memory payload_ - ) internal returns (bytes32 triggerId) { - PlugConfig memory plugConfig = _plugConfigs[plug_]; + function _triggerAppGateway(address plug_) internal returns (bytes32 triggerId) { + PlugConfig storage plugConfig = _plugConfigs[plug_]; // if no sibling plug is found for the given chain slug, revert // sends the trigger to connected app gateway - if (plugConfig.appGatewayId == bytes32(0)) revert PlugDisconnected(); + if (plugConfig.appGatewayId == bytes32(0)) revert PlugNotFound(); // creates a unique ID for the message triggerId = _encodeTriggerId(); - emit AppGatewayCallRequested(triggerId, chainSlug, plug_, overrides_, payload_); + emit AppGatewayCallRequested( + triggerId, + plugConfig.switchboard, + plug_, + // gets the overrides from the plug + IPlug(plug_).overrides(), + msg.data + ); } /// @notice Fallback function that forwards all calls to Socket's callAppGateway /// @dev The calldata is passed as-is to the gateways /// @dev if ETH sent with the call, it will revert fallback(bytes calldata) external returns (bytes memory) { - // gets the overrides from the plug - bytes memory overrides = IPlug(msg.sender).overrides(); - // return the trigger id - return abi.encode(_triggerAppGateway(msg.sender, overrides, msg.data)); + return abi.encode(_triggerAppGateway(msg.sender)); } } diff --git a/contracts/protocol/socket/SocketBatcher.sol b/contracts/protocol/socket/SocketBatcher.sol index 388a9e09..ad37696f 100644 --- a/contracts/protocol/socket/SocketBatcher.sol +++ b/contracts/protocol/socket/SocketBatcher.sol @@ -36,12 +36,13 @@ contract SocketBatcher is ISocketBatcher, Ownable { */ function attestAndExecute( ExecuteParams calldata executeParams_, + address switchboard_, bytes32 digest_, bytes calldata proof_, bytes calldata transmitterSignature_, address refundAddress_ - ) external payable returns (bytes memory) { - ISwitchboard(executeParams_.switchboard).attest(digest_, proof_); + ) external payable returns (bool, bool, bytes memory) { + ISwitchboard(switchboard_).attest(digest_, proof_); return socket__.execute{value: msg.value}( executeParams_, diff --git a/contracts/protocol/socket/SocketConfig.sol b/contracts/protocol/socket/SocketConfig.sol index b47a2754..96aebd12 100644 --- a/contracts/protocol/socket/SocketConfig.sol +++ b/contracts/protocol/socket/SocketConfig.sol @@ -6,10 +6,10 @@ import "../../interfaces/ISwitchboard.sol"; import {IPlug} from "../../interfaces/IPlug.sol"; import "../utils/AccessControl.sol"; -import {GOVERNANCE_ROLE, RESCUE_ROLE} from "../utils/common/AccessRoles.sol"; -import {PlugConfig, SwitchboardStatus, ExecutionStatus} from "../utils/common/Structs.sol"; +import {GOVERNANCE_ROLE, RESCUE_ROLE, SWITCHBOARD_DISABLER_ROLE} from "../utils/common/AccessRoles.sol"; +import {CallType, PlugConfig, SwitchboardStatus, ExecutionStatus} from "../utils/common/Structs.sol"; +import {PlugNotFound, InvalidAppGateway, InvalidTransmitter} from "../utils/common/Errors.sol"; import "../../interfaces/ISocketFeeManager.sol"; -import {PlugDisconnected, InvalidAppGateway, InvalidTransmitter} from "../utils/common/Errors.sol"; import {MAX_COPY_BYTES} from "../utils/common/Constants.sol"; /** @@ -21,7 +21,7 @@ import {MAX_COPY_BYTES} from "../utils/common/Constants.sol"; abstract contract SocketConfig is ISocket, AccessControl { // socket fee manager ISocketFeeManager public socketFeeManager; - + // @notice mapping of switchboard address to its status, helps socket to block invalid switchboards mapping(address => SwitchboardStatus) public isValidSwitchboard; @@ -44,6 +44,8 @@ abstract contract SocketConfig is ISocket, AccessControl { event SwitchboardAdded(address switchboard); // @notice event triggered when a switchboard is disabled event SwitchboardDisabled(address switchboard); + // @notice event triggered when a switchboard is enabled + event SwitchboardEnabled(address switchboard); event SocketFeeManagerUpdated(address oldSocketFeeManager, address newSocketFeeManager); // @notice function to register a switchboard @@ -58,11 +60,17 @@ abstract contract SocketConfig is ISocket, AccessControl { // @notice function to disable a switchboard // @dev only callable by governance role - function disableSwitchboard() external onlyRole(GOVERNANCE_ROLE) { + function disableSwitchboard() external onlyRole(SWITCHBOARD_DISABLER_ROLE) { isValidSwitchboard[msg.sender] = SwitchboardStatus.DISABLED; emit SwitchboardDisabled(msg.sender); } + // @notice function to enable a switchboard + // @dev only callable by governance role + function enableSwitchboard() external onlyRole(GOVERNANCE_ROLE) { + isValidSwitchboard[msg.sender] = SwitchboardStatus.REGISTERED; + emit SwitchboardEnabled(msg.sender); + } function setSocketFeeManager(address socketFeeManager_) external onlyRole(GOVERNANCE_ROLE) { emit SocketFeeManagerUpdated(address(socketFeeManager), socketFeeManager_); @@ -72,10 +80,6 @@ abstract contract SocketConfig is ISocket, AccessControl { /** * @notice connects Plug to Socket and sets the config for given `siblingChainSlug_` */ - // @notice function to connect a plug to a socket - // @dev only callable by plugs (msg.sender) - // @param appGatewayId_ The app gateway id - // @param switchboard_ address of switchboard on sibling chain function connect(bytes32 appGatewayId_, address switchboard_) external override { if (isValidSwitchboard[switchboard_] != SwitchboardStatus.REGISTERED) revert InvalidSwitchboard(); diff --git a/contracts/protocol/socket/SocketUtils.sol b/contracts/protocol/socket/SocketUtils.sol index 805de8d4..7000b771 100644 --- a/contracts/protocol/socket/SocketUtils.sol +++ b/contracts/protocol/socket/SocketUtils.sol @@ -18,13 +18,12 @@ abstract contract SocketUtils is SocketConfig { bytes32 public immutable version; // ChainSlug for this deployed socket instance uint32 public immutable chainSlug; + // Prefix for trigger ID containing chain slug and address bits + uint256 private immutable triggerPrefix; // @notice counter for trigger id uint64 public triggerCounter; - // @notice mapping of payload id to execution status - mapping(bytes32 => ExecutionStatus) public payloadExecuted; - /* * @notice constructor for creating a new Socket contract instance. * @param chainSlug_ The unique identifier of the chain this socket is deployed on. @@ -34,6 +33,8 @@ abstract contract SocketUtils is SocketConfig { constructor(uint32 chainSlug_, address owner_, string memory version_) { chainSlug = chainSlug_; version = keccak256(bytes(version_)); + triggerPrefix = (uint256(chainSlug_) << 224) | (uint256(uint160(address(this))) << 64); + _initializeOwner(owner_); } @@ -59,14 +60,13 @@ abstract contract SocketUtils is SocketConfig { payloadId_, executeParams_.deadline, executeParams_.callType, - executeParams_.writeFinality, executeParams_.gasLimit, executeParams_.value, - executeParams_.readAt, executeParams_.payload, executeParams_.target, appGatewayId_, - executeParams_.prevDigestsHash + executeParams_.prevDigestsHash, + executeParams_.extraData ) ); } @@ -112,12 +112,7 @@ abstract contract SocketUtils is SocketConfig { * @return The trigger ID */ function _encodeTriggerId() internal returns (bytes32) { - return - bytes32( - (uint256(chainSlug) << 224) | - (uint256(uint160(address(this))) << 64) | - triggerCounter++ - ); + return bytes32(triggerPrefix | triggerCounter++); } ////////////////////////////////////////////// diff --git a/contracts/protocol/socket/switchboard/FastSwitchboard.sol b/contracts/protocol/socket/switchboard/FastSwitchboard.sol index 12e0500a..ee0679a4 100644 --- a/contracts/protocol/socket/switchboard/FastSwitchboard.sol +++ b/contracts/protocol/socket/switchboard/FastSwitchboard.sol @@ -42,7 +42,10 @@ contract FastSwitchboard is SwitchboardBase { function attest(bytes32 digest_, bytes calldata proof_) external { if (isAttested[digest_]) revert AlreadyAttested(); - address watcher = _recoverSigner(keccak256(abi.encode(address(this), digest_)), proof_); + address watcher = _recoverSigner( + keccak256(abi.encode(address(this), chainSlug, digest_)), + proof_ + ); if (!_hasRole(WATCHER_ROLE, watcher)) revert WatcherNotFound(); isAttested[digest_] = true; diff --git a/contracts/protocol/utils/common/AccessRoles.sol b/contracts/protocol/utils/common/AccessRoles.sol index 13279b25..e1406a49 100644 --- a/contracts/protocol/utils/common/AccessRoles.sol +++ b/contracts/protocol/utils/common/AccessRoles.sol @@ -10,3 +10,5 @@ bytes32 constant GOVERNANCE_ROLE = keccak256("GOVERNANCE_ROLE"); bytes32 constant TRANSMITTER_ROLE = keccak256("TRANSMITTER_ROLE"); // used by switchboard watchers who work against transmitters bytes32 constant WATCHER_ROLE = keccak256("WATCHER_ROLE"); +// used to disable switchboard +bytes32 constant SWITCHBOARD_DISABLER_ROLE = keccak256("SWITCHBOARD_DISABLER_ROLE"); diff --git a/contracts/protocol/utils/common/Errors.sol b/contracts/protocol/utils/common/Errors.sol index dd13ac46..ebfe9dc6 100644 --- a/contracts/protocol/utils/common/Errors.sol +++ b/contracts/protocol/utils/common/Errors.sol @@ -10,7 +10,7 @@ error LimitReached(); error FeesAlreadyPaid(); error NotAuctionManager(); error CallFailed(); -error PlugDisconnected(); +error PlugNotFound(); error InvalidAppGateway(); error AppGatewayAlreadyCalled(); error InvalidInboxCaller(); diff --git a/contracts/protocol/utils/common/Structs.sol b/contracts/protocol/utils/common/Structs.sol index 4be9d768..16eb6736 100644 --- a/contracts/protocol/utils/common/Structs.sol +++ b/contracts/protocol/utils/common/Structs.sol @@ -132,14 +132,12 @@ struct DigestParams { bytes32 payloadId; uint256 deadline; CallType callType; - WriteFinality writeFinality; uint256 gasLimit; uint256 value; - uint256 readAt; bytes payload; address target; bytes32 appGatewayId; - bytes32 prevDigestsHash; // should be id? hash of hashes + bytes32 prevDigestsHash; } struct QueuePayloadParams { @@ -222,19 +220,17 @@ struct RequestMetadata { } struct ExecuteParams { - uint256 deadline; CallType callType; - WriteFinality writeFinality; + uint256 deadline; uint256 gasLimit; uint256 value; - uint256 readAt; bytes payload; address target; uint40 requestCount; uint40 batchCount; uint40 payloadCount; - bytes32 prevDigestsHash; // should be id? hash of hashes - address switchboard; + bytes32 prevDigestsHash; + bytes extraData; } struct TransmissionParams { diff --git a/contracts/protocol/watcherPrecompile/core/WatcherPrecompileCore.sol b/contracts/protocol/watcherPrecompile/core/WatcherPrecompileCore.sol index dc05fb30..873f97f3 100644 --- a/contracts/protocol/watcherPrecompile/core/WatcherPrecompileCore.sol +++ b/contracts/protocol/watcherPrecompile/core/WatcherPrecompileCore.sol @@ -90,10 +90,8 @@ abstract contract WatcherPrecompileCore is params_.payloadId, deadline, params_.payloadHeader.getCallType(), - params_.payloadHeader.getWriteFinality(), params_.gasLimit, params_.value, - params_.readAt, params_.payload, params_.target, _encodeAppGatewayId(params_.appGateway), @@ -120,6 +118,7 @@ abstract contract WatcherPrecompileCore is // ================== Helper functions ================== /// @notice Calculates the digest hash of payload parameters + /// @dev extraData is empty for now, not needed for this EVMx /// @param params_ The payload parameters to calculate the digest for /// @return digest The calculated digest hash /// @dev This function creates a keccak256 hash of the payload parameters @@ -131,14 +130,13 @@ abstract contract WatcherPrecompileCore is params_.payloadId, params_.deadline, params_.callType, - params_.writeFinality, params_.gasLimit, params_.value, - params_.readAt, params_.payload, params_.target, params_.appGatewayId, - params_.prevDigestsHash + params_.prevDigestsHash, + bytes("") ) ); } @@ -158,10 +156,8 @@ abstract contract WatcherPrecompileCore is p.payloadId, p.deadline, p.payloadHeader.getCallType(), - p.payloadHeader.getWriteFinality(), p.gasLimit, p.value, - p.readAt, p.payload, p.target, _encodeAppGatewayId(p.appGateway), diff --git a/test/Inbox.t.sol b/test/Inbox.t.sol index f02b6a5b..cf3bbb40 100644 --- a/test/Inbox.t.sol +++ b/test/Inbox.t.sol @@ -12,7 +12,7 @@ contract TriggerTest is DeliveryHelperTest { event AppGatewayCallRequested( bytes32 triggerId, - uint32 chainSlug, + address switchboard, address plug, bytes overrides, bytes payload @@ -69,7 +69,13 @@ contract TriggerTest is DeliveryHelperTest { ); vm.expectEmit(true, true, true, true); - emit AppGatewayCallRequested(triggerId, arbChainSlug, address(counter), bytes(""), payload); + emit AppGatewayCallRequested( + triggerId, + address(arbConfig.switchboard), + address(counter), + bytes(""), + payload + ); counter.increaseOnGateway(incrementValue); TriggerParams[] memory params = new TriggerParams[](1); diff --git a/test/SetupTest.t.sol b/test/SetupTest.t.sol index 08329881..6efb5045 100644 --- a/test/SetupTest.t.sol +++ b/test/SetupTest.t.sol @@ -76,7 +76,7 @@ contract SetupTest is Test { ERC1967Factory public proxyFactory; event Initialized(uint64 version); - event FinalizeRequested(bytes32 payloadId, PayloadParams payloadParams); + event FinalizeRequested(bytes32 digest, PayloadParams payloadParams); //////////////////////////////////// Setup //////////////////////////////////// @@ -246,7 +246,7 @@ contract SetupTest is Test { isLastPayload ); } else { - bytes memory returnData = _uploadProofAndExecute(payloadParams); + (, , bytes memory returnData) = _uploadProofAndExecute(payloadParams); _resolveAndExpectFinalizeRequested( payloadParams.payloadId, payloadParams, @@ -260,7 +260,7 @@ contract SetupTest is Test { function _uploadProofAndExecute( PayloadParams memory payloadParams - ) internal returns (bytes memory) { + ) internal returns (bool, bool, bytes memory) { (bytes memory watcherProof, bytes32 digest) = _generateWatcherProof(payloadParams); _writeProof(payloadParams.payloadId, watcherProof); @@ -275,6 +275,7 @@ contract SetupTest is Test { return socketBatcher.attestAndExecute( params, + payloadParams.switchboard, digest, watcherProof, transmitterSig, @@ -307,10 +308,8 @@ contract SetupTest is Test { params_.payloadId, params_.deadline, params_.payloadHeader.getCallType(), - params_.payloadHeader.getWriteFinality(), params_.gasLimit, params_.value, - params_.readAt, params_.payload, params_.target, _encodeAppGatewayId(params_.appGateway), @@ -318,7 +317,9 @@ contract SetupTest is Test { ); bytes32 digest = watcherPrecompile.getDigest(digestParams_); - bytes32 sigDigest = keccak256(abi.encode(address(socketConfig.switchboard), digest)); + bytes32 sigDigest = keccak256( + abi.encode(address(socketConfig.switchboard), socketConfig.chainSlug, digest) + ); bytes memory proof = _createSignature(sigDigest, watcherPrivateKey); return (proof, digest); } @@ -359,19 +360,17 @@ contract SetupTest is Test { transmitterSig = _createSignature(transmitterDigest, transmitterPrivateKey); params = ExecuteParams({ - deadline: payloadParams.deadline, callType: payloadParams.payloadHeader.getCallType(), - writeFinality: payloadParams.payloadHeader.getWriteFinality(), + deadline: payloadParams.deadline, gasLimit: payloadParams.gasLimit, value: payloadParams.value, - readAt: payloadParams.readAt, payload: payloadParams.payload, target: payloadParams.target, requestCount: payloadParams.payloadHeader.getRequestCount(), batchCount: payloadParams.payloadHeader.getBatchCount(), payloadCount: payloadParams.payloadHeader.getPayloadCount(), prevDigestsHash: payloadParams.prevDigestsHash, - switchboard: payloadParams.switchboard + extraData: bytes("") }); value = payloadParams.value; diff --git a/test/SocketFeeManager.t.sol b/test/SocketFeeManager.t.sol index 8742fff5..e57dc809 100644 --- a/test/SocketFeeManager.t.sol +++ b/test/SocketFeeManager.t.sol @@ -126,19 +126,17 @@ contract SocketFeeManagerTest is SetupTest { bytes memory payload ) internal view returns (ExecuteParams memory, TransmissionParams memory) { ExecuteParams memory executeParams = ExecuteParams({ - deadline: block.timestamp + 1 days, callType: CallType.WRITE, - writeFinality: WriteFinality.HIGH, + deadline: block.timestamp + 1 days, gasLimit: 100000, value: 0, - readAt: 0, payload: payload, target: address(counter), requestCount: 0, batchCount: 0, payloadCount: 0, prevDigestsHash: bytes32(0), - switchboard: address(mockSwitchboard) + extraData: bytes("") }); TransmissionParams memory transmissionParams = TransmissionParams({ diff --git a/test/apps/Counter.t.sol b/test/apps/Counter.t.sol index 243abcfc..cb9b8290 100644 --- a/test/apps/Counter.t.sol +++ b/test/apps/Counter.t.sol @@ -27,7 +27,7 @@ contract CounterTest is DeliveryHelperTest { requestCount = _deploy(chainSlug, IAppGateway(counterGateway), contractIds); } - function testCounterDeployment() external { + function testCounterDeployment1() external { deploySetup(); deployCounterApp(arbChainSlug); diff --git a/test/mock/MockSocket.sol b/test/mock/MockSocket.sol index 82ea33b3..b4e0f483 100644 --- a/test/mock/MockSocket.sol +++ b/test/mock/MockSocket.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import {PlugDisconnected, InvalidAppGateway} from "../../contracts/protocol/utils/common/Errors.sol"; +import {InvalidAppGateway} from "../../contracts/protocol/utils/common/Errors.sol"; import "../../contracts/interfaces/ISwitchboard.sol"; import "../../contracts/interfaces/ISocket.sol"; @@ -94,7 +94,13 @@ contract MockSocket is ISocket { PlugConfig memory plugConfig = _plugConfigs[msg.sender]; // creates a unique ID for the message triggerId = _encodeTriggerId(plugConfig.appGatewayId); - emit AppGatewayCallRequested(triggerId, chainSlug, msg.sender, overrides, payload); + emit AppGatewayCallRequested( + triggerId, + address(plugConfig.switchboard__), + msg.sender, + overrides, + payload + ); } /** @@ -103,7 +109,7 @@ contract MockSocket is ISocket { function execute( ExecuteParams memory executeParams_, TransmissionParams memory transmissionParams_ - ) external payable override returns (bytes memory) { + ) external payable override returns (bool, bool, bytes memory) { // execute payload // return // _execute( @@ -139,7 +145,7 @@ contract MockSocket is ISocket { bytes memory ) internal returns (bytes memory) { bytes memory returnData = hex"00010203"; - emit ExecutionSuccess(payloadId_, returnData); + emit ExecutionSuccess(payloadId_, false, returnData); return returnData; }