Skip to content

Commit ae04e49

Browse files
committed
Merge branch 'staging' into 1415-getBatchFromDataService
2 parents 98c7202 + 698de75 commit ae04e49

43 files changed

Lines changed: 4157 additions & 382 deletions

Some content is hidden

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

Makefile

Lines changed: 101 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ anvil_start_with_block_time:
132132
@echo "Starting Anvil..."
133133
anvil --load-state contracts/scripts/anvil/state/alignedlayer-deployed-anvil-state.json --block-time 7
134134

135+
anvil_start_with_block_time_with_more_prefunded_accounts:
136+
@echo "Starting Anvil..."
137+
anvil --load-state contracts/scripts/anvil/state/alignedlayer-deployed-anvil-state.json --block-time 7 -a 2000
138+
135139
_AGGREGATOR_:
136140

137141
aggregator_start:
@@ -284,7 +288,7 @@ verifier_disable:
284288

285289
__BATCHER__:
286290

287-
BURST_SIZE=5
291+
BURST_SIZE ?= 5
288292

289293
user_fund_payment_service:
290294
@. ./scripts/user_fund_payment_service_devnet.sh
@@ -301,6 +305,11 @@ batcher_start_local: user_fund_payment_service
301305
@$(MAKE) run_storage &
302306
@cargo run --manifest-path ./batcher/aligned-batcher/Cargo.toml --release -- --config ./config-files/config-batcher.yaml --env-file ./batcher/aligned-batcher/.env.dev
303307

308+
batcher_start_local_no_fund:
309+
@echo "Starting Batcher..."
310+
@$(MAKE) run_storage &
311+
@cargo run --manifest-path ./batcher/aligned-batcher/Cargo.toml --release -- --config ./config-files/config-batcher.yaml --env-file ./batcher/aligned-batcher/.env.dev
312+
304313
install_batcher:
305314
@cargo install --path batcher/aligned-batcher
306315

@@ -401,7 +410,7 @@ batcher_send_plonk_bn254_burst: batcher/target/release/aligned
401410
--vk ../../scripts/test_files/gnark_plonk_bn254_script/plonk.vk \
402411
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
403412
--rpc_url $(RPC_URL) \
404-
--repetitions 4 \
413+
--repetitions $(BURST_SIZE) \
405414
--network $(NETWORK)
406415

407416
batcher_send_plonk_bls12_381_task: batcher/target/release/aligned
@@ -448,6 +457,82 @@ batcher_send_burst_groth16: batcher/target/release/aligned
448457
@mkdir -p scripts/test_files/gnark_groth16_bn254_infinite_script/infinite_proofs
449458
@./batcher/aligned/send_burst_tasks.sh $(BURST_SIZE) $(START_COUNTER)
450459

460+
461+
__TASK_SENDER__:
462+
BURST_TIME_SECS ?= 3
463+
464+
task_sender_generate_groth16_proofs:
465+
@cd batcher/aligned-task-sender && \
466+
cargo run --release -- generate-proofs \
467+
--number-of-proofs $(NUMBER_OF_PROOFS) --proof-type groth16 \
468+
--dir-to-save-proofs $(CURDIR)/scripts/test_files/task_sender/proofs
469+
470+
# ===== DEVNET =====
471+
task_sender_fund_wallets_devnet:
472+
@cd batcher/aligned-task-sender && \
473+
cargo run --release -- generate-and-fund-wallets \
474+
--eth-rpc-url http://localhost:8545 \
475+
--network devnet \
476+
--amount-to-deposit 1 \
477+
--amount-to-deposit-to-aligned 0.9999 \
478+
--private-keys-filepath $(CURDIR)/batcher/aligned-task-sender/wallets/devnet
479+
480+
task_sender_send_infinite_proofs_devnet:
481+
@cd batcher/aligned-task-sender && \
482+
cargo run --release -- send-infinite-proofs \
483+
--burst-size $(BURST_SIZE) --burst-time-secs $(BURST_TIME_SECS) \
484+
--eth-rpc-url http://localhost:8545 \
485+
--batcher-url ws://localhost:8080 \
486+
--network devnet \
487+
--proofs-dirpath $(CURDIR)/scripts/test_files/task_sender/proofs \
488+
--private-keys-filepath $(CURDIR)/batcher/aligned-task-sender/wallets/devnet
489+
490+
task_sender_test_connections_devnet:
491+
@cd batcher/aligned-task-sender && \
492+
cargo run --release -- test-connections \
493+
--batcher-url ws://localhost:8080 \
494+
--num-senders $(NUM_SENDERS)
495+
496+
# ===== HOLESKY-STAGE =====
497+
task_sender_generate_and_fund_wallets_holesky_stage:
498+
@cd batcher/aligned-task-sender && \
499+
cargo run --release -- generate-and-fund-wallets \
500+
--eth-rpc-url https://ethereum-holesky-rpc.publicnode.com \
501+
--network holesky-stage \
502+
--funding-wallet-private-key $(FUNDING_WALLET_PRIVATE_KEY) \
503+
--number-wallets $(NUM_WALLETS) \
504+
--amount-to-deposit $(AMOUNT_TO_DEPOSIT) \
505+
--amount-to-deposit-to-aligned $(AMOUNT_TO_DEPOSIT_TO_ALIGNED) \
506+
--private-keys-filepath $(CURDIR)/batcher/aligned-task-sender/wallets/holesky-stage
507+
508+
task_sender_send_infinite_proofs_holesky_stage:
509+
@cd batcher/aligned-task-sender && \
510+
cargo run --release -- send-infinite-proofs \
511+
--burst-size $(BURST_SIZE) --burst-time-secs $(BURST_TIME_SECS) \
512+
--eth-rpc-url https://ethereum-holesky-rpc.publicnode.com \
513+
--batcher-url wss://stage.batcher.alignedlayer.com \
514+
--network holesky-stage \
515+
--proofs-dirpath $(CURDIR)/scripts/test_files/task_sender/proofs \
516+
--private-keys-filepath $(CURDIR)/batcher/aligned-task-sender/wallets/holesky-stage
517+
518+
task_sender_test_connections_holesky_stage:
519+
@cd batcher/aligned-task-sender && \
520+
cargo run --release -- test-connections \
521+
--batcher-url wss://stage.batcher.alignedlayer.com \
522+
--num-senders $(NUM_SENDERS)
523+
524+
__UTILS__:
525+
aligned_get_user_balance_devnet:
526+
@cd batcher/aligned/ && cargo run --release -- get-user-balance \
527+
--user_addr $(USER_ADDR)
528+
529+
aligned_get_user_balance_holesky:
530+
@cd batcher/aligned/ && cargo run --release -- get-user-balance \
531+
--rpc_url https://ethereum-holesky-rpc.publicnode.com \
532+
--network holesky \
533+
--user_addr $(USER_ADDR)
534+
535+
451536
__GENERATE_PROOFS__:
452537
# TODO add a default proving system
453538

@@ -1092,6 +1177,20 @@ ansible_batcher_deploy: ## Deploy the Batcher. Parameters: INVENTORY, KEYSTORE
10921177
-i $(INVENTORY) \
10931178
-e "keystore_path=$(KEYSTORE)"
10941179

1180+
ansible_aggregator_create_env: ## Create empty variables files for the Aggregator deploy
1181+
@cp -n infra/ansible/playbooks/ini/config-aggregator.ini.example infra/ansible/playbooks/ini/config-aggregator.ini
1182+
@echo "Config files for the Aggregator created in infra/ansible/playbooks/ini"
1183+
@echo "Please complete the values and run make ansible_aggregator_deploy"
1184+
1185+
ansible_aggregator_deploy: ## Deploy the Operator. Parameters: INVENTORY
1186+
@if [ -z "$(INVENTORY)" ] || [ -z "$(ECDSA_KEYSTORE)" ] || [ -z "$(BLS_KEYSTORE)" ]; then \
1187+
echo "Error: INVENTORY, ECDSA_KEYSTORE, BLS_KEYSTORE must be set."; \
1188+
exit 1; \
1189+
fi
1190+
@ansible-playbook infra/ansible/playbooks/aggregator.yaml \
1191+
-i $(INVENTORY) \
1192+
-e "ecdsa_keystore_path=$(ECDSA_KEYSTORE)" \
1193+
-e "bls_keystore_path=$(BLS_KEYSTORE)"
10951194

10961195
ansible_operator_create_env: ## Create empty variables files for the Operator deploy
10971196
@cp -n infra/ansible/playbooks/ini/config-operator.ini.example infra/ansible/playbooks/ini/config-operator.ini

aggregator/pkg/aggregator.go

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ type Aggregator struct {
7474
// Note: In case of a reboot it can start from 0 again
7575
nextBatchIndex uint32
7676

77-
// Mutex to protect batchesIdentifierHashByIdx, batchesIdxByIdentifierHash and nextBatchIndex
77+
// Mutex to protect:
78+
// - batchesIdentifierHashByIdx
79+
// - batchesIdxByIdentifierHash
80+
// - batchCreatedBlockByIdx
81+
// - batchDataByIdentifierHash
82+
// - nextBatchIndex
7883
taskMutex *sync.Mutex
7984

8085
// Mutex to protect ethereum wallet
@@ -93,6 +98,15 @@ type Aggregator struct {
9398
func NewAggregator(aggregatorConfig config.AggregatorConfig) (*Aggregator, error) {
9499
newBatchChan := make(chan *servicemanager.ContractAlignedLayerServiceManagerNewBatchV3)
95100

101+
logger := aggregatorConfig.BaseConfig.Logger
102+
103+
// Metrics
104+
reg := prometheus.NewRegistry()
105+
aggregatorMetrics := metrics.NewMetrics(aggregatorConfig.Aggregator.MetricsIpPortAddress, reg, logger)
106+
107+
// Telemetry
108+
aggregatorTelemetry := NewTelemetry(aggregatorConfig.Aggregator.TelemetryIpPortAddress, logger)
109+
96110
avsReader, err := chainio.NewAvsReaderFromConfig(aggregatorConfig.BaseConfig, aggregatorConfig.EcdsaConfig)
97111
if err != nil {
98112
return nil, err
@@ -103,7 +117,7 @@ func NewAggregator(aggregatorConfig config.AggregatorConfig) (*Aggregator, error
103117
return nil, err
104118
}
105119

106-
avsWriter, err := chainio.NewAvsWriterFromConfig(aggregatorConfig.BaseConfig, aggregatorConfig.EcdsaConfig)
120+
avsWriter, err := chainio.NewAvsWriterFromConfig(aggregatorConfig.BaseConfig, aggregatorConfig.EcdsaConfig, aggregatorMetrics)
107121
if err != nil {
108122
return nil, err
109123
}
@@ -124,7 +138,6 @@ func NewAggregator(aggregatorConfig config.AggregatorConfig) (*Aggregator, error
124138

125139
aggregatorPrivateKey := aggregatorConfig.EcdsaConfig.PrivateKey
126140

127-
logger := aggregatorConfig.BaseConfig.Logger
128141
clients, err := sdkclients.BuildAll(chainioConfig, aggregatorPrivateKey, logger)
129142
if err != nil {
130143
logger.Errorf("Cannot create sdk clients", "err", err)
@@ -150,13 +163,6 @@ func NewAggregator(aggregatorConfig config.AggregatorConfig) (*Aggregator, error
150163
avsRegistryService := avsregistry.NewAvsRegistryServiceChainCaller(avsReader.ChainReader, operatorPubkeysService, logger)
151164
blsAggregationService := blsagg.NewBlsAggregatorService(avsRegistryService, hashFunction, logger)
152165

153-
// Metrics
154-
reg := prometheus.NewRegistry()
155-
aggregatorMetrics := metrics.NewMetrics(aggregatorConfig.Aggregator.MetricsIpPortAddress, reg, logger)
156-
157-
// Telemetry
158-
aggregatorTelemetry := NewTelemetry(aggregatorConfig.Aggregator.TelemetryIpPortAddress, logger)
159-
160166
nextBatchIndex := uint32(0)
161167

162168
aggregator := Aggregator{
@@ -443,6 +449,8 @@ func (agg *Aggregator) ClearTasksFromMaps() {
443449
agg.logger.Warn("No old tasks found")
444450
continue // Retry in the next iteration
445451
}
452+
agg.taskMutex.Lock()
453+
agg.AggregatorConfig.BaseConfig.Logger.Info("- Locked Resources: Cleaning finalized tasks")
446454

447455
taskIdxToDelete := agg.batchesIdxByIdentifierHash[*oldTaskIdHash]
448456
agg.logger.Info("Old task found", "taskIndex", taskIdxToDelete)
@@ -460,6 +468,8 @@ func (agg *Aggregator) ClearTasksFromMaps() {
460468
}
461469
}
462470
lastIdxDeleted = taskIdxToDelete
471+
agg.taskMutex.Unlock()
472+
agg.AggregatorConfig.BaseConfig.Logger.Info("- Unlocked Resources: Cleaning finalized tasks")
463473
agg.AggregatorConfig.BaseConfig.Logger.Info("Done cleaning finalized tasks from maps")
464474
}
465475
}

0 commit comments

Comments
 (0)