Skip to content

Commit 0f196f2

Browse files
committed
Merge branch 'testnet' into staging
2 parents 91c954c + bdda0d2 commit 0f196f2

File tree

31 files changed

+512
-448
lines changed

31 files changed

+512
-448
lines changed

aggregator/cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func aggregatorMain(ctx *cli.Context) error {
4949
return err
5050
}
5151

52-
// Listen for new task created in the ServiceManager contract in a separate goroutine
52+
// Listen for new task created in the ServiceManager contract in a separate goroutine, both V1 and V2 subscriptions:
5353
go func() {
5454
listenErr := aggregator.SubscribeToNewTasks()
5555
if listenErr != nil {

aggregator/internal/pkg/aggregator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,14 @@ func (agg *Aggregator) handleBlsAggServiceResponse(blsAggServiceResp blsagg.BlsA
276276

277277
agg.logger.Info("Sending aggregated response onchain", "taskIndex", blsAggServiceResp.TaskIndex,
278278
"batchIdentifierHash", "0x"+hex.EncodeToString(batchIdentifierHash[:]))
279-
279+
// current_task_block := agg.batchCreatedBlockByIdx[blsAggServiceResp.TaskIndex]
280280
for i := 0; i < MaxSentTxRetries; i++ {
281281
_, err = agg.sendAggregatedResponse(batchData.BatchMerkleRoot, batchData.SenderAddress, nonSignerStakesAndSignature)
282282
if err == nil {
283283
agg.logger.Info("Aggregator successfully responded to task",
284284
"taskIndex", blsAggServiceResp.TaskIndex,
285285
"batchIdentifierHash", "0x"+hex.EncodeToString(batchIdentifierHash[:]))
286-
286+
287287
return
288288
}
289289

batcher/aligned-sdk/abi/AlignedLayerServiceManager.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

contracts/bindings/AlignedLayerServiceManager/binding.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/bindings/ERC20Mock/binding.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/scripts/anvil/state/alignedlayer-deployed-anvil-state.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

contracts/src/core/AlignedLayerServiceManager.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,14 @@ contract AlignedLayerServiceManager is
9595

9696
batchesState[batchIdentifier] = batchState;
9797

98+
// For operators:
9899
emit NewBatchV2(
99100
batchMerkleRoot,
100101
msg.sender,
101102
uint32(block.number),
102103
batchDataPointer
103104
);
105+
// For aggregator:
104106
emit NewBatchV3(
105107
batchMerkleRoot,
106108
msg.sender,

core/chainio/avs_subscriber.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ func (s *AvsSubscriber) getLatestTaskFromEthereum() (*servicemanager.ContractAli
207207
}
208208

209209
// We just care about the NewBatch event
210-
newBatchEvent := alignedLayerServiceManagerABI.Events["NewBatch"]
210+
newBatchEvent := alignedLayerServiceManagerABI.Events["NewBatchV3"]
211211
if newBatchEvent.ID == (ethcommon.Hash{}) {
212212
return nil, fmt.Errorf("NewBatch event not found in ABI")
213213
}
@@ -234,7 +234,7 @@ func (s *AvsSubscriber) getLatestTaskFromEthereum() (*servicemanager.ContractAli
234234
lastLog := logs[len(logs)-1]
235235

236236
var latestTask servicemanager.ContractAlignedLayerServiceManagerNewBatchV3
237-
err = alignedLayerServiceManagerABI.UnpackIntoInterface(&latestTask, "NewBatch", lastLog.Data)
237+
err = alignedLayerServiceManagerABI.UnpackIntoInterface(&latestTask, "NewBatchV3", lastLog.Data)
238238
if err != nil {
239239
return nil, fmt.Errorf("failed to unpack log data: %w", err)
240240
}

core/types/signed_task_response.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ import (
55
eigentypes "github.com/Layr-Labs/eigensdk-go/types"
66
)
77

8+
// type SignedTaskResponse struct {
9+
// BatchMerkleRoot [32]byte
10+
// BlsSignature bls.Signature
11+
// OperatorId eigentypes.OperatorId
12+
// }
13+
814
type SignedTaskResponse struct {
915
BatchMerkleRoot [32]byte
1016
SenderAddress [20]byte

docs/3_guides/2_integrating_aligned_into_your_application.md

Lines changed: 26 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,13 @@ The proof submission and verification can be done either with the SDK or by usin
116116

117117
#### Using the SDK
118118

119-
To submit a proof using the SDK, you can use the `submit` function, and then you can use the `verify_proof_onchain` function to check if the proof was correctly verified in Aligned.
120-
119+
To submit a proof using the SDK, you can use the `submit_and_wait_verification` function.
120+
This function submits the proof to aligned and waits for it to be verified in Aligned.
121+
Alternatively you can call `submit` if you dont want to wait for proof verification.
121122
The following code is an example of how to submit a proof using the SDK:
122123

123124
```rust
124-
use aligned_sdk::sdk::{submit, get_next_nonce};
125+
use aligned_sdk::sdk::{submit_and_wait_verification, get_next_nonce};
125126
use aligned_sdk::types::{ProvingSystemId, VerificationData};
126127
use ethers::prelude::*;
127128

@@ -147,13 +148,33 @@ async fn submit_proof_to_aligned(
147148
.await
148149
.map_err(|e| anyhow::anyhow!("Failed to get next nonce: {:?}", e))?;
149150

150-
submit(BATCHER_URL, &verification_data, wallet, nonce).await
151-
.map_err(|e| anyhow::anyhow!("Failed to submit proof: {:?}", e))
151+
match submit_and_wait_verification(
152+
BATCHER_URL,
153+
&rpc_url,
154+
Chain::Holesky,
155+
&verification_data,
156+
wallet.clone(),
157+
nonce,
158+
BATCHER_PAYMENTS_ADDRESS
159+
)
160+
161+
submit_and_wait_verification(
162+
BATCHER_URL,
163+
RPC_URL,
164+
Chain::Holesky,
165+
&verification_data,
166+
wallet,
167+
nonce,
168+
BATCHER_CONTRACT_ADDRESS
169+
).await.map_err(|e| anyhow::anyhow!("Failed to submit proof: {:?}", e))
152170
}
153171

154172
#[tokio::main]
155173
async fn main() {
156174
let wallet = // Initialize wallet
175+
176+
let wallet = wallet.with_chain_id(17000u64)
177+
157178
let proof = // Generate or obtain proof
158179

159180
match submit_proof_to_aligned(proof, wallet).await {
@@ -163,41 +184,6 @@ async fn main() {
163184
}
164185
```
165186

166-
The following code is an example of how to verify the proof was correctly verified in Aligned using the SDK:
167-
168-
```rust
169-
use aligned_sdk::sdk::verify_proof_onchain;
170-
use aligned_sdk::types::{AlignedVerificationData, Chain};
171-
use ethers::prelude::*;
172-
use tokio::time::{sleep, Duration};
173-
174-
async fn wait_for_proof_verification(
175-
aligned_verification_data: AlignedVerificationData,
176-
rpc_url: String,
177-
) -> Result<(), anyhow::Error> {
178-
for _ in 0..10 {
179-
if verify_proof_onchain(aligned_verification_data.clone(), Chain::Holesky, rpc_url.as_str()).await.is_ok_and(|r| r) {
180-
println!("Proof verified successfully.");
181-
return Ok(());
182-
}
183-
println!("Proof not verified yet. Waiting 10 seconds before checking again...");
184-
sleep(Duration::from_secs(10)).await;
185-
}
186-
anyhow::bail!("Proof verification failed")
187-
}
188-
189-
#[tokio::main]
190-
async fn main() {
191-
let aligned_verification_data = // Obtain aligned verification data
192-
let rpc_url = "https://ethereum-holesky-rpc.publicnode.com".to_string();
193-
194-
match wait_for_proof_verification(aligned_verification_data, rpc_url).await {
195-
Ok(_) => println!("Proof verified"),
196-
Err(err) => println!("Error: {:?}", err),
197-
}
198-
}
199-
```
200-
201187
You can find an example of the proof submission and verification in the [ZKQuiz Program](../../examples/zkquiz/quiz/script/src/main.rs).
202188

203189
This example generates a proof, instantiates a wallet to submit the proof, and then submits the proof to Aligned for verification. It then waits for the proof to be verified in Aligned.

0 commit comments

Comments
 (0)