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

Make deployment scripts more flexible #54

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
25 changes: 13 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ help:

AGGREGATOR_ECDSA_PRIV_KEY=0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6
CHALLENGER_ECDSA_PRIV_KEY=0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a

DEPLOYER_PRIVATE_KEY=0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6
CHAINID=31337
# Make sure to update this if the strategy address changes
# check in contracts/script/output/${CHAINID}/credible_squaring_avs_deployment_output.json
STRATEGY_ADDRESS=0x7a2088a1bFc9d81c55368AE168C2C02570cB814F
DEPLOYMENT_FILES_DIR=contracts/script/output/${CHAINID}
# Operator key information are saved in tests/keys/test.ecdsa.key.json
OPERATOR_ADDRESS=0x860B6912C2d0337ef05bbC89b0C2CB6CbAEAB4A5

-----------------------------: ##

Expand Down Expand Up @@ -46,45 +48,44 @@ __CLI__: ##
cli-setup-operator: send-fund cli-register-operator-with-eigenlayer cli-deposit-into-mocktoken-strategy cli-register-operator-with-avs ## registers operator with eigenlayer and avs

cli-register-operator-with-eigenlayer: ## registers operator with delegationManager
go run cli/main.go --config config-files/operator.anvil.yaml register-operator-with-eigenlayer
go run cli/main.go --config config-files/${CHAINID}/operator.anvil.yaml register-operator-with-eigenlayer

cli-deposit-into-mocktoken-strategy: ##
./scripts/deposit-into-mocktoken-strategy.sh

cli-register-operator-with-avs: ##
go run cli/main.go --config config-files/operator.anvil.yaml register-operator-with-avs
go run cli/main.go --config config-files/${CHAINID}/operator.anvil.yaml register-operator-with-avs

cli-deregister-operator-with-avs: ##
go run cli/main.go --config config-files/operator.anvil.yaml deregister-operator-with-avs
go run cli/main.go --config config-files/${CHAINID}/operator.anvil.yaml deregister-operator-with-avs

cli-print-operator-status: ##
go run cli/main.go --config config-files/operator.anvil.yaml print-operator-status

send-fund: ## sends fund to the operator saved in tests/keys/test.ecdsa.key.json
cast send 0x860B6912C2d0337ef05bbC89b0C2CB6CbAEAB4A5 --value 10ether --private-key 0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6
go run cli/main.go --config config-files/${CHAINID}/operator.anvil.yaml print-operator-status

send-fund: ## sends fund to the operator
cast send ${OPERATOR_ADDRESS} --value 10ether --private-key ${DEPLOYER_PRIVATE_KEY}
-----------------------------: ##
# We pipe all zapper logs through https://github.com/maoueh/zap-pretty so make sure to install it
# TODO: piping to zap-pretty only works when zapper environment is set to production, unsure why
____OFFCHAIN_SOFTWARE___: ##
start-aggregator: ##
go run aggregator/cmd/main.go --config config-files/aggregator.yaml \
go run aggregator/cmd/main.go --config config-files/${CHAINID}/aggregator.yaml \
--credible-squaring-deployment ${DEPLOYMENT_FILES_DIR}/credible_squaring_avs_deployment_output.json \
--ecdsa-private-key ${AGGREGATOR_ECDSA_PRIV_KEY} \
2>&1 | zap-pretty

start-operator: ##
go run operator/cmd/main.go --config config-files/operator.anvil.yaml \
go run operator/cmd/main.go --config config-files/${CHAINID}/operator.anvil.yaml \
2>&1 | zap-pretty

start-challenger: ##
go run challenger/cmd/main.go --config config-files/challenger.yaml \
go run challenger/cmd/main.go --config config-files/${CHAINID}/challenger.yaml \
--credible-squaring-deployment ${DEPLOYMENT_FILES_DIR}/credible_squaring_avs_deployment_output.json \
--ecdsa-private-key ${CHALLENGER_ECDSA_PRIV_KEY} \
2>&1 | zap-pretty

run-plugin: ##
go run plugin/cmd/main.go --config config-files/operator.anvil.yaml
go run plugin/cmd/main.go --config config-files/${CHAINID}/operator.anvil.yaml
-----------------------------: ##
_____HELPER_____: ##
mocks: ## generates mocks for tests
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Register the operator with eigenlayer and incredible-squaring, and then start th
make start-operator
```

> By default, the `start-operator` command will also setup the operator (see `register_operator_on_startup` flag in `config-files/operator.anvil.yaml`). To disable this, set `register_operator_on_startup` to false, and run `make cli-setup-operator` before running `start-operator`.
> By default, the `start-operator` command will also setup the operator (see `register_operator_on_startup` flag in `config-files/31337/operator.anvil.yaml`). To disable this, set `register_operator_on_startup` to false, and run `make cli-setup-operator` before running `start-operator`.

## Running via docker compose

Expand Down Expand Up @@ -114,4 +114,4 @@ When running on anvil, a typical log for the operator is
[2024-04-09 18:25:10.679 PDT] INFO (logging/zap_logger.go:49) Signed task response header accepted by aggregator. {"reply":false}
```

The error `task 2 not initialized or already completed` is expected behavior. This is because the aggregator needs to setup its data structures before it can accept responses. But on a local anvil setup, the operator had time to receive the websocket event for the new task, square the number, sign the response, and send it to the aggregator process before the aggregator has finalized its setup. Hence, the operator retries sending the response 2 seconds later and it is accepted.
The error `task 2 not initialized or already completed` is expected behavior. This is because the aggregator needs to setup its data structures before it can accept responses. But on a local anvil setup, the operator had time to receive the websocket event for the new task, square the number, sign the response, and send it to the aggregator process before the aggregator has finalized its setup. Hence, the operator retries sending the response 2 seconds later and it is accepted.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion core/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

// Config contains all of the configuration information for a credible squaring aggregators and challengers.
// Operators use a separate config. (see config-files/operator.anvil.yaml)
// Operators use a separate config. (see config-files/31337/operator.anvil.yaml)
type Config struct {
EcdsaPrivateKey *ecdsa.PrivateKey
BlsPrivateKey *bls.PrivateKey
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ services:
working_dir: /incredible-squaring
command:
- --config
- config-files/aggregator-docker-compose.yaml
- config-files/31337/aggregator-docker-compose.yaml
- --credible-squaring-deployment
- contracts/script/output/31337/credible_squaring_avs_deployment_output.json
- --ecdsa-private-key
Expand All @@ -65,7 +65,7 @@ services:
volumes:
- ./:/incredible-squaring/
working_dir: /incredible-squaring
command: --config config-files/operator-docker-compose.anvil.yaml
command: --config config-files/31337/operator-docker-compose.anvil.yaml
networks:
- incredible-squaring-network

Expand All @@ -78,7 +78,7 @@ services:
# volumes:
# - ./:/incredible-squaring/
# working_dir: /incredible-squaring
# command: --config config-files/operator-docker-compose.anvil.yaml --credible-squaring-deployment contracts/script/output/31337/credible_squaring_avs_deployment_output.json --ecdsa-private-key 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d --bls-private-key 2
# command: --config config-files/31337/operator-docker-compose.anvil.yaml --credible-squaring-deployment contracts/script/output/31337/credible_squaring_avs_deployment_output.json --ecdsa-private-key 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d --bls-private-key 2
# networks:
# - incredible-squaring-network

Expand Down
2 changes: 1 addition & 1 deletion scripts/deposit-into-mocktoken-strategy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ CHAINID=$(cast chain-id)
DEPLOYMENT_OUTPUT_FILE=./contracts/script/output/${CHAINID}/credible_squaring_avs_deployment_output.json
STRATEGY_ADDRESS=$(jq -r '.addresses.erc20MockStrategy' $DEPLOYMENT_OUTPUT_FILE)

go run cli/main.go --config config-files/operator.anvil.yaml deposit-into-strategy --strategy-addr ${STRATEGY_ADDRESS} --amount 100
go run cli/main.go --config config-files/${CHAINID}/operator.anvil.yaml deposit-into-strategy --strategy-addr ${STRATEGY_ADDRESS} --amount 100
Copy link
Collaborator

Choose a reason for hiding this comment

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

if you can change this to ${CHAINID:?} or use set -o nounset at the top of the file. This way the script will early exit if the variable is not defined.

Copy link
Author

Choose a reason for hiding this comment

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

The following works

make CHAINID=32382 start-aggregator

so, there is an easy way to overwrite the CHAINID and other variables. However, I agree that maybe setting the CHAINID in the Makefile is not optimal. I just wanted to make an incremental change. Collect all variables in one place, so they can be handled better.

Copy link
Contributor

Choose a reason for hiding this comment

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

@wawrzek could you update this to reflect 2 items:

  1. to use ${CHAINID:?} (in spite of make CHAIND=32382... working)
  2. update the README to highlight that start-aggregator should be run with a CHAINID env var

Otherwise lgtm

Copy link
Author

Choose a reason for hiding this comment

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

@NimaVaziri , I've been looking at changing the behaviour of the make commands and I don't like it. Despite me wanting to use a different chain id I think the change should not make life harder for others, so keep the current behaviour when the CHAINID might be omitted.
I suggest an alternative. Keep current Makefile, but extend documentation by a paragraph describing how to deploy AVS into a network different from the anvil one. The change is in the latest commit.

4 changes: 2 additions & 2 deletions tests/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestIntegration(t *testing.T) {

/* Prepare the config file for aggregator */
var aggConfigRaw config.ConfigRaw
aggConfigFilePath := "../../config-files/aggregator.yaml"
aggConfigFilePath := "../../config-files/31337/aggregator.yaml"
sdkutils.ReadYamlConfig(aggConfigFilePath, &aggConfigRaw)
aggConfigRaw.EthRpcUrl = "http://" + anvilEndpoint
aggConfigRaw.EthWsUrl = "ws://" + anvilEndpoint
Expand Down Expand Up @@ -114,7 +114,7 @@ func TestIntegration(t *testing.T) {

/* Prepare the config file for operator */
nodeConfig := types.NodeConfig{}
nodeConfigFilePath := "../../config-files/operator.anvil.yaml"
nodeConfigFilePath := "../../config-files/31337/operator.anvil.yaml"
err = sdkutils.ReadYamlConfig(nodeConfigFilePath, &nodeConfig)
if err != nil {
t.Fatalf("Failed to read yaml config: %s", err.Error())
Expand Down
Loading