Skip to content

Commit 067607e

Browse files
entropidelicJuArce
andauthored
refactor(batcher-client): set verifybatchinclusion as view and remove signer from client (#404)
Co-authored-by: JuArce <[email protected]>
1 parent f42e0c7 commit 067607e

File tree

7 files changed

+23
-31
lines changed

7 files changed

+23
-31
lines changed

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,24 +122,22 @@ aligned submit \
122122
```
123123

124124
### Creating a transaction from the CLI to verify proof in Ethereum
125-
After running the commands of the previous section to submit proofs to the batcher, you will receive responses that will be written to disk in a JSON format inside the `<batch_inclusion_data_directory_path>`, for example `19f04bbb143af72105e2287935c320cc2aa9eeda0fe1f3ffabbe4e59cdbab691_0.json`. By default, the `batch_inclusion_data` directory will be created where the submit command is being executed, but you can specify it with the `<batch_inclusion_data_directory_path>` argument. To verify their inclusion in a batch, run the following command, replacing the `<path_to_batch_inclusion_data>` placeholder with the path to your response file, and `<private_key_store>` with the path to your ECDSA key store:
125+
After running the commands of the previous section to submit proofs to the batcher, you will receive responses that will be written to disk in a JSON format inside the `<batch_inclusion_data_directory_path>`, for example `19f04bbb143af72105e2287935c320cc2aa9eeda0fe1f3ffabbe4e59cdbab691_0.json`. By default, the `batch_inclusion_data` directory will be created where the submit command is being executed, but you can specify it with the `<batch_inclusion_data_directory_path>` argument. To verify their inclusion in a batch, run the following command, replacing the `<path_to_batch_inclusion_data>` placeholder with the path to your response file.
126126

127127
```bash
128128
aligned verify-proof-onchain \
129-
--aligned-verification-data <path_to_verification_data> \
130-
--private-key-store <path_to_private_key_store> \
131-
--eth_rpc_url <holesky_rpc_url> \
129+
--aligned-verification-data <path_to_your_verification_data> \
130+
--rpc <holesky_rpc_url> \
132131
--chain holesky
133132
```
134133

135-
As an example,
134+
As a quick example for trying it out, you can use verification data provided by us in `./batcher/aligned/test_files/batch_inclusion_data/17bd5db82ef731ba3710b22df8e3c1ca6a5cde0a8d1ca1681664e4ff9b25574f_295.json`:
136135

137136
```bash
138137
aligned verify-proof-onchain \
139-
--aligned-verification-data 19f04bbb143af72105e2287935c320cc2aa9eeda0fe1f3ffabbe4e59cdbab691_0.json --private-key-store config-files/anvil.ecdsa.key.json \
140-
--eth_rpc_url https://ethereum-holesky-rpc.publicnode.com \
138+
--aligned-verification-data ./batcher/aligned/test_files/batch_inclusion_data/17bd5db82ef731ba3710b22df8e3c1ca6a5cde0a8d1ca1681664e4ff9b25574f_295.json \
139+
--rpc https://ethereum-holesky-rpc.publicnode.com \
141140
--chain holesky
142-
143141
```
144142

145143
## Register as an Aligned operator in testnet

batcher/aligned/abi/AlignedLayerServiceManager.json

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

batcher/aligned/src/eth.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
use crate::eth::k256::ecdsa::SigningKey;
2-
use ethers::prelude::*;
3-
use std::path::PathBuf;
41
use std::str::FromStr;
52
use std::sync::Arc;
63

4+
use ethers::prelude::*;
5+
76
use crate::errors::BatcherClientError;
87

98
abigen!(
@@ -12,23 +11,15 @@ abigen!(
1211
);
1312

1413
pub type AlignedLayerServiceManager =
15-
AlignedLayerServiceManagerContract<SignerMiddleware<Provider<Http>, Wallet<SigningKey>>>;
14+
AlignedLayerServiceManagerContract<Provider<Http>>;
1615

1716
pub async fn aligned_service_manager(
1817
provider: Provider<Http>,
1918
contract_address: &str,
20-
private_key_store_path: PathBuf,
21-
private_key_store_password: &str,
2219
) -> Result<AlignedLayerServiceManager, BatcherClientError> {
23-
let chain_id = provider.get_chainid().await?;
24-
25-
let wallet = Wallet::decrypt_keystore(private_key_store_path, private_key_store_password)?
26-
.with_chain_id(chain_id.as_u64());
27-
28-
let signer = Arc::new(SignerMiddleware::new(provider, wallet));
29-
20+
let client = Arc::new(provider);
3021
let contract_addr = H160::from_str(contract_address)
3122
.map_err(|e| BatcherClientError::EthError(e.to_string()))?;
3223

33-
Ok(AlignedLayerServiceManager::new(contract_addr, signer))
24+
Ok(AlignedLayerServiceManager::new(contract_addr, client))
3425
}

batcher/aligned/src/main.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ pub struct VerifyProofOnchainArgs {
9797
default_value = "http://localhost:8545"
9898
)]
9999
eth_rpc_url: String,
100-
#[arg(name = "Private key store path", long = "private-key-store")]
101-
private_key_store_path: PathBuf,
102100
#[arg(
103101
name = "The Ethereum network's name",
104102
long = "chain",
@@ -178,15 +176,12 @@ async fn main() -> Result<(), errors::BatcherClientError> {
178176
let eth_rpc_url = verify_inclusion_args.eth_rpc_url;
179177

180178
let eth_rpc_provider = Provider::<Http>::try_from(eth_rpc_url).unwrap();
181-
let private_key_store_path = verify_inclusion_args.private_key_store_path;
182179

183180
// FIXME(marian): We are passing an empty string as the private key password for the moment.
184181
// We should think how to handle this correctly.
185182
let service_manager = eth::aligned_service_manager(
186183
eth_rpc_provider,
187184
contract_address,
188-
private_key_store_path,
189-
"",
190185
)
191186
.await?;
192187

@@ -201,7 +196,14 @@ async fn main() -> Result<(), errors::BatcherClientError> {
201196
);
202197

203198
match call.call().await {
204-
Ok(response) => info!("Batch inclusion verification response: {}", response),
199+
Ok(response) => {
200+
if response {
201+
info!("Your proof was verified in Aligned and included in the batch!");
202+
} else {
203+
info!("Your proof was not included in the batch.");
204+
}
205+
}
206+
205207
Err(err) => error!("Error while reading batch inclusion verification: {}", err),
206208
}
207209
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"verification_data_commitment":{"proof_commitment":[214,153,226,186,70,52,178,56,177,95,26,155,222,79,140,50,16,155,247,253,148,212,127,204,137,72,56,104,37,241,65,62],"pub_input_commitment":[0,30,254,69,168,234,6,219,2,20,107,191,249,51,172,61,209,244,50,36,244,58,60,169,40,101,175,43,84,253,91,178],"proving_system_aux_data_commitment":[187,126,20,41,108,203,7,235,181,242,102,121,103,110,241,178,222,85,174,142,101,224,148,217,28,219,62,22,206,111,168,95],"proof_generator_addr":[243,159,214,229,26,173,136,246,244,206,106,184,130,114,121,207,255,185,34,102]},"batch_merkle_root":[23,189,93,184,46,247,49,186,55,16,178,45,248,227,193,202,106,92,222,10,141,28,161,104,22,100,228,255,155,37,87,79],"batch_inclusion_proof":{"merkle_path":[[63,251,248,123,110,43,112,178,235,0,20,163,98,123,126,86,68,71,78,87,1,102,16,53,238,17,69,23,177,217,236,129],[14,55,193,146,95,206,25,61,144,141,112,149,191,150,167,136,46,62,15,54,159,1,16,80,234,71,200,6,95,219,115,184],[142,175,116,202,189,155,221,98,214,131,106,167,59,2,158,68,221,61,242,178,36,126,175,127,141,80,48,217,83,50,20,168],[70,59,66,54,71,169,209,88,75,85,121,164,197,29,251,122,144,28,162,49,225,235,147,253,93,148,163,97,180,167,237,30],[189,10,11,46,122,80,130,159,166,185,247,248,107,171,208,220,144,55,39,114,179,187,59,226,1,201,242,141,187,52,94,136],[30,23,91,191,80,173,188,191,233,79,118,209,180,9,251,59,121,246,74,46,4,226,69,174,177,19,77,41,228,107,95,162],[73,110,239,135,220,81,154,222,107,134,69,31,179,107,234,96,86,95,90,230,39,173,6,182,199,85,158,138,237,148,128,118],[45,2,66,15,179,156,150,221,63,156,215,131,43,0,195,48,96,107,97,25,152,214,152,35,120,154,86,197,161,40,170,65],[84,37,53,249,226,35,85,7,203,93,123,214,164,219,163,115,221,78,11,27,236,178,204,26,151,20,126,56,239,38,190,55],[105,197,236,110,121,124,150,108,56,151,149,153,173,129,59,117,99,45,5,179,118,90,115,22,172,5,85,142,21,236,223,42]]},"verification_data_batch_index":295}

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ contract AlignedLayerServiceManager is
123123
bytes32 batchMerkleRoot,
124124
bytes memory merkleProof,
125125
uint verificationDataBatchIndex
126-
) external returns (bool) {
126+
) external view returns (bool) {
127127
require(
128128
batchesState[batchMerkleRoot].taskCreatedBlock != 0,
129129
"Batch doesn't exist"

0 commit comments

Comments
 (0)