-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Interfaces for execution (#2063)
* First draft for Executor interface * Interface for execution fees custody contract
1 parent
e780c6a
commit 8930c83
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
packages/contracts-communication/contracts/interfaces/IExecutionFees.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
interface IExecutionFees { | ||
/// @notice Add the execution fee for a transaction. The attached value will be added to the | ||
/// rewards for the executor completing the transaction. | ||
/// Note: this could be used to store the execution fee for a new transaction, or to add more | ||
/// funds to the execution fee of an existing transaction. Therefore this function is payable, | ||
/// and does not implement any caller restrictions. | ||
/// @dev Will revert if the executor is already recorded for the transaction. | ||
/// @param dstChainId The chain id of the destination chain. | ||
/// @param transactionId The id of the transaction to add the execution fee to. | ||
function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable; | ||
|
||
/// @notice Record the executor (who completed the transaction) for a transaction, | ||
/// and update the accumulated rewards for the executor. | ||
/// @dev Could only be called by the Recorder. | ||
/// @param dstChainId The chain id of the destination chain. | ||
/// @param transactionId The id of the transaction to record the executor for. | ||
/// @param executor The address of the executor who completed the transaction. | ||
function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external; | ||
|
||
/// @notice Allows the executor to claim their unclaimed rewards. | ||
/// @dev Will revert if the executor has no unclaimed rewards. | ||
function claimExecutionFees() external; | ||
|
||
// ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════ | ||
|
||
/// @notice Get the accumulated rewards for an executor. | ||
/// @param executor The address of the executor to get the rewards for. | ||
function getAccumulatedRewards(address executor) external view returns (uint256 accumulated); | ||
|
||
/// @notice Get the unclaimed rewards for an executor. | ||
/// @param executor The address of the executor to get the rewards for. | ||
function getUnclaimedRewards(address executor) external view returns (uint256 unclaimed); | ||
} |
39 changes: 39 additions & 0 deletions
39
packages/contracts-communication/contracts/interfaces/IExecutor.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
interface IExecutor { | ||
/// @notice Request the execution of an Interchain Transaction on a remote chain. | ||
/// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient | ||
/// event with the same transactionId, then execute the transaction on the remote chain: | ||
/// `dstInterchainClient.executeTransaction(transactionPayload)` | ||
/// Once the execution is confirmed on the source chain, the off-chain actor will be able | ||
/// to claim `executionFee` in the ExecutionFees contract. | ||
/// @dev Could only be called by `InterchainClient` contracts. | ||
/// Will revert if the execution fee is not big enough. | ||
/// @param dstChainId The chain id of the destination chain. | ||
/// @param txPayloadSize The size of the transaction payload to use for the execution. | ||
/// @param transactionId The id of the transaction to execute. | ||
/// @param executionFee The fee paid for the execution. | ||
/// @param options The options to use for the execution. | ||
function requestExecution( | ||
uint256 dstChainId, | ||
uint256 txPayloadSize, | ||
bytes32 transactionId, | ||
uint256 executionFee, | ||
bytes memory options | ||
) | ||
external; | ||
|
||
/// @notice Get the execution fee for executing an Interchain Transaction on a remote chain. | ||
/// @param dstChainId The chain id of the destination chain. | ||
/// @param txPayloadSize The size of the transaction payload to use for the execution. | ||
/// @param options The options to use for the execution. | ||
function getExecutionFee( | ||
uint256 dstChainId, | ||
uint256 txPayloadSize, | ||
bytes memory options | ||
) | ||
external | ||
view | ||
returns (uint256); | ||
} |