Skip to content

Commit

Permalink
refactor whitelist check on validator registration
Browse files Browse the repository at this point in the history
  • Loading branch information
mtabasco committed Jul 3, 2024
1 parent 453d75b commit bac7ff4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions contracts/libraries/OperatorLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,14 @@ library OperatorLib {
// msg.sender is not whitelisted via bitmap or legacy whitelist/whitelisting contract
revert ISSVNetworkCore.CallerNotWhitelistedWithData(operatorId);
}
// Legacy address whitelists (EOAs or generic contracts)
// Legacy address & whitelisting contract check
if (whitelistedAddress != msg.sender) {
// Check if msg.sender is whitelisted via whitelisting contract
if (!OperatorLib.isWhitelistingContract(whitelistedAddress)) {
revert ISSVNetworkCore.InvalidWhitelistingContract(whitelistedAddress);
}
if (!ISSVWhitelistingContract(whitelistedAddress).isWhitelisted(msg.sender, operatorId)) {
// Check if whitelistedAddress is a valid whitelisting contract and if msg.sender is whitelisted by it
// For non-whitelisting contracts, check if msg.sender is whitelisted (EOAs or generic contracts)
if (
!OperatorLib.isWhitelistingContract(whitelistedAddress) ||
!ISSVWhitelistingContract(whitelistedAddress).isWhitelisted(msg.sender, operatorId)
) {
revert ISSVNetworkCore.CallerNotWhitelistedWithData(operatorId);
}
}
Expand Down
2 changes: 1 addition & 1 deletion test-forked/operators-whitelist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('Whitelisting Tests (fork) - Pre-upgrade SSV Core Contracts Tests', ()
],
{ account: owners[2].account },
),
).to.be.rejectedWith('InvalidWhitelistingContract');
).to.be.rejectedWith('CallerNotWhitelistedWithData');
});

it('Register using legacy whitelisted operators in 4 operators cluster events/logic', async () => {
Expand Down

0 comments on commit bac7ff4

Please sign in to comment.