Skip to content

Commit 3845a1f

Browse files
authored
v0.10.0 (#1296)
2 parents 95c2db3 + 192a535 commit 3845a1f

File tree

116 files changed

+9132
-4463
lines changed

Some content is hidden

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

116 files changed

+9132
-4463
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ jobs:
3535
run: go build operator/cmd/main.go
3636
- name: Build aggregator
3737
run: go build aggregator/cmd/main.go
38+

.github/workflows/build-and-test-rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
cargo build --all
4848
4949
test:
50-
runs-on: ubuntu-latest
50+
runs-on: aligned-runner
5151
needs: build
5252
steps:
5353
- name: Checkout code

Makefile

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ OS := $(shell uname -s)
66
CONFIG_FILE?=config-files/config.yaml
77
AGG_CONFIG_FILE?=config-files/config-aggregator.yaml
88

9-
OPERATOR_VERSION=v0.9.2
9+
OPERATOR_VERSION=v0.10.0
1010

1111
ifeq ($(OS),Linux)
1212
BUILD_ALL_FFI = $(MAKE) build_all_ffi_linux
@@ -17,7 +17,15 @@ ifeq ($(OS),Darwin)
1717
endif
1818

1919
ifeq ($(OS),Linux)
20-
export LD_LIBRARY_PATH := $(CURDIR)/operator/risc_zero/lib
20+
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
2129
endif
2230

2331

@@ -85,6 +93,10 @@ anvil_upgrade_add_aggregator:
8593
@echo "Adding Aggregator to Aligned Contracts..."
8694
. contracts/scripts/anvil/upgrade_add_aggregator_to_service_manager.sh
8795

96+
anvil_upgrade_initialize_disable_verifiers:
97+
@echo "Initializing disabled verifiers..."
98+
. contracts/scripts/anvil/upgrade_disabled_verifiers_in_service_manager.sh
99+
88100
lint_contracts:
89101
@cd contracts && npm run lint:sol
90102

@@ -120,6 +132,14 @@ operator_full_registration: operator_get_eth operator_register_with_eigen_layer
120132
operator_register_and_start: operator_full_registration operator_start
121133

122134
build_operator: deps
135+
$(BUILD_OPERATOR)
136+
137+
build_operator_macos:
138+
@echo "Building Operator..."
139+
@go build -ldflags "-X main.Version=$(OPERATOR_VERSION)" -o ./operator/build/aligned-operator ./operator/cmd/main.go
140+
@echo "Operator built into /operator/build/aligned-operator"
141+
142+
build_operator_linux:
123143
@echo "Building Operator..."
124144
@go build -ldflags "-X main.Version=$(OPERATOR_VERSION) -r $(LD_LIBRARY_PATH)" -o ./operator/build/aligned-operator ./operator/cmd/main.go
125145
@echo "Operator built into /operator/build/aligned-operator"
@@ -214,6 +234,23 @@ operator_register_with_aligned_layer:
214234
operator_deposit_and_register: operator_deposit_into_strategy operator_register_with_aligned_layer
215235

216236

237+
# The verifier ID to enable or disable corresponds to the index of the verifier in the `ProvingSystemID` enum.
238+
verifier_enable_devnet:
239+
@echo "Enabling verifier with id: $(VERIFIER_ID)"
240+
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 RPC_URL=http://localhost:8545 OUTPUT_PATH=./script/output/devnet/alignedlayer_deployment_output.json ./contracts/scripts/enable_verifier.sh $(VERIFIER_ID)
241+
242+
verifier_disable_devnet:
243+
@echo "Disabling verifier with id: $(VERIFIER_ID)"
244+
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 RPC_URL=http://localhost:8545 OUTPUT_PATH=./script/output/devnet/alignedlayer_deployment_output.json ./contracts/scripts/disable_verifier.sh $(VERIFIER_ID)
245+
246+
verifier_enable:
247+
@echo "Enabling verifier with ID: $(VERIFIER_ID)"
248+
@. contracts/scripts/.env && . contracts/scripts/enable_verifier.sh $(VERIFIER_ID)
249+
250+
verifier_disable:
251+
@echo "Disabling verifier with ID: $(VERIFIER_ID)"
252+
@. contracts/scripts/.env && . contracts/scripts/disable_verifier.sh $(VERIFIER_ID)
253+
217254
__BATCHER__:
218255

219256
BURST_SIZE=5
@@ -291,6 +328,16 @@ batcher_send_risc0_task:
291328
--rpc_url $(RPC_URL) \
292329
--network $(NETWORK)
293330

331+
batcher_send_risc0_task_no_pub_input:
332+
@echo "Sending Risc0 fibonacci task to Batcher..."
333+
@cd batcher/aligned/ && cargo run --release -- submit \
334+
--proving_system Risc0 \
335+
--proof ../../scripts/test_files/risc_zero/no_public_inputs/risc_zero_no_pub_input.proof \
336+
--vm_program ../../scripts/test_files/risc_zero/no_public_inputs/no_pub_input_id.bin \
337+
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
338+
--rpc_url $(RPC_URL) \
339+
--payment_service_addr $(BATCHER_PAYMENTS_CONTRACT_ADDRESS)
340+
294341
batcher_send_risc0_burst:
295342
@echo "Sending Risc0 fibonacci task to Batcher..."
296343
@cd batcher/aligned/ && cargo run --release -- submit \
@@ -390,6 +437,7 @@ generate_groth16_ineq_proof: ## Run the gnark_plonk_bn254_script
390437
@go run scripts/test_files/gnark_groth16_bn254_infinite_script/cmd/main.go 1
391438

392439
__METRICS__:
440+
# Prometheus and graphana
393441
run_metrics: ## Run metrics using metrics-docker-compose.yaml
394442
@echo "Running metrics..."
395443
@docker compose -f metrics-docker-compose.yaml up
@@ -428,6 +476,10 @@ upgrade_add_aggregator: ## Add Aggregator to Aligned Contracts
428476
@echo "Adding Aggregator to Aligned Contracts..."
429477
@. contracts/scripts/.env && . contracts/scripts/upgrade_add_aggregator_to_service_manager.sh
430478

479+
upgrade_initialize_disabled_verifiers:
480+
@echo "Adding disabled verifiers to Aligned Service Manager..."
481+
@. contracts/scripts/.env && . contracts/scripts/upgrade_disabled_verifiers_in_service_manager.sh
482+
431483
deploy_verify_batch_inclusion_caller:
432484
@echo "Deploying VerifyBatchInclusionCaller contract..."
433485
@. examples/verify/.env && . examples/verify/scripts/deploy_verify_batch_inclusion_caller.sh
@@ -486,6 +538,11 @@ generate_sp1_fibonacci_proof:
486538
@mv scripts/test_files/sp1/fibonacci_proof_generator/script/sp1_fibonacci.proof scripts/test_files/sp1/
487539
@echo "Fibonacci proof and ELF generated in scripts/test_files/sp1 folder"
488540

541+
generate_risc_zero_empty_journal_proof:
542+
@cd scripts/test_files/risc_zero/no_public_inputs && RUST_LOG=info cargo run --release
543+
@echo "Fibonacci proof and ELF with empty journal generated in scripts/test_files/risc_zero/no_public_inputs folder"
544+
545+
489546
__RISC_ZERO_FFI__: ##
490547
build_risc_zero_macos:
491548
@cd operator/risc_zero/lib && cargo build $(RELEASE_FLAG)
@@ -642,11 +699,19 @@ tracker_dump_db:
642699
@echo "Dumped database successfully to /operator_tracker"
643700

644701
__TELEMETRY__:
702+
# Collector, Jaeger and Elixir API
703+
telemetry_full_start: open_telemetry_start telemetry_start
704+
705+
# Collector and Jaeger
645706
open_telemetry_start: ## Run open telemetry services using telemetry-docker-compose.yaml
646-
## TODO(juarce) ADD DOCKER COMPOSE
647707
@echo "Running telemetry..."
648708
@docker compose -f telemetry-docker-compose.yaml up -d
649709

710+
open_telemetry_prod_start: ## Run open telemetry services with Cassandra using telemetry-prod-docker-compose.yaml
711+
@echo "Running telemetry for Prod..."
712+
@docker compose -f telemetry-prod-docker-compose.yaml up -d
713+
714+
# Elixir API
650715
telemetry_start: telemetry_run_db telemetry_ecto_migrate ## Run Telemetry API
651716
@cd telemetry_api && \
652717
./start.sh

aggregator/cmd/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ func aggregatorMain(ctx *cli.Context) error {
4949
return err
5050
}
5151

52+
// Supervisor revives garbage collector
53+
go func() {
54+
for {
55+
log.Println("Starting Garbage collector")
56+
aggregator.ClearTasksFromMaps()
57+
log.Println("Garbage collector panicked, Supervisor restarting")
58+
}
59+
}()
60+
5261
// Listen for new task created in the ServiceManager contract in a separate goroutine, both V1 and V2 subscriptions:
5362
go func() {
5463
listenErr := aggregator.SubscribeToNewTasks()

aggregator/internal/pkg/aggregator.go

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ type Aggregator struct {
6060
// and can start from zero
6161
batchesIdxByIdentifierHash map[[32]byte]uint32
6262

63-
// Stores the taskCreatedBlock for each batch bt batch index
63+
// Stores the taskCreatedBlock for each batch by batch index
6464
batchCreatedBlockByIdx map[uint32]uint64
6565

6666
// Stores the TaskResponse for each batch by batchIdentifierHash
@@ -215,6 +215,8 @@ func (agg *Aggregator) Start(ctx context.Context) error {
215215

216216
const MaxSentTxRetries = 5
217217

218+
const BLS_AGG_SERVICE_TIMEOUT = 100 * time.Second
219+
218220
func (agg *Aggregator) handleBlsAggServiceResponse(blsAggServiceResp blsagg.BlsAggregationServiceResponse) {
219221
agg.taskMutex.Lock()
220222
agg.AggregatorConfig.BaseConfig.Logger.Info("- Locked Resources: Fetching task data")
@@ -275,6 +277,7 @@ func (agg *Aggregator) handleBlsAggServiceResponse(blsAggServiceResp blsagg.BlsA
275277
agg.logger.Info("Aggregator successfully responded to task",
276278
"taskIndex", blsAggServiceResp.TaskIndex,
277279
"batchIdentifierHash", "0x"+hex.EncodeToString(batchIdentifierHash[:]))
280+
278281
return
279282
}
280283

@@ -361,12 +364,17 @@ func (agg *Aggregator) AddNewTask(batchMerkleRoot [32]byte, senderAddress [20]by
361364
BatchMerkleRoot: batchMerkleRoot,
362365
SenderAddress: senderAddress,
363366
}
367+
agg.logger.Info(
368+
"Task Info added in aggregator:",
369+
"Task", batchIndex,
370+
"batchIdentifierHash", batchIdentifierHash,
371+
)
364372
agg.nextBatchIndex += 1
365373

366374
quorumNums := eigentypes.QuorumNums{eigentypes.QuorumNum(QUORUM_NUMBER)}
367375
quorumThresholdPercentages := eigentypes.QuorumThresholdPercentages{eigentypes.QuorumThresholdPercentage(QUORUM_THRESHOLD)}
368376

369-
err := agg.blsAggregationService.InitializeNewTask(batchIndex, taskCreatedBlock, quorumNums, quorumThresholdPercentages, 100*time.Second)
377+
err := agg.blsAggregationService.InitializeNewTask(batchIndex, taskCreatedBlock, quorumNums, quorumThresholdPercentages, BLS_AGG_SERVICE_TIMEOUT)
370378
// FIXME(marian): When this errors, should we retry initializing new task? Logging fatal for now.
371379
if err != nil {
372380
agg.logger.Fatalf("BLS aggregation service error when initializing new task: %s", err)
@@ -377,3 +385,51 @@ func (agg *Aggregator) AddNewTask(batchMerkleRoot [32]byte, senderAddress [20]by
377385
agg.AggregatorConfig.BaseConfig.Logger.Info("- Unlocked Resources: Adding new task")
378386
agg.logger.Info("New task added", "batchIndex", batchIndex, "batchIdentifierHash", "0x"+hex.EncodeToString(batchIdentifierHash[:]))
379387
}
388+
389+
// Long-lived goroutine that periodically checks and removes old Tasks from stored Maps
390+
// It runs every GarbageCollectorPeriod and removes all tasks older than GarbageCollectorTasksAge
391+
// This was added because each task occupies memory in the maps, and we need to free it to avoid a memory leak
392+
func (agg *Aggregator) ClearTasksFromMaps() {
393+
defer func() {
394+
err := recover() //stops panics
395+
if err != nil {
396+
agg.logger.Error("Recovered from panic", "err", err)
397+
}
398+
}()
399+
400+
agg.AggregatorConfig.BaseConfig.Logger.Info(fmt.Sprintf("- Removing finalized Task Infos from Maps every %v", agg.AggregatorConfig.Aggregator.GarbageCollectorPeriod))
401+
lastIdxDeleted := uint32(0)
402+
403+
for {
404+
time.Sleep(agg.AggregatorConfig.Aggregator.GarbageCollectorPeriod)
405+
406+
agg.AggregatorConfig.BaseConfig.Logger.Info("Cleaning finalized tasks from maps")
407+
oldTaskIdHash, err := agg.avsReader.GetOldTaskHash(agg.AggregatorConfig.Aggregator.GarbageCollectorTasksAge, agg.AggregatorConfig.Aggregator.GarbageCollectorTasksInterval)
408+
if err != nil {
409+
agg.logger.Error("Error getting old task hash, skipping this garbage collect", "err", err)
410+
continue // Retry in the next iteration
411+
}
412+
if oldTaskIdHash == nil {
413+
agg.logger.Warn("No old tasks found")
414+
continue // Retry in the next iteration
415+
}
416+
417+
taskIdxToDelete := agg.batchesIdxByIdentifierHash[*oldTaskIdHash]
418+
agg.logger.Info("Old task found", "taskIndex", taskIdxToDelete)
419+
// delete from lastIdxDeleted to taskIdxToDelete
420+
for i := lastIdxDeleted + 1; i <= taskIdxToDelete; i++ {
421+
batchIdentifierHash, exists := agg.batchesIdentifierHashByIdx[i]
422+
if exists {
423+
agg.logger.Info("Cleaning up finalized task", "taskIndex", i)
424+
delete(agg.batchesIdxByIdentifierHash, batchIdentifierHash)
425+
delete(agg.batchCreatedBlockByIdx, i)
426+
delete(agg.batchesIdentifierHashByIdx, i)
427+
delete(agg.batchDataByIdentifierHash, batchIdentifierHash)
428+
} else {
429+
agg.logger.Warn("Task not found in maps", "taskIndex", i)
430+
}
431+
}
432+
lastIdxDeleted = taskIdxToDelete
433+
agg.AggregatorConfig.BaseConfig.Logger.Info("Done cleaning finalized tasks from maps")
434+
}
435+
}

0 commit comments

Comments
 (0)