Skip to content

Commit 2b5d50b

Browse files
author
Julian Ventura
committed
Merge branch 'staging' into fix/operator-ffi-panic-catch
2 parents aa92c6f + 8164a8f commit 2b5d50b

File tree

128 files changed

+9163
-6044
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+9163
-6044
lines changed

.github/workflows/build-go.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ jobs:
3131
run: make build_risc_zero_linux
3232
- name: Build Merkle Tree bindings
3333
run: make build_merkle_tree_linux
34-
- name: Build Old Merkle Tree bindings
35-
run: make build_merkle_tree_linux_old
3634
- name: Build operator
3735
run: go build operator/cmd/main.go
3836
- name: Build aggregator

Makefile

Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
.PHONY: help tests
22

3+
SHELL := /bin/bash
34
OS := $(shell uname -s)
45

56
CONFIG_FILE?=config-files/config.yaml
67
AGG_CONFIG_FILE?=config-files/config-aggregator.yaml
78

8-
OPERATOR_VERSION=v0.8.0
9+
OPERATOR_VERSION=v0.9.2
910

1011
ifeq ($(OS),Linux)
1112
BUILD_ALL_FFI = $(MAKE) build_all_ffi_linux
@@ -15,6 +16,19 @@ ifeq ($(OS),Darwin)
1516
BUILD_ALL_FFI = $(MAKE) build_all_ffi_macos
1617
endif
1718

19+
ifeq ($(OS),Linux)
20+
export LD_LIBRARY_PATH += $(CURDIR)/operator/risc_zero/lib
21+
endif
22+
23+
ifeq ($(OS),Linux)
24+
BUILD_OPERATOR = $(MAKE) build_operator_linux
25+
endif
26+
27+
ifeq ($(OS),Darwin)
28+
BUILD_OPERATOR = $(MAKE) build_operator_macos
29+
endif
30+
31+
1832
FFI_FOR_RELEASE ?= true
1933

2034
ifeq ($(FFI_FOR_RELEASE),true)
@@ -32,7 +46,7 @@ submodules:
3246
git submodule update --init --recursive
3347
@echo "Updated submodules"
3448

35-
deps: submodules build_all_ffi ## Install deps
49+
deps: submodules go_deps build_all_ffi ## Install deps
3650

3751
go_deps:
3852
@echo "Installing Go dependencies..."
@@ -79,10 +93,6 @@ anvil_upgrade_add_aggregator:
7993
@echo "Adding Aggregator to Aligned Contracts..."
8094
. contracts/scripts/anvil/upgrade_add_aggregator_to_service_manager.sh
8195

82-
anvil_add_type_hash_to_batcher_payment_service:
83-
@echo "Adding Type Hash to Batcher Payment Service..."
84-
. contracts/scripts/anvil/upgrade_add_type_hash_to_batcher_payment_service.sh
85-
8696
lint_contracts:
8797
@cd contracts && npm run lint:sol
8898

@@ -94,6 +104,8 @@ anvil_start_with_block_time:
94104
@echo "Starting Anvil..."
95105
anvil --load-state contracts/scripts/anvil/state/alignedlayer-deployed-anvil-state.json --block-time 7
96106

107+
_AGGREGATOR_:
108+
97109
aggregator_start:
98110
@echo "Starting Aggregator..."
99111
@go run aggregator/cmd/main.go --config $(AGG_CONFIG_FILE) \
@@ -103,16 +115,29 @@ aggregator_send_dummy_responses:
103115
@echo "Sending dummy responses to Aggregator..."
104116
@cd aggregator && go run dummy/submit_task_responses.go
105117

118+
119+
__OPERATOR__:
120+
106121
operator_start:
107122
@echo "Starting Operator..."
108123
go run operator/cmd/main.go start --config $(CONFIG_FILE) \
109124
2>&1 | zap-pretty
110125

126+
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
127+
111128
operator_register_and_start: operator_full_registration operator_start
112129

113130
build_operator: deps
131+
$(BUILD_OPERATOR)
132+
133+
build_operator_macos:
134+
@echo "Building Operator..."
135+
@go build -ldflags "-X main.Version=$(OPERATOR_VERSION)" -o ./operator/build/aligned-operator ./operator/cmd/main.go
136+
@echo "Operator built into /operator/build/aligned-operator"
137+
138+
build_operator_linux:
114139
@echo "Building Operator..."
115-
@go build -ldflags "-X main.Version=$(OPERATOR_VERSION) -r $(LD_LIBRARY_PATH):$(CURDIR)/operator/risc_zero/lib" -o ./operator/build/aligned-operator ./operator/cmd/main.go
140+
@go build -ldflags "-X main.Version=$(OPERATOR_VERSION) -r $(LD_LIBRARY_PATH)" -o ./operator/build/aligned-operator ./operator/cmd/main.go
116141
@echo "Operator built into /operator/build/aligned-operator"
117142

118143
update_operator:
@@ -126,15 +151,13 @@ operator_valid_marshall_fuzz_macos:
126151

127152
operator_valid_marshall_fuzz_linux:
128153
@cd operator/pkg && \
129-
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(CURDIR)/operator/risc_zero/lib \
130154
go test -fuzz=FuzzValidMarshall
131155

132156
operator_marshall_unmarshall_fuzz_macos:
133157
@cd operator/pkg && go test -fuzz=FuzzMarshalUnmarshal -ldflags=-extldflags=-Wl,-ld_classic
134158

135159
operator_marshall_unmarshall_fuzz_linux:
136160
@cd operator/pkg && \
137-
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(CURDIR)/operator/risc_zero/lib \
138161
go test -fuzz=FuzzMarshalUnmarshal
139162

140163
bindings:
@@ -186,9 +209,8 @@ operator_whitelist:
186209
@. contracts/scripts/.env && . contracts/scripts/whitelist_operator.sh $(OPERATOR_ADDRESS)
187210

188211
operator_deposit_into_mock_strategy:
189-
@echo "Depositing into strategy"
212+
@echo "Depositing into mock strategy"
190213
$(eval STRATEGY_ADDRESS = $(shell jq -r '.addresses.strategies.MOCK' contracts/script/output/devnet/eigenlayer_deployment_output.json))
191-
192214
@go run operator/cmd/main.go deposit-into-strategy \
193215
--config $(CONFIG_FILE) \
194216
--strategy-address $(STRATEGY_ADDRESS) \
@@ -207,7 +229,6 @@ operator_register_with_aligned_layer:
207229

208230
operator_deposit_and_register: operator_deposit_into_strategy operator_register_with_aligned_layer
209231

210-
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
211232

212233
__BATCHER__:
213234

@@ -286,6 +307,16 @@ batcher_send_risc0_task:
286307
--rpc_url $(RPC_URL) \
287308
--network $(NETWORK)
288309

310+
batcher_send_risc0_task_no_pub_input:
311+
@echo "Sending Risc0 fibonacci task to Batcher..."
312+
@cd batcher/aligned/ && cargo run --release -- submit \
313+
--proving_system Risc0 \
314+
--proof ../../scripts/test_files/risc_zero/no_public_inputs/risc_zero_no_pub_input.proof \
315+
--vm_program ../../scripts/test_files/risc_zero/no_public_inputs/no_pub_input_id.bin \
316+
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
317+
--rpc_url $(RPC_URL) \
318+
--payment_service_addr $(BATCHER_PAYMENTS_CONTRACT_ADDRESS)
319+
289320
batcher_send_risc0_burst:
290321
@echo "Sending Risc0 fibonacci task to Batcher..."
291322
@cd batcher/aligned/ && cargo run --release -- submit \
@@ -435,10 +466,6 @@ upgrade_add_aggregator: ## Add Aggregator to Aligned Contracts
435466
@echo "Adding Aggregator to Aligned Contracts..."
436467
@. contracts/scripts/.env && . contracts/scripts/upgrade_add_aggregator_to_service_manager.sh
437468

438-
upgrade_batcher_payments_add_type_hash: ## Add Type Hash to Batcher Payment Service
439-
@echo "Adding Type Hash to Batcher Payment Service..."
440-
@. contracts/scripts/.env && . contracts/scripts/upgrade_add_type_hash_to_batcher_payment_service.sh
441-
442469
deploy_verify_batch_inclusion_caller:
443470
@echo "Deploying VerifyBatchInclusionCaller contract..."
444471
@. examples/verify/.env && . examples/verify/scripts/deploy_verify_batch_inclusion_caller.sh
@@ -497,6 +524,11 @@ generate_sp1_fibonacci_proof:
497524
@mv scripts/test_files/sp1/fibonacci_proof_generator/script/sp1_fibonacci.proof scripts/test_files/sp1/
498525
@echo "Fibonacci proof and ELF generated in scripts/test_files/sp1 folder"
499526

527+
generate_risc_zero_empty_journal_proof:
528+
@cd scripts/test_files/risc_zero/no_public_inputs && RUST_LOG=info cargo run --release
529+
@echo "Fibonacci proof and ELF with empty journal generated in scripts/test_files/risc_zero/no_public_inputs folder"
530+
531+
500532
__RISC_ZERO_FFI__: ##
501533
build_risc_zero_macos:
502534
@cd operator/risc_zero/lib && cargo build $(RELEASE_FLAG)
@@ -516,7 +548,6 @@ test_risc_zero_go_bindings_macos: build_risc_zero_macos
516548

517549
test_risc_zero_go_bindings_linux: build_risc_zero_linux
518550
@echo "Testing RISC Zero Go bindings..."
519-
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(CURDIR)/operator/risc_zero/lib \
520551
go test ./operator/risc_zero/... -v
521552

522553
generate_risc_zero_fibonacci_proof:
@@ -530,29 +561,15 @@ build_merkle_tree_macos:
530561
@cp operator/merkle_tree/lib/target/$(TARGET_REL_PATH)/libmerkle_tree.dylib operator/merkle_tree/lib/libmerkle_tree.dylib
531562
@cp operator/merkle_tree/lib/target/$(TARGET_REL_PATH)/libmerkle_tree.a operator/merkle_tree/lib/libmerkle_tree.a
532563

533-
build_merkle_tree_macos_old:
534-
@cd operator/merkle_tree_old/lib && cargo build $(RELEASE_FLAG)
535-
@cp operator/merkle_tree_old/lib/target/$(TARGET_REL_PATH)/libmerkle_tree.dylib operator/merkle_tree_old/lib/libmerkle_tree.dylib
536-
@cp operator/merkle_tree_old/lib/target/$(TARGET_REL_PATH)/libmerkle_tree.a operator/merkle_tree_old/lib/libmerkle_tree.a
537-
538564
build_merkle_tree_linux:
539565
@cd operator/merkle_tree/lib && cargo build $(RELEASE_FLAG)
540566
@cp operator/merkle_tree/lib/target/$(TARGET_REL_PATH)/libmerkle_tree.so operator/merkle_tree/lib/libmerkle_tree.so
541567
@cp operator/merkle_tree/lib/target/$(TARGET_REL_PATH)/libmerkle_tree.a operator/merkle_tree/lib/libmerkle_tree.a
542568

543-
build_merkle_tree_linux_old:
544-
@cd operator/merkle_tree_old/lib && cargo build $(RELEASE_FLAG)
545-
@cp operator/merkle_tree_old/lib/target/$(TARGET_REL_PATH)/libmerkle_tree.so operator/merkle_tree_old/lib/libmerkle_tree.so
546-
@cp operator/merkle_tree_old/lib/target/$(TARGET_REL_PATH)/libmerkle_tree.a operator/merkle_tree_old/lib/libmerkle_tree.a
547-
548569
test_merkle_tree_rust_ffi:
549570
@echo "Testing Merkle Tree Rust FFI source code..."
550571
@cd operator/merkle_tree/lib && RUST_MIN_STACK=83886080 cargo t --release
551572

552-
test_merkle_tree_rust_ffi_old:
553-
@echo "Testing Old Merkle Tree Rust FFI source code..."
554-
@cd operator/merkle_tree_old/lib && RUST_MIN_STACK=83886080 cargo t --release
555-
556573
test_merkle_tree_go_bindings_macos: build_merkle_tree_macos
557574
@echo "Testing Merkle Tree Go bindings..."
558575
go test ./operator/merkle_tree/... -v
@@ -565,9 +582,6 @@ test_merkle_tree_old_go_bindings_macos: build_merkle_tree_macos_old
565582
@echo "Testing Old Merkle Tree Go bindings..."
566583
go test ./operator/merkle_tree_old/... -v
567584

568-
test_merkle_tree_go_bindings_linux_old: build_merkle_tree_linux_old
569-
@echo "Testing Merkle Tree Go bindings..."
570-
go test ./operator/merkle_tree_old/... -v
571585

572586
__BUILD_ALL_FFI__:
573587

@@ -580,18 +594,15 @@ build_all_ffi_macos: ## Build all FFIs for macOS
580594
@$(MAKE) build_sp1_macos
581595
@$(MAKE) build_risc_zero_macos
582596
@$(MAKE) build_merkle_tree_macos
583-
@$(MAKE) build_merkle_tree_macos_old
584597
@echo "All macOS FFIs built successfully."
585598

586599
build_all_ffi_linux: ## Build all FFIs for Linux
587600
@echo "Building all FFIs for Linux..."
588601
@$(MAKE) build_sp1_linux
589602
@$(MAKE) build_risc_zero_linux
590603
@$(MAKE) build_merkle_tree_linux
591-
@$(MAKE) build_merkle_tree_linux_old
592604
@echo "All Linux FFIs built successfully."
593605

594-
595606
__EXPLORER__:
596607
run_explorer: explorer_run_db explorer_ecto_setup_db
597608
@cd explorer/ && \
@@ -675,10 +686,13 @@ tracker_dump_db:
675686

676687
__TELEMETRY__:
677688
open_telemetry_start: ## Run open telemetry services using telemetry-docker-compose.yaml
678-
## TODO(juarce) ADD DOCKER COMPOSE
679689
@echo "Running telemetry..."
680690
@docker compose -f telemetry-docker-compose.yaml up -d
681691

692+
open_telemetry_prod_start: ## Run open telemetry services with Cassandra using telemetry-prod-docker-compose.yaml
693+
@echo "Running telemetry for Prod..."
694+
@docker compose -f telemetry-prod-docker-compose.yaml up -d
695+
682696
telemetry_start: telemetry_run_db telemetry_ecto_migrate ## Run Telemetry API
683697
@cd telemetry_api && \
684698
./start.sh

aggregator/internal/pkg/aggregator.go

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/prometheus/client_golang/prometheus"
1313
"github.com/yetanotherco/aligned_layer/metrics"
1414

15-
"github.com/Layr-Labs/eigensdk-go/chainio/clients"
1615
sdkclients "github.com/Layr-Labs/eigensdk-go/chainio/clients"
1716
"github.com/Layr-Labs/eigensdk-go/logging"
1817
"github.com/Layr-Labs/eigensdk-go/services/avsregistry"
@@ -80,8 +79,12 @@ type Aggregator struct {
8079

8180
logger logging.Logger
8281

82+
// Metrics
8383
metricsReg *prometheus.Registry
8484
metrics *metrics.Metrics
85+
86+
// Telemetry
87+
telemetry *Telemetry
8588
}
8689

8790
func NewAggregator(aggregatorConfig config.AggregatorConfig) (*Aggregator, error) {
@@ -119,7 +122,7 @@ func NewAggregator(aggregatorConfig config.AggregatorConfig) (*Aggregator, error
119122
aggregatorPrivateKey := aggregatorConfig.EcdsaConfig.PrivateKey
120123

121124
logger := aggregatorConfig.BaseConfig.Logger
122-
clients, err := clients.BuildAll(chainioConfig, aggregatorPrivateKey, logger)
125+
clients, err := sdkclients.BuildAll(chainioConfig, aggregatorPrivateKey, logger)
123126
if err != nil {
124127
logger.Errorf("Cannot create sdk clients", "err", err)
125128
return nil, err
@@ -148,6 +151,9 @@ func NewAggregator(aggregatorConfig config.AggregatorConfig) (*Aggregator, error
148151
reg := prometheus.NewRegistry()
149152
aggregatorMetrics := metrics.NewMetrics(aggregatorConfig.Aggregator.MetricsIpPortAddress, reg, logger)
150153

154+
// Telemetry
155+
aggregatorTelemetry := NewTelemetry(aggregatorConfig.Aggregator.TelemetryIpPortAddress, logger)
156+
151157
nextBatchIndex := uint32(0)
152158

153159
aggregator := Aggregator{
@@ -169,6 +175,7 @@ func NewAggregator(aggregatorConfig config.AggregatorConfig) (*Aggregator, error
169175
logger: logger,
170176
metricsReg: reg,
171177
metrics: aggregatorMetrics,
178+
telemetry: aggregatorTelemetry,
172179
}
173180

174181
return &aggregator, nil
@@ -209,11 +216,20 @@ func (agg *Aggregator) Start(ctx context.Context) error {
209216
const MaxSentTxRetries = 5
210217

211218
func (agg *Aggregator) handleBlsAggServiceResponse(blsAggServiceResp blsagg.BlsAggregationServiceResponse) {
219+
agg.taskMutex.Lock()
220+
agg.AggregatorConfig.BaseConfig.Logger.Info("- Locked Resources: Fetching task data")
221+
batchIdentifierHash := agg.batchesIdentifierHashByIdx[blsAggServiceResp.TaskIndex]
222+
batchData := agg.batchDataByIdentifierHash[batchIdentifierHash]
223+
taskCreatedBlock := agg.batchCreatedBlockByIdx[blsAggServiceResp.TaskIndex]
224+
agg.taskMutex.Unlock()
225+
agg.AggregatorConfig.BaseConfig.Logger.Info("- Unlocked Resources: Fetching task data")
226+
227+
// Finish task trace once the task is processed (either successfully or not)
228+
defer agg.telemetry.FinishTrace(batchData.BatchMerkleRoot)
229+
212230
if blsAggServiceResp.Err != nil {
213-
agg.taskMutex.Lock()
214-
batchIdentifierHash := agg.batchesIdentifierHashByIdx[blsAggServiceResp.TaskIndex]
231+
agg.telemetry.LogTaskError(batchData.BatchMerkleRoot, blsAggServiceResp.Err)
215232
agg.logger.Error("BlsAggregationServiceResponse contains an error", "err", blsAggServiceResp.Err, "batchIdentifierHash", hex.EncodeToString(batchIdentifierHash[:]))
216-
agg.taskMutex.Unlock()
217233
return
218234
}
219235
nonSignerPubkeys := []servicemanager.BN254G1Point{}
@@ -236,13 +252,7 @@ func (agg *Aggregator) handleBlsAggServiceResponse(blsAggServiceResp blsagg.BlsA
236252
NonSignerStakeIndices: blsAggServiceResp.NonSignerStakeIndices,
237253
}
238254

239-
agg.taskMutex.Lock()
240-
agg.AggregatorConfig.BaseConfig.Logger.Info("- Locked Resources: Fetching merkle root")
241-
batchIdentifierHash := agg.batchesIdentifierHashByIdx[blsAggServiceResp.TaskIndex]
242-
batchData := agg.batchDataByIdentifierHash[batchIdentifierHash]
243-
taskCreatedBlock := agg.batchCreatedBlockByIdx[blsAggServiceResp.TaskIndex]
244-
agg.AggregatorConfig.BaseConfig.Logger.Info("- Unlocked Resources: Fetching merkle root")
245-
agg.taskMutex.Unlock()
255+
agg.telemetry.LogQuorumReached(batchData.BatchMerkleRoot)
246256

247257
agg.logger.Info("Threshold reached", "taskIndex", blsAggServiceResp.TaskIndex,
248258
"batchIdentifierHash", "0x"+hex.EncodeToString(batchIdentifierHash[:]))
@@ -278,6 +288,7 @@ func (agg *Aggregator) handleBlsAggServiceResponse(blsAggServiceResp blsagg.BlsA
278288
"merkleRoot", "0x"+hex.EncodeToString(batchData.BatchMerkleRoot[:]),
279289
"senderAddress", "0x"+hex.EncodeToString(batchData.SenderAddress[:]),
280290
"batchIdentifierHash", "0x"+hex.EncodeToString(batchIdentifierHash[:]))
291+
agg.telemetry.LogTaskError(batchData.BatchMerkleRoot, err)
281292
}
282293

283294
// / Sends response to contract and waits for transaction receipt
@@ -294,6 +305,7 @@ func (agg *Aggregator) sendAggregatedResponse(batchIdentifierHash [32]byte, batc
294305
if err != nil {
295306
agg.walletMutex.Unlock()
296307
agg.logger.Infof("- Unlocked Wallet Resources: Error sending aggregated response for batch %s. Error: %s", hex.EncodeToString(batchIdentifierHash[:]), err)
308+
agg.telemetry.LogTaskError(batchMerkleRoot, err)
297309
return nil, err
298310
}
299311

@@ -303,6 +315,7 @@ func (agg *Aggregator) sendAggregatedResponse(batchIdentifierHash [32]byte, batc
303315
receipt, err := utils.WaitForTransactionReceipt(
304316
agg.AggregatorConfig.BaseConfig.EthRpcClient, context.Background(), *txHash)
305317
if err != nil {
318+
agg.telemetry.LogTaskError(batchMerkleRoot, err)
306319
return nil, err
307320
}
308321

@@ -312,6 +325,7 @@ func (agg *Aggregator) sendAggregatedResponse(batchIdentifierHash [32]byte, batc
312325
}
313326

314327
func (agg *Aggregator) AddNewTask(batchMerkleRoot [32]byte, senderAddress [20]byte, taskCreatedBlock uint32) {
328+
agg.telemetry.InitNewTrace(batchMerkleRoot)
315329
batchIdentifier := append(batchMerkleRoot[:], senderAddress[:]...)
316330
var batchIdentifierHash = *(*[32]byte)(crypto.Keccak256(batchIdentifier))
317331

@@ -358,6 +372,7 @@ func (agg *Aggregator) AddNewTask(batchMerkleRoot [32]byte, senderAddress [20]by
358372
agg.logger.Fatalf("BLS aggregation service error when initializing new task: %s", err)
359373
}
360374

375+
agg.metrics.IncAggregatorReceivedTasks()
361376
agg.taskMutex.Unlock()
362377
agg.AggregatorConfig.BaseConfig.Logger.Info("- Unlocked Resources: Adding new task")
363378
agg.logger.Info("New task added", "batchIndex", batchIndex, "batchIdentifierHash", "0x"+hex.EncodeToString(batchIdentifierHash[:]))

0 commit comments

Comments
 (0)