Skip to content

Commit

Permalink
fix: dont upload nonce to bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
taturosati committed Aug 1, 2024
1 parent 83c4254 commit 6bad051
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 238 deletions.
10 changes: 8 additions & 2 deletions batcher/aligned-batcher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ use std::sync::Arc;

use aligned_sdk::core::types::{
BatchInclusionData, ClientMessage, NoncedVerificationData, ResponseMessage,
ValidityResponseMessage, VerificationCommitmentBatch, VerificationDataCommitment,
ValidityResponseMessage, VerificationCommitmentBatch, VerificationData,
VerificationDataCommitment,
};
use aws_sdk_s3::client::Client as S3Client;
use eth::BatcherPaymentService;
Expand Down Expand Up @@ -459,12 +460,17 @@ impl Batcher {
block_number: u64,
finalized_batch: BatchQueue,
) -> Result<(), BatcherError> {
let batch_verification_data: Vec<NoncedVerificationData> = finalized_batch
let nonced_batch_verifcation_data: Vec<NoncedVerificationData> = finalized_batch
.clone()
.into_iter()
.map(|(data, _, _, _)| data)
.collect();

let batch_verification_data: Vec<VerificationData> = nonced_batch_verifcation_data
.iter()
.map(|vd| vd.verification_data.clone())
.collect();

let batch_bytes = serde_json::to_vec(batch_verification_data.as_slice())
.expect("Failed to serialize batch");

Expand Down
6 changes: 5 additions & 1 deletion batcher/aligned-sdk/src/core/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ pub struct VerificationDataCommitment {

impl From<&NoncedVerificationData> for VerificationDataCommitment {
fn from(nonced_verification_data: &NoncedVerificationData) -> Self {
let verification_data = nonced_verification_data.verification_data.clone();
nonced_verification_data.verification_data.clone().into()
}
}

impl From<VerificationData> for VerificationDataCommitment {
fn from(verification_data: VerificationData) -> Self {
let mut hasher = Keccak256::new();

// compute proof commitment
Expand Down
225 changes: 0 additions & 225 deletions batcher/aligned-sdk/src/types.rs

This file was deleted.

6 changes: 3 additions & 3 deletions operator/merkle_tree/lib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use aligned_sdk::core::types::{
NoncedVerificationData, VerificationCommitmentBatch, VerificationDataCommitment,
VerificationCommitmentBatch, VerificationData, VerificationDataCommitment,
};
use lambdaworks_crypto::merkle_tree::merkle::MerkleTree;

Expand All @@ -15,15 +15,15 @@ pub extern "C" fn verify_merkle_tree_batch_ffi(

let batch_bytes = unsafe { std::slice::from_raw_parts(batch_ptr, batch_len) };

let batch = match serde_json::from_slice::<Vec<NoncedVerificationData>>(batch_bytes) {
let batch = match serde_json::from_slice::<Vec<VerificationData>>(batch_bytes) {
Ok(batch) => batch,
Err(_e) => {
return false;
}
};

let batch_data_comm: Vec<VerificationDataCommitment> =
batch.into_iter().map(|v| v.clone().into()).collect();
batch.into_iter().map(|v| v.into()).collect();

let computed_batch_merkle_tree: MerkleTree<VerificationCommitmentBatch> =
MerkleTree::build(&batch_data_comm);
Expand Down
4 changes: 2 additions & 2 deletions operator/pkg/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (o *Operator) getBatchFromS3(batchURL string, expectedMerkleRoot [32]byte)
}
o.Logger.Infof("Batch merkle tree verified")

var batch []NoncedVerificationData
var batch []VerificationData

err = json.Unmarshal(batchBytes, &batch)
if err != nil {
Expand All @@ -60,7 +60,7 @@ func (o *Operator) getBatchFromS3(batchURL string, expectedMerkleRoot [32]byte)
// get only the verification data
var batchData []VerificationData
for _, data := range batch {

Check failure on line 62 in operator/pkg/s3.go

View workflow job for this annotation

GitHub Actions / lint

S1011: should replace loop with `batchData = append(batchData, batch...)` (gosimple)
batchData = append(batchData, data.VerificationData)
batchData = append(batchData, data)
}

return batchData, nil
Expand Down
5 changes: 0 additions & 5 deletions operator/pkg/verification_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,3 @@ type VerificationData struct {
VerificationKey []byte `json:"verification_key"`
VmProgramCode []byte `json:"vm_program_code"`
}

type NoncedVerificationData struct {
VerificationData VerificationData `json:"verification_data"`
Nonce []byte `json:"nonce"`
}

0 comments on commit 6bad051

Please sign in to comment.