Skip to content

Commit e7c447a

Browse files
authored
v0.13.0 (#1560)
2 parents 96458a3 + 306f72d commit e7c447a

File tree

136 files changed

+6358
-2263
lines changed

Some content is hidden

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

136 files changed

+6358
-2263
lines changed

Makefile

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CONFIG_FILE?=config-files/config.yaml
77
export OPERATOR_ADDRESS ?= $(shell yq -r '.operator.address' $(CONFIG_FILE))
88
AGG_CONFIG_FILE?=config-files/config-aggregator.yaml
99

10-
OPERATOR_VERSION=v0.12.2
10+
OPERATOR_VERSION=v0.13.0
1111

1212
ifeq ($(OS),Linux)
1313
BUILD_ALL_FFI = $(MAKE) build_all_ffi_linux
@@ -557,7 +557,13 @@ generate_groth16_ineq_proof: ## Run the gnark_plonk_bn254_script
557557
@go run scripts/test_files/gnark_groth16_bn254_infinite_script/cmd/main.go 1
558558

559559
__METRICS__:
560-
# Prometheus and graphana
560+
# Prometheus and Grafana
561+
metrics_remove_containers:
562+
@docker stop prometheus grafana
563+
@docker rm prometheus grafana
564+
metrics_clean_db: metrics_remove_containers
565+
@docker volume rm aligned_layer_grafana_data aligned_layer_prometheus_data
566+
561567
run_metrics: ## Run metrics using metrics-docker-compose.yaml
562568
@echo "Running metrics..."
563569
@docker compose -f metrics-docker-compose.yaml up
@@ -604,6 +610,16 @@ upgrade_add_aggregator: ## Add Aggregator to Aligned Contracts
604610
@echo "Adding Aggregator to Aligned Contracts..."
605611
@. contracts/scripts/.env && . contracts/scripts/upgrade_add_aggregator_to_service_manager.sh
606612

613+
set_aggregator_address:
614+
@echo "Setting Aggregator Address in Aligned Service Manager Contract on $(NETWORK) network..."
615+
@echo "Aggregator address: $(AGGREGATOR_ADDRESS)"
616+
@. contracts/scripts/.env.$(NETWORK) && . contracts/scripts/set_aggregator_address.sh $(AGGREGATOR_ADDRESS)
617+
618+
set_aggregator_address_devnet:
619+
@echo "Setting Aggregator Address in Aligned Service Manager Contract..."
620+
@echo "Aggregator address: $(AGGREGATOR_ADDRESS)"
621+
RPC_URL="http://localhost:8545" PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" OUTPUT_PATH=./script/output/devnet/alignedlayer_deployment_output.json ./contracts/scripts/set_aggregator_address.sh $(AGGREGATOR_ADDRESS)
622+
607623
upgrade_initialize_disabled_verifiers:
608624
@echo "Adding disabled verifiers to Aligned Service Manager..."
609625
@. contracts/scripts/.env && . contracts/scripts/upgrade_disabled_verifiers_in_service_manager.sh
@@ -906,7 +922,7 @@ docker_down:
906922
@echo "Everything down"
907923
docker ps
908924

909-
DOCKER_BURST_SIZE=2
925+
DOCKER_BURST_SIZE=1
910926
DOCKER_PROOFS_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
911927

912928
docker_batcher_send_sp1_burst:
@@ -918,7 +934,8 @@ docker_batcher_send_sp1_burst:
918934
--vm_program ./scripts/test_files/sp1/sp1_fibonacci.elf \
919935
--repetitions $(DOCKER_BURST_SIZE) \
920936
--proof_generator_addr $(PROOF_GENERATOR_ADDRESS) \
921-
--rpc_url $(DOCKER_RPC_URL)
937+
--rpc_url $(DOCKER_RPC_URL) \
938+
--max_fee 0.1ether
922939

923940
docker_batcher_send_risc0_burst:
924941
@echo "Sending Risc0 fibonacci task to Batcher..."
@@ -930,7 +947,8 @@ docker_batcher_send_risc0_burst:
930947
--public_input ./scripts/test_files/risc_zero/fibonacci_proof_generator/risc_zero_fibonacci.pub \
931948
--repetitions $(DOCKER_BURST_SIZE) \
932949
--proof_generator_addr $(PROOF_GENERATOR_ADDRESS) \
933-
--rpc_url $(DOCKER_RPC_URL)
950+
--rpc_url $(DOCKER_RPC_URL) \
951+
--max_fee 0.1ether
934952

935953
docker_batcher_send_plonk_bn254_burst:
936954
@echo "Sending Groth16Bn254 1!=0 task to Batcher..."
@@ -942,7 +960,8 @@ docker_batcher_send_plonk_bn254_burst:
942960
--vk ./scripts/test_files/gnark_plonk_bn254_script/plonk.vk \
943961
--proof_generator_addr $(PROOF_GENERATOR_ADDRESS) \
944962
--rpc_url $(DOCKER_RPC_URL) \
945-
--repetitions $(DOCKER_BURST_SIZE)
963+
--repetitions $(DOCKER_BURST_SIZE) \
964+
--max_fee 0.1ether
946965

947966
docker_batcher_send_plonk_bls12_381_burst:
948967
@echo "Sending Groth16 BLS12-381 1!=0 task to Batcher..."
@@ -954,19 +973,21 @@ docker_batcher_send_plonk_bls12_381_burst:
954973
--vk ./scripts/test_files/gnark_plonk_bls12_381_script/plonk.vk \
955974
--proof_generator_addr $(PROOF_GENERATOR_ADDRESS) \
956975
--repetitions $(DOCKER_BURST_SIZE) \
957-
--rpc_url $(DOCKER_RPC_URL)
976+
--rpc_url $(DOCKER_RPC_URL) \
977+
--max_fee 0.1ether
958978

959979
docker_batcher_send_groth16_burst:
960980
@echo "Sending Groth16 BLS12-381 1!=0 task to Batcher..."
961981
docker exec $(shell docker ps | grep batcher | awk '{print $$1}') aligned submit \
962-
--private_key $(DOCKER_PROOFS_PRIVATE_KEY) \
963-
--proving_system Groth16Bn254 \
964-
--proof ./scripts/test_files/gnark_groth16_bn254_script/groth16.proof \
965-
--public_input ./scripts/test_files/gnark_groth16_bn254_script/plonk_pub_input.pub \
966-
--vk ./scripts/test_files/gnark_groth16_bn254_script/groth16.vk \
967-
--proof_generator_addr $(PROOF_GENERATOR_ADDRESS) \
968-
--repetitions $(DOCKER_BURST_SIZE) \
969-
--rpc_url $(DOCKER_RPC_URL)
982+
--private_key $(DOCKER_PROOFS_PRIVATE_KEY) \
983+
--proving_system Groth16Bn254 \
984+
--proof ./scripts/test_files/gnark_groth16_bn254_script/groth16.proof \
985+
--public_input ./scripts/test_files/gnark_groth16_bn254_script/plonk_pub_input.pub \
986+
--vk ./scripts/test_files/gnark_groth16_bn254_script/groth16.vk \
987+
--proof_generator_addr $(PROOF_GENERATOR_ADDRESS) \
988+
--repetitions $(DOCKER_BURST_SIZE) \
989+
--rpc_url $(DOCKER_RPC_URL) \
990+
--max_fee 0.1ether
970991

971992
# Update target as new proofs are supported.
972993
docker_batcher_send_all_proofs_burst:
@@ -993,6 +1014,7 @@ docker_batcher_send_infinite_groth16:
9931014
--public_input scripts/test_files/gnark_groth16_bn254_infinite_script/infinite_proofs/ineq_$${counter}_groth16.pub \
9941015
--vk scripts/test_files/gnark_groth16_bn254_infinite_script/infinite_proofs/ineq_$${counter}_groth16.vk \
9951016
--proof_generator_addr $(PROOF_GENERATOR_ADDRESS); \
1017+
--max_fee 0.1ether
9961018
sleep $${timer}; \
9971019
counter=$$((counter + 1)); \
9981020
done \
@@ -1010,7 +1032,7 @@ docker_verify_proofs_onchain:
10101032
done \
10111033
'
10121034

1013-
DOCKER_PROOFS_WAIT_TIME=30
1035+
DOCKER_PROOFS_WAIT_TIME=60
10141036

10151037
docker_verify_proof_submission_success:
10161038
@echo "Verifying proofs were successfully submitted..."
@@ -1032,7 +1054,7 @@ docker_verify_proof_submission_success:
10321054
fi; \
10331055
echo "---------------------------------------------------------------------------------------------------"; \
10341056
done; \
1035-
if [ $$(ls -1 ./aligned_verification_data/*.cbor | wc -l) -ne 10 ]; then \
1057+
if [ $$(ls -1 ./aligned_verification_data/*.cbor | wc -l) -ne 5 ]; then \
10361058
echo "ERROR: Some proofs were verified successfully, but some proofs are missing in the aligned_verification_data/ directory"; \
10371059
exit 1; \
10381060
fi; \

aggregator/pkg/aggregator.go

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ type Aggregator struct {
6767
// Stores the TaskResponse for each batch by batchIdentifierHash
6868
batchDataByIdentifierHash map[[32]byte]BatchData
6969

70+
// Stores the start time for each batch of the aggregator by task index
71+
batchStartTimeByIdx map[uint32]time.Time
72+
7073
// This task index is to communicate with the local BLS
7174
// Service.
7275
// Note: In case of a reboot it can start from 0 again
@@ -78,6 +81,7 @@ type Aggregator struct {
7881
// - batchCreatedBlockByIdx
7982
// - batchDataByIdentifierHash
8083
// - nextBatchIndex
84+
// - batchStartTimeByIdx
8185
taskMutex *sync.Mutex
8286

8387
// Mutex to protect ethereum wallet
@@ -124,6 +128,7 @@ func NewAggregator(aggregatorConfig config.AggregatorConfig) (*Aggregator, error
124128
batchesIdxByIdentifierHash := make(map[[32]byte]uint32)
125129
batchDataByIdentifierHash := make(map[[32]byte]BatchData)
126130
batchCreatedBlockByIdx := make(map[uint32]uint64)
131+
batchStartTimeByIdx := make(map[uint32]time.Time)
127132

128133
chainioConfig := sdkclients.BuildAllConfig{
129134
EthHttpUrl: aggregatorConfig.BaseConfig.EthRpcUrl,
@@ -172,6 +177,7 @@ func NewAggregator(aggregatorConfig config.AggregatorConfig) (*Aggregator, error
172177
batchesIdxByIdentifierHash: batchesIdxByIdentifierHash,
173178
batchDataByIdentifierHash: batchDataByIdentifierHash,
174179
batchCreatedBlockByIdx: batchCreatedBlockByIdx,
180+
batchStartTimeByIdx: batchStartTimeByIdx,
175181
nextBatchIndex: nextBatchIndex,
176182
taskMutex: &sync.Mutex{},
177183
walletMutex: &sync.Mutex{},
@@ -233,6 +239,7 @@ func (agg *Aggregator) handleBlsAggServiceResponse(blsAggServiceResp blsagg.BlsA
233239
batchIdentifierHash := agg.batchesIdentifierHashByIdx[blsAggServiceResp.TaskIndex]
234240
batchData := agg.batchDataByIdentifierHash[batchIdentifierHash]
235241
taskCreatedBlock := agg.batchCreatedBlockByIdx[blsAggServiceResp.TaskIndex]
242+
taskCreatedAt := agg.batchStartTimeByIdx[blsAggServiceResp.TaskIndex]
236243
agg.taskMutex.Unlock()
237244
agg.AggregatorConfig.BaseConfig.Logger.Info("- Unlocked Resources: Fetching task data")
238245

@@ -266,6 +273,9 @@ func (agg *Aggregator) handleBlsAggServiceResponse(blsAggServiceResp blsagg.BlsA
266273

267274
agg.telemetry.LogQuorumReached(batchData.BatchMerkleRoot)
268275

276+
// Only observe quorum reached if successful
277+
agg.metrics.ObserveTaskQuorumReached(time.Since(taskCreatedAt))
278+
269279
agg.logger.Info("Threshold reached", "taskIndex", blsAggServiceResp.TaskIndex,
270280
"batchIdentifierHash", "0x"+hex.EncodeToString(batchIdentifierHash[:]))
271281

@@ -285,10 +295,12 @@ func (agg *Aggregator) handleBlsAggServiceResponse(blsAggServiceResp blsagg.BlsA
285295
if err == nil {
286296
// In some cases, we may fail to retrieve the receipt for the transaction.
287297
txHash := "Unknown"
298+
effectiveGasPrice := "Unknown"
288299
if receipt != nil {
289300
txHash = receipt.TxHash.String()
301+
effectiveGasPrice = receipt.EffectiveGasPrice.String()
290302
}
291-
agg.telemetry.TaskSentToEthereum(batchData.BatchMerkleRoot, txHash)
303+
agg.telemetry.TaskSentToEthereum(batchData.BatchMerkleRoot, txHash, effectiveGasPrice)
292304
agg.logger.Info("Aggregator successfully responded to task",
293305
"taskIndex", blsAggServiceResp.TaskIndex,
294306
"batchIdentifierHash", "0x"+hex.EncodeToString(batchIdentifierHash[:]))
@@ -316,10 +328,11 @@ func (agg *Aggregator) sendAggregatedResponse(batchIdentifierHash [32]byte, batc
316328
"batchIdentifierHash", hex.EncodeToString(batchIdentifierHash[:]))
317329

318330
// This function is a callback that is called when the gas price is bumped on the avsWriter.SendAggregatedResponse
319-
onGasPriceBumped := func(bumpedGasPrice *big.Int) {
320-
agg.metrics.IncBumpedGasPriceForAggregatedResponse()
321-
agg.telemetry.BumpedTaskGasPrice(batchMerkleRoot, bumpedGasPrice.String())
331+
onSetGasPrice := func(gasPrice *big.Int) {
332+
agg.telemetry.TaskSetGasPrice(batchMerkleRoot, gasPrice.String())
322333
}
334+
335+
startTime := time.Now()
323336
receipt, err := agg.avsWriter.SendAggregatedResponse(
324337
batchIdentifierHash,
325338
batchMerkleRoot,
@@ -329,15 +342,18 @@ func (agg *Aggregator) sendAggregatedResponse(batchIdentifierHash [32]byte, batc
329342
agg.AggregatorConfig.Aggregator.GasBumpIncrementalPercentage,
330343
agg.AggregatorConfig.Aggregator.GasBumpPercentageLimit,
331344
agg.AggregatorConfig.Aggregator.TimeToWaitBeforeBump,
332-
onGasPriceBumped,
345+
agg.metrics,
346+
onSetGasPrice,
333347
)
334348
if err != nil {
335349
agg.walletMutex.Unlock()
336350
agg.logger.Infof("- Unlocked Wallet Resources: Error sending aggregated response for batch %s. Error: %s", hex.EncodeToString(batchIdentifierHash[:]), err)
337-
agg.telemetry.LogTaskError(batchMerkleRoot, err)
338351
return nil, err
339352
}
340353

354+
// We only send the latency metric if the response is successul
355+
agg.metrics.ObserveLatencyForRespondToTask(time.Since(startTime))
356+
341357
agg.walletMutex.Unlock()
342358
agg.logger.Infof("- Unlocked Wallet Resources: Sending aggregated response for batch %s", hex.EncodeToString(batchIdentifierHash[:]))
343359

@@ -383,6 +399,7 @@ func (agg *Aggregator) AddNewTask(batchMerkleRoot [32]byte, senderAddress [20]by
383399
BatchMerkleRoot: batchMerkleRoot,
384400
SenderAddress: senderAddress,
385401
}
402+
agg.batchStartTimeByIdx[batchIndex] = time.Now()
386403
agg.logger.Info(
387404
"Task Info added in aggregator:",
388405
"Task", batchIndex,
@@ -447,6 +464,7 @@ func (agg *Aggregator) ClearTasksFromMaps() {
447464
delete(agg.batchCreatedBlockByIdx, i)
448465
delete(agg.batchesIdentifierHashByIdx, i)
449466
delete(agg.batchDataByIdentifierHash, batchIdentifierHash)
467+
delete(agg.batchStartTimeByIdx, i)
450468
} else {
451469
agg.logger.Warn("Task not found in maps", "taskIndex", i)
452470
}

aggregator/pkg/telemetry.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ type TaskErrorMessage struct {
3030
TaskError string `json:"error"`
3131
}
3232

33-
type TaskGasPriceBumpMessage struct {
34-
MerkleRoot string `json:"merkle_root"`
35-
BumpedGasPrice string `json:"bumped_gas_price"`
33+
type TaskSetGasPriceMessage struct {
34+
MerkleRoot string `json:"merkle_root"`
35+
GasPrice string `json:"gas_price"`
3636
}
3737

3838
type TaskSentToEthereumMessage struct {
39-
MerkleRoot string `json:"merkle_root"`
40-
TxHash string `json:"tx_hash"`
39+
MerkleRoot string `json:"merkle_root"`
40+
TxHash string `json:"tx_hash"`
41+
EffectiveGasPrice string `json:"effective_gas_price"`
4142
}
4243

4344
type Telemetry struct {
@@ -101,20 +102,21 @@ func (t *Telemetry) LogTaskError(batchMerkleRoot [32]byte, taskError error) {
101102
}
102103
}
103104

104-
func (t *Telemetry) BumpedTaskGasPrice(batchMerkleRoot [32]byte, bumpedGasPrice string) {
105-
body := TaskGasPriceBumpMessage{
106-
MerkleRoot: fmt.Sprintf("0x%s", hex.EncodeToString(batchMerkleRoot[:])),
107-
BumpedGasPrice: bumpedGasPrice,
105+
func (t *Telemetry) TaskSetGasPrice(batchMerkleRoot [32]byte, gasPrice string) {
106+
body := TaskSetGasPriceMessage{
107+
MerkleRoot: fmt.Sprintf("0x%s", hex.EncodeToString(batchMerkleRoot[:])),
108+
GasPrice: gasPrice,
108109
}
109-
if err := t.sendTelemetryMessage("/api/aggregatorTaskGasPriceBump", body); err != nil {
110+
if err := t.sendTelemetryMessage("/api/aggregatorTaskSetGasPrice", body); err != nil {
110111
t.logger.Warn("[Telemetry] Error in LogOperatorResponse", "error", err)
111112
}
112113
}
113114

114-
func (t *Telemetry) TaskSentToEthereum(batchMerkleRoot [32]byte, txHash string) {
115+
func (t *Telemetry) TaskSentToEthereum(batchMerkleRoot [32]byte, txHash string, effectiveGasPrice string) {
115116
body := TaskSentToEthereumMessage{
116-
MerkleRoot: fmt.Sprintf("0x%s", hex.EncodeToString(batchMerkleRoot[:])),
117-
TxHash: txHash,
117+
MerkleRoot: fmt.Sprintf("0x%s", hex.EncodeToString(batchMerkleRoot[:])),
118+
TxHash: txHash,
119+
EffectiveGasPrice: effectiveGasPrice,
118120
}
119121
if err := t.sendTelemetryMessage("/api/aggregatorTaskSent", body); err != nil {
120122
t.logger.Warn("[Telemetry] Error in TaskSentToEthereum", "error", err)

0 commit comments

Comments
 (0)