Skip to content

Commit

Permalink
fix(avs): resolve more audit findings (#220)
Browse files Browse the repository at this point in the history
* fix audit TOW-02:avs deregister

* add events for all transactions

* fix(tests): use correct case

* fix: use blank slash contract not 0x0000

* update proto enum phase

The `runTx` ensures that, upon a message failure, the cache is not
written to disk.

* format the address in lowercase

* Fix the missing field of topic in the event

* fix type errors in ABI

---------

Co-authored-by: MaxMustermann2 <[email protected]>
  • Loading branch information
trestinlsd and MaxMustermann2 authored Nov 5, 2024
1 parent 9773245 commit a361c1d
Show file tree
Hide file tree
Showing 36 changed files with 2,047 additions and 641 deletions.
120 changes: 82 additions & 38 deletions precompiles/avs/IAVSManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,43 @@ pragma solidity >=0.8.17;
address constant AVSMANAGER_PRECOMPILE_ADDRESS = 0x0000000000000000000000000000000000000901;

/// @dev The avs-manager contract's instance.
IAVSManager constant AVSMANAGER_CONTRACT = IAVSManager(
AVSMANAGER_PRECOMPILE_ADDRESS
);

IAVSManager constant AVSMANAGER_CONTRACT = IAVSManager(AVSMANAGER_PRECOMPILE_ADDRESS);
/// @author Exocore Team
/// @title AVS-Manager Precompile Contract
/// @dev The interface through which solidity contracts will interact with AVS-Manager
/// @custom:address 0x0000000000000000000000000000000000000901

interface IAVSManager {
// note:string and bytes will be hashed. address / uintX will not be hashed when using indexed.
event AVSRegistered(address indexed avsAddr, string sender, string avsName);
event AVSUpdated(address indexed avsAddr, string sender, string avsName);
event AVSDeregistered(address indexed avsAddr, string sender, string avsName);
event OperatorJoined(address indexed avsAddr, string sender);
event OperatorLeft(address indexed avsAddr, string sender);
event TaskCreated(
address indexed taskContractAddress,
uint64 indexed taskId,
string sender,
string name,
bytes hash,
uint64 taskResponsePeriod,
uint64 taskChallengePeriod,
uint64 thresholdPercentage,
uint64 taskStatisticalPeriod
);
event ChallengeInitiated(
string sender, bytes taskHash, uint64 taskID, bytes taskResponseHash, string operatorAddress
);
event PublicKeyRegistered(string sender, string name);
event TaskSubmittedByOperator(
address indexed taskContractAddress,
uint64 indexed taskId,
string sender,
bytes taskResponse,
bytes blsSignature,
uint8 phase
);

/// @dev Register AVS contract to EXO.
/// @param sender The external address for calling this method.
/// @param avsName The name of AVS.
Expand Down Expand Up @@ -78,23 +106,15 @@ interface IAVSManager {
/// @dev Deregister avs from exo
/// @param sender The external address for calling this method.
/// @param avsName The name of AVS.
function deregisterAVS(
address sender,
string memory avsName
) external returns (bool success);
function deregisterAVS(address sender, string memory avsName) external returns (bool success);

/// @dev RegisterOperatorToAVS operator opt in current avs
/// @param sender The external address for calling this method.
function registerOperatorToAVS(
address sender
) external returns (bool success);
function registerOperatorToAVS(address sender) external returns (bool success);

/// @dev DeregisterOperatorFromAVS operator opt out current avs
/// @param sender The external address for calling this method.
function deregisterOperatorFromAVS(
address sender
) external returns (bool success);

function deregisterOperatorFromAVS(address sender) external returns (bool success);

/// @dev CreateTask , avs owner create a new task
/// @param sender The external address for calling this method.
Expand All @@ -112,7 +132,7 @@ interface IAVSManager {
uint64 taskChallengePeriod,
uint64 thresholdPercentage,
uint64 taskStatisticalPeriod
) external returns (bool success);
) external returns (uint64 taskID);

/// @dev challenge , this function enables a challenger to raise and resolve a challenge.
/// @param sender The external address for calling this method.
Expand All @@ -128,7 +148,6 @@ interface IAVSManager {
string memory operatorAddress
) external returns (bool success);


/// @dev Called by the avs manager service register an operator as the owner of a BLS public key.
/// @param sender The external address for calling this method.
/// @param name the name of public keys
Expand All @@ -143,40 +162,65 @@ interface IAVSManager {
bytes calldata pubkeyRegistrationMessageHash
) external returns (bool success);

/// @dev operatorSubmitTask , this function enables a operator submit a task result.
/// @param sender The external address for calling this method.
/// @param taskID The id of task.
/// @param taskResponse is the task response data..
/// @param blsSignature is the operator bls sig info..
/// @param taskContractAddress is contract address of task.
/// @param phase The phase of the Two-Phase Commit protocol:
/// 1 = Prepare phase (commit preparation)
/// 2 = Commit phase (final commitment)
function operatorSubmitTask(
address sender,
uint64 taskID,
bytes calldata taskResponse,
bytes calldata blsSignature,
address taskContractAddress,
uint8 phase
) external returns (bool success);


/// QUERIES
/// @dev Returns the pubkey and pubkey hash of an operator
/// @param operator is the operator for whom the key is being registered
function getRegisteredPubkey(string memory operator) external pure returns (bytes memory pubkey);
function getRegisteredPubkey(string memory operator) external view returns (bytes memory pubkey);

/// @dev Returns the operators of all opt-in in the current avs
/// @param avsAddress avs address
function getOptInOperators(address avsAddress) external returns (string[] memory operators);
function getOptInOperators(address avsAddress) external view returns (string[] memory operators);

/// @dev getAVSUSDValue is a function to retrieve the USD share of specified Avs.
/// @param avsAddr The address of the avs
/// @return amount The total USD share of specified operator and Avs.
function getAVSUSDValue(
address avsAddr
) external view returns (uint256 amount);
function getAVSUSDValue(address avsAddr) external view returns (uint256 amount);

/// @dev getOperatorOptedUSDValue is a function to retrieve the USD share of specified operator and Avs.
/// @param avsAddr The address of the avs
/// @param operatorAddr The address of the operator
/// @return amount The total USD share of specified operator and Avs.
function getOperatorOptedUSDValue(
address avsAddr,
string memory operatorAddr
) external view returns (uint256 amount);
function getOperatorOptedUSDValue(address avsAddr, string memory operatorAddr)
external
view
returns (uint256 amount);

event TaskCreated(
uint64 taskId,
string taskContractAddress,
string name,
bytes hash,
uint64 taskResponsePeriod,
uint64 taskChallengePeriod,
uint64 thresholdPercentage,
uint64 taskStatisticalPeriod
);
}
/// @dev getAVSEpochIdentifier returns the epoch identifier for the given AVS.
/// @param avsAddr The address of the avs
function getAVSEpochIdentifier(address avsAddr) external view returns (string memory epochIdentifier);

/// @dev getTaskInfo is a function to query task info.
/// @param taskAddr The address of the avs task
/// @param taskID The id of task.
/// @return info Array containing task information in the following order:
/// [0] = startingEpochNumber
/// [1] = taskResponsePeriod
/// [2] = taskStatisticalPeriod
function getTaskInfo(address taskAddr, uint64 taskID) external view returns (uint64[] memory info);

/// @dev isOperator checks if the given address is registered as an operator on exocore.
/// @param operatorAddr The address of the operator
function isOperator(address operatorAddr) external view returns (bool);

/// @dev getCurrentEpoch obtain the specified current epoch based on epochIdentifier.
/// @param epochIdentifier is a descriptive or unique identifier for the epoch
function getCurrentEpoch(string memory epochIdentifier) external view returns (int64 currentEpoch);
}
Loading

0 comments on commit a361c1d

Please sign in to comment.