Skip to content

Commit 59fb024

Browse files
refactor: rename append-with-proofs to append (#1829)s
* refactor: rename append-with-proofs to append * fix circuit type handling * batch append rename
1 parent 5ca22ae commit 59fb024

24 files changed

+200
-206
lines changed

cli/src/commands/start-prover/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ class StartProver extends Command {
3434
"inclusion",
3535
"non-inclusion",
3636
"combined",
37-
"append-with-proofs",
37+
"append",
3838
"update",
3939
"address-append",
40-
"append-with-proofs-test",
40+
"append-test",
4141
"update-test",
4242
"address-append-test",
4343
],

forester-utils/src/instructions/state_batch_append.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ use light_hasher::bigint::bigint_to_be_bytes_array;
1010
use light_merkle_tree_metadata::QueueType;
1111
use light_prover_client::{
1212
proof_client::ProofClient,
13-
proof_types::batch_append::{
14-
get_batch_append_with_proofs_inputs, BatchAppendWithProofsCircuitInputs,
15-
},
13+
proof_types::batch_append::{get_batch_append_inputs, BatchAppendsCircuitInputs},
1614
};
1715
use light_sparse_merkle_tree::changelog::ChangelogEntry;
1816
use tracing::{error, trace};
@@ -117,7 +115,7 @@ pub async fn create_append_batch_ix_data<R: Rpc, I: Indexer>(
117115
let adjusted_start_index =
118116
merkle_tree_next_index as u32 + (batch_idx * zkp_batch_size as usize) as u32;
119117

120-
let (circuit_inputs, batch_changelogs) = get_batch_append_with_proofs_inputs::<32>(
118+
let (circuit_inputs, batch_changelogs) = get_batch_append_inputs::<32>(
121119
current_root,
122120
adjusted_start_index,
123121
leaves,
@@ -163,7 +161,7 @@ pub async fn create_append_batch_ix_data<R: Rpc, I: Indexer>(
163161
Ok(instruction_data_vec)
164162
}
165163
async fn generate_zkp_proof(
166-
circuit_inputs: BatchAppendWithProofsCircuitInputs,
164+
circuit_inputs: BatchAppendsCircuitInputs,
167165
) -> Result<(CompressedProof, [u8; 32]), ForesterUtilsError> {
168166
let proof_client = ProofClient::local();
169167
let (proof, new_root) = proof_client

program-tests/utils/src/mock_batched_forester.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use light_prover_client::{
88
proof_client::ProofClient,
99
proof_types::{
1010
batch_address_append::get_batch_address_append_circuit_inputs,
11-
batch_append::get_batch_append_with_proofs_inputs, batch_update::get_batch_update_inputs,
11+
batch_append::get_batch_append_inputs, batch_update::get_batch_update_inputs,
1212
},
1313
};
1414
use light_sparse_merkle_tree::{
@@ -101,7 +101,7 @@ impl<const HEIGHT: usize> MockBatchedForester<HEIGHT> {
101101
self.merkle_tree.update(leaf, index).unwrap();
102102
}
103103
}
104-
let (circuit_inputs, _) = match get_batch_append_with_proofs_inputs::<HEIGHT>(
104+
let (circuit_inputs, _) = match get_batch_append_inputs::<HEIGHT>(
105105
old_root,
106106
account_next_index as u32,
107107
leaves,
@@ -114,7 +114,7 @@ impl<const HEIGHT: usize> MockBatchedForester<HEIGHT> {
114114
Ok(val) => val,
115115
Err(e) => {
116116
return Err(ProverClientError::GenericError(format!(
117-
"get_batch_append_with_proofs_inputs error: {:?}",
117+
"get_batch_append_inputs error: {:?}",
118118
e
119119
)));
120120
}

program-tests/utils/src/test_batch_forester.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use light_prover_client::{
3030
proof_client::ProofClient,
3131
proof_types::{
3232
batch_address_append::{get_batch_address_append_circuit_inputs, to_json},
33-
batch_append::{get_batch_append_with_proofs_inputs, BatchAppendWithProofsInputsJson},
33+
batch_append::{get_batch_append_inputs, BatchAppendInputsJson},
3434
batch_update::{get_batch_update_inputs, update_inputs_string},
3535
},
3636
};
@@ -149,7 +149,7 @@ pub async fn create_append_batch_ix_data<R: Rpc>(
149149

150150
// TODO: remove unwraps
151151
let (circuit_inputs, _) =
152-
get_batch_append_with_proofs_inputs::<{ DEFAULT_BATCH_STATE_TREE_HEIGHT as usize }>(
152+
get_batch_append_inputs::<{ DEFAULT_BATCH_STATE_TREE_HEIGHT as usize }>(
153153
old_root,
154154
merkle_tree_next_index as u32,
155155
batch_update_leaves,
@@ -165,12 +165,9 @@ pub async fn create_append_batch_ix_data<R: Rpc>(
165165
bundle.merkle_tree.root()
166166
);
167167
let proof_client = ProofClient::local();
168-
let inputs_json = BatchAppendWithProofsInputsJson::from_inputs(&circuit_inputs).to_string();
168+
let inputs_json = BatchAppendInputsJson::from_inputs(&circuit_inputs).to_string();
169169

170-
match proof_client
171-
.generate_proof(inputs_json, "append-with-proofs")
172-
.await
173-
{
170+
match proof_client.generate_proof(inputs_json, "append").await {
174171
Ok(compressed_proof) => (
175172
compressed_proof,
176173
bigint_to_be_bytes_array::<32>(&circuit_inputs.new_root.to_biguint().unwrap())

prover/client/src/proof_client.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::{
1313
},
1414
proof_types::{
1515
batch_address_append::{to_json, BatchAddressAppendInputs},
16-
batch_append::{BatchAppendWithProofsCircuitInputs, BatchAppendWithProofsInputsJson},
16+
batch_append::{BatchAppendInputsJson, BatchAppendsCircuitInputs},
1717
batch_update::{update_inputs_string, BatchUpdateCircuitInputs},
1818
},
1919
};
@@ -517,15 +517,13 @@ impl ProofClient {
517517

518518
pub async fn generate_batch_append_proof(
519519
&self,
520-
circuit_inputs: BatchAppendWithProofsCircuitInputs,
520+
circuit_inputs: BatchAppendsCircuitInputs,
521521
) -> Result<(ProofCompressed, [u8; 32]), ProverClientError> {
522522
let new_root = light_hasher::bigint::bigint_to_be_bytes_array::<32>(
523523
&circuit_inputs.new_root.to_biguint().unwrap(),
524524
)?;
525-
let inputs_json = BatchAppendWithProofsInputsJson::from_inputs(&circuit_inputs).to_string();
526-
let proof = self
527-
.generate_proof(inputs_json, "append-with-proofs")
528-
.await?;
525+
let inputs_json = BatchAppendInputsJson::from_inputs(&circuit_inputs).to_string();
526+
let proof = self.generate_proof(inputs_json, "append").await?;
529527
Ok((proof, new_root))
530528
}
531529

prover/client/src/proof_type.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ pub enum ProofType {
55
Inclusion,
66
NonInclusion,
77
Combined,
8-
BatchAppendWithProofs,
8+
BatchAppend,
99
BatchUpdate,
1010
BatchAddressAppend,
1111
BatchUpdateTest,
12-
BatchAppendWithProofsTest,
12+
BatchAppendTest,
1313
BatchAddressAppendTest,
1414
}
1515

@@ -22,11 +22,11 @@ impl Display for ProofType {
2222
ProofType::Inclusion => "inclusion",
2323
ProofType::NonInclusion => "non-inclusion",
2424
ProofType::Combined => "combined",
25-
ProofType::BatchAppendWithProofs => "append-with-proofs",
25+
ProofType::BatchAppend => "append",
2626
ProofType::BatchUpdate => "update",
2727
ProofType::BatchUpdateTest => "update-test",
28-
ProofType::BatchAppendWithProofsTest => "append-with-proofs-test",
29-
ProofType::BatchAddressAppend => "addressAppend",
28+
ProofType::BatchAppendTest => "append-test",
29+
ProofType::BatchAddressAppend => "address-append",
3030
ProofType::BatchAddressAppendTest => "address-append-test",
3131
}
3232
)

prover/client/src/proof_types/batch_append/json.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use serde::Serialize;
22

33
use crate::{
44
helpers::{big_int_to_string, create_json_from_struct},
5-
proof_types::{batch_append::BatchAppendWithProofsCircuitInputs, circuit_type::CircuitType},
5+
proof_types::{batch_append::BatchAppendsCircuitInputs, circuit_type::CircuitType},
66
};
77

88
#[derive(Debug, Clone, Serialize)]
9-
pub struct BatchAppendWithProofsInputsJson {
9+
pub struct BatchAppendInputsJson {
1010
#[serde(rename = "circuitType")]
1111
circuit_type: String,
1212
#[serde(rename = "publicInputHash")]
@@ -31,10 +31,10 @@ pub struct BatchAppendWithProofsInputsJson {
3131
batch_size: u32,
3232
}
3333

34-
impl BatchAppendWithProofsInputsJson {
35-
pub fn from_inputs(inputs: &BatchAppendWithProofsCircuitInputs) -> Self {
34+
impl BatchAppendInputsJson {
35+
pub fn from_inputs(inputs: &BatchAppendsCircuitInputs) -> Self {
3636
Self {
37-
circuit_type: CircuitType::BatchAppendWithProofs.to_string(),
37+
circuit_type: CircuitType::BatchAppend.to_string(),
3838
public_input_hash: big_int_to_string(&inputs.public_input_hash),
3939
old_root: big_int_to_string(&inputs.old_root),
4040
new_root: big_int_to_string(&inputs.new_root),

prover/client/src/proof_types/batch_append/proof_inputs.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010
};
1111

1212
#[derive(Debug, Clone, Serialize)]
13-
pub struct BatchAppendWithProofsCircuitInputs {
13+
pub struct BatchAppendsCircuitInputs {
1414
pub public_input_hash: BigInt,
1515
pub old_root: BigInt,
1616
pub new_root: BigInt,
@@ -23,14 +23,14 @@ pub struct BatchAppendWithProofsCircuitInputs {
2323
pub batch_size: u32,
2424
}
2525

26-
impl BatchAppendWithProofsCircuitInputs {
26+
impl BatchAppendsCircuitInputs {
2727
pub fn public_inputs_arr(&self) -> [u8; 32] {
2828
bigint_to_u8_32(&self.public_input_hash).unwrap()
2929
}
3030
}
3131

3232
#[allow(clippy::too_many_arguments)]
33-
pub fn get_batch_append_with_proofs_inputs<const HEIGHT: usize>(
33+
pub fn get_batch_append_inputs<const HEIGHT: usize>(
3434
// get this from Merkle tree account
3535
current_root: [u8; 32],
3636
// get this from Merkle tree account
@@ -45,13 +45,7 @@ pub fn get_batch_append_with_proofs_inputs<const HEIGHT: usize>(
4545
merkle_proofs: Vec<Vec<[u8; 32]>>,
4646
batch_size: u32,
4747
previous_changelogs: &[ChangelogEntry<HEIGHT>],
48-
) -> Result<
49-
(
50-
BatchAppendWithProofsCircuitInputs,
51-
Vec<ChangelogEntry<HEIGHT>>,
52-
),
53-
ProverClientError,
54-
> {
48+
) -> Result<(BatchAppendsCircuitInputs, Vec<ChangelogEntry<HEIGHT>>), ProverClientError> {
5549
let mut new_root = [0u8; 32];
5650
let mut changelog: Vec<ChangelogEntry<HEIGHT>> = Vec::new();
5751
let mut circuit_merkle_proofs = Vec::with_capacity(batch_size as usize);
@@ -127,7 +121,7 @@ pub fn get_batch_append_with_proofs_inputs<const HEIGHT: usize>(
127121
start_index_bytes,
128122
])?;
129123
Ok((
130-
BatchAppendWithProofsCircuitInputs {
124+
BatchAppendsCircuitInputs {
131125
public_input_hash: BigInt::from_bytes_be(Sign::Plus, &public_input_hash),
132126
old_root: BigInt::from_bytes_be(Sign::Plus, &current_root),
133127
new_root: BigInt::from_bytes_be(Sign::Plus, &new_root),

prover/client/src/proof_types/circuit_type.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pub enum CircuitType {
33
Combined,
44
Inclusion,
55
NonInclusion,
6-
BatchAppendWithProofs,
6+
BatchAppend,
77
BatchUpdate,
88
BatchAddressAppend,
99
}
@@ -15,7 +15,7 @@ impl CircuitType {
1515
Self::Combined => "combined".to_string(),
1616
Self::Inclusion => "inclusion".to_string(),
1717
Self::NonInclusion => "non-inclusion".to_string(),
18-
Self::BatchAppendWithProofs => "append-with-proofs".to_string(),
18+
Self::BatchAppend => "append".to_string(),
1919
Self::BatchUpdate => "update".to_string(),
2020
Self::BatchAddressAppend => "address-append".to_string(),
2121
}

prover/client/tests/batch_append.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ use light_hasher::{hash_chain::create_hash_chain_from_slice, Hasher, Poseidon};
22
use light_merkle_tree_reference::MerkleTree;
33
use light_prover_client::{
44
constants::{DEFAULT_BATCH_STATE_TREE_HEIGHT, PROVE_PATH, SERVER_ADDRESS},
5-
proof_types::batch_append::{
6-
get_batch_append_with_proofs_inputs, BatchAppendWithProofsInputsJson,
7-
},
5+
proof_types::batch_append::{get_batch_append_inputs, BatchAppendInputsJson},
86
prover::{spawn_prover, ProverConfig},
97
};
108
use reqwest::Client;
@@ -55,8 +53,8 @@ async fn prove_batch_append_with_proofs() {
5553
let root = merkle_tree.root();
5654
let leaves_hashchain = create_hash_chain_from_slice(&leaves).unwrap();
5755

58-
// Generate inputs for BatchAppendWithProofsCircuit
59-
let (inputs, _) = get_batch_append_with_proofs_inputs::<HEIGHT>(
56+
// Generate inputs for BatchAppendCircuit
57+
let (inputs, _) = get_batch_append_inputs::<HEIGHT>(
6058
root,
6159
(i * num_insertions) as u32,
6260
leaves.clone(),
@@ -70,7 +68,7 @@ async fn prove_batch_append_with_proofs() {
7068

7169
// Serialize inputs to JSON
7270
let client = Client::new();
73-
let inputs_json = BatchAppendWithProofsInputsJson::from_inputs(&inputs).to_string();
71+
let inputs_json = BatchAppendInputsJson::from_inputs(&inputs).to_string();
7472
// Send proof request to server
7573
let response_result = client
7674
.post(format!("{}{}", SERVER_ADDRESS, PROVE_PATH))

0 commit comments

Comments
 (0)