Skip to content

Commit

Permalink
feat: return multiple booleans from validatorOptInRouter.areValidator…
Browse files Browse the repository at this point in the history
…sOptedIn
  • Loading branch information
shaspitz committed Nov 7, 2024
1 parent 443e126 commit 6d49ffd
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 38 deletions.
21 changes: 19 additions & 2 deletions contracts-abi/abi/ValidatorOptInRouter.abi
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,25 @@
"outputs": [
{
"name": "",
"type": "bool[]",
"internalType": "bool[]"
"type": "tuple[]",
"internalType": "struct IValidatorOptInRouter.OptInStatus[]",
"components": [
{
"name": "isVanillaOptedIn",
"type": "bool",
"internalType": "bool"
},
{
"name": "isAvsOptedIn",
"type": "bool",
"internalType": "bool"
},
{
"name": "isMiddlewareOptedIn",
"type": "bool",
"internalType": "bool"
}
]
}
],
"stateMutability": "view"
Expand Down
25 changes: 16 additions & 9 deletions contracts-abi/clients/ValidatorOptInRouter/ValidatorOptInRouter.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions contracts/contracts/interfaces/IValidatorOptInRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import {IMevCommitMiddleware} from "./IMevCommitMiddleware.sol";

interface IValidatorOptInRouter {

struct OptInStatus {
bool isVanillaOptedIn;
bool isAvsOptedIn;
bool isMiddlewareOptedIn;
}

/// @notice Emitted when the vanilla registry contract is set.
event VanillaRegistrySet(address oldContract, address newContract);

Expand All @@ -33,6 +39,6 @@ interface IValidatorOptInRouter {
/// @notice Allows the owner to set the mev-commit middleware contract.
function setMevCommitMiddleware(IMevCommitMiddleware _mevCommitMiddleware) external;

/// @notice Returns an array of bools indicating whether each validator pubkey is opted in to mev-commit.
function areValidatorsOptedIn(bytes[] calldata valBLSPubKeys) external view returns (bool[] memory);
/// @notice Returns an array of OptInStatus structs indicating whether each validator pubkey is opted in to mev-commit.
function areValidatorsOptedIn(bytes[] calldata valBLSPubKeys) external view returns (OptInStatus[] memory);
}
26 changes: 13 additions & 13 deletions contracts/contracts/validator-registry/ValidatorOptInRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ contract ValidatorOptInRouter is IValidatorOptInRouter, ValidatorOptInRouterStor
emit MevCommitMiddlewareSet(oldContract, address(mevCommitMiddleware));
}

/// @notice Returns an array of bools indicating whether each validator pubkey is opted in to mev-commit.
function areValidatorsOptedIn(bytes[] calldata valBLSPubKeys) external view returns (bool[] memory) {
/// @notice Returns an array of OptInStatus structs indicating whether each validator pubkey is opted in to mev-commit.
function areValidatorsOptedIn(bytes[] calldata valBLSPubKeys) external view returns (OptInStatus[] memory) {
uint256 len = valBLSPubKeys.length;
bool[] memory optedIn = new bool[](len);
OptInStatus[] memory optInStatuses = new OptInStatus[](len);
for (uint256 i = 0; i < len; ++i) {
optedIn[i] = _isValidatorOptedIn(valBLSPubKeys[i]);
optInStatuses[i] = _isValidatorOptedIn(valBLSPubKeys[i]);
}
return optedIn;
return optInStatuses;
}

/*
Expand All @@ -85,13 +85,13 @@ contract ValidatorOptInRouter is IValidatorOptInRouter, ValidatorOptInRouterStor
function _authorizeUpgrade(address) internal override onlyOwner {}

/// @notice Internal function to check if a validator is opted in to mev-commit with either simple staking or restaking.
function _isValidatorOptedIn(bytes calldata valBLSPubKey) internal view returns (bool) {
if (vanillaRegistry.isValidatorOptedIn(valBLSPubKey)) {
return true;
}
if (mevCommitAVS.isValidatorOptedIn(valBLSPubKey)) {
return true;
}
return mevCommitMiddleware.isValidatorOptedIn(valBLSPubKey);
/// @return OptInStatus struct indicating whether the validator is opted in to vanilla registry,
/// eigen avs registry, and/or symbiotic middleware registry.
function _isValidatorOptedIn(bytes calldata valBLSPubKey) internal view returns (OptInStatus memory) {
OptInStatus memory optInStatus;
optInStatus.isVanillaOptedIn = vanillaRegistry.isValidatorOptedIn(valBLSPubKey);
optInStatus.isAvsOptedIn = mevCommitAVS.isValidatorOptedIn(valBLSPubKey);
optInStatus.isMiddlewareOptedIn = mevCommitMiddleware.isValidatorOptedIn(valBLSPubKey);
return optInStatus;
}
}
Loading

0 comments on commit 6d49ffd

Please sign in to comment.