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

feat: enable whitelist of multiple operators on a single call #1491

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,20 @@ operator_whitelist_devnet:
@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)

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/remove_from_whitelist_operator.sh $(OPERATOR_ADDRESS)

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

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

operator_deposit_into_mock_strategy:
@echo "Depositing into mock strategy"
$(eval STRATEGY_ADDRESS = $(shell jq -r '.addresses.strategies.MOCK' contracts/script/output/devnet/eigenlayer_deployment_output.json))
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 @@ -9,8 +9,10 @@ cd "$parent_path"
cd ../

# Check if the number of arguments is correct
if [ "$#" -ne 1 ]; then
echo "Usage: add_operator_to_whitelist.sh <OPERATOR_ADDRESS>"
if [ "$#" -lt 1 ]; then
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,19 @@ if [ -z "$PRIVATE_KEY" ]; then
exit 1
fi

# Call the add function on the contract
cast send \
--rpc-url=$RPC_URL \
--private-key=$PRIVATE_KEY \
$REGISTRY_COORDINATOR 'add(address)' \
$OPERATOR_ADDRESS
if [ "$#" -gt 1 ]; then
OPERATORS=$(echo "$@" | sed 's/ /,/g') # separate the operators with a comma
echo "Adding many operators to whitelist: $@"
cast send \
--rpc-url=$RPC_URL \
--private-key=$PRIVATE_KEY \
$REGISTRY_COORDINATOR 'remove_multiple(address[])' \
"[$OPERATORS]"
else
echo "Adding operator to whitelist: $OPERATOR_ADDRESS"
cast send \
--rpc-url=$RPC_URL \
--private-key=$PRIVATE_KEY \
$REGISTRY_COORDINATOR 'remove(address)' \
$OPERATOR_ADDRESS
fi
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ cd "$parent_path"
cd ../

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Export and source were not working for me. I had to add source scripts/.env here.

# Check if the number of arguments is correct
if [ "$#" -ne 1 ]; then
echo "Usage: add_operator_to_whitelist.sh <OPERATOR_ADDRESS>"
if [ "$#" -lt 1 ]; then
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,19 @@ if [ -z "$PRIVATE_KEY" ]; then
exit 1
fi

# Call the add function on the contract
cast send \
--rpc-url=$RPC_URL \
--private-key=$PRIVATE_KEY \
$REGISTRY_COORDINATOR 'remove(address)' \
$OPERATOR_ADDRESS
if [ "$#" -gt 1 ]; then
OPERATORS=$(echo "$@" | sed 's/ /,/g') # separate the operators with a comma
echo "Adding many operators to whitelist: $@"
cast send \
--rpc-url=$RPC_URL \
--private-key=$PRIVATE_KEY \
$REGISTRY_COORDINATOR 'add_multiple(address[])' \
"[$OPERATORS]"
else
echo "Adding operator to whitelist: $OPERATOR_ADDRESS"
cast send \
--rpc-url=$RPC_URL \
--private-key=$PRIVATE_KEY \
$REGISTRY_COORDINATOR 'add(address)' \
$OPERATOR_ADDRESS
fi
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:
```
export contracts/scripts/.env
contracts/scripts/operator_whitelist.sh <operator_address_1> <operator_address_2> ... <operator_address_n>
```

### 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:
```
export contracts/scripts/.env
contracts/scripts/operator_remove_from_whitelist.sh <operator_address_1> <operator_address_2> ... <operator_address_n>
```

### 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