Skip to content

Commit 042d8d8

Browse files
authored
v0.8.0 (#1123)
2 parents cf84ee8 + 601a50d commit 042d8d8

File tree

85 files changed

+4503
-3668
lines changed

Some content is hidden

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

85 files changed

+4503
-3668
lines changed
Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: build-rust-projects
1+
name: build-and-test-rust-projects
22

33
on:
44
merge_group:
@@ -7,13 +7,13 @@ on:
77
pull_request:
88
branches: ["*"]
99
paths:
10-
- 'batcher/**'
11-
- '.github/workflows/build-rust.yml'
10+
- "batcher/**"
11+
- ".github/workflows/build-rust.yml"
1212

1313
jobs:
1414
build:
1515
runs-on: aligned-runner
16-
16+
1717
steps:
1818
- uses: actions/checkout@v4
1919

@@ -45,3 +45,24 @@ jobs:
4545
run: |
4646
cd batcher
4747
cargo build --all
48+
49+
test:
50+
runs-on: ubuntu-latest
51+
needs: build
52+
steps:
53+
- name: Checkout code
54+
uses: actions/checkout@v4
55+
- name: Cache Rust dependencies
56+
uses: actions/cache@v3
57+
with:
58+
path: |
59+
~/.cargo/registry
60+
~/.cargo/git
61+
batcher/target
62+
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
63+
restore-keys: |
64+
${{ runner.os }}-rust-
65+
- name: Run tests
66+
run: |
67+
cd batcher
68+
cargo test --all

Makefile

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

8-
OPERATOR_VERSION=v0.7.3
8+
OPERATOR_VERSION=v0.8.0
99

1010
ifeq ($(OS),Linux)
1111
BUILD_ALL_FFI = $(MAKE) build_all_ffi_linux
@@ -121,6 +121,22 @@ update_operator:
121121
@make build_operator
122122
@./operator/build/aligned-operator --version
123123

124+
operator_valid_marshall_fuzz_macos:
125+
@cd operator/pkg && go test -fuzz=FuzzValidMarshall -ldflags=-extldflags=-Wl,-ld_classic
126+
127+
operator_valid_marshall_fuzz_linux:
128+
@cd operator/pkg && \
129+
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(CURDIR)/operator/risc_zero/lib \
130+
go test -fuzz=FuzzValidMarshall
131+
132+
operator_marshall_unmarshall_fuzz_macos:
133+
@cd operator/pkg && go test -fuzz=FuzzMarshalUnmarshal -ldflags=-extldflags=-Wl,-ld_classic
134+
135+
operator_marshall_unmarshall_fuzz_linux:
136+
@cd operator/pkg && \
137+
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(CURDIR)/operator/risc_zero/lib \
138+
go test -fuzz=FuzzMarshalUnmarshal
139+
124140
bindings:
125141
cd contracts && ./generate-go-bindings.sh
126142

@@ -159,6 +175,12 @@ operator_whitelist_devnet:
159175
@echo "Operator address: $(OPERATOR_ADDRESS)"
160176
RPC_URL="http://localhost:8545" PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" OUTPUT_PATH=./script/output/devnet/alignedlayer_deployment_output.json ./contracts/scripts/whitelist_operator.sh $(OPERATOR_ADDRESS)
161177

178+
operator_remove_devnet:
179+
@echo "Removing operator"
180+
$(eval OPERATOR_ADDRESS = $(shell yq -r '.operator.address' $(CONFIG_FILE)))
181+
@echo "Operator address: $(OPERATOR_ADDRESS)"
182+
RPC_URL="http://localhost:8545" PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" OUTPUT_PATH=./script/output/devnet/alignedlayer_deployment_output.json ./contracts/scripts/remove_operator.sh $(OPERATOR_ADDRESS)
183+
162184
operator_whitelist:
163185
@echo "Whitelisting operator $(OPERATOR_ADDRESS)"
164186
@. contracts/scripts/.env && . contracts/scripts/whitelist_operator.sh $(OPERATOR_ADDRESS)
@@ -226,7 +248,7 @@ batcher/target/release/aligned:
226248

227249

228250
RPC_URL=http://localhost:8545
229-
BATCHER_PAYMENTS_CONTRACT_ADDRESS=0x7969c5eD335650692Bc04293B07F5BF2e7A673C0
251+
NETWORK=devnet # devnet | holesky-stage | holesky
230252

231253
batcher_send_sp1_task:
232254
@echo "Sending SP1 fibonacci task to Batcher..."
@@ -236,7 +258,7 @@ batcher_send_sp1_task:
236258
--vm_program ../../scripts/test_files/sp1/sp1_fibonacci.elf \
237259
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
238260
--rpc_url $(RPC_URL) \
239-
--payment_service_addr $(BATCHER_PAYMENTS_CONTRACT_ADDRESS)
261+
--network $(NETWORK)
240262

241263
batcher_send_sp1_burst:
242264
@echo "Sending SP1 fibonacci task to Batcher..."
@@ -247,7 +269,7 @@ batcher_send_sp1_burst:
247269
--repetitions $(BURST_SIZE) \
248270
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
249271
--rpc_url $(RPC_URL) \
250-
--payment_service_addr $(BATCHER_PAYMENTS_CONTRACT_ADDRESS)
272+
--network $(NETWORK)
251273

252274
batcher_send_infinite_sp1:
253275
@echo "Sending infinite SP1 fibonacci task to Batcher..."
@@ -262,7 +284,7 @@ batcher_send_risc0_task:
262284
--public_input ../../scripts/test_files/risc_zero/fibonacci_proof_generator/risc_zero_fibonacci.pub \
263285
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
264286
--rpc_url $(RPC_URL) \
265-
--payment_service_addr $(BATCHER_PAYMENTS_CONTRACT_ADDRESS)
287+
--network $(NETWORK)
266288

267289
batcher_send_risc0_burst:
268290
@echo "Sending Risc0 fibonacci task to Batcher..."
@@ -274,7 +296,7 @@ batcher_send_risc0_burst:
274296
--repetitions $(BURST_SIZE) \
275297
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
276298
--rpc_url $(RPC_URL) \
277-
--payment_service_addr $(BATCHER_PAYMENTS_CONTRACT_ADDRESS)
299+
--network $(NETWORK)
278300

279301
batcher_send_plonk_bn254_task: batcher/target/release/aligned
280302
@echo "Sending Groth16Bn254 1!=0 task to Batcher..."
@@ -285,7 +307,7 @@ batcher_send_plonk_bn254_task: batcher/target/release/aligned
285307
--vk ../../scripts/test_files/gnark_plonk_bn254_script/plonk.vk \
286308
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
287309
--rpc_url $(RPC_URL) \
288-
--payment_service_addr $(BATCHER_PAYMENTS_CONTRACT_ADDRESS)
310+
--network $(NETWORK)
289311

290312
batcher_send_plonk_bn254_burst: batcher/target/release/aligned
291313
@echo "Sending Groth16Bn254 1!=0 task to Batcher..."
@@ -297,7 +319,7 @@ batcher_send_plonk_bn254_burst: batcher/target/release/aligned
297319
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
298320
--rpc_url $(RPC_URL) \
299321
--repetitions 4 \
300-
--payment_service_addr $(BATCHER_PAYMENTS_CONTRACT_ADDRESS)
322+
--network $(NETWORK)
301323

302324
batcher_send_plonk_bls12_381_task: batcher/target/release/aligned
303325
@echo "Sending Groth16 BLS12-381 1!=0 task to Batcher..."
@@ -308,7 +330,7 @@ batcher_send_plonk_bls12_381_task: batcher/target/release/aligned
308330
--vk ../../scripts/test_files/gnark_plonk_bls12_381_script/plonk.vk \
309331
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
310332
--rpc_url $(RPC_URL) \
311-
--payment_service_addr $(BATCHER_PAYMENTS_CONTRACT_ADDRESS)
333+
--network $(NETWORK)
312334

313335
batcher_send_plonk_bls12_381_burst: batcher/target/release/aligned
314336
@echo "Sending Groth16 BLS12-381 1!=0 task to Batcher..."
@@ -320,8 +342,7 @@ batcher_send_plonk_bls12_381_burst: batcher/target/release/aligned
320342
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
321343
--repetitions 15 \
322344
--rpc_url $(RPC_URL) \
323-
--payment_service_addr $(BATCHER_PAYMENTS_CONTRACT_ADDRESS)
324-
345+
--network $(NETWORK)
325346

326347
batcher_send_groth16_bn254_task: batcher/target/release/aligned
327348
@echo "Sending Groth16Bn254 1!=0 task to Batcher..."
@@ -332,7 +353,7 @@ batcher_send_groth16_bn254_task: batcher/target/release/aligned
332353
--vk ../../scripts/test_files/gnark_groth16_bn254_infinite_script/infinite_proofs/ineq_1_groth16.vk \
333354
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
334355
--rpc_url $(RPC_URL) \
335-
--payment_service_addr $(BATCHER_PAYMENTS_CONTRACT_ADDRESS)
356+
--network $(NETWORK)
336357

337358
batcher_send_infinite_groth16: batcher/target/release/aligned ## Send a different Groth16 BN254 proof using the client every 3 seconds
338359
@mkdir -p scripts/test_files/gnark_groth16_bn254_infinite_script/infinite_proofs
@@ -352,7 +373,7 @@ batcher_send_halo2_ipa_task: batcher/target/release/aligned
352373
--public_input ../../scripts/test_files/halo2_ipa/pub_input.bin \
353374
--vk ../../scripts/test_files/halo2_ipa/params.bin \
354375
--rpc_url $(RPC_URL) \
355-
--payment_service_addr $(BATCHER_PAYMENTS_CONTRACT_ADDRESS)
376+
--network $(NETWORK)
356377

357378
batcher_send_halo2_ipa_task_burst_5: batcher/target/release/aligned
358379
@echo "Sending Halo2 IPA 1!=0 task to Batcher..."
@@ -363,7 +384,7 @@ batcher_send_halo2_ipa_task_burst_5: batcher/target/release/aligned
363384
--vk ../../scripts/test_files/halo2_ipa/params.bin \
364385
--repetitions 5 \
365386
--rpc_url $(RPC_URL) \
366-
--payment_service_addr $(BATCHER_PAYMENTS_CONTRACT_ADDRESS)
387+
--network $(NETWORK)
367388

368389
batcher_send_halo2_kzg_task: batcher/target/release/aligned
369390
@echo "Sending Halo2 KZG 1!=0 task to Batcher..."
@@ -374,7 +395,7 @@ batcher_send_halo2_kzg_task: batcher/target/release/aligned
374395
--vk ../../scripts/test_files/halo2_kzg/params.bin \
375396
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
376397
--rpc_url $(RPC_URL) \
377-
--payment_service_addr $(BATCHER_PAYMENTS_CONTRACT_ADDRESS)
398+
--network $(NETWORK)
378399

379400
batcher_send_halo2_kzg_task_burst_5: batcher/target/release/aligned
380401
@echo "Sending Halo2 KZG 1!=0 task to Batcher..."
@@ -386,7 +407,7 @@ batcher_send_halo2_kzg_task_burst_5: batcher/target/release/aligned
386407
--repetitions 5 \
387408
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
388409
--rpc_url $(RPC_URL) \
389-
--payment_service_addr $(BATCHER_PAYMENTS_CONTRACT_ADDRESS)
410+
--network $(NETWORK)
390411

391412
__GENERATE_PROOFS__:
392413
# TODO add a default proving system
@@ -467,9 +488,9 @@ build_aligned_contracts:
467488

468489
show_aligned_error_codes:
469490
@echo "\nAlignedLayerServiceManager errors:"
470-
@cd contracts/src/core && forge inspect IAlignedLayerServiceManager.sol:IAlignedLayerServiceManager errors
491+
@cd contracts && forge inspect src/core/IAlignedLayerServiceManager.sol:IAlignedLayerServiceManager errors
471492
@echo "\nBatcherPaymentService errors:"
472-
@cd contracts/src/core && forge inspect BatcherPaymentService.sol:BatcherPaymentService errors
493+
@cd contracts && forge inspect src/core/BatcherPaymentService.sol:BatcherPaymentService errors
473494

474495
__BUILD__:
475496
build_binaries:

aggregator/cmd/main.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ func aggregatorMain(ctx *cli.Context) error {
5858
}()
5959

6060
err = aggregator.Start(context.Background())
61-
if err != nil {
62-
return err
63-
}
6461

65-
return nil
62+
return err
6663
}

aggregator/internal/pkg/aggregator.go

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

70-
// Stores if an operator already submitted a response for a batch
71-
// This is to avoid double submissions
72-
// struct{} is used as a placeholder because it is the smallest type
73-
// go does not have a set type
74-
operatorRespondedBatch map[uint32]map[eigentypes.Bytes32]struct{}
75-
7670
// This task index is to communicate with the local BLS
7771
// Service.
7872
// Note: In case of a reboot it can start from 0 again
@@ -146,7 +140,7 @@ func NewAggregator(aggregatorConfig config.AggregatorConfig) (*Aggregator, error
146140
return taskResponseDigest, nil
147141
}
148142

149-
operatorPubkeysService := oppubkeysserv.NewOperatorsInfoServiceInMemory(context.Background(), clients.AvsRegistryChainSubscriber, clients.AvsRegistryChainReader, nil, logger)
143+
operatorPubkeysService := oppubkeysserv.NewOperatorsInfoServiceInMemory(context.Background(), clients.AvsRegistryChainSubscriber, clients.AvsRegistryChainReader, nil, oppubkeysserv.Opts{}, logger)
150144
avsRegistryService := avsregistry.NewAvsRegistryServiceChainCaller(avsReader.ChainReader, operatorPubkeysService, logger)
151145
blsAggregationService := blsagg.NewBlsAggregatorService(avsRegistryService, hashFunction, logger)
152146

@@ -167,7 +161,6 @@ func NewAggregator(aggregatorConfig config.AggregatorConfig) (*Aggregator, error
167161
batchesIdxByIdentifierHash: batchesIdxByIdentifierHash,
168162
batchDataByIdentifierHash: batchDataByIdentifierHash,
169163
batchCreatedBlockByIdx: batchCreatedBlockByIdx,
170-
operatorRespondedBatch: make(map[uint32]map[eigentypes.Bytes32]struct{}),
171164
nextBatchIndex: nextBatchIndex,
172165
taskMutex: &sync.Mutex{},
173166
walletMutex: &sync.Mutex{},
@@ -220,12 +213,6 @@ func (agg *Aggregator) handleBlsAggServiceResponse(blsAggServiceResp blsagg.BlsA
220213
agg.taskMutex.Lock()
221214
batchIdentifierHash := agg.batchesIdentifierHashByIdx[blsAggServiceResp.TaskIndex]
222215
agg.logger.Error("BlsAggregationServiceResponse contains an error", "err", blsAggServiceResp.Err, "batchIdentifierHash", hex.EncodeToString(batchIdentifierHash[:]))
223-
agg.logger.Info("- Locking task mutex: Delete task from operator map", "taskIndex", blsAggServiceResp.TaskIndex)
224-
225-
// Remove task from the list of tasks
226-
delete(agg.operatorRespondedBatch, blsAggServiceResp.TaskIndex)
227-
228-
agg.logger.Info("- Unlocking task mutex: Delete task from operator map", "taskIndex", blsAggServiceResp.TaskIndex)
229216
agg.taskMutex.Unlock()
230217
return
231218
}
@@ -254,10 +241,6 @@ func (agg *Aggregator) handleBlsAggServiceResponse(blsAggServiceResp blsagg.BlsA
254241
batchIdentifierHash := agg.batchesIdentifierHashByIdx[blsAggServiceResp.TaskIndex]
255242
batchData := agg.batchDataByIdentifierHash[batchIdentifierHash]
256243
taskCreatedBlock := agg.batchCreatedBlockByIdx[blsAggServiceResp.TaskIndex]
257-
258-
// Delete the task from the map
259-
delete(agg.operatorRespondedBatch, blsAggServiceResp.TaskIndex)
260-
261244
agg.AggregatorConfig.BaseConfig.Logger.Info("- Unlocked Resources: Fetching merkle root")
262245
agg.taskMutex.Unlock()
263246

@@ -282,7 +265,6 @@ func (agg *Aggregator) handleBlsAggServiceResponse(blsAggServiceResp blsagg.BlsA
282265
agg.logger.Info("Aggregator successfully responded to task",
283266
"taskIndex", blsAggServiceResp.TaskIndex,
284267
"batchIdentifierHash", "0x"+hex.EncodeToString(batchIdentifierHash[:]))
285-
286268
return
287269
}
288270

aggregator/internal/pkg/server.go

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import (
77
"net/rpc"
88
"time"
99

10-
eigentypes "github.com/Layr-Labs/eigensdk-go/types"
11-
1210
"github.com/yetanotherco/aligned_layer/core/types"
1311
)
1412

@@ -33,11 +31,8 @@ func (agg *Aggregator) ServeOperators() error {
3331
agg.AggregatorConfig.Aggregator.ServerIpPortAddress)
3432

3533
err = http.ListenAndServe(agg.AggregatorConfig.Aggregator.ServerIpPortAddress, nil)
36-
if err != nil {
37-
return err
38-
}
3934

40-
return nil
35+
return err
4136
}
4237

4338
// Aggregator Methods
@@ -77,26 +72,6 @@ func (agg *Aggregator) ProcessOperatorSignedTaskResponseV2(signedTaskResponse *t
7772
return nil
7873
}
7974

80-
// Note: we already have lock here
81-
agg.logger.Debug("- Checking if operator already responded")
82-
batchResponses, ok := agg.operatorRespondedBatch[taskIndex]
83-
if !ok {
84-
batchResponses = make(map[eigentypes.Bytes32]struct{})
85-
agg.operatorRespondedBatch[taskIndex] = batchResponses
86-
}
87-
88-
if _, ok := batchResponses[signedTaskResponse.OperatorId]; ok {
89-
*reply = 0
90-
agg.logger.Warn("Operator already responded, ignoring",
91-
"operatorId", hex.EncodeToString(signedTaskResponse.OperatorId[:]),
92-
"taskIndex", taskIndex, "batchMerkleRoot", hex.EncodeToString(signedTaskResponse.BatchMerkleRoot[:]))
93-
94-
agg.taskMutex.Unlock()
95-
return nil
96-
}
97-
98-
batchResponses[signedTaskResponse.OperatorId] = struct{}{}
99-
10075
// Don't wait infinitely if it can't answer
10176
// Create a context with a timeout of 5 seconds
10277
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
@@ -114,9 +89,7 @@ func (agg *Aggregator) ProcessOperatorSignedTaskResponseV2(signedTaskResponse *t
11489

11590
if err != nil {
11691
agg.logger.Warnf("BLS aggregation service error: %s", err)
117-
// remove operator from the list of operators that responded
118-
// so that it can try again
119-
delete(batchResponses, signedTaskResponse.OperatorId)
92+
// todo shouldn't we here close the channel with a reply = 1?
12093
} else {
12194
agg.logger.Info("BLS process succeeded")
12295
}

0 commit comments

Comments
 (0)