From 3d542f3a34fc1949772befd370c47bae6830acb5 Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Tue, 22 Apr 2025 14:02:07 +0530 Subject: [PATCH 01/17] feat: sb disable and enable --- contracts/protocol/socket/Socket.sol | 3 +++ contracts/protocol/socket/SocketConfig.sol | 13 +++++++++++-- contracts/protocol/socket/SocketUtils.sol | 3 --- contracts/protocol/utils/common/AccessRoles.sol | 2 ++ 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/contracts/protocol/socket/Socket.sol b/contracts/protocol/socket/Socket.sol index 83a455b6..fd392474 100644 --- a/contracts/protocol/socket/Socket.sol +++ b/contracts/protocol/socket/Socket.sol @@ -12,6 +12,9 @@ import "./SocketUtils.sol"; contract Socket is SocketUtils { using LibCall for address; + // @notice mapping of payload id to execution status + mapping(bytes32 => ExecutionStatus) public payloadExecuted; + //////////////////////////////////////////////////////// ////////////////////// ERRORS ////////////////////////// //////////////////////////////////////////////////////// diff --git a/contracts/protocol/socket/SocketConfig.sol b/contracts/protocol/socket/SocketConfig.sol index 7035601e..a480966b 100644 --- a/contracts/protocol/socket/SocketConfig.sol +++ b/contracts/protocol/socket/SocketConfig.sol @@ -6,7 +6,7 @@ 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 {GOVERNANCE_ROLE, RESCUE_ROLE, SWITCHBOARD_DISABLER_ROLE} from "../utils/common/AccessRoles.sol"; import {PlugConfig, SwitchboardStatus, ExecutionStatus} from "../utils/common/Structs.sol"; import {PlugDisconnected, InvalidAppGateway, InvalidTransmitter} from "../utils/common/Errors.sol"; import {MAX_COPY_BYTES} from "../utils/common/Constants.sol"; @@ -40,6 +40,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); // @notice function to register a switchboard // @dev only callable by switchboards @@ -53,11 +55,18 @@ 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); + } + // @notice function to connect a plug to a socket // @dev only callable by plugs (msg.sender) // @param appGatewayId_ The app gateway id diff --git a/contracts/protocol/socket/SocketUtils.sol b/contracts/protocol/socket/SocketUtils.sol index 805de8d4..2b8c40f2 100644 --- a/contracts/protocol/socket/SocketUtils.sol +++ b/contracts/protocol/socket/SocketUtils.sol @@ -22,9 +22,6 @@ abstract contract SocketUtils is SocketConfig { // @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. 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"); From 914f4a3217060f5229458bcb3e589a4d73dd71d6 Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Tue, 22 Apr 2025 15:16:55 +0530 Subject: [PATCH 02/17] fix: optimise trigger --- contracts/protocol/socket/Socket.sol | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/contracts/protocol/socket/Socket.sol b/contracts/protocol/socket/Socket.sol index fd392474..fa33b93b 100644 --- a/contracts/protocol/socket/Socket.sol +++ b/contracts/protocol/socket/Socket.sol @@ -152,13 +152,11 @@ 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_ + bytes memory overrides_ ) internal returns (bytes32 triggerId) { PlugConfig memory plugConfig = _plugConfigs[plug_]; @@ -168,17 +166,18 @@ contract Socket is SocketUtils { // creates a unique ID for the message triggerId = _encodeTriggerId(); - emit AppGatewayCallRequested(triggerId, chainSlug, plug_, overrides_, payload_); + emit AppGatewayCallRequested(triggerId, chainSlug, 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) { + address plug = msg.sender; // gets the overrides from the plug - bytes memory overrides = IPlug(msg.sender).overrides(); + bytes memory overrides = IPlug(plug).overrides(); // return the trigger id - return abi.encode(_triggerAppGateway(msg.sender, overrides, msg.data)); + return abi.encode(_triggerAppGateway(plug, overrides)); } } From 3be12b23133b3811f4fc266805d6dfecd13d7c18 Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Tue, 22 Apr 2025 15:17:54 +0530 Subject: [PATCH 03/17] fix: rename errors --- contracts/protocol/socket/Socket.sol | 4 ++-- contracts/protocol/socket/SocketConfig.sol | 2 +- contracts/protocol/utils/common/Errors.sol | 2 +- test/mock/MockSocket.sol | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/contracts/protocol/socket/Socket.sol b/contracts/protocol/socket/Socket.sol index fa33b93b..39bec0d7 100644 --- a/contracts/protocol/socket/Socket.sol +++ b/contracts/protocol/socket/Socket.sol @@ -67,7 +67,7 @@ contract Socket is SocketUtils { 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(); // check if the message value is insufficient if (msg.value < executeParams_.value) revert InsufficientMsgValue(); @@ -162,7 +162,7 @@ contract Socket is SocketUtils { // 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(); diff --git a/contracts/protocol/socket/SocketConfig.sol b/contracts/protocol/socket/SocketConfig.sol index a480966b..c2638a4c 100644 --- a/contracts/protocol/socket/SocketConfig.sol +++ b/contracts/protocol/socket/SocketConfig.sol @@ -8,7 +8,7 @@ import {IPlug} from "../../interfaces/IPlug.sol"; import "../utils/AccessControl.sol"; import {GOVERNANCE_ROLE, RESCUE_ROLE, SWITCHBOARD_DISABLER_ROLE} from "../utils/common/AccessRoles.sol"; import {PlugConfig, SwitchboardStatus, ExecutionStatus} from "../utils/common/Structs.sol"; -import {PlugDisconnected, InvalidAppGateway, InvalidTransmitter} from "../utils/common/Errors.sol"; +import {PlugNotFound, InvalidAppGateway, InvalidTransmitter} from "../utils/common/Errors.sol"; import {MAX_COPY_BYTES} from "../utils/common/Constants.sol"; /** diff --git a/contracts/protocol/utils/common/Errors.sol b/contracts/protocol/utils/common/Errors.sol index e5261dc4..8848900b 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/test/mock/MockSocket.sol b/test/mock/MockSocket.sol index 5489ea08..1e9a4fac 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"; From c91ab9c5154049e71217ecf5c02ca6bf01fdd890 Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Tue, 22 Apr 2025 15:21:55 +0530 Subject: [PATCH 04/17] fix: event --- contracts/interfaces/ISocket.sol | 4 ++-- contracts/protocol/socket/Socket.sol | 8 +++++++- test/Inbox.t.sol | 10 ++++++++-- test/mock/MockSocket.sol | 8 +++++++- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/contracts/interfaces/ISocket.sol b/contracts/interfaces/ISocket.sol index 042fb7cc..0bca51b2 100644 --- a/contracts/interfaces/ISocket.sol +++ b/contracts/interfaces/ISocket.sol @@ -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 diff --git a/contracts/protocol/socket/Socket.sol b/contracts/protocol/socket/Socket.sol index 39bec0d7..1a59d606 100644 --- a/contracts/protocol/socket/Socket.sol +++ b/contracts/protocol/socket/Socket.sol @@ -166,7 +166,13 @@ contract Socket is SocketUtils { // creates a unique ID for the message triggerId = _encodeTriggerId(); - emit AppGatewayCallRequested(triggerId, chainSlug, plug_, overrides_, msg.data); + emit AppGatewayCallRequested( + triggerId, + plugConfig.switchboard, + plug_, + overrides_, + msg.data + ); } /// @notice Fallback function that forwards all calls to Socket's callAppGateway diff --git a/test/Inbox.t.sol b/test/Inbox.t.sol index 1dc5ce62..9406b0f5 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/mock/MockSocket.sol b/test/mock/MockSocket.sol index 1e9a4fac..77e91790 100644 --- a/test/mock/MockSocket.sol +++ b/test/mock/MockSocket.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 + ); } /** From 1cc000759736ea2f310863410e4986e2db3a9580 Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Tue, 22 Apr 2025 16:01:43 +0530 Subject: [PATCH 05/17] fix: remove extra params --- contracts/protocol/socket/SocketUtils.sol | 2 -- contracts/protocol/utils/common/Structs.sol | 2 -- test/SetupTest.t.sol | 2 -- 3 files changed, 6 deletions(-) diff --git a/contracts/protocol/socket/SocketUtils.sol b/contracts/protocol/socket/SocketUtils.sol index 2b8c40f2..2b8920d9 100644 --- a/contracts/protocol/socket/SocketUtils.sol +++ b/contracts/protocol/socket/SocketUtils.sol @@ -55,11 +55,9 @@ abstract contract SocketUtils is SocketConfig { transmitter_, payloadId_, executeParams_.deadline, - executeParams_.callType, executeParams_.writeFinality, executeParams_.gasLimit, executeParams_.value, - executeParams_.readAt, executeParams_.payload, executeParams_.target, appGatewayId_, diff --git a/contracts/protocol/utils/common/Structs.sol b/contracts/protocol/utils/common/Structs.sol index 547306b4..2928e607 100644 --- a/contracts/protocol/utils/common/Structs.sol +++ b/contracts/protocol/utils/common/Structs.sol @@ -223,11 +223,9 @@ struct RequestMetadata { struct ExecuteParams { uint256 deadline; - CallType callType; WriteFinality writeFinality; uint256 gasLimit; uint256 value; - uint256 readAt; bytes payload; address target; uint40 requestCount; diff --git a/test/SetupTest.t.sol b/test/SetupTest.t.sol index 88cc2f4e..77bf40cf 100644 --- a/test/SetupTest.t.sol +++ b/test/SetupTest.t.sol @@ -347,11 +347,9 @@ contract SetupTest is Test { params = ExecuteParams({ deadline: payloadParams.deadline, - callType: payloadParams.dump.getCallType(), writeFinality: payloadParams.dump.getWriteFinality(), gasLimit: payloadParams.gasLimit, value: payloadParams.value, - readAt: payloadParams.readAt, payload: payloadParams.payload, target: payloadParams.target, requestCount: payloadParams.dump.getRequestCount(), From 33aeece239ce854a8f740447afc5f7fbe4d5b42c Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Tue, 22 Apr 2025 16:02:07 +0530 Subject: [PATCH 06/17] fix: emit and return call return details --- contracts/interfaces/ISocket.sol | 6 +++--- contracts/interfaces/ISocketBatcher.sol | 2 +- contracts/protocol/socket/Socket.sol | 19 ++++++++----------- contracts/protocol/socket/SocketBatcher.sol | 2 +- test/SetupTest.t.sol | 4 ++-- test/mock/MockSocket.sol | 4 ++-- 6 files changed, 17 insertions(+), 20 deletions(-) diff --git a/contracts/interfaces/ISocket.sol b/contracts/interfaces/ISocket.sol index 0bca51b2..057edbc8 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 @@ -54,7 +54,7 @@ interface ISocket { function execute( ExecuteParams memory executeParams_, bytes memory transmitterSignature_ - ) 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 d2991f4e..b6ae52e1 100644 --- a/contracts/interfaces/ISocketBatcher.sol +++ b/contracts/interfaces/ISocketBatcher.sol @@ -21,5 +21,5 @@ interface ISocketBatcher { bytes32 digest_, bytes calldata proof_, bytes calldata transmitterSignature_ - ) external payable returns (bytes memory); + ) external payable returns (bool, bool, bytes memory); } diff --git a/contracts/protocol/socket/Socket.sol b/contracts/protocol/socket/Socket.sol index 1a59d606..1961b8c3 100644 --- a/contracts/protocol/socket/Socket.sol +++ b/contracts/protocol/socket/Socket.sol @@ -61,7 +61,7 @@ contract Socket is SocketUtils { function execute( ExecuteParams memory executeParams_, bytes memory transmitterSignature_ - ) 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(); @@ -118,27 +118,24 @@ contract Socket is SocketUtils { function _execute( bytes32 payloadId_, ExecuteParams memory executeParams_ - ) internal returns (bytes memory) { + ) internal returns (bool, bool, bytes memory) { // check if the gas limit is sufficient if (gasleft() < executeParams_.gasLimit) revert LowGasLimit(); // NOTE: external un-trusted call - (bool success, , bytes memory returnData) = executeParams_.target.tryCall( - msg.value, - executeParams_.gasLimit, - maxCopyBytes, - executeParams_.payload - ); + (bool success, bool exceededMaxCopy, bytes memory returnData) = executeParams_ + .target + .tryCall(msg.value, executeParams_.gasLimit, maxCopyBytes, executeParams_.payload); // if the execution failed, set the execution status to reverted if (!success) { payloadExecuted[payloadId_] = ExecutionStatus.Reverted; - emit ExecutionFailed(payloadId_, returnData); + emit ExecutionFailed(payloadId_, exceededMaxCopy, returnData); } else { - emit ExecutionSuccess(payloadId_, returnData); + emit ExecutionSuccess(payloadId_, exceededMaxCopy, returnData); } - return returnData; + return (success, exceededMaxCopy, returnData); } function _validateExecutionStatus(bytes32 payloadId_) internal { diff --git a/contracts/protocol/socket/SocketBatcher.sol b/contracts/protocol/socket/SocketBatcher.sol index 5bd605a4..a3ac5ba4 100644 --- a/contracts/protocol/socket/SocketBatcher.sol +++ b/contracts/protocol/socket/SocketBatcher.sol @@ -39,7 +39,7 @@ contract SocketBatcher is ISocketBatcher, Ownable { bytes32 digest_, bytes calldata proof_, bytes calldata transmitterSignature_ - ) external payable returns (bytes memory) { + ) external payable returns (bool, bool, bytes memory) { ISwitchboard(executeParams_.switchboard).attest(digest_, proof_); return socket__.execute{value: msg.value}(executeParams_, transmitterSignature_); } diff --git a/test/SetupTest.t.sol b/test/SetupTest.t.sol index 77bf40cf..a5c8f1dd 100644 --- a/test/SetupTest.t.sol +++ b/test/SetupTest.t.sol @@ -244,7 +244,7 @@ contract SetupTest is Test { isLastPayload ); } else { - bytes memory returnData = _uploadProofAndExecute(payloadParams); + (, , bytes memory returnData) = _uploadProofAndExecute(payloadParams); _resolveAndExpectFinalizeRequested( payloadParams.payloadId, payloadParams, @@ -258,7 +258,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); diff --git a/test/mock/MockSocket.sol b/test/mock/MockSocket.sol index 77e91790..b2b5478a 100644 --- a/test/mock/MockSocket.sol +++ b/test/mock/MockSocket.sol @@ -109,7 +109,7 @@ contract MockSocket is ISocket { function execute( ExecuteParams memory executeParams_, bytes memory transmitterSignature_ - ) external payable override returns (bytes memory) { + ) external payable override returns (bool, bool, bytes memory) { // execute payload // return // _execute( @@ -145,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; } From 339938a67b65854b7d337876d2b78edf834f5d6f Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Tue, 22 Apr 2025 16:50:32 +0530 Subject: [PATCH 07/17] fix: clean execute params --- contracts/interfaces/ISocketBatcher.sol | 1 + contracts/protocol/socket/SocketBatcher.sol | 3 ++- contracts/protocol/socket/SocketConfig.sol | 2 +- contracts/protocol/socket/SocketUtils.sol | 2 +- contracts/protocol/utils/common/Structs.sol | 4 ---- .../core/WatcherPrecompileCore.sol | 6 ------ test/SetupTest.t.sol | 14 ++++++++------ 7 files changed, 13 insertions(+), 19 deletions(-) diff --git a/contracts/interfaces/ISocketBatcher.sol b/contracts/interfaces/ISocketBatcher.sol index b6ae52e1..e114bcb9 100644 --- a/contracts/interfaces/ISocketBatcher.sol +++ b/contracts/interfaces/ISocketBatcher.sol @@ -18,6 +18,7 @@ interface ISocketBatcher { */ function attestAndExecute( ExecuteParams calldata executeParams_, + address switchboard_, bytes32 digest_, bytes calldata proof_, bytes calldata transmitterSignature_ diff --git a/contracts/protocol/socket/SocketBatcher.sol b/contracts/protocol/socket/SocketBatcher.sol index a3ac5ba4..292ede25 100644 --- a/contracts/protocol/socket/SocketBatcher.sol +++ b/contracts/protocol/socket/SocketBatcher.sol @@ -36,11 +36,12 @@ contract SocketBatcher is ISocketBatcher, Ownable { */ function attestAndExecute( ExecuteParams calldata executeParams_, + address switchboard_, bytes32 digest_, bytes calldata proof_, bytes calldata transmitterSignature_ ) external payable returns (bool, bool, bytes memory) { - ISwitchboard(executeParams_.switchboard).attest(digest_, proof_); + ISwitchboard(switchboard_).attest(digest_, proof_); return socket__.execute{value: msg.value}(executeParams_, transmitterSignature_); } diff --git a/contracts/protocol/socket/SocketConfig.sol b/contracts/protocol/socket/SocketConfig.sol index c2638a4c..94778ad4 100644 --- a/contracts/protocol/socket/SocketConfig.sol +++ b/contracts/protocol/socket/SocketConfig.sol @@ -7,7 +7,7 @@ import {IPlug} from "../../interfaces/IPlug.sol"; import "../utils/AccessControl.sol"; import {GOVERNANCE_ROLE, RESCUE_ROLE, SWITCHBOARD_DISABLER_ROLE} from "../utils/common/AccessRoles.sol"; -import {PlugConfig, SwitchboardStatus, ExecutionStatus} from "../utils/common/Structs.sol"; +import {CallType, PlugConfig, SwitchboardStatus, ExecutionStatus} from "../utils/common/Structs.sol"; import {PlugNotFound, InvalidAppGateway, InvalidTransmitter} from "../utils/common/Errors.sol"; import {MAX_COPY_BYTES} from "../utils/common/Constants.sol"; diff --git a/contracts/protocol/socket/SocketUtils.sol b/contracts/protocol/socket/SocketUtils.sol index 2b8920d9..e862b6a1 100644 --- a/contracts/protocol/socket/SocketUtils.sol +++ b/contracts/protocol/socket/SocketUtils.sol @@ -55,7 +55,7 @@ abstract contract SocketUtils is SocketConfig { transmitter_, payloadId_, executeParams_.deadline, - executeParams_.writeFinality, + CallType.WRITE, executeParams_.gasLimit, executeParams_.value, executeParams_.payload, diff --git a/contracts/protocol/utils/common/Structs.sol b/contracts/protocol/utils/common/Structs.sol index 2928e607..c6e3f29d 100644 --- a/contracts/protocol/utils/common/Structs.sol +++ b/contracts/protocol/utils/common/Structs.sol @@ -132,10 +132,8 @@ struct DigestParams { bytes32 payloadId; uint256 deadline; CallType callType; - WriteFinality writeFinality; uint256 gasLimit; uint256 value; - uint256 readAt; bytes payload; address target; bytes32 appGatewayId; @@ -223,7 +221,6 @@ struct RequestMetadata { struct ExecuteParams { uint256 deadline; - WriteFinality writeFinality; uint256 gasLimit; uint256 value; bytes payload; @@ -232,7 +229,6 @@ struct ExecuteParams { uint40 batchCount; uint40 payloadCount; bytes32 prevDigestsHash; // should be id? hash of hashes - address switchboard; } /// @notice Struct containing fee amounts and status diff --git a/contracts/protocol/watcherPrecompile/core/WatcherPrecompileCore.sol b/contracts/protocol/watcherPrecompile/core/WatcherPrecompileCore.sol index b7824a3a..1c3881dc 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_.dump.getCallType(), - params_.dump.getWriteFinality(), params_.gasLimit, params_.value, - params_.readAt, params_.payload, params_.target, _encodeAppGatewayId(params_.appGateway), @@ -130,10 +128,8 @@ abstract contract WatcherPrecompileCore is params_.payloadId, params_.deadline, params_.callType, - params_.writeFinality, params_.gasLimit, params_.value, - params_.readAt, params_.payload, params_.target, params_.appGatewayId, @@ -157,10 +153,8 @@ abstract contract WatcherPrecompileCore is p.payloadId, p.deadline, p.dump.getCallType(), - p.dump.getWriteFinality(), p.gasLimit, p.value, - p.readAt, p.payload, p.target, _encodeAppGatewayId(p.appGateway), diff --git a/test/SetupTest.t.sol b/test/SetupTest.t.sol index a5c8f1dd..20b84491 100644 --- a/test/SetupTest.t.sol +++ b/test/SetupTest.t.sol @@ -269,7 +269,13 @@ contract SetupTest is Test { bytes memory transmitterSig ) = _getExecuteParams(payloadParams); - return socketBatcher.attestAndExecute(params, digest, watcherProof, transmitterSig); + return socketBatcher.attestAndExecute( + params, + payloadParams.switchboard, + digest, + watcherProof, + transmitterSig + ); } function resolvePromises(bytes32[] memory payloadIds, bytes[] memory returnData) internal { @@ -297,10 +303,8 @@ contract SetupTest is Test { params_.payloadId, params_.deadline, params_.dump.getCallType(), - params_.dump.getWriteFinality(), params_.gasLimit, params_.value, - params_.readAt, params_.payload, params_.target, _encodeAppGatewayId(params_.appGateway), @@ -347,7 +351,6 @@ contract SetupTest is Test { params = ExecuteParams({ deadline: payloadParams.deadline, - writeFinality: payloadParams.dump.getWriteFinality(), gasLimit: payloadParams.gasLimit, value: payloadParams.value, payload: payloadParams.payload, @@ -355,8 +358,7 @@ contract SetupTest is Test { requestCount: payloadParams.dump.getRequestCount(), batchCount: payloadParams.dump.getBatchCount(), payloadCount: payloadParams.dump.getPayloadCount(), - prevDigestsHash: payloadParams.prevDigestsHash, - switchboard: payloadParams.switchboard + prevDigestsHash: payloadParams.prevDigestsHash }); value = payloadParams.value; From 4d75d32fdf48305ecd687a5b6074237787f93695 Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Wed, 23 Apr 2025 11:32:52 +0530 Subject: [PATCH 08/17] fix: read reentrancy --- contracts/protocol/socket/Socket.sol | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/contracts/protocol/socket/Socket.sol b/contracts/protocol/socket/Socket.sol index 1961b8c3..407214fc 100644 --- a/contracts/protocol/socket/Socket.sol +++ b/contracts/protocol/socket/Socket.sol @@ -155,7 +155,7 @@ contract Socket is SocketUtils { address plug_, bytes memory overrides_ ) internal returns (bytes32 triggerId) { - PlugConfig memory plugConfig = _plugConfigs[plug_]; + PlugConfig storage plugConfig = _plugConfigs[plug_]; // if no sibling plug is found for the given chain slug, revert // sends the trigger to connected app gateway @@ -167,7 +167,8 @@ contract Socket is SocketUtils { triggerId, plugConfig.switchboard, plug_, - overrides_, + // gets the overrides from the plug + IPlug(plug_).overrides(), msg.data ); } @@ -176,11 +177,7 @@ contract Socket is SocketUtils { /// @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) { - address plug = msg.sender; - // gets the overrides from the plug - bytes memory overrides = IPlug(plug).overrides(); - // return the trigger id - return abi.encode(_triggerAppGateway(plug, overrides)); + return abi.encode(_triggerAppGateway(plug, msg.sender)); } } From e7d5b0201431f8f14eb72fb64ad87fb9e8c2ebba Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Wed, 23 Apr 2025 11:35:17 +0530 Subject: [PATCH 09/17] feat: bump gas left by 5% --- contracts/protocol/socket/Socket.sol | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/contracts/protocol/socket/Socket.sol b/contracts/protocol/socket/Socket.sol index 407214fc..d67d97c8 100644 --- a/contracts/protocol/socket/Socket.sol +++ b/contracts/protocol/socket/Socket.sol @@ -15,6 +15,9 @@ contract Socket is SocketUtils { // @notice mapping of payload id to execution status mapping(bytes32 => ExecutionStatus) public payloadExecuted; + // @notice buffer to account for gas used by current contract execution + uint256 public constant GAS_LIMIT_BUFFER = 105; + //////////////////////////////////////////////////////// ////////////////////// ERRORS ////////////////////////// //////////////////////////////////////////////////////// @@ -120,7 +123,8 @@ contract Socket is SocketUtils { ExecuteParams memory executeParams_ ) 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, bool exceededMaxCopy, bytes memory returnData) = executeParams_ From 9d946e5708040874837069b10cf58d5db21878ad Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Wed, 23 Apr 2025 11:36:14 +0530 Subject: [PATCH 10/17] fix: unique sign for each chain --- contracts/protocol/socket/switchboard/FastSwitchboard.sol | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; From 6a4d16f868a0a271a930df024e025a0da683bb12 Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Wed, 23 Apr 2025 11:40:36 +0530 Subject: [PATCH 11/17] fix: build --- contracts/protocol/socket/Socket.sol | 8 ++------ test/SetupTest.t.sol | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/contracts/protocol/socket/Socket.sol b/contracts/protocol/socket/Socket.sol index d67d97c8..3ea590e7 100644 --- a/contracts/protocol/socket/Socket.sol +++ b/contracts/protocol/socket/Socket.sol @@ -153,12 +153,8 @@ contract Socket is SocketUtils { //////////////////////////////////////////////////////// /** * @notice To trigger to a connected remote chain. Should only be called by a plug. - * @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_ - ) internal returns (bytes32 triggerId) { + 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 @@ -182,6 +178,6 @@ contract Socket is SocketUtils { /// @dev if ETH sent with the call, it will revert fallback(bytes calldata) external returns (bytes memory) { // return the trigger id - return abi.encode(_triggerAppGateway(plug, msg.sender)); + return abi.encode(_triggerAppGateway(msg.sender)); } } diff --git a/test/SetupTest.t.sol b/test/SetupTest.t.sol index 20b84491..9849031e 100644 --- a/test/SetupTest.t.sol +++ b/test/SetupTest.t.sol @@ -269,13 +269,14 @@ contract SetupTest is Test { bytes memory transmitterSig ) = _getExecuteParams(payloadParams); - return socketBatcher.attestAndExecute( - params, - payloadParams.switchboard, - digest, - watcherProof, - transmitterSig - ); + return + socketBatcher.attestAndExecute( + params, + payloadParams.switchboard, + digest, + watcherProof, + transmitterSig + ); } function resolvePromises(bytes32[] memory payloadIds, bytes[] memory returnData) internal { @@ -312,7 +313,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); } From c9ae29c757e7e6970872a808885ee584c2cc9330 Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Wed, 23 Apr 2025 11:43:23 +0530 Subject: [PATCH 12/17] feat: store digest in socket --- contracts/protocol/socket/Socket.sol | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contracts/protocol/socket/Socket.sol b/contracts/protocol/socket/Socket.sol index 3ea590e7..f197a541 100644 --- a/contracts/protocol/socket/Socket.sol +++ b/contracts/protocol/socket/Socket.sol @@ -15,6 +15,9 @@ contract Socket is SocketUtils { // @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; @@ -93,6 +96,7 @@ contract Socket is SocketUtils { plugConfig.appGatewayId, executeParams_ ); + payloadIdToDigest[payloadId] = digest; // verify the digest _verify(digest, payloadId, plugConfig.switchboard); From 250bc8f9190302d802f947ffa17d033c45120f1a Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Wed, 23 Apr 2025 16:34:00 +0530 Subject: [PATCH 13/17] fix: app gateway id --- .../protocol/payload-delivery/app-gateway/RequestQueue.sol | 2 +- test/SetupTest.t.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/protocol/payload-delivery/app-gateway/RequestQueue.sol b/contracts/protocol/payload-delivery/app-gateway/RequestQueue.sol index b49ae310..8085cf8e 100644 --- a/contracts/protocol/payload-delivery/app-gateway/RequestQueue.sol +++ b/contracts/protocol/payload-delivery/app-gateway/RequestQueue.sol @@ -133,7 +133,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/test/SetupTest.t.sol b/test/SetupTest.t.sol index 9849031e..f6636df2 100644 --- a/test/SetupTest.t.sol +++ b/test/SetupTest.t.sol @@ -75,7 +75,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 //////////////////////////////////// From a8856eb7bdf44f7cc36b6c12e34cc47ed2c2e5e6 Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Wed, 23 Apr 2025 19:26:25 +0530 Subject: [PATCH 14/17] fix: cache trigger prefix --- contracts/protocol/socket/SocketUtils.sol | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/contracts/protocol/socket/SocketUtils.sol b/contracts/protocol/socket/SocketUtils.sol index e862b6a1..9384e5c9 100644 --- a/contracts/protocol/socket/SocketUtils.sol +++ b/contracts/protocol/socket/SocketUtils.sol @@ -18,6 +18,8 @@ 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; @@ -31,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_); } @@ -107,12 +111,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++); } ////////////////////////////////////////////// From 930caf840b2756039f3f3f92b974a62afaab24a2 Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Wed, 23 Apr 2025 19:32:27 +0530 Subject: [PATCH 15/17] feat: extra data in digest --- contracts/protocol/socket/SocketUtils.sol | 3 ++- contracts/protocol/utils/common/Structs.sol | 1 + .../protocol/watcherPrecompile/core/WatcherPrecompileCore.sol | 4 +++- test/SetupTest.t.sol | 3 ++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/contracts/protocol/socket/SocketUtils.sol b/contracts/protocol/socket/SocketUtils.sol index 9384e5c9..bbcd22b3 100644 --- a/contracts/protocol/socket/SocketUtils.sol +++ b/contracts/protocol/socket/SocketUtils.sol @@ -65,7 +65,8 @@ abstract contract SocketUtils is SocketConfig { executeParams_.payload, executeParams_.target, appGatewayId_, - executeParams_.prevDigestsHash + executeParams_.prevDigestsHash, + executeParams_.extraData ) ); } diff --git a/contracts/protocol/utils/common/Structs.sol b/contracts/protocol/utils/common/Structs.sol index c6e3f29d..03bf96f3 100644 --- a/contracts/protocol/utils/common/Structs.sol +++ b/contracts/protocol/utils/common/Structs.sol @@ -229,6 +229,7 @@ struct ExecuteParams { uint40 batchCount; uint40 payloadCount; bytes32 prevDigestsHash; // should be id? hash of hashes + bytes extraData; } /// @notice Struct containing fee amounts and status diff --git a/contracts/protocol/watcherPrecompile/core/WatcherPrecompileCore.sol b/contracts/protocol/watcherPrecompile/core/WatcherPrecompileCore.sol index 1c3881dc..d5c968d0 100644 --- a/contracts/protocol/watcherPrecompile/core/WatcherPrecompileCore.sol +++ b/contracts/protocol/watcherPrecompile/core/WatcherPrecompileCore.sol @@ -133,7 +133,9 @@ abstract contract WatcherPrecompileCore is params_.payload, params_.target, params_.appGatewayId, - params_.prevDigestsHash + params_.prevDigestsHash, + // later can take it form app gateway in forwarder, no use right now + bytes("") ) ); } diff --git a/test/SetupTest.t.sol b/test/SetupTest.t.sol index f6636df2..7db4c388 100644 --- a/test/SetupTest.t.sol +++ b/test/SetupTest.t.sol @@ -361,7 +361,8 @@ contract SetupTest is Test { requestCount: payloadParams.dump.getRequestCount(), batchCount: payloadParams.dump.getBatchCount(), payloadCount: payloadParams.dump.getPayloadCount(), - prevDigestsHash: payloadParams.prevDigestsHash + prevDigestsHash: payloadParams.prevDigestsHash, + extraData: bytes("") }); value = payloadParams.value; From 2ef4bccfb6ad1ef7b4761ab104cf18dddd486f26 Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Wed, 23 Apr 2025 23:41:32 +0530 Subject: [PATCH 16/17] fix: tests --- contracts/protocol/socket/Socket.sol | 6 ++++++ contracts/protocol/socket/SocketUtils.sol | 2 +- contracts/protocol/utils/common/Structs.sol | 1 + test/SetupTest.t.sol | 1 + test/apps/Counter.t.sol | 2 +- 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/contracts/protocol/socket/Socket.sol b/contracts/protocol/socket/Socket.sol index f197a541..f4b44bee 100644 --- a/contracts/protocol/socket/Socket.sol +++ b/contracts/protocol/socket/Socket.sol @@ -48,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 @@ -70,6 +74,8 @@ contract Socket is SocketUtils { ) 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 diff --git a/contracts/protocol/socket/SocketUtils.sol b/contracts/protocol/socket/SocketUtils.sol index bbcd22b3..7000b771 100644 --- a/contracts/protocol/socket/SocketUtils.sol +++ b/contracts/protocol/socket/SocketUtils.sol @@ -59,7 +59,7 @@ abstract contract SocketUtils is SocketConfig { transmitter_, payloadId_, executeParams_.deadline, - CallType.WRITE, + executeParams_.callType, executeParams_.gasLimit, executeParams_.value, executeParams_.payload, diff --git a/contracts/protocol/utils/common/Structs.sol b/contracts/protocol/utils/common/Structs.sol index 03bf96f3..4b2ba690 100644 --- a/contracts/protocol/utils/common/Structs.sol +++ b/contracts/protocol/utils/common/Structs.sol @@ -220,6 +220,7 @@ struct RequestMetadata { } struct ExecuteParams { + CallType callType; uint256 deadline; uint256 gasLimit; uint256 value; diff --git a/test/SetupTest.t.sol b/test/SetupTest.t.sol index 7db4c388..39d03809 100644 --- a/test/SetupTest.t.sol +++ b/test/SetupTest.t.sol @@ -353,6 +353,7 @@ contract SetupTest is Test { transmitterSig = _createSignature(transmitterDigest, transmitterPrivateKey); params = ExecuteParams({ + callType: payloadParams.dump.getCallType(), deadline: payloadParams.deadline, gasLimit: payloadParams.gasLimit, value: payloadParams.value, 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); From ca5d7d5a3d575e0bbae8bb7275c8d8277789b9e5 Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Wed, 23 Apr 2025 23:44:34 +0530 Subject: [PATCH 17/17] fix: comments --- contracts/protocol/utils/common/Structs.sol | 4 ++-- .../protocol/watcherPrecompile/core/WatcherPrecompileCore.sol | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/protocol/utils/common/Structs.sol b/contracts/protocol/utils/common/Structs.sol index 4b2ba690..96c5e72d 100644 --- a/contracts/protocol/utils/common/Structs.sol +++ b/contracts/protocol/utils/common/Structs.sol @@ -137,7 +137,7 @@ struct DigestParams { bytes payload; address target; bytes32 appGatewayId; - bytes32 prevDigestsHash; // should be id? hash of hashes + bytes32 prevDigestsHash; } struct QueuePayloadParams { @@ -229,7 +229,7 @@ struct ExecuteParams { uint40 requestCount; uint40 batchCount; uint40 payloadCount; - bytes32 prevDigestsHash; // should be id? hash of hashes + bytes32 prevDigestsHash; bytes extraData; } diff --git a/contracts/protocol/watcherPrecompile/core/WatcherPrecompileCore.sol b/contracts/protocol/watcherPrecompile/core/WatcherPrecompileCore.sol index d5c968d0..a6cc0400 100644 --- a/contracts/protocol/watcherPrecompile/core/WatcherPrecompileCore.sol +++ b/contracts/protocol/watcherPrecompile/core/WatcherPrecompileCore.sol @@ -117,6 +117,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 @@ -134,7 +135,6 @@ abstract contract WatcherPrecompileCore is params_.target, params_.appGatewayId, params_.prevDigestsHash, - // later can take it form app gateway in forwarder, no use right now bytes("") ) );