Skip to content

Commit f42e0c7

Browse files
MauroToscanoJuArcetaturosatiuri-99
authored
feat (operator): Dockerfile (#378)
Co-authored-by: JuArce <[email protected]> Co-authored-by: Santos Rosati <[email protected]> Co-authored-by: Tatu <[email protected]> Co-authored-by: Urix <[email protected]>
1 parent 1f912f0 commit f42e0c7

File tree

13 files changed

+262
-81
lines changed

13 files changed

+262
-81
lines changed

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ operator_deposit_and_register: operator_deposit_into_strategy operator_register_
154154

155155
operator_full_registration: operator_get_eth operator_register_with_eigen_layer operator_mint_mock_tokens operator_deposit_into_mock_strategy operator_whitelist_devnet operator_register_with_aligned_layer
156156

157+
operator_start_docker:
158+
@echo "Starting Operator..."
159+
@docker-compose -f operator/docker/compose.yaml up
160+
157161
__BATCHER__:
158162

159163
BURST_SIZE=5
@@ -651,7 +655,7 @@ build_all_ffi: ## Build all FFIs
651655
build_all_ffi_macos: ## Build all FFIs for macOS
652656
@echo "Building all FFIs for macOS..."
653657
@$(MAKE) build_sp1_macos
654-
@$(MAKE) build_risc_zero_macos
658+
# @$(MAKE) build_risc_zero_macos
655659
# @$(MAKE) build_merkle_tree_macos
656660
@$(MAKE) build_halo2_ipa_macos
657661
@$(MAKE) build_halo2_kzg_macos
@@ -660,7 +664,7 @@ build_all_ffi_macos: ## Build all FFIs for macOS
660664
build_all_ffi_linux: ## Build all FFIs for Linux
661665
@echo "Building all FFIs for Linux..."
662666
@$(MAKE) build_sp1_linux
663-
@$(MAKE) build_risc_zero_linux
667+
# @$(MAKE) build_risc_zero_linux
664668
# @$(MAKE) build_merkle_tree_linux
665669
@$(MAKE) build_halo2_ipa_linux
666670
@$(MAKE) build_halo2_kzg_linux

README.md

Lines changed: 55 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,17 @@ This guide assumes you are already [registered as an operator with EigenLayer](h
156156
Minimum hardware requirements:
157157

158158
| Component | Specification |
159-
| ------------- | ----------------- |
159+
|---------------|-------------------|
160160
| **CPU** | 16 cores |
161161
| **Memory** | 32 GB RAM |
162162
| **Bandwidth** | 1 Gbps |
163163
| **Storage** | 256 GB disk space |
164164

165-
#### Software Requirements
165+
### Dependencies
166166

167-
Ensure you have the following installed:
167+
#### From Source (Recommended)
168168

169+
Ensure you have the following installed:
169170
- [Go](https://go.dev/doc/install)
170171
- [Rust](https://www.rust-lang.org/tools/install)
171172
- [Foundry](https://book.getfoundry.sh/getting-started/installation)
@@ -182,35 +183,49 @@ make install_foundry
182183
foundryup
183184
```
184185

185-
#### Install the Operator Binary
186+
#### Using Docker
186187

187-
To install the operator binary, run:
188-
189-
```bash
190-
make build_operator
191-
```
188+
Ensure you have the following installed:
189+
- [Docker](https://docs.docker.com/get-docker/)
190+
- [Docker Compose](https://docs.docker.com/compose/install/)
192191

193-
#### Update the operator
192+
### Configuration
194193

195-
To update the operator, first stop the process running the operator (if there is any) and then run:
196-
197-
```bash
198-
git pull
199-
make build_operator
200-
```
201-
202-
#### Configuration
194+
#### From source (Recommended)
203195

204196
Update the following placeholders in `./config-files/config-operator.yaml`:
205-
206-
- `"<ecdsa_key_store_location_path>"`
207-
- `"<bls_key_store_location_path>"`
208197
- `"<operator_address>"`
209198
- `"<earnings_receiver_address>"`
199+
- `"<ecdsa_key_store_location_path>"`
200+
- `"<ecdsa_key_store_password>"`
201+
- `"<bls_key_store_location_path>"`
202+
- `"<bls_key_store_password>"`
210203

211204
`"<ecdsa_key_store_location_path>"` and `"<bls_key_store_location_path>"` are the paths to your keys generated with the EigenLayer CLI, `"<operator_address>"` and `"<earnings_receiver_address>"` can be found in the `operator.yaml` file created in the EigenLayer registration process.
212205
The keys are stored by default in the `~/.eigenlayer/operator_keys/` directory, so for example `<ecdsa_key_store_location_path>` could be `/path/to/home/.eigenlayer/operator_keys/some_key.ecdsa.key.json` and for `<bls_key_store_location_path>` it could be `/path/to/home/.eigenlayer/operator_keys/some_key.bls.key.json`.
213206

207+
#### Using docker
208+
209+
Update the following placeholders in `./config-files/config-operator.docker.yaml`:
210+
- `"<operator_address>"`
211+
- `"<earnings_receiver_address>"`
212+
- `"<ecdsa_key_store_password>"`
213+
- `"<bls_key_store_password>"`
214+
215+
Make sure not to update the `ecdsa_key_store_location_path` and `bls_key_store_location_path`
216+
as they are already set to the correct path.
217+
218+
Then create a .env file in `operator/docker/.env`.
219+
An example of the file can be found in `operator/docker/.env.example`.
220+
221+
The file should contain the following variables:
222+
223+
| Variable Name | Description |
224+
|-----------------------------|---------------------------------------------------------------------------------------------------------------|
225+
| `ECDSA_KEY_FILE_HOST` | Absolute path to the ECDSA key file. If generated from Eigen cli it should be in ~/.eigenlayer/operator_keys/ |
226+
| `BLS_KEY_FILE_HOST` | Absolute path to the BLS key file. If generated from Eigen cli it should be in ~/.eigenlayer/operator_keys/ |
227+
| `OPERATOR_CONFIG_FILE_HOST` | Absolute path to the operator config file. It should be path to config-files/config-operator.docker.yaml |
228+
214229
### Deposit Strategy Tokens
215230

216231
We are using [WETH](https://holesky.eigenlayer.xyz/restake/WETH) as the strategy token.
@@ -223,39 +238,45 @@ You will need to stake a minimum of a 1000 Wei in WETH. We recommend to stake a
223238
EigenLayer's guide can be found [here](https://docs.eigenlayer.xyz/eigenlayer/restaking-guides/restaking-user-guide/liquid-restaking/restake-lsts).
224239

225240
#### Option 2:
226-
If you have ETH and need to convert it to WETH you can use the following command, that will convert 1 Eth to WETH. Change the parameter in ```---value``` if you want to wrap a different amount:
241+
If you have ETH and need to convert it to WETH you can use the following command, that will convert 1 Eth to WETH.
242+
Make sure to have [foundry](https://book.getfoundry.sh/getting-started/installation) installed.
243+
Change the parameter in ```---value``` if you want to wrap a different amount:
227244

228245
```bash
229246
cast send 0x94373a4919B3240D86eA41593D5eBa789FEF3848 --rpc-url https://ethereum-holesky-rpc.publicnode.com --private-key <private_key> --value 1ether
230247
```
231248

232249
Here `<private_key>` is the placeholder for the ECDSA key specified in the output when generating your keys with the EigenLayer CLI.
233250

234-
Finally, to end the staking process, you need to deposit into the strategy, as shown in EigenLayer's guide, or alternatively, you can run the following command to deposit 1 WETH:
251+
Finally, to end the staking process, you need to deposit into the WETH strategy,
252+
as shown in the Eigen guide.
235253

236-
```bash
237-
./operator/build/aligned-operator deposit-into-strategy --config ./config-files/config-operator.yaml --strategy-address 0x80528D6e9A2BAbFc766965E0E26d5aB08D9CFaF9 --amount 1000000000000000000
238-
```
254+
<details>
255+
<summary>An alternative using the CLI (only when running without docker)</summary>
256+
257+
Run the following command to deposit one WETH
258+
```bash
259+
./operator/build/aligned-operator deposit-into-strategy --config ./config-files/config-operator.yaml --strategy-address 0x80528D6e9A2BAbFc766965E0E26d5aB08D9CFaF9 --amount 1000000000000000000
260+
```
261+
</details>
239262

240263
If you don't have Holesky Eth, these are some useful faucets:
241264

242265
- [Google Cloud for Web3 Holesky Faucet](https://cloud.google.com/application/web3/faucet/ethereum/holesky)
243266
- [Holesky PoW Faucet](https://holesky-faucet.pk910.de/)
244267

245-
### Register as an operator with Aligned
268+
### Start the operator
246269

247-
To register the operator with Aligned, run:
270+
#### From Source (Recommended)
248271

249-
```bash
250-
./operator/build/aligned-operator register --config ./config-files/config-operator.yaml
272+
```
273+
./operator/build/aligned-operator start --config ./config-files/config-operator.yaml
251274
```
252275

253-
### Start the operator
254-
255-
To start the Aligned operator, run:
276+
#### Using Docker
256277

257278
```bash
258-
./operator/build/aligned-operator start --config ./config-files/config-operator.yaml
279+
make operator_start_docker
259280
```
260281

261282
### Unregister the operator from Aligned

anvil.Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Use the latest foundry image
2+
FROM debian:bookworm-slim
3+
4+
RUN apt-get update; apt-get -y install curl ; apt-get install make
5+
# Copy our source code into the container
6+
COPY Makefile Makefile
7+
8+
9+
ENTRYPOINT ["tail", "-f", "/dev/null"]
10+
11+
#RUN curl -L https://foundry.paradigm.xyz | bash
12+
#RUN source /home/ubuntu/.bashrc
13+
#ENTRYPOINT ["make", "anvil_start_with_block_time"]

compose.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
services:
2+
anvil_blockchain:
3+
image: anvil_blockchain
4+
build:
5+
context: .
6+
dockerfile: anvil.Dockerfile
7+
ports:
8+
- "8000:5000"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Common variables for all the services
2+
# 'production' only prints info and above. 'development' also prints debug
3+
environment: "production"
4+
aligned_layer_deployment_config_file_path: "/usr/src/app/contracts/script/output/holesky/alignedlayer_deployment_output.json"
5+
eigen_layer_deployment_config_file_path: "/usr/src/app/contracts/script/output/holesky/eigenlayer_deployment_output.json"
6+
eth_rpc_url: "https://ethereum-holesky-rpc.publicnode.com"
7+
eth_ws_url: "wss://ethereum-holesky-rpc.publicnode.com"
8+
eigen_metrics_ip_port_address: "localhost:9090"
9+
10+
## ECDSA Configurations
11+
ecdsa:
12+
private_key_store_path: "/usr/src/config/operator.ecdsa.key.json"
13+
private_key_store_password: "<ecdsa_key_store_password>"
14+
15+
## BLS Configurations
16+
bls:
17+
private_key_store_path: "/usr/src/config/operator.bls.key.json"
18+
private_key_store_password: "<bls_key_store_password>"
19+
20+
## Operator Configurations
21+
operator:
22+
aggregator_rpc_server_ip_port_address: aggregator.alignedlayer.com:8090
23+
address: "<operator_address>"
24+
earnings_receiver_address: "<earnings_receiver_address>" #Can be the same as the operator.
25+
delegation_approver_address: "0x0000000000000000000000000000000000000000"
26+
staker_opt_out_window_blocks: 0
27+
metadata_url: "https://yetanotherco.github.io/operator_metadata/metadata.json"
28+
enable_metrics: true
29+
metrics_ip_port_address: localhost:9092
30+
max_batch_size: 268435456 # 256 MiB

config-files/config-operator.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ eigen_metrics_ip_port_address: "localhost:9090"
1010
## ECDSA Configurations
1111
ecdsa:
1212
private_key_store_path: "<ecdsa_key_store_location_path>"
13-
private_key_store_password: ""
13+
private_key_store_password: "<ecdsa_key_store_password>"
1414

1515
## BLS Configurations
1616
bls:
1717
private_key_store_path: "<bls_key_store_location_path>"
18-
private_key_store_password: ""
18+
private_key_store_password: "<bls_key_store_password>"
1919

2020
## Operator Configurations
2121
operator:

operator/cmd/actions/register.go

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ package actions
22

33
import (
44
"context"
5-
"math/big"
5+
operator "github.com/yetanotherco/aligned_layer/operator/pkg"
66
"time"
77

8-
"github.com/Layr-Labs/eigensdk-go/types"
98
"github.com/ethereum/go-ethereum/crypto"
109
"github.com/urfave/cli/v2"
11-
"github.com/yetanotherco/aligned_layer/core/chainio"
1210
"github.com/yetanotherco/aligned_layer/core/config"
1311
)
1412

@@ -35,46 +33,11 @@ func registerOperatorMain(ctx *cli.Context) error {
3533

3634
copy(salt[:], crypto.Keccak256([]byte("churn"), []byte(time.Now().String()), quorumNumbers, privateKeyBytes))
3735

38-
expiry := big.NewInt(time.Now().Add(10 * time.Minute).Unix())
39-
quorumNumbersArr := types.QuorumNums{0}
40-
socket := "Not Needed"
41-
42-
err := registerOperator(context.Background(), config,
43-
socket, quorumNumbersArr, salt, expiry)
36+
err := operator.RegisterOperator(context.Background(), config, salt)
4437
if err != nil {
4538
config.BaseConfig.Logger.Error("Failed to register operator", "err", err)
4639
return err
4740
}
4841

4942
return nil
5043
}
51-
52-
// RegisterOperator operator registers the operator with the given public key for the given quorum IDs.
53-
// RegisterOperator registers a new operator with the given public key and socket with the provided quorum ids.
54-
// If the operator is already registered with a given quorum id, the transaction will fail (noop) and an error
55-
// will be returned.
56-
func registerOperator(
57-
ctx context.Context,
58-
configuration *config.OperatorConfig,
59-
socket string,
60-
quorumNumbers types.QuorumNums,
61-
operatorToAvsRegistrationSigSalt [32]byte,
62-
operatorToAvsRegistrationSigExpiry *big.Int,
63-
) error {
64-
writer, err := chainio.NewAvsWriterFromConfig(configuration.BaseConfig, configuration.EcdsaConfig)
65-
if err != nil {
66-
configuration.BaseConfig.Logger.Error("Failed to create AVS writer", "err", err)
67-
return err
68-
}
69-
70-
_, err = writer.RegisterOperatorInQuorumWithAVSRegistryCoordinator(ctx, configuration.EcdsaConfig.PrivateKey,
71-
operatorToAvsRegistrationSigSalt, operatorToAvsRegistrationSigExpiry, configuration.BlsConfig.KeyPair,
72-
quorumNumbers, socket)
73-
74-
if err != nil {
75-
configuration.BaseConfig.Logger.Error("Failed to register operator", "err", err)
76-
return err
77-
}
78-
79-
return nil
80-
}

operator/docker/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ECDSA_KEY_FILE_HOST=<full-path-to-.ecdsa.key.json>
2+
BLS_KEY_FILE_HOST=<full-path-to-.bls.key.json>
3+
OPERATOR_CONFIG_FILE_HOST=<full-path-to-operator_config.docker.yaml>

operator/docker/compose.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
services:
2+
operator:
3+
env_file:
4+
- .env
5+
container_name: operator
6+
image: operator:latest
7+
build:
8+
context: ../../
9+
dockerfile: operator/docker/operator.Dockerfile
10+
11+
volumes:
12+
- "${ECDSA_KEY_FILE_HOST}:/usr/src/config/operator.ecdsa.key.json:readonly"
13+
- "${BLS_KEY_FILE_HOST}:/usr/src/config/operator.bls.key.json:readonly"
14+
- "${OPERATOR_CONFIG_FILE_HOST}:/usr/src/config/operator.yaml:readonly"
15+
restart: unless-stopped
16+
extra_hosts:
17+
- "host.docker.internal:host-gateway"
18+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
FROM golang:1.22.4
2+
3+
# Update default packages
4+
RUN apt-get update
5+
6+
# Get Ubuntu packages
7+
RUN apt-get install -y \
8+
build-essential \
9+
curl \
10+
openssl \
11+
libssl-dev
12+
13+
# Update new packages
14+
RUN apt-get update
15+
16+
# Get Rust
17+
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
18+
19+
# Add cargo to path
20+
ENV PATH="/root/.cargo/bin:${PATH}"
21+
22+
WORKDIR /usr/src/app
23+
24+
# Copy the Makefile and the operator (for the FFI)
25+
COPY Makefile /usr/src/app
26+
COPY operator /usr/src/app/operator
27+
28+
# Build the FFI
29+
RUN make build_all_ffi_linux
30+
31+
# Copy dependencies
32+
COPY go.mod go.sum ./
33+
COPY metrics /usr/src/app/metrics
34+
COPY contracts/script/output /usr/src/app/contracts/script/output
35+
COPY contracts/bindings /usr/src/app/contracts/bindings
36+
COPY core /usr/src/app/core
37+
COPY common /usr/src/app/common
38+
39+
# Download dependencies
40+
RUN go mod download && go mod tidy && go mod verify
41+
42+
# Build the operator
43+
RUN go build -v -o /usr/local/bin/operator /usr/src/app/operator/cmd/main.go
44+
45+
ENTRYPOINT [ "/usr/local/bin/operator", "start", "--config", "/usr/src/config/operator.yaml"]

0 commit comments

Comments
 (0)