From 86c0af221c9f77880e774201933e4e6bb3cc9a9f Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Thu, 3 Apr 2025 15:55:25 +0530 Subject: [PATCH 1/2] fix: diff counter for timeout --- .../protocol/watcherPrecompile/WatcherPrecompileCore.sol | 9 ++++----- test/DeliveryHelper.t.sol | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/contracts/protocol/watcherPrecompile/WatcherPrecompileCore.sol b/contracts/protocol/watcherPrecompile/WatcherPrecompileCore.sol index 7950823e..cdc88171 100644 --- a/contracts/protocol/watcherPrecompile/WatcherPrecompileCore.sol +++ b/contracts/protocol/watcherPrecompile/WatcherPrecompileCore.sol @@ -32,7 +32,7 @@ abstract contract WatcherPrecompileCore is // from auction manager watcherPrecompileLimits__.consumeLimit(_getCoreAppGateway(msg.sender), SCHEDULE, 1); uint256 executeAt = block.timestamp + delayInSeconds_; - timeoutId = _encodeId(evmxSlug, address(this)); + timeoutId = _encodeTimeoutId(evmxSlug, address(this)); timeoutRequests[timeoutId] = TimeoutRequest( timeoutId, msg.sender, @@ -192,18 +192,17 @@ abstract contract WatcherPrecompileCore is if (switchboard != switchboard_) revert InvalidSwitchboard(); } - // todo: revisit when we do timeout precompile - function _encodeId( + function _encodeTimeoutId( uint32 chainSlug_, address switchboardOrWatcher_ ) internal returns (bytes32) { - // Encode payload ID by bit-shifting and combining: + // Encode timeout ID by bit-shifting and combining: // chainSlug (32 bits) | switchboard or watcher precompile address (160 bits) | counter (64 bits) return bytes32( (uint256(chainSlug_) << 224) | (uint256(uint160(switchboardOrWatcher_)) << 64) | - payloadCounter++ + timeoutCounter++ ); } diff --git a/test/DeliveryHelper.t.sol b/test/DeliveryHelper.t.sol index 09ecc39d..ea346775 100644 --- a/test/DeliveryHelper.t.sol +++ b/test/DeliveryHelper.t.sol @@ -279,7 +279,7 @@ contract DeliveryHelperTest is SetupTest { function endAuction(uint40 requestCount_) internal { if (auctionEndDelaySeconds == 0) return; - bytes32 timeoutId = _encodeId(evmxSlug, address(watcherPrecompile), timeoutIdCounter++); + bytes32 timeoutId = _encodeTimeoutId(evmxSlug, address(watcherPrecompile), timeoutIdCounter++); bytes memory watcherSignature = _createWatcherSignature( address(watcherPrecompile), @@ -300,7 +300,7 @@ contract DeliveryHelperTest is SetupTest { } //////////////////////////////////// Utils /////////////////////////////////// - function _encodeId( + function _encodeTimeoutId( uint32 chainSlug_, address sbOrWatcher_, uint256 counter_ From df32d7d7e340b814d3dfc2de5c6c5af539d4e8b6 Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Thu, 3 Apr 2025 21:41:12 +0530 Subject: [PATCH 2/2] fix: rename --- .../protocol/watcherPrecompile/WatcherPrecompileCore.sol | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/contracts/protocol/watcherPrecompile/WatcherPrecompileCore.sol b/contracts/protocol/watcherPrecompile/WatcherPrecompileCore.sol index cdc88171..44f583ab 100644 --- a/contracts/protocol/watcherPrecompile/WatcherPrecompileCore.sol +++ b/contracts/protocol/watcherPrecompile/WatcherPrecompileCore.sol @@ -192,17 +192,12 @@ abstract contract WatcherPrecompileCore is if (switchboard != switchboard_) revert InvalidSwitchboard(); } - function _encodeTimeoutId( - uint32 chainSlug_, - address switchboardOrWatcher_ - ) internal returns (bytes32) { + function _encodeTimeoutId(uint32 chainSlug_, address watcher_) internal returns (bytes32) { // Encode timeout ID by bit-shifting and combining: // chainSlug (32 bits) | switchboard or watcher precompile address (160 bits) | counter (64 bits) return bytes32( - (uint256(chainSlug_) << 224) | - (uint256(uint160(switchboardOrWatcher_)) << 64) | - timeoutCounter++ + (uint256(chainSlug_) << 224) | (uint256(uint160(watcher_)) << 64) | timeoutCounter++ ); }