Skip to content

Commit

Permalink
feat: enable whitelist of multiple operators on a single call (#1491)
Browse files Browse the repository at this point in the history
  • Loading branch information
uri-99 authored and PatStiles committed Nov 27, 2024
1 parent 59ca78e commit 9d39c51
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 20 deletions.
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -229,19 +229,21 @@ operator_mint_mock_tokens:

operator_whitelist_devnet:
@echo "Whitelisting operator"
$(eval OPERATOR_ADDRESS = $(shell yq -r '.operator.address' $(CONFIG_FILE)))
@echo "Operator address: $(OPERATOR_ADDRESS)"
RPC_URL="http://localhost:8545" PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" OUTPUT_PATH=./script/output/devnet/alignedlayer_deployment_output.json ./contracts/scripts/whitelist_operator.sh $(OPERATOR_ADDRESS)
RPC_URL="http://localhost:8545" PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" OUTPUT_PATH=./script/output/devnet/alignedlayer_deployment_output.json ./contracts/scripts/operator_whitelist.sh $(OPERATOR_ADDRESS)

operator_remove_devnet:
operator_remove_from_whitelist_devnet:
@echo "Removing operator"
$(eval OPERATOR_ADDRESS = $(shell yq -r '.operator.address' $(CONFIG_FILE)))
@echo "Operator address: $(OPERATOR_ADDRESS)"
RPC_URL="http://localhost:8545" PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" OUTPUT_PATH=./script/output/devnet/alignedlayer_deployment_output.json ./contracts/scripts/remove_operator.sh $(OPERATOR_ADDRESS)
RPC_URL="http://localhost:8545" PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" OUTPUT_PATH=./script/output/devnet/alignedlayer_deployment_output.json ./contracts/scripts/operator_remove_from_whitelist.sh $(OPERATOR_ADDRESS)

operator_whitelist:
@echo "Whitelisting operator $(OPERATOR_ADDRESS)"
@. contracts/scripts/.env && . contracts/scripts/whitelist_operator.sh $(OPERATOR_ADDRESS)
@. contracts/scripts/.env && . contracts/scripts/operator_whitelist.sh $(OPERATOR_ADDRESS)

operator_remove_from_whitelist:
@echo "Removing operator $(OPERATOR_ADDRESS)"
@. contracts/scripts/.env && . contracts/scripts/operator_remove_from_whitelist.sh $(OPERATOR_ADDRESS)

operator_deposit_into_mock_strategy:
@echo "Depositing into mock strategy"
Expand Down
2 changes: 1 addition & 1 deletion contracts/lib/eigenlayer-middleware

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ cd ../

# Check if the number of arguments is correct
if [ "$#" -ne 1 ]; then
echo "Usage: add_operator_to_whitelist.sh <OPERATOR_ADDRESS>"
echo "Usage: operator_remove_from_whitelist.sh <OPERATOR_ADDRESS>"
echo "or"
echo "Usage: operator_remove_from_whitelist.sh <OPERATOR_ADDRESS_1,OPERATOR_ADDRESS_2,...,OPERATOR_ADDRESS_N>"
exit 1
fi

Expand All @@ -37,9 +39,9 @@ if [ -z "$PRIVATE_KEY" ]; then
exit 1
fi

# Call the add function on the contract
echo "Removing operators from whitelist: $@"
cast send \
--rpc-url=$RPC_URL \
--private-key=$PRIVATE_KEY \
$REGISTRY_COORDINATOR 'add(address)' \
$OPERATOR_ADDRESS
--rpc-url=$RPC_URL \
--private-key=$PRIVATE_KEY \
$REGISTRY_COORDINATOR 'remove_multiple(address[])' \
"[$OPERATOR_ADDRESS]"
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ cd ../

# Check if the number of arguments is correct
if [ "$#" -ne 1 ]; then
echo "Usage: add_operator_to_whitelist.sh <OPERATOR_ADDRESS>"
echo "Usage: operator_whitelist.sh <OPERATOR_ADDRESS>"
echo "or"
echo "Usage: operator_whitelist.sh <OPERATOR_ADDRESS_1,OPERATOR_ADDRESS_2,...,OPERATOR_ADDRESS_N>"
exit 1
fi

Expand All @@ -37,9 +39,9 @@ if [ -z "$PRIVATE_KEY" ]; then
exit 1
fi

# Call the add function on the contract
echo "Adding operators to whitelist: $@"
cast send \
--rpc-url=$RPC_URL \
--private-key=$PRIVATE_KEY \
$REGISTRY_COORDINATOR 'remove(address)' \
$OPERATOR_ADDRESS
--rpc-url=$RPC_URL \
--private-key=$PRIVATE_KEY \
$REGISTRY_COORDINATOR 'add_multiple(address[])' \
"[$OPERATOR_ADDRESS]"
53 changes: 53 additions & 0 deletions docs/0_internal/whitelist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Whitelist

Whitelisting is a functionality added by the Aligned dev team to the `eigenlayer-middleware` contracts.

This functionality is added in `contracts/lib/eigenlayer-middleware/src/Whitelist.sol`, and its functionality ends up present in the `RegistryCoordinator` contract.

The reason behind this functionality is to control which Operators can operate in Aligned, making necessary for the team to manually whitelist an Operator before it can join the network.

## Interacting with whitelisting

### Adding an Operator

There are 2 ways of adding Operators to the whitelist.

To add only 1 Operator:
```
make operator_whitelist OPERATOR_ADDRESS=<operator_address>
```

To add a list of Operators:
```
make operator_whitelist OPERATOR_ADDRESS=<operator_address1,operator_address2,...,operator_addressN>
```
(Note how there is no spaces between the different operator addresses)

### Removing an Operator

There are 2 ways of removing Operators from the whitelist.

To remove only 1 Operator:
```
make operator_remove_from_whitelist OPERATOR_ADDRESS=<operator_address>
```

To remove a list of Operators:
```
make operator_remove_from_whitelist OPERATOR_ADDRESS=<operator_address1,operator_address2,...,operator_addressN>
```
(Note how there is no spaces between the different operator addresses)

### Querying the state of an Operator

To view the whitelist state of an Operator you can:

```
cast call <aligned_registry_coordinator_address> "isWhitelisted(address)(bool)" <operator_address>
```

or in Etherscan:

1. Locate the Aligned `registryCoordinator` contract address, in `aligned_deployment_output.json`
2. `Read as Proxy` in Etherscan
3. Find the `isWhitelisted` function, and put the Operator's address as the parameter

0 comments on commit 9d39c51

Please sign in to comment.