Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(avs): resolve more audit findings #220

Merged
merged 27 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
19b4845
fix audit TOW-02:avs deregister
trestinlsd Oct 16, 2024
b8e2d11
fix audit TOW-02:avs deregister
trestinlsd Oct 16, 2024
5b97953
add some new precompile func
trestinlsd Oct 17, 2024
264f534
fix avs precompile test err
trestinlsd Oct 17, 2024
cf1a45c
add events for all transactions
trestinlsd Oct 17, 2024
33d7704
fix lint err
trestinlsd Oct 17, 2024
3c8d1bd
add precompile query func
trestinlsd Oct 17, 2024
2ab3e57
Merge branch 'ExocoreNetwork:develop' into develop
trestinlsd Oct 17, 2024
3dbac18
Merge branch 'ExocoreNetwork:develop' into develop
trestinlsd Oct 21, 2024
64993ff
obtain the specified current epoch based on epochIdentifier
trestinlsd Oct 21, 2024
6ccf100
fix some comments
trestinlsd Oct 23, 2024
8c3649c
fix lint err
trestinlsd Oct 23, 2024
c7dc3ad
fix comments
trestinlsd Oct 24, 2024
ecbb71c
fix comments
trestinlsd Oct 25, 2024
08849fb
update for comments
trestinlsd Oct 25, 2024
7f1dabf
fix comments of max
trestinlsd Oct 29, 2024
d84a457
fix(tests): use correct case
MaxMustermann2 Oct 29, 2024
4bbf229
fix: use blank slash contract not 0x0000
MaxMustermann2 Oct 29, 2024
33875a4
update proto enum phase
trestinlsd Oct 29, 2024
b909d83
revert unnecessary change
MaxMustermann2 Oct 30, 2024
b75d7a5
refactor(avs): remove unnecessary CommitPhase
MaxMustermann2 Oct 30, 2024
2c2927b
format the address in lowercase
trestinlsd Oct 31, 2024
ff21910
Fix the missing field of topic in the event
trestinlsd Oct 31, 2024
8b3468f
update hex address format
trestinlsd Oct 31, 2024
b7b874b
Merge branch 'ExocoreNetwork:develop' into develop
trestinlsd Oct 31, 2024
f566312
format the address in lowercase for operator module
trestinlsd Nov 4, 2024
0c527a1
fix type errors in ABI
trestinlsd Nov 4, 2024
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
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)
MaxMustermann2 marked this conversation as resolved.
Show resolved Hide resolved
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);
MaxMustermann2 marked this conversation as resolved.
Show resolved Hide resolved

/// @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);
MaxMustermann2 marked this conversation as resolved.
Show resolved Hide resolved

/// @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
Loading