Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions contracts/protocol/watcherPrecompile/WatcherPrecompileCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -192,18 +192,12 @@ abstract contract WatcherPrecompileCore is
if (switchboard != switchboard_) revert InvalidSwitchboard();
}

// todo: revisit when we do timeout precompile
function _encodeId(
uint32 chainSlug_,
address switchboardOrWatcher_
) internal returns (bytes32) {
// Encode payload ID by bit-shifting and combining:
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) |
payloadCounter++
(uint256(chainSlug_) << 224) | (uint256(uint160(watcher_)) << 64) | timeoutCounter++
);
}

Expand Down
4 changes: 2 additions & 2 deletions test/DeliveryHelper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -300,7 +300,7 @@ contract DeliveryHelperTest is SetupTest {
}

//////////////////////////////////// Utils ///////////////////////////////////
function _encodeId(
function _encodeTimeoutId(
uint32 chainSlug_,
address sbOrWatcher_,
uint256 counter_
Expand Down