Skip to content

Commit

Permalink
refactor: update health check timeout in spawn_prover function, rewri…
Browse files Browse the repository at this point in the history
…te prove_batch_append test

Change CI runner to buildjet-8vcpu-ubuntu-2204 for rust tests

run rust.yml on buildjet-16vcpu-ubuntu-2204

debug rust.yml workflow

Add step to download proving keys for big batches

Remove redundant setup steps and update test configurations

Update ProverConfig to use test-specific circuits
  • Loading branch information
sergeytimoshin committed Oct 29, 2024
1 parent d1cb64c commit d700441
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 66 deletions.
1 change: 1 addition & 0 deletions .github/actionlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ self-hosted-runner:
- buildjet-2vcpu-ubuntu-2204
- buildjet-4vcpu-ubuntu-2204
- buildjet-8vcpu-ubuntu-2204
- buildjet-16vcpu-ubuntu-2204
# Configuration variables in array of strings defined in your repository or
# organization. `null` means disabling configuration variables check.
# Empty array means no configuration variable is allowed.
Expand Down
2 changes: 1 addition & 1 deletion circuit-lib/light-prover-client/src/gnark/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub async fn spawn_prover(restart: bool, config: ProverConfig) {

let _ = command.spawn().expect("Failed to start prover process");

let health_result = health_check(20, 5).await;
let health_result = health_check(20, 30).await;
if health_result {
info!("Prover started successfully");
} else {
Expand Down
99 changes: 39 additions & 60 deletions circuit-lib/light-prover-client/tests/gnark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async fn prove_inclusion() {
false,
ProverConfig {
run_mode: None,
circuits: vec![ProofType::BatchUpdate],
circuits: vec![ProofType::BatchUpdateTest],
},
)
.await;
Expand Down Expand Up @@ -169,7 +169,7 @@ async fn prove_batch_update() {
false,
ProverConfig {
run_mode: None,
circuits: vec![ProofType::BatchUpdate],
circuits: vec![ProofType::BatchUpdateTest],
},
)
.await;
Expand Down Expand Up @@ -221,102 +221,81 @@ async fn prove_batch_update() {
.send()
.await
.expect("Failed to execute request.");
assert!(response_result.status().is_success());

let status = response_result.status();
let body = response_result.text().await.unwrap();
assert!(
status.is_success(),
"Batch append proof generation failed. Status: {}, Body: {}",
status,
body
);
}
}

#[serial]
#[tokio::test]
async fn prove_batch_append() {
init_logger();
println!("spawning prover");
spawn_prover(
true,
ProverConfig {
run_mode: None,
circuits: vec![ProofType::BatchAppend],
circuits: vec![ProofType::BatchAppendTest],
},
)
.await;
println!("prover spawned");

const HEIGHT: usize = 26;
const CANOPY: usize = 0;
let num_insertions = 10;
let tx_hash = [0u8; 32];

info!("initializing merkle tree for update.");
let mut merkle_tree = MerkleTree::<Poseidon>::new(HEIGHT, CANOPY);
// Do multiple rounds of batch appends
for _ in 0..2 {
info!("initializing merkle tree for append.");
let merkle_tree = MerkleTree::<Poseidon>::new(HEIGHT, CANOPY);

let old_subtrees = merkle_tree.get_subtrees();
let mut leaves = vec![];
let mut nullifiers = vec![];

// Create leaves for this batch append
for i in 0..num_insertions {
let mut bn: [u8; 32] = [0; 32];
bn[31] = i as u8;
let leaf: [u8; 32] = Poseidon::hash(&bn).unwrap();
leaves.push(leaf);
merkle_tree.append(&leaf).unwrap();
let nullifier = Poseidon::hashv(&[&leaf, &tx_hash]).unwrap();
nullifiers.push(nullifier);
}

let mut merkle_proofs = vec![];
let mut path_indices = vec![];
for index in 0..leaves.len() {
let proof = merkle_tree.get_proof_of_leaf(index, true).unwrap();
merkle_proofs.push(proof.to_vec());
path_indices.push(index as u32);
}
let root = merkle_tree.root();
let leaves_hashchain = calculate_hash_chain(&nullifiers);
let inputs = get_batch_update_inputs::<HEIGHT>(
root,
vec![tx_hash; num_insertions],
let leaves_hashchain = calculate_hash_chain(&leaves);

// Generate inputs for batch append operation
let inputs = get_batch_append_inputs::<HEIGHT>(
merkle_tree.layers[0].len(),
old_subtrees.try_into().unwrap(),
leaves,
leaves_hashchain,
merkle_proofs,
path_indices,
num_insertions as u32,
);
let client = Client::new();
let inputs = update_inputs_string(&inputs);

// Send proof request to the server
let client = Client::new();
let inputs = append_inputs_string(&inputs);
let response_result = client
.post(&format!("{}{}", SERVER_ADDRESS, PROVE_PATH))
.header("Content-Type", "text/plain; charset=utf-8")
.body(inputs)
.send()
.await
.expect("Failed to execute request.");
assert!(response_result.status().is_success());
}

let num_insertions = 10;

info!("initializing merkle tree for append.");
let merkle_tree = MerkleTree::<Poseidon>::new(HEIGHT, CANOPY);

let old_subtrees = merkle_tree.get_subtrees();
let mut leaves = vec![];
for i in 0..num_insertions {
let mut bn: [u8; 32] = [0; 32];
bn[31] = i as u8;
let leaf: [u8; 32] = Poseidon::hash(&bn).unwrap();
leaves.push(leaf);
let status = response_result.status();
let body = response_result.text().await.unwrap();
assert!(
status.is_success(),
"Batch append proof generation failed. Status: {}, Body: {}",
status,
body
);
}

let leaves_hashchain = calculate_hash_chain(&leaves);
let inputs = get_batch_append_inputs::<HEIGHT>(
merkle_tree.layers[0].len(),
old_subtrees.try_into().unwrap(),
leaves,
leaves_hashchain,
);
let client = Client::new();
let inputs = append_inputs_string(&inputs);
let response_result = client
.post(&format!("{}{}", SERVER_ADDRESS, PROVE_PATH))
.header("Content-Type", "text/plain; charset=utf-8")
.body(inputs)
.send()
.await
.expect("Failed to execute request.");
assert!(response_result.status().is_success());
}
2 changes: 1 addition & 1 deletion cli/src/utils/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export async function waitForServers(
({ port, path }) => `http-get://127.0.0.1:${port}${path}`,
),
delay: 1000,
timeout: 25000,
timeout: 360_000,
interval: 300,
simultaneous: 2,
validateStatus: function (status: number) {
Expand Down
6 changes: 3 additions & 3 deletions programs/account-compression/src/state/batched_merkle_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ mod tests {
true,
ProverConfig {
run_mode: None,
circuits: vec![ProofType::BatchAppend, ProofType::BatchUpdate],
circuits: vec![ProofType::BatchAppendTest, ProofType::BatchUpdateTest],
},
)
.await;
Expand Down Expand Up @@ -1301,7 +1301,7 @@ mod tests {
false,
ProverConfig {
run_mode: None,
circuits: vec![ProofType::BatchAppend, ProofType::BatchUpdate],
circuits: vec![ProofType::BatchAppendTest, ProofType::BatchUpdateTest],
},
)
.await;
Expand Down Expand Up @@ -1801,7 +1801,7 @@ mod tests {
false,
ProverConfig {
run_mode: None,
circuits: vec![ProofType::BatchAppend, ProofType::BatchUpdate],
circuits: vec![ProofType::BatchAppendTest, ProofType::BatchUpdateTest],
},
)
.await;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ async fn test_init_state_merkle_tree() {
false,
ProverConfig {
run_mode: None,
circuits: vec![ProofType::BatchAppend, ProofType::BatchUpdate],
circuits: vec![ProofType::BatchAppendTest, ProofType::BatchUpdateTest],
},
)
.await;
Expand Down

0 comments on commit d700441

Please sign in to comment.