Skip to content

Commit 13cdc86

Browse files
authored
fix: Merge testnet to staging v3 (#983)
2 parents 91c954c + 9348ff3 commit 13cdc86

File tree

30 files changed

+495
-448
lines changed

30 files changed

+495
-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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,13 @@ 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-
280279
for i := 0; i < MaxSentTxRetries; i++ {
281280
_, err = agg.sendAggregatedResponse(batchData.BatchMerkleRoot, batchData.SenderAddress, nonSignerStakesAndSignature)
282281
if err == nil {
283282
agg.logger.Info("Aggregator successfully responded to task",
284283
"taskIndex", blsAggServiceResp.TaskIndex,
285284
"batchIdentifierHash", "0x"+hex.EncodeToString(batchIdentifierHash[:]))
286-
285+
287286
return
288287
}
289288

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 in v0.5.2 and v0.6.0
9899
emit NewBatchV2(
99100
batchMerkleRoot,
100101
msg.sender,
101102
uint32(block.number),
102103
batchDataPointer
103104
);
105+
// For aggregator and operators in v0.7.0
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
}

docs/3_guides/2_integrating_aligned_into_your_application.md

Lines changed: 16 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,23 @@ 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,
157+
nonce,
158+
BATCHER_CONTRACT_ADDRESS
159+
).await.map_err(|e| anyhow::anyhow!("Failed to submit proof: {:?}", e))
152160
}
153161

154162
#[tokio::main]
155163
async fn main() {
156164
let wallet = // Initialize wallet
165+
166+
let wallet = wallet.with_chain_id(17000u64)
167+
157168
let proof = // Generate or obtain proof
158169

159170
match submit_proof_to_aligned(proof, wallet).await {
@@ -163,41 +174,6 @@ async fn main() {
163174
}
164175
```
165176

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-
201177
You can find an example of the proof submission and verification in the [ZKQuiz Program](../../examples/zkquiz/quiz/script/src/main.rs).
202178

203179
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.

docs/3_guides/3_validating_public_input.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This guide assumes you are in the `examples/validating-public-input` directory.
1010

1111
## Generate your ZK Proof
1212

13-
> [!IMPORTANT]
13+
> [!IMPORTANT]
1414
> To generate the proof ensure you have [docker](https://www.docker.com/get-started/) installed and the docker daemon running.
1515
> This is necessary to ensure deterministic builds of the binary we want to generate a proof of. If not used, builds may differ depending on the system you are running on. To know more about this, check [this link](https://dev.risczero.com/terminology#deterministic-builds) from RiscZero docs.
1616
@@ -42,15 +42,17 @@ pragma solidity ^0.8.12;
4242
4343
contract FibonacciValidator {
4444
address public alignedServiceManager;
45+
address public paymentServiceAddr;
4546
bytes32 public fibonacciProgramId;
4647
4748
bytes32 public fibonacciProgramIdCommitment =
4849
0x069ed9f3972550a2901523723f4beb5e240749dcafa30e1623d0778e17d69d70;
4950
5051
event FibonacciNumbers(uint32 fibN, uint32 fibNPlusOne);
5152
52-
constructor(address _alignedServiceManager) {
53+
constructor(address _alignedServiceManager, address _paymentServiceAddr) {
5354
alignedServiceManager = _alignedServiceManager;
55+
paymentServiceAddr = _paymentServiceAddr;
5456
}
5557
5658
function verifyBatchInclusion(
@@ -78,14 +80,15 @@ contract FibonacciValidator {
7880
bytes memory proofIsIncluded
7981
) = alignedServiceManager.staticcall(
8082
abi.encodeWithSignature(
81-
"verifyBatchInclusion(bytes32,bytes32,bytes32,bytes20,bytes32,bytes,uint256)",
83+
"verifyBatchInclusion(bytes32,bytes32,bytes32,bytes20,bytes32,bytes,uint256,address)",
8284
proofCommitment,
8385
pubInputCommitment,
8486
programIdCommitment,
8587
proofGeneratorAddr,
8688
batchMerkleRoot,
8789
merkleProof,
88-
verificationDataBatchIndex
90+
verificationDataBatchIndex,
91+
paymentServiceAddr
8992
)
9093
);
9194
@@ -116,6 +119,7 @@ contract FibonacciValidator {
116119
return (first, second);
117120
}
118121
}
122+
119123
```
120124

121125
### Explanation
@@ -146,14 +150,15 @@ require(
146150
bytes memory proofIsIncluded
147151
) = alignedServiceManager.staticcall(
148152
abi.encodeWithSignature(
149-
"verifyBatchInclusion(bytes32,bytes32,bytes32,bytes20,bytes32,bytes,uint256)",
153+
"verifyBatchInclusion(bytes32,bytes32,bytes32,bytes20,bytes32,bytes,uint256,address)",
150154
proofCommitment,
151155
pubInputCommitment,
152156
programIdCommitment,
153157
proofGeneratorAddr,
154158
batchMerkleRoot,
155159
merkleProof,
156-
verificationDataBatchIndex
160+
verificationDataBatchIndex,
161+
paymentServiceAddr
157162
)
158163
);
159164
@@ -192,6 +197,7 @@ To deploy the contract, first you will need to set up the `.env` file in the con
192197
RPC_URL=<rpc_url> #You can use publicnode RPC: https://ethereum-holesky-rpc.publicnode.com
193198
PRIVATE_KEY=<private_key>
194199
ALIGNED_SERVICE_MANAGER_ADDRESS=<service_manager_address> #0x58F280BeBE9B34c9939C3C39e0890C81f163B623 for Holesky
200+
PAYMENT_SERVICE_ADDRESS=<payment_service_address> #0x815aeCA64a974297942D2Bbf034ABEe22a38A003 for Holesky
195201
```
196202

197203
Then, run `make deploy_fibonacci_validator`.

0 commit comments

Comments
 (0)