diff --git a/EventTopics.md b/EventTopics.md index 0a408806..26cce93c 100644 --- a/EventTopics.md +++ b/EventTopics.md @@ -24,6 +24,8 @@ | `AppGatewayCallRequested` | `(triggerId: bytes32, appGatewayId: bytes32, switchboardId: uint64, plug: bytes32, overrides: bytes, payload: bytes)` | `0x8ff0599581fd62c5733e52cea3abd7874731f4a9f86ebb929e5e4afe103f74d4` | | `ExecutionFailed` | `(payloadId: bytes32, exceededMaxCopy: bool, returnData: bytes)` | `0x385334bc68a32c4d164625189adc7633e6074eb1b837fb4d11d768245151e4ce` | | `ExecutionSuccess` | `(payloadId: bytes32, exceededMaxCopy: bool, returnData: bytes)` | `0x324d63a433b21a12b90e79cd2ba736b2a5238be6165e03b750fa4a7d5193d5d9` | +| `GasLimitBufferUpdated` | `(gasLimitBuffer: uint256)` | `0xd0e3eb5d0d212f0a08af2be98373721fc901ed26fbac645e08bd664fef818366` | +| `MaxCopyBytesUpdated` | `(maxCopyBytes: uint16)` | `0x294d0c11af52572317e5a0e1362cbf85b3b7c1f7b3f6c7b7e3e5c29c76da33e2` | | `OwnershipHandoverCanceled` | `(pendingOwner: address)` | `0xfa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92` | | `OwnershipHandoverRequested` | `(pendingOwner: address)` | `0xdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d` | | `OwnershipTransferred` | `(oldOwner: address, newOwner: address)` | `0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0` | @@ -287,14 +289,14 @@ ## SchedulePrecompile -| Event | Arguments | Topic | -| ------------------------------ | ---------------------------------------------------------------- | -------------------------------------------------------------------- | -| `ExpiryTimeSet` | `(expiryTime_: uint256)` | `0x07e837e13ad9a34715a6bd45f49bbf12de19f06df79cb0be12b3a7d7f2397fa9` | -| `MaxScheduleDelayInSecondsSet` | `(maxScheduleDelayInSeconds_: uint256)` | `0xfd5e4f0e96753ffb08a583390c2f151c51001d8e560625ab93b7fa7b4dac6d75` | -| `ScheduleCallbackFeesSet` | `(scheduleCallbackFees_: uint256)` | `0x82a2f41efc81ce7bfabc0affda7354dae42a3d09bd74a6196e8904b223138a52` | -| `ScheduleFeesPerSecondSet` | `(scheduleFeesPerSecond_: uint256)` | `0x7901a21229f6d2543d8676f53e21214d15f42513e7d46e0dcb510357222bdc7c` | -| `ScheduleRequested` | `(payloadId: bytes32, executeAfter: uint256, deadline: uint256)` | `0xd099d3e3d0f0e2c9c40e0066affeea125aab71d763b7ab0a279ccec3dff70b64` | -| `ScheduleResolved` | `(payloadId: bytes32)` | `0x925dc6c3ebffa07cac89d6e9675f1a5d04e045f2ed9a4fa442665935cb73e26b` | +| Event | Arguments | Topic | +| ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- | +| `ExpiryTimeSet` | `(expiryTime_: uint256)` | `0x07e837e13ad9a34715a6bd45f49bbf12de19f06df79cb0be12b3a7d7f2397fa9` | +| `MaxScheduleDelayInSecondsSet` | `(maxScheduleDelayInSeconds_: uint256)` | `0xfd5e4f0e96753ffb08a583390c2f151c51001d8e560625ab93b7fa7b4dac6d75` | +| `ScheduleCallbackFeesSet` | `(scheduleCallbackFees_: uint256)` | `0x82a2f41efc81ce7bfabc0affda7354dae42a3d09bd74a6196e8904b223138a52` | +| `ScheduleFeesPerSecondSet` | `(scheduleFeesPerSecond_: uint256)` | `0x7901a21229f6d2543d8676f53e21214d15f42513e7d46e0dcb510357222bdc7c` | +| `ScheduleRequested` | `(payloadId: bytes32, executeAfter: uint256, deadline: uint256, localInvoker: address, callbackSelector: bytes4, callbackData: bytes)` | `0xbeceaccdb128631e58b881241d4fb46e53d8b2b2aa3f1ce77ba6fb80af038e30` | +| `ScheduleResolved` | `(payloadId: bytes32)` | `0x925dc6c3ebffa07cac89d6e9675f1a5d04e045f2ed9a4fa442665935cb73e26b` | ## WritePrecompile diff --git a/FunctionSignatures.md b/FunctionSignatures.md index fc6866b7..e86293ef 100644 --- a/FunctionSignatures.md +++ b/FunctionSignatures.md @@ -16,9 +16,9 @@ | `consumeFrom` | `0x40dd78be` | | `creationCodeWithArgs` | `0xc126dcc4` | | `deployForwarder__` | `0xd4e3b034` | -| `endAuction` | `0x1212e653` | +| `endAuction` | `0x7426f0f6` | | `evmxSlug` | `0x8bae77c2` | -| `expireBid` | `0x1dd5022c` | +| `expireBid` | `0x33b5b234` | | `feesManager__` | `0x70568b58` | | `forwarderAddresses` | `0x5390fdcb` | | `getOnChainAddress` | `0xb6abffd7` | diff --git a/contracts/evmx/AuctionManager.sol b/contracts/evmx/AuctionManager.sol index 1c4b0a9f..ff593e94 100644 --- a/contracts/evmx/AuctionManager.sol +++ b/contracts/evmx/AuctionManager.sol @@ -169,8 +169,10 @@ contract AuctionManager is AuctionManagerStorage, Initializable, AppGatewayBase, } /// @notice Ends an auction - /// @param requestCount_ The ID of the auction - function endAuction(uint40 requestCount_) external override onlyPromises { + /// @param data The encoded request count + function endAuction(bytes memory data, bytes memory) external onlyPromises { + uint40 requestCount_ = abi.decode(data, (uint40)); + if (requestCount_ == 0) revert InvalidBid(); if ( auctionStatus[requestCount_] == AuctionStatus.CLOSED || auctionStatus[requestCount_] == AuctionStatus.NOT_STARTED @@ -207,10 +209,11 @@ contract AuctionManager is AuctionManagerStorage, Initializable, AppGatewayBase, /// @notice Expires a bid and restarts an auction in case a request is not fully executed. /// @dev Auction can be restarted only for `maxReAuctionCount` times. /// @dev It also unblocks the fees from last transmitter to be assigned to the new winner. - /// @param requestCount_ The request id - function expireBid(uint40 requestCount_) external override onlyPromises { - if (reAuctionCount[requestCount_] >= maxReAuctionCount) revert MaxReAuctionCountReached(); - RequestParams memory requestParams = watcher__().getRequestParams(requestCount_); + /// @param data The encoded request count + function expireBid(bytes memory data, bytes memory) external override onlyPromises { + uint40 requestCount = abi.decode(data, (uint40)); + if (reAuctionCount[requestCount] >= maxReAuctionCount) revert MaxReAuctionCountReached(); + RequestParams memory requestParams = watcher__().getRequestParams(requestCount); // if executed or cancelled, bid is not expired if ( @@ -218,15 +221,15 @@ contract AuctionManager is AuctionManagerStorage, Initializable, AppGatewayBase, requestParams.requestTrackingParams.isRequestCancelled ) return; - delete winningBids[requestCount_]; - auctionStatus[requestCount_] = AuctionStatus.RESTARTED; - reAuctionCount[requestCount_]++; + delete winningBids[requestCount]; + auctionStatus[requestCount] = AuctionStatus.RESTARTED; + reAuctionCount[requestCount]++; watcher__().requestHandler__().assignTransmitter( - requestCount_, + requestCount, Bid({fee: 0, transmitter: address(0), extraData: ""}) ); - emit AuctionRestarted(requestCount_); + emit AuctionRestarted(requestCount); } function _createRequest( diff --git a/contracts/evmx/interfaces/IAuctionManager.sol b/contracts/evmx/interfaces/IAuctionManager.sol index 5bacbf3a..af867f81 100644 --- a/contracts/evmx/interfaces/IAuctionManager.sol +++ b/contracts/evmx/interfaces/IAuctionManager.sol @@ -25,14 +25,15 @@ interface IAuctionManager { ) external; /// @notice Ends an auction - /// @param requestCount_ The request count - function endAuction(uint40 requestCount_) external; + /// @param data The encoded request count + function endAuction(bytes memory data, bytes memory) external; /// @notice Expires a bid and restarts an auction in case a request is not fully executed. /// @dev Auction can be restarted only for `maxReAuctionCount` times. /// @dev It also unblocks the fees from last transmitter to be assigned to the new winner. - /// @param requestCount_ The request id - function expireBid(uint40 requestCount_) external; + /// @param data The encoded request count + /// @param returnData The return data from the bid + function expireBid(bytes memory data, bytes memory returnData) external; /// @notice Checks if an auction is closed /// @param requestCount_ The request count diff --git a/contracts/evmx/interfaces/IPromise.sol b/contracts/evmx/interfaces/IPromise.sol index 9809d549..f323ae69 100644 --- a/contracts/evmx/interfaces/IPromise.sol +++ b/contracts/evmx/interfaces/IPromise.sol @@ -12,6 +12,12 @@ interface IPromise { /// @dev The callback will be executed on this address function localInvoker() external view returns (address); + /// @notice The callback selector of the promise + function callbackSelector() external view returns (bytes4); + + /// @notice The callback data of the promise + function callbackData() external view returns (bytes memory); + /// @notice The request count of the promise function requestCount() external view returns (uint40); diff --git a/contracts/evmx/watcher/precompiles/SchedulePrecompile.sol b/contracts/evmx/watcher/precompiles/SchedulePrecompile.sol index 597928c7..186c9b42 100644 --- a/contracts/evmx/watcher/precompiles/SchedulePrecompile.sol +++ b/contracts/evmx/watcher/precompiles/SchedulePrecompile.sol @@ -2,6 +2,8 @@ pragma solidity ^0.8.21; import "../../interfaces/IPrecompile.sol"; +import "../../interfaces/IPromise.sol"; + import "../../../utils/common/Structs.sol"; import {InvalidScheduleDelay, ResolvingScheduleTooEarly} from "../../../utils/common/Errors.sol"; import "../../../utils/RescueFundsLib.sol"; @@ -32,7 +34,14 @@ contract SchedulePrecompile is IPrecompile, WatcherBase { /// @notice Emitted when the expiry time for a schedule is set event ExpiryTimeSet(uint256 expiryTime_); /// @notice Emitted when a schedule is requested - event ScheduleRequested(bytes32 payloadId, uint256 executeAfter, uint256 deadline); + event ScheduleRequested( + bytes32 payloadId, + uint256 executeAfter, + uint256 deadline, + address localInvoker, + bytes4 callbackSelector, + bytes callbackData + ); /// @notice Emitted when a schedule is resolved event ScheduleResolved(bytes32 payloadId); @@ -128,8 +137,17 @@ contract SchedulePrecompile is IPrecompile, WatcherBase { precompileData = abi.encode(delayInSeconds, executeAfter); fees = getPrecompileFees(precompileData); + IPromise promise_ = IPromise(payloadParams.asyncPromise); + // emits event for watcher to track schedule and resolve when deadline is reached - emit ScheduleRequested(payloadParams.payloadId, executeAfter, deadline); + emit ScheduleRequested( + payloadParams.payloadId, + executeAfter, + deadline, + promise_.localInvoker(), + promise_.callbackSelector(), + promise_.callbackData() + ); } function resolvePayload(PayloadParams calldata payloadParams_) external onlyRequestHandler { diff --git a/contracts/protocol/Socket.sol b/contracts/protocol/Socket.sol index f08e44cc..4d4b2257 100644 --- a/contracts/protocol/Socket.sol +++ b/contracts/protocol/Socket.sol @@ -14,30 +14,22 @@ import {createPayloadId} from "../utils/common/IdUtils.sol"; contract Socket is SocketUtils { using LibCall for address; - // @notice mapping of payload id to execution status + // mapping of payload id to execution status mapping(bytes32 => ExecutionStatus) public payloadExecuted; - // @notice mapping of payload id to execution status + // mapping of payload id to digest mapping(bytes32 => bytes32) public payloadIdToDigest; //////////////////////////////////////////////////////// ////////////////////// ERRORS ////////////////////////// //////////////////////////////////////////////////////// - /** - * @dev Error emitted when a payload has already been executed - */ + /// @notice Thrown when a payload has already been executed error PayloadAlreadyExecuted(ExecutionStatus status); - /** - * @dev Error emitted when verification fails - */ + /// @notice Thrown when verification fails error VerificationFailed(); - /** - * @dev Error emitted when less gas limit is provided for execution than expected - */ + /// @notice Thrown when less gas limit is provided for execution than expected error LowGasLimit(); - /** - * @dev Error emitted when the message value is insufficient - */ + /// @notice Thrown when the message value is insufficient error InsufficientMsgValue(); /** @@ -56,6 +48,10 @@ contract Socket is SocketUtils { /** * @notice Executes a payload that has been delivered by transmitters and authenticated by switchboards + * @param executeParams_ The execution parameters + * @param transmissionParams_ The transmission parameters + * @return success True if the payload was executed successfully + * @return returnData The return data from the execution */ function execute( ExecuteParams calldata executeParams_, @@ -67,10 +63,11 @@ contract Socket is SocketUtils { // check if the call type is valid if (executeParams_.callType != WRITE) revert InvalidCallType(); - PlugConfigEvm memory plugConfig = _plugConfigs[executeParams_.target]; - // check if the plug is disconnected + // check if the plug is connected + PlugConfigEvm storage plugConfig = _plugConfigs[executeParams_.target]; if (plugConfig.appGatewayId == bytes32(0)) revert PlugNotFound(); + // check if the message value is sufficient if (msg.value < executeParams_.value + transmissionParams_.socketFees) revert InsufficientMsgValue(); @@ -85,12 +82,21 @@ contract Socket is SocketUtils { // verify the digest _verify(payloadId, plugConfig, executeParams_, transmissionParams_.transmitterProof); + + // execute the payload return _execute(payloadId, executeParams_, transmissionParams_); } //////////////////////////////////////////////////////// ////////////////// INTERNAL FUNCS ////////////////////// //////////////////////////////////////////////////////// + /** + * @notice Verifies the digest of the payload + * @param payloadId_ The id of the payload + * @param plugConfig_ The plug configuration + * @param executeParams_ The execution parameters (appGatewayId, value, payloadPointer, callType, gasLimit) + * @param transmitterProof_ The transmitter proof + */ function _verify( bytes32 payloadId_, PlugConfigEvm memory plugConfig_, @@ -123,9 +129,10 @@ contract Socket is SocketUtils { } /** - * This function assumes localPlug_ will have code while executing. As the payload - * execution failure is not blocking the system, it is not necessary to check if - * code exists in the given address. + * @notice Executes the payload + * @param payloadId_ The id of the payload + * @param executeParams_ The execution parameters (appGatewayId, value, payloadPointer, callType, gasLimit) + * @param transmissionParams_ The transmission parameters (socketFees, transmitterProof, refundAddress) */ function _execute( bytes32 payloadId_, @@ -148,6 +155,7 @@ contract Socket is SocketUtils { if (success) { emit ExecutionSuccess(payloadId_, exceededMaxCopy, returnData); + // pay and check fees if (address(socketFeeManager) != address(0)) { socketFeeManager.payAndCheckFees{value: transmissionParams_.socketFees}( executeParams_, @@ -157,17 +165,20 @@ contract Socket is SocketUtils { } else { payloadExecuted[payloadId_] = ExecutionStatus.Reverted; - address receiver = transmissionParams_.refundAddress == address(0) - ? msg.sender - : transmissionParams_.refundAddress; + // refund the fees + address receiver = transmissionParams_.refundAddress; + if (receiver == address(0)) receiver = msg.sender; SafeTransferLib.forceSafeTransferETH(receiver, msg.value); emit ExecutionFailed(payloadId_, exceededMaxCopy, returnData); } return (success, returnData); } - /// @notice Validates the execution status of a payload - /// @dev This function can be retried till execution status is executed + /** + * @notice Validates the execution status of a payload + * @dev This function can be retried till execution status is executed + * @param payloadId_ The id of the payload + */ function _validateExecutionStatus(bytes32 payloadId_) internal { if (payloadExecuted[payloadId_] == ExecutionStatus.Executed) revert PayloadAlreadyExecuted(payloadExecuted[payloadId_]); @@ -179,13 +190,21 @@ contract Socket is SocketUtils { ////////////////////// Trigger ////////////////////// //////////////////////////////////////////////////////// - /// @notice To trigger to a connected remote chain. Should only be called by a plug. + /** + * @notice To trigger to a connected remote chain. Should only be called by a plug. + * @param data_ The data to trigger the app gateway + * @return triggerId The id of the trigger + */ function triggerAppGateway(bytes calldata data_) external payable returns (bytes32 triggerId) { triggerId = _triggerAppGateway(msg.sender, msg.value, data_); } /** * @notice To trigger to a connected remote chain. Should only be called by a plug. + * @param plug_ The address of the plug + * @param value_ The value to trigger the app gateway + * @param data_ The data to trigger the app gateway + * @return triggerId The id of the trigger */ function _triggerAppGateway( address plug_, @@ -220,14 +239,19 @@ contract Socket is SocketUtils { ); } - /// @notice Fallback function that forwards all calls to Socket's callAppGateway - /// @dev The calldata is passed as-is to the gateways + /** + * @notice Fallback function that forwards all calls to Socket's callAppGateway + * @dev The calldata is passed as-is to the gateways + * @return The trigger id + */ fallback(bytes calldata) external payable returns (bytes memory) { // return the trigger id return abi.encode(_triggerAppGateway(msg.sender, msg.value, msg.data)); } - /// @notice Receive function that forwards all calls to Socket's callAppGateway + /** + * @notice Sending ETH to the socket will revert + */ receive() external payable { revert("Socket does not accept ETH"); } diff --git a/contracts/protocol/SocketBatcher.sol b/contracts/protocol/SocketBatcher.sol index 85710e77..1ed5a359 100644 --- a/contracts/protocol/SocketBatcher.sol +++ b/contracts/protocol/SocketBatcher.sol @@ -10,13 +10,17 @@ import "../utils/RescueFundsLib.sol"; import {ExecuteParams, TransmissionParams, CCTPBatchParams, CCTPExecutionParams} from "../utils/common/Structs.sol"; import {createPayloadId} from "../utils/common/IdUtils.sol"; +/** + * @title IFastSwitchboard + * @notice Interface for the fast switchboard + */ interface IFastSwitchboard is ISwitchboard { function attest(bytes32 digest_, bytes calldata proof_) external; } /** * @title SocketBatcher - * @notice The SocketBatcher contract is responsible for batching payloads and transmitting them to the destination chain + * @notice The SocketBatcher contract is responsible for batching payloads and executing them on the socket */ contract SocketBatcher is ISocketBatcher, Ownable { // socket contract @@ -61,6 +65,14 @@ contract SocketBatcher is ISocketBatcher, Ownable { ); } + /** + * @notice Attests a CCTP payload and proves and executes it + * @param execParams_ The execution parameters + * @param cctpParams_ The CCTP parameters + * @param switchboardId_ The switchboard id + * @return success True if the payload was executed successfully + * @return returnData The return data from the execution + */ function attestCCTPAndProveAndExecute( CCTPExecutionParams calldata execParams_, CCTPBatchParams calldata cctpParams_, diff --git a/contracts/protocol/SocketConfig.sol b/contracts/protocol/SocketConfig.sol index a9c0e2ed..990003f4 100644 --- a/contracts/protocol/SocketConfig.sol +++ b/contracts/protocol/SocketConfig.sol @@ -55,23 +55,38 @@ abstract contract SocketConfig is ISocket, AccessControl { event SwitchboardEnabled(uint64 switchboardId); // @notice event triggered when a socket fee manager is updated event SocketFeeManagerUpdated(address oldSocketFeeManager, address newSocketFeeManager); + // @notice event triggered when the gas limit buffer is updated + event GasLimitBufferUpdated(uint256 gasLimitBuffer); + // @notice event triggered when the max copy bytes is updated + event MaxCopyBytesUpdated(uint16 maxCopyBytes); - // @notice function to register a switchboard - // @dev only callable by switchboards + /** + * @notice Registers a switchboard on the socket + * @dev This function is called by the switchboard to register itself on the socket + * @dev This function will revert if the switchboard already exists + * @return switchboardId The id of the switchboard + */ function registerSwitchboard() external returns (uint64 switchboardId) { switchboardId = switchboardIds[msg.sender]; if (switchboardId != 0) revert SwitchboardExists(); + // increment the switchboard id counter switchboardId = switchboardIdCounter++; + + // set the switchboard id and address switchboardIds[msg.sender] = switchboardId; switchboardAddresses[switchboardId] = msg.sender; - isValidSwitchboard[switchboardId] = SwitchboardStatus.REGISTERED; + // set the switchboard status to registered + isValidSwitchboard[switchboardId] = SwitchboardStatus.REGISTERED; emit SwitchboardAdded(msg.sender, switchboardId); } - // @notice function to disable a switchboard - // @dev only callable by governance role + /** + * @notice Disables a switchboard + * @dev This function is called by the governance role to disable a switchboard + * @param switchboardId_ The id of the switchboard to disable + */ function disableSwitchboard( uint64 switchboardId_ ) external onlyRole(SWITCHBOARD_DISABLER_ROLE) { @@ -79,25 +94,32 @@ abstract contract SocketConfig is ISocket, AccessControl { emit SwitchboardDisabled(switchboardId_); } - // @notice function to enable a switchboard if disabled - // @dev only callable by governance role + /** + * @notice Enables a switchboard if disabled + * @dev This function is called by the governance role to enable a switchboard + * @param switchboardId_ The id of the switchboard to enable + */ function enableSwitchboard(uint64 switchboardId_) external onlyRole(GOVERNANCE_ROLE) { isValidSwitchboard[switchboardId_] = SwitchboardStatus.REGISTERED; emit SwitchboardEnabled(switchboardId_); } - // @notice function to set the socket fee manager - // @dev only callable by governance role - // @param socketFeeManager_ address of the socket fee manager + /** + * @notice Sets the socket fee manager + * @dev This function is called by the governance role to set the socket fee manager + * @param socketFeeManager_ The address of the socket fee manager + */ function setSocketFeeManager(address socketFeeManager_) external onlyRole(GOVERNANCE_ROLE) { socketFeeManager = ISocketFeeManager(socketFeeManager_); emit SocketFeeManagerUpdated(address(socketFeeManager), socketFeeManager_); } - // @notice function to connect a plug to socket - // @dev only callable by plug - // @param appGatewayId_ app gateway id - // @param switchboardId_ switchboard id + /** + * @notice Connects a plug to socket + * @dev This function is called by the plug to connect itself to the socket + * @param appGatewayId_ The app gateway id + * @param switchboardId_ The switchboard id + */ function connect(bytes32 appGatewayId_, uint64 switchboardId_) external override { if (isValidSwitchboard[switchboardId_] != SwitchboardStatus.REGISTERED) revert InvalidSwitchboard(); @@ -109,8 +131,10 @@ abstract contract SocketConfig is ISocket, AccessControl { emit PlugConnected(msg.sender, appGatewayId_, switchboardId_); } - // @notice function to disconnect a plug from socket - // @dev only callable by plug + /** + * @notice Disconnects a plug from socket + * @dev This function is called by the plug to disconnect itself from the socket + */ function disconnect() external override { PlugConfigEvm storage _plugConfig = _plugConfigs[msg.sender]; if (_plugConfig.appGatewayId == bytes32(0)) revert PlugNotConnected(); @@ -120,23 +144,29 @@ abstract contract SocketConfig is ISocket, AccessControl { emit PlugDisconnected(msg.sender); } - // @notice function to set the gas limit buffer for socket - // @dev only callable by governance role - // @param gasLimitBuffer_ gas limit buffer for socket + /** + * @notice Sets the gas limit buffer for socket + * @dev This function is called by the governance role to set the gas limit buffer for socket + * @param gasLimitBuffer_ The gas limit buffer for socket + */ function setGasLimitBuffer(uint256 gasLimitBuffer_) external onlyRole(GOVERNANCE_ROLE) { gasLimitBuffer = gasLimitBuffer_; + emit GasLimitBufferUpdated(gasLimitBuffer_); } - // @notice function to set the max copy bytes for socket - // @dev only callable by governance role - // @param maxCopyBytes_ max copy bytes for socket + /** + * @notice Sets the max copy bytes for socket + * @dev This function is called by the governance role to set the max copy bytes for socket + * @param maxCopyBytes_ The max copy bytes for socket + */ function setMaxCopyBytes(uint16 maxCopyBytes_) external onlyRole(GOVERNANCE_ROLE) { maxCopyBytes = maxCopyBytes_; + emit MaxCopyBytesUpdated(maxCopyBytes_); } /** - * @notice returns the config for given `plugAddress_` - * @param plugAddress_ address of plug present at current chain + * @notice Returns the config for given `plugAddress_` + * @param plugAddress_ The address of the plug present at current chain * @return appGatewayId The app gateway id * @return switchboardId The switchboard id */ diff --git a/contracts/protocol/SocketFeeManager.sol b/contracts/protocol/SocketFeeManager.sol index 3e3bfa8e..c0b7b946 100644 --- a/contracts/protocol/SocketFeeManager.sol +++ b/contracts/protocol/SocketFeeManager.sol @@ -12,12 +12,28 @@ import "../utils/RescueFundsLib.sol"; * @notice The SocketFeeManager contract is responsible for managing socket fees */ contract SocketFeeManager is ISocketFeeManager, AccessControl { - // Current socket fees in native tokens + // current socket fees in native tokens uint256 public socketFees; + //////////////////////////////////////////////////////////// + ////////////////////// ERRORS ////////////////////////// + //////////////////////////////////////////////////////////// + + /// @notice Thrown when the fees are insufficient error InsufficientFees(); + + /// @notice Thrown when the fees are too low error FeeTooLow(); + //////////////////////////////////////////////////////////// + ////////////////////// EVENTS ////////////////////////// + //////////////////////////////////////////////////////////// + + /** + * @notice Emitted when the socket fees are updated + * @param oldFees The old socket fees + * @param newFees The new socket fees + */ event SocketFeesUpdated(uint256 oldFees, uint256 newFees); /** @@ -26,14 +42,16 @@ contract SocketFeeManager is ISocketFeeManager, AccessControl { * @param socketFees_ Initial socket fees amount */ constructor(address owner_, uint256 socketFees_) { - emit SocketFeesUpdated(0, socketFees_); - socketFees = socketFees_; _grantRole(GOVERNANCE_ROLE, owner_); _grantRole(RESCUE_ROLE, owner_); + + socketFees = socketFees_; + emit SocketFeesUpdated(0, socketFees_); } /** * @notice Pays and validates fees for execution + * @dev This function is payable and will revert if the fees are insufficient */ function payAndCheckFees(ExecuteParams memory, TransmissionParams memory) external payable { if (msg.value < socketFees) revert InsufficientFees(); diff --git a/contracts/protocol/SocketUtils.sol b/contracts/protocol/SocketUtils.sol index ac652670..303d67ab 100644 --- a/contracts/protocol/SocketUtils.sol +++ b/contracts/protocol/SocketUtils.sol @@ -25,30 +25,35 @@ abstract contract SocketUtils is SocketConfig { bytes payload; } + // address of the off-chain caller address public constant OFF_CHAIN_CALLER = address(0xDEAD); - // Prefix for trigger ID containing chain slug and address bits + // prefix for trigger ID containing chain slug and address bits uint256 private immutable triggerPrefix; - // Version string for this socket instance + // version string for this socket instance bytes32 public immutable version; - // ChainSlug for this deployed socket instance + // chain slug for this deployed socket instance uint32 public immutable chainSlug; - // @notice counter for trigger id + // counter for trigger id uint64 public triggerCounter; + /// @notice Thrown when the caller is not off-chain error OnlyOffChain(); + + /// @notice Thrown when the simulation fails error SimulationFailed(); + /// @notice Modifier to check if the caller is off-chain modifier onlyOffChain() { if (msg.sender != OFF_CHAIN_CALLER) revert OnlyOffChain(); _; } - /* - * @notice constructor for creating a new Socket contract instance. - * @param chainSlug_ The unique identifier of the chain this socket is deployed on. - * @param owner_ The address of the owner who has the initial admin role. - * @param version_ The version string which is hashed and stored in socket. + /** + * @notice constructor for creating a new Socket contract instance + * @param chainSlug_ The unique identifier of the chain this socket is deployed on + * @param owner_ The address of the owner who has the initial admin role + * @param version_ The version string which is hashed and stored in socket */ constructor(uint32 chainSlug_, address owner_, string memory version_) { chainSlug = chainSlug_; @@ -59,12 +64,13 @@ abstract contract SocketUtils is SocketConfig { } /** - * @notice creates the digest for the payload + * @notice Creates the digest for the payload * @param transmitter_ The address of the transmitter * @param payloadId_ The ID of the payload * @param appGatewayId_ The id of the app gateway * @param executeParams_ The parameters of the payload * @return The packed payload as a bytes32 hash + * @dev This function is used to create the digest for the payload */ function _createDigest( address transmitter_, @@ -94,17 +100,30 @@ abstract contract SocketUtils is SocketConfig { /** * @notice Encodes the trigger ID with the chain slug, socket address and nonce * @return The trigger ID + * @dev This function is used to encode the trigger ID with the chain slug, socket address and nonce */ function _encodeTriggerId() internal returns (bytes32) { return bytes32(triggerPrefix | triggerCounter++); } + /** + * @notice Simulation result + * @param success True if the simulation was successful + * @param returnData The return data from the simulation + * @param exceededMaxCopy True if the simulation exceeded the max copy bytes + */ struct SimulationResult { bool success; bytes returnData; bool exceededMaxCopy; } + /** + * @notice Simulates the payload + * @dev This function is used to simulate the payload offchain for gas estimation and checking reverts + * @param params The parameters of the simulation + * @return The simulation results + */ function simulate( SimulateParams[] calldata params ) external payable onlyOffChain returns (SimulationResult[] memory) { @@ -127,9 +146,9 @@ abstract contract SocketUtils is SocketConfig { /** * @notice Rescues funds from the contract if they are locked by mistake. This contract does not * theoretically need this function but it is added for safety. - * @param token_ The address of the token contract. - * @param rescueTo_ The address where rescued tokens need to be sent. - * @param amount_ The amount of tokens to be rescued. + * @param token_ The address of the token contract + * @param rescueTo_ The address where rescued tokens need to be sent + * @param amount_ The amount of tokens to be rescued */ function rescueFunds( address token_, diff --git a/contracts/protocol/base/PlugBase.sol b/contracts/protocol/base/PlugBase.sol index 46c9bf9b..a6eda992 100644 --- a/contracts/protocol/base/PlugBase.sol +++ b/contracts/protocol/base/PlugBase.sol @@ -9,11 +9,19 @@ import {NotSocket, SocketAlreadyInitialized} from "../../utils/common/Errors.sol /// @notice Abstract contract for plugs /// @dev This contract contains helpers for socket connection, disconnection, and overrides abstract contract PlugBase is IPlug { + // socket instance ISocket public socket__; + + // app gateway id connected to this plug bytes32 public appGatewayId; + + // tracks if socket is initialized uint256 public isSocketInitialized; + + // overrides encoded in bytes bytes public overrides; + // event emitted when plug is disconnected event ConnectorPlugDisconnected(); /// @notice Modifier to ensure only the socket can call the function @@ -41,6 +49,8 @@ abstract contract PlugBase is IPlug { ) internal { _setSocket(socket_); appGatewayId = appGatewayId_; + + // connect to the app gateway and switchboard socket__.connect(appGatewayId_, switchboardId_); } @@ -57,11 +67,18 @@ abstract contract PlugBase is IPlug { } /// @notice Sets the overrides needed for the trigger + /// @dev encoding format depends on the watcher system /// @param overrides_ The overrides function _setOverrides(bytes memory overrides_) internal { overrides = overrides_; } + /// @notice Initializes the socket + /// @dev this function should be called even if deployed independently + /// to avoid ownership and permission exploit + /// @param appGatewayId_ The app gateway id + /// @param socket_ The socket address + /// @param switchboardId_ The switchboard id function initSocket( bytes32 appGatewayId_, address socket_, diff --git a/contracts/protocol/interfaces/ICCTPSwitchboard.sol b/contracts/protocol/interfaces/ICCTPSwitchboard.sol index 796ee602..cbf8894d 100644 --- a/contracts/protocol/interfaces/ICCTPSwitchboard.sol +++ b/contracts/protocol/interfaces/ICCTPSwitchboard.sol @@ -45,14 +45,20 @@ interface ICCTPSwitchboard is ISwitchboard { /** * @notice Verifies the attestations - * @param messages_ The messages - * @param attestations_ The attestations + * @param messages_ The list of messages + * @param attestations_ The list of attestations */ function verifyAttestations( bytes[] calldata messages_, bytes[] calldata attestations_ ) external; + /** + * @notice Attests, verifies and proves the executions + * @param execParams_ The execution parameters + * @param cctpParams_ The CCTP parameters + * @param payloadId_ The payload id + */ function attestVerifyAndProveExecutions( CCTPExecutionParams calldata execParams_, CCTPBatchParams calldata cctpParams_, diff --git a/contracts/protocol/interfaces/IMessageHandler.sol b/contracts/protocol/interfaces/IMessageHandler.sol index c6c29b10..cdc4764e 100644 --- a/contracts/protocol/interfaces/IMessageHandler.sol +++ b/contracts/protocol/interfaces/IMessageHandler.sol @@ -1,15 +1,15 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; + /** * @title IMessageHandler - * @notice Handles messages on destination domain forwarded from - * an IReceiver + * @notice Handles messages on destination forwarded from IReceiver */ interface IMessageHandler { /** - * @notice handles an incoming message from a Receiver - * @param sourceDomain the source domain of the message - * @param sender the sender of the message + * @notice Handles an incoming message from a Receiver + * @param sourceDomain The source chain slug of the message + * @param sender The sender of the message * @param messageBody The message raw bytes * @return success bool, true if successful */ diff --git a/contracts/protocol/interfaces/IMessageTransmitter.sol b/contracts/protocol/interfaces/IMessageTransmitter.sol index 427f2813..a00626f0 100644 --- a/contracts/protocol/interfaces/IMessageTransmitter.sol +++ b/contracts/protocol/interfaces/IMessageTransmitter.sol @@ -1,19 +1,44 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; +/** + * @title IMessageTransmitter + * @notice Transmits messages to a destination domain + */ interface IMessageTransmitter { + /** + * @notice Sends a message to a destination domain + * @param destinationDomain The destination domain + * @param recipient The recipient of the message + * @param messageBody The message body + * @return nonce The nonce of the message + */ function sendMessage( uint32 destinationDomain, bytes32 recipient, bytes calldata messageBody ) external returns (uint64 nonce); + /** + * @notice Receives a message from a source domain + * @param message The message body + * @param attestation The attestation + * @return success True if the message was received successfully + */ function receiveMessage( bytes calldata message, bytes calldata attestation ) external returns (bool success); + /** + * @notice Returns the local domain + * @return localDomain The local domain + */ function localDomain() external view returns (uint32); + /** + * @notice Returns the attestation manager + * @return attestationManager The attestation manager address + */ function attestationManager() external view returns (address); } diff --git a/contracts/protocol/interfaces/IPlug.sol b/contracts/protocol/interfaces/IPlug.sol index 2eb70721..f67160a4 100644 --- a/contracts/protocol/interfaces/IPlug.sol +++ b/contracts/protocol/interfaces/IPlug.sol @@ -13,6 +13,7 @@ interface IPlug { function initSocket(bytes32 appGatewayId_, address socket_, uint64 switchboardId_) external; /// @notice Gets the overrides + /// @dev encoding format depends on the watcher system /// @return overrides_ The overrides function overrides() external view returns (bytes memory overrides_); } diff --git a/contracts/protocol/interfaces/ISocket.sol b/contracts/protocol/interfaces/ISocket.sol index 04bc8d85..166c0f88 100644 --- a/contracts/protocol/interfaces/ISocket.sol +++ b/contracts/protocol/interfaces/ISocket.sol @@ -26,15 +26,15 @@ interface ISocket { /** * @notice emits the config set by a plug for a remoteChainSlug - * @param plug address of plug on current chain - * @param appGatewayId address of plug on sibling chain - * @param switchboardId outbound switchboard (select from registered options) + * @param plug The address of plug on current chain + * @param appGatewayId The address of plug on sibling chain + * @param switchboardId The outbound switchboard (select from registered options) */ event PlugConnected(address plug, bytes32 appGatewayId, uint64 switchboardId); /** * @notice emits the config set by a plug for a remoteChainSlug - * @param plug address of plug on current chain + * @param plug The address of plug on current chain */ event PlugDisconnected(address plug); @@ -56,7 +56,11 @@ interface ISocket { ); /** - * @notice executes a payload + * @notice Executes a payload + * @param executeParams_ The execution parameters + * @param transmissionParams_ The transmission parameters + * @return success True if the payload was executed successfully + * @return returnData The return data from the execution */ function execute( ExecuteParams calldata executeParams_, @@ -65,36 +69,62 @@ interface ISocket { /** * @notice sets the config specific to the plug - * @param appGatewayId_ address of plug present at sibling chain - * @param switchboardId_ the id of switchboard to use for executing payloads + * @param appGatewayId_ The address of plug present at sibling chain + * @param switchboardId_ The id of switchboard to use for executing payloads */ function connect(bytes32 appGatewayId_, uint64 switchboardId_) external; /** - * @notice disconnects Plug from Socket + * @notice Disconnects Plug from Socket */ function disconnect() external; /** - * @notice registers a switchboard for the socket + * @notice Registers a switchboard for the socket + * @return switchboardId The id of the switchboard */ function registerSwitchboard() external returns (uint64); /** - * @notice returns the config for given `plugAddress_` and `siblingChainSlug_` - * @param plugAddress_ address of plug present at current chain + * @notice Returns the config for given `plugAddress_` and `siblingChainSlug_` + * @param plugAddress_ The address of plug present at current chain + * @return appGatewayId The address of plug on sibling chain + * @return switchboardId The id of the switchboard */ function getPlugConfig( address plugAddress_ ) external view returns (bytes32 appGatewayId, uint64 switchboardId); + /** + * @notice Returns the execution status of a payload + * @param payloadId_ The payload id + * @return executionStatus The execution status + */ function payloadExecuted(bytes32 payloadId_) external view returns (ExecutionStatus); + /** + * @notice Returns the chain slug + * @return chainSlug The chain slug + */ function chainSlug() external view returns (uint32); + /** + * @notice Returns the digest of a payload + * @param payloadId_ The payload id + * @return digest The digest + */ function payloadIdToDigest(bytes32 payloadId_) external view returns (bytes32); + /** + * @notice Returns the current trigger counter + * @return triggerCounter The trigger counter + */ function triggerCounter() external view returns (uint64); + /** + * @notice Returns the switchboard address for a given switchboard id + * @param switchboardId_ The switchboard id + * @return switchboardAddress The switchboard address + */ function switchboardAddresses(uint64 switchboardId_) external view returns (address); } diff --git a/contracts/protocol/interfaces/ISocketBatcher.sol b/contracts/protocol/interfaces/ISocketBatcher.sol index 662a477e..f31782b1 100644 --- a/contracts/protocol/interfaces/ISocketBatcher.sol +++ b/contracts/protocol/interfaces/ISocketBatcher.sol @@ -5,7 +5,8 @@ import {ExecuteParams} from "../../utils/common/Structs.sol"; /** * @title ISocketBatcher - * @notice Interface for a helper contract for socket which batches attest (on sb) and execute calls (on socket). + * @notice Interface for a helper contract for socket which batches attest (on sb) + * and execute calls (on socket) */ interface ISocketBatcher { /** @@ -14,6 +15,7 @@ interface ISocketBatcher { * @param digest_ The digest of the payload * @param proof_ The proof of the payload * @param transmitterSignature_ The signature of the transmitter + * @param refundAddress_ The address to refund the fees to * @return The return data after execution */ function attestAndExecute( diff --git a/contracts/protocol/interfaces/ISocketFeeManager.sol b/contracts/protocol/interfaces/ISocketFeeManager.sol index b1029300..029379e5 100644 --- a/contracts/protocol/interfaces/ISocketFeeManager.sol +++ b/contracts/protocol/interfaces/ISocketFeeManager.sol @@ -3,11 +3,15 @@ pragma solidity ^0.8.21; import {ExecuteParams, TransmissionParams} from "../../utils/common/Structs.sol"; +/** + * @title ISocketFeeManager + * @notice Interface for the socket fee manager + */ interface ISocketFeeManager { /** * @notice Pays and validates fees for execution - * @param executeParams_ Execute params - * @param transmissionParams_ Transmission params + * @param executeParams_ The execution parameters + * @param transmissionParams_ The transmission parameters */ function payAndCheckFees( ExecuteParams memory executeParams_, @@ -16,19 +20,19 @@ interface ISocketFeeManager { /** * @notice Gets minimum fees required for execution - * @return nativeFees Minimum native token fees required + * @return nativeFees The minimum native token fees required */ function getMinSocketFees() external view returns (uint256 nativeFees); /** * @notice Sets socket fees - * @param socketFees_ New socket fees amount + * @param socketFees_ The new socket fees amount */ function setSocketFees(uint256 socketFees_) external; /** * @notice Gets current socket fees - * @return Current socket fees amount + * @return socketFees The current socket fees amount */ function socketFees() external view returns (uint256); } diff --git a/contracts/protocol/interfaces/ISwitchboard.sol b/contracts/protocol/interfaces/ISwitchboard.sol index e8518d64..f462cd18 100644 --- a/contracts/protocol/interfaces/ISwitchboard.sol +++ b/contracts/protocol/interfaces/ISwitchboard.sol @@ -17,6 +17,8 @@ interface ISwitchboard { /** * @notice Processes a trigger and creates payload + * @dev This function is called by the socket to process a trigger + * @dev sb can override this function to add additional logic * @param triggerId_ Trigger ID from socket * @param plug_ Source plug address * @param payload_ Payload data diff --git a/contracts/protocol/switchboard/FastSwitchboard.sol b/contracts/protocol/switchboard/FastSwitchboard.sol index 95a41629..abdd3ce7 100644 --- a/contracts/protocol/switchboard/FastSwitchboard.sol +++ b/contracts/protocol/switchboard/FastSwitchboard.sol @@ -61,6 +61,9 @@ contract FastSwitchboard is SwitchboardBase { return isAttested[digest_]; } + /** + * @inheritdoc ISwitchboard + */ function processTrigger( address plug_, bytes32 triggerId_, diff --git a/contracts/protocol/switchboard/SwitchboardBase.sol b/contracts/protocol/switchboard/SwitchboardBase.sol index a6ae97cb..43d5cf52 100644 --- a/contracts/protocol/switchboard/SwitchboardBase.sol +++ b/contracts/protocol/switchboard/SwitchboardBase.sol @@ -11,11 +11,13 @@ import {RESCUE_ROLE} from "../../utils/common/AccessRoles.sol"; /// @title SwitchboardBase /// @notice Base contract for switchboards, contains common and util functions for all switchboards abstract contract SwitchboardBase is ISwitchboard, AccessControl { + // socket contract ISocket public immutable socket__; // chain slug of deployed chain uint32 public immutable chainSlug; + // switchboard id uint64 public switchboardId; /** @@ -29,12 +31,23 @@ abstract contract SwitchboardBase is ISwitchboard, AccessControl { _initializeOwner(owner_); } + /** + * @notice Registers a switchboard on the socket + * @dev This function is called by the owner of the switchboard + */ function registerSwitchboard() external onlyOwner { switchboardId = socket__.registerSwitchboard(); } + /** + * @notice Returns the transmitter for a given payload + * @dev If the transmitter signature is provided, the function will return the signer of the signature + * @param payloadId_ The payload id + * @param transmitterSignature_ The transmitter signature (optional) + * @return transmitter The transmitter address + */ function getTransmitter( - address sender_, + address, bytes32 payloadId_, bytes calldata transmitterSignature_ ) external view returns (address transmitter) { diff --git a/deployments/dev_addresses.json b/deployments/dev_addresses.json index 800d41be..a540d6af 100644 --- a/deployments/dev_addresses.json +++ b/deployments/dev_addresses.json @@ -5,7 +5,7 @@ "AsyncDeployer": "0xF1D3ebDF91Cf4b1bc7C9A1D78413CD1Ed2d3123d", "AsyncDeployerImpl": "0x8daf174Be9Bb708c04b708A92b88Cc89bd223498", "AuctionManager": "0xE4243383566fcA32aA6815dE83e8EA86b2027b8b", - "AuctionManagerImpl": "0x122beAFCfc2E99D825322a78EAFD8a11fa2d9E0b", + "AuctionManagerImpl": "0x8EB4402AFAa335b05Bb37f80377F77eeC678b734", "Configurations": "0x6a6697A2AD51DB9a41BaEE78e194335c1aD7369d", "ConfigurationsImpl": "0x8A9256F31b0bb85863c253F8CAE800A32Cb2d595", "DeployForwarder": "0xE986bCd19b8725ea3417C2A7728158ecABA6C8bE", @@ -18,13 +18,31 @@ "ReadPrecompile": "0xE693bEc40e39223749AC351156E713b7256541B0", "RequestHandler": "0xE785Fdbd049D0647e8B2Bd28C75a679dEBaD9D6f", "RequestHandlerImpl": "0x5332d341cd7B423C2f75AF7Ca295455e5F08fAcb", - "SchedulePrecompile": "0x99af65efe676C4899F6e500DF18d4fD84dbe0A1D", + "SchedulePrecompile": "0x1099338aB85627640bB7A0D55c683921EA766C75", "startBlock": 10904, "Watcher": "0x96ACe2d4a36a1Fd6e3eeE1cD3FeDA36eA62E3064", "WatcherImpl": "0xE5542FAB56B652A95aBD05a08E920687d1ef3849", "WritePrecompile": "0x27794dd1166ED0c6A70c655C297BB79bF06bf44A", "WritePrecompileImpl": "0xc2Ca571f4d4C2008Da4Bd750BaD3d50A5705ffF8" }, + "84532": { + "CCTPSwitchboard": "0xBD6770182fB47DD77924aDf3F200246Ab851f9c2", + "CCTPSwitchboardId": "2", + "ContractFactoryPlug": "0x6320Ff773a4E01Cb8EB849EA906F17Cf6c48Ff9c", + "FastSwitchboard": "0x2420B85D7e126d1948a4602f0c78a685655292Bd", + "FastSwitchboardId": "1", + "FeesPlug": "0x89634ecFea933aFaD5d3D6557b13cb8D466313d2", + "MessageSwitchboard": "0xd94741a4654953817faEe228739a6d10C0683839", + "MessageSwitchboardId": "3", + "Socket": "0xA90f2aB2804e8575D021882aAB74399fa282A8A3", + "SocketBatcher": "0x138C1B6e301C7d1B59920bEe2834f5B481bA39dF", + "startBlock": 29270214, + "SwitchboardIdToAddressMap": { + "1": "0x2420B85D7e126d1948a4602f0c78a685655292Bd", + "2": "0xBD6770182fB47DD77924aDf3F200246Ab851f9c2", + "3": "0xd94741a4654953817faEe228739a6d10C0683839" + } + }, "421614": { "CCTPSwitchboard": "0xaF912b7eaD59f5d8c8179f8606A3fa93459a612C", "CCTPSwitchboardId": "2", diff --git a/deployments/dev_verification.json b/deployments/dev_verification.json index 3b3f4600..9040b3a1 100644 --- a/deployments/dev_verification.json +++ b/deployments/dev_verification.json @@ -1,5 +1,6 @@ { "14323": [], + "84532": [], "421614": [], "7625382": [ [ diff --git a/foundry.toml b/foundry.toml index 5144b5ba..2499c44b 100644 --- a/foundry.toml +++ b/foundry.toml @@ -10,26 +10,26 @@ evm_version = 'paris' via_ir = false [labels] -0xAA77c2dE14CfFF4244a127deED6b53ce79481e14 = "AddressResolver" -0xe857a826D330Fc0429c67FaBEB8B66C26ea1DD5f = "AddressResolverImpl" -0x24c3f774c231ADFeb5e22Ad826a666A0FF9742C8 = "AsyncDeployer" -0xB7Bf09935108753491E59114dc0B713cDa6F703F = "AsyncDeployerImpl" -0xd5853f69f5dE728AEF7d1cF029cB3bF1581A4ED4 = "AuctionManager" -0x89A0D4550D5aFa809B74856624D4595188641BCe = "AuctionManagerImpl" -0x0f2801ee741A3BdeA2245d97AB54B1C4d7734534 = "Configurations" -0xD41d93042Dd1aB8c712C212A6907d4dC0718D021 = "ConfigurationsImpl" -0x54676a772aEe69E3F87178F2b5E4414dcE9A9720 = "DeployForwarder" -0x9882ce57b618175Bd9d3a4eC50ebD682B39bc467 = "DeployForwarderImpl" -0x61788F19CA1b098cE8437f8eb13B1Ad68f4FcD77 = "ERC1967Factory" -0x9339e8D915Aaf467d2fC01a4e694c8FE85621e94 = "FeesManager" -0x27b763c5410E83c02F21D97B33555729B77B2Ce1 = "FeesManagerImpl" -0xC8d803B7c1719cdF21392405879D1B56398045C4 = "FeesPool" -0x9BE3513a5d32E74935a54e5516b4daa198da5574 = "PromiseResolver" -0x784730D5e5D2F64eA63BfafeDC759317438c9186 = "ReadPrecompile" -0x22FaddfD47B9E0B545f83a2E7Cd05c12889c7a57 = "RequestHandler" -0xAA6EfF8dbd53B8d95a02c59Fe5C8A8422B08F5AA = "RequestHandlerImpl" -0x074118aB15e54A84b42Ff3de5233721434cF9f55 = "SchedulePrecompile" -0xdd25a87AeB5bCEeBAc0EB27aFfaBB6eB5a2857ca = "Watcher" -0xb143810f13fDF66F7a9B973252AEC80ec47FF0cb = "WatcherImpl" -0x66ce424303EC8499C5cdC4F6437A0434D8bd9b81 = "WritePrecompile" -0x962E1db23f6C5879A5c9D58CcB8c67CD282F1000 = "WritePrecompileImpl" +0x774f608eD8fc03B05a9da51588F8571ced4c2eb2 = "AddressResolver" +0x9c58dAABeBE7D6DfD8F70097c6f9c87FEC9b83DE = "AddressResolverImpl" +0xF1D3ebDF91Cf4b1bc7C9A1D78413CD1Ed2d3123d = "AsyncDeployer" +0x8daf174Be9Bb708c04b708A92b88Cc89bd223498 = "AsyncDeployerImpl" +0xE4243383566fcA32aA6815dE83e8EA86b2027b8b = "AuctionManager" +0x8EB4402AFAa335b05Bb37f80377F77eeC678b734 = "AuctionManagerImpl" +0x6a6697A2AD51DB9a41BaEE78e194335c1aD7369d = "Configurations" +0x8A9256F31b0bb85863c253F8CAE800A32Cb2d595 = "ConfigurationsImpl" +0xE986bCd19b8725ea3417C2A7728158ecABA6C8bE = "DeployForwarder" +0xfBe803842B50d8A2a91DA3dD88B67E92D5C0bd97 = "DeployForwarderImpl" +0x4f1Cd0CdBc7EA445b8B34Af8844fA4D4B5f48b79 = "ERC1967Factory" +0xa6D93e7B2cde3C8d318f45890dE3dB0a2E54058B = "FeesManager" +0x38A7558D2C3b4097c2098444a46D625D51E7336F = "FeesManagerImpl" +0x13A3018920c7b56B20dd34E29C298121025E6de4 = "FeesPool" +0x40834274ee715B1748e450A67cFf2B52b0388eC3 = "PromiseResolver" +0xE693bEc40e39223749AC351156E713b7256541B0 = "ReadPrecompile" +0xE785Fdbd049D0647e8B2Bd28C75a679dEBaD9D6f = "RequestHandler" +0x5332d341cd7B423C2f75AF7Ca295455e5F08fAcb = "RequestHandlerImpl" +0x1099338aB85627640bB7A0D55c683921EA766C75 = "SchedulePrecompile" +0x96ACe2d4a36a1Fd6e3eeE1cD3FeDA36eA62E3064 = "Watcher" +0xE5542FAB56B652A95aBD05a08E920687d1ef3849 = "WatcherImpl" +0x27794dd1166ED0c6A70c655C297BB79bF06bf44A = "WritePrecompile" +0xc2Ca571f4d4C2008Da4Bd750BaD3d50A5705ffF8 = "WritePrecompileImpl" diff --git a/hardhat-scripts/deploy/6.connect.ts b/hardhat-scripts/deploy/6.connect.ts index 32975a63..031e12b9 100644 --- a/hardhat-scripts/deploy/6.connect.ts +++ b/hardhat-scripts/deploy/6.connect.ts @@ -1,9 +1,8 @@ -import { ethers, Wallet } from "ethers"; +import { Wallet } from "ethers"; import { ChainAddressesObj, ChainSlug, Contracts } from "../../src"; import { chains, EVMX_CHAIN_ID, mode } from "../config"; import { AppGatewayConfig, DeploymentAddresses } from "../constants"; import { - checkIfAddressExists, checkIfAppGatewayIdExists, getAddresses, getAppGatewayId, @@ -56,7 +55,12 @@ async function connectPlug( } // Connect the plug - const tx = await plug.functions["connectSocket"]( + let functionName = "initSocket"; + + const isInitialized = await plug.isSocketInitialized(); + if (isInitialized.toNumber() === 1) functionName = "connectSocket"; + + const tx = await plug.functions[functionName]( appGatewayId, socket.address, switchboardId, diff --git a/test/Socket.t.sol b/test/Socket.t.sol index 190cdcb3..10bcf4e0 100644 --- a/test/Socket.t.sol +++ b/test/Socket.t.sol @@ -869,7 +869,7 @@ contract SocketRescueTest is SocketTestBase { function testSendingEthToSocket() public { vm.expectRevert("Socket does not accept ETH"); - address(socket).call{value: 1 ether}(""); + (bool success, ) = address(socket).call{value: 1 ether}(""); } function testRescueNFT() public { diff --git a/test/apps/app-gateways/counter/CounterAppGateway.sol b/test/apps/app-gateways/counter/CounterAppGateway.sol index 8615c82c..ac887076 100644 --- a/test/apps/app-gateways/counter/CounterAppGateway.sol +++ b/test/apps/app-gateways/counter/CounterAppGateway.sol @@ -119,8 +119,9 @@ contract CounterAppGateway is AppGatewayBase, Ownable { then(this.resolveSchedule.selector, abi.encode(block.timestamp)); } - function resolveSchedule(uint256 creationTimestamp_) external onlyPromises { - emit CounterScheduleResolved(creationTimestamp_, block.timestamp); + function resolveSchedule(bytes memory data, bytes memory) external onlyPromises { + uint256 creationTimestamp = abi.decode(data, (uint256)); + emit CounterScheduleResolved(creationTimestamp, block.timestamp); } // UTILS