Skip to content

Commit 5adec30

Browse files
committed
Replace eprintln calls with logger
1 parent 59b1fe0 commit 5adec30

File tree

5 files changed

+19
-13
lines changed

5 files changed

+19
-13
lines changed

batcher/Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

operator/mina/lib/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ blake2 = "0.10.6"
3131
once_cell = "1.19.0"
3232
mina_bridge_core = { git = "https://github.com/lambdaclass/mina_bridge", rev = "884f28b834b62133384661fdf73c9db283f68c62" }
3333
bincode = "1.3.3"
34+
log = "0.4.21"
3435

3536
[patch.crates-io]
3637
ark-ff = { git = "https://github.com/lambdaclass/openmina_algebra", branch = "mina_bridge" }

operator/mina/lib/src/lib.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
mod consensus_state;
55
mod verifier_index;
66

7+
use log::error;
78
use mina_bridge_core::proof::state_proof::{MinaStateProof, MinaStatePubInputs};
89

910
use ark_ec::short_weierstrass_jacobian::GroupAffine;
@@ -39,26 +40,26 @@ pub extern "C" fn verify_mina_state_ffi(
3940
pub_input_len: usize,
4041
) -> bool {
4142
let Some(proof_buffer_slice) = proof_buffer.get(..proof_len) else {
42-
eprintln!("Proof length argument is greater than max proof size");
43+
error!("Proof length argument is greater than max proof size");
4344
return false;
4445
};
4546

4647
let Some(pub_input_buffer_slice) = pub_input_buffer.get(..pub_input_len) else {
47-
eprintln!("Public input length argument is greater than max public input size");
48+
error!("Public input length argument is greater than max public input size");
4849
return false;
4950
};
5051

5152
let proof: MinaStateProof = match bincode::deserialize(proof_buffer_slice) {
5253
Ok(proof) => proof,
5354
Err(err) => {
54-
eprintln!("Failed to deserialize state proof: {}", err);
55+
error!("Failed to deserialize state proof: {}", err);
5556
return false;
5657
}
5758
};
5859
let pub_inputs: MinaStatePubInputs = match bincode::deserialize(pub_input_buffer_slice) {
5960
Ok(pub_inputs) => pub_inputs,
6061
Err(err) => {
61-
eprintln!("Failed to deserialize state pub inputs: {}", err);
62+
error!("Failed to deserialize state pub inputs: {}", err);
6263
return false;
6364
}
6465
};
@@ -68,7 +69,7 @@ pub extern "C" fn verify_mina_state_ffi(
6869
match check_pub_inputs(&proof, &pub_inputs) {
6970
Ok(validated_data) => validated_data,
7071
Err(err) => {
71-
eprintln!("Failed to check pub inputs: {err}");
72+
error!("Failed to check pub inputs: {err}");
7273
return false;
7374
}
7475
};
@@ -77,12 +78,12 @@ pub extern "C" fn verify_mina_state_ffi(
7778
let secure_chain = match select_secure_chain(&candidate_tip_state, &bridge_tip_state) {
7879
Ok(res) => res,
7980
Err(err) => {
80-
eprintln!("Failed consensus checks for candidate tip: {err}");
81+
error!("Failed consensus checks for candidate tip: {err}");
8182
return false;
8283
}
8384
};
8485
if secure_chain == ChainResult::Bridge {
85-
eprintln!("Failed consensus checks for candidate tip: bridge's tip is more secure");
86+
error!("Failed consensus checks for candidate tip: bridge's tip is more secure");
8687
return false;
8788
}
8889

operator/mina_account/lib/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ sha3 = "0.10.8"
3030
mina_bridge_core = { git = "https://github.com/lambdaclass/mina_bridge", rev = "884f28b834b62133384661fdf73c9db283f68c62" }
3131
bincode = "1.3.3"
3232
alloy = { version = "0.3.3", features = ["full"] }
33+
log = "0.4.21"
3334

3435
[patch.crates-io]
3536
ark-ff = { git = "https://github.com/lambdaclass/openmina_algebra", branch = "mina_bridge" }

operator/mina_account/lib/src/lib.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use alloy::sol_types::SolValue;
2+
use log::error;
23
use merkle_verifier::verify_merkle_proof;
34
use mina_bridge_core::{
45
proof::account_proof::{MinaAccountProof, MinaAccountPubInputs},
@@ -20,12 +21,12 @@ pub extern "C" fn verify_account_inclusion_ffi(
2021
pub_input_len: usize,
2122
) -> bool {
2223
let Some(proof_buffer_slice) = proof_buffer.get(..proof_len) else {
23-
eprintln!("Proof length argument is greater than max proof size");
24+
error!("Proof length argument is greater than max proof size");
2425
return false;
2526
};
2627

2728
let Some(pub_input_buffer_slice) = pub_input_buffer.get(..pub_input_len) else {
28-
eprintln!("Public input length argument is greater than max public input size");
29+
error!("Public input length argument is greater than max public input size");
2930
return false;
3031
};
3132

@@ -35,7 +36,7 @@ pub extern "C" fn verify_account_inclusion_ffi(
3536
} = match bincode::deserialize(proof_buffer_slice) {
3637
Ok(proof) => proof,
3738
Err(err) => {
38-
eprintln!("Failed to deserialize account proof: {}", err);
39+
error!("Failed to deserialize account proof: {}", err);
3940
return false;
4041
}
4142
};
@@ -45,21 +46,21 @@ pub extern "C" fn verify_account_inclusion_ffi(
4546
} = match bincode::deserialize(pub_input_buffer_slice) {
4647
Ok(pub_inputs) => pub_inputs,
4748
Err(err) => {
48-
eprintln!("Failed to deserialize account pub inputs: {}", err);
49+
error!("Failed to deserialize account pub inputs: {}", err);
4950
return false;
5051
}
5152
};
5253

5354
let expected_encoded_account = match MinaAccountValidation::Account::try_from(&account) {
5455
Ok(account) => account,
5556
Err(err) => {
56-
eprintln!("Failed to convert Mina account to Solidity struct: {}", err);
57+
error!("Failed to convert Mina account to Solidity struct: {}", err);
5758
return false;
5859
}
5960
}
6061
.abi_encode();
6162
if expected_encoded_account != encoded_account {
62-
eprintln!("ABI encoded account in public inputs doesn't match the account on the proof");
63+
error!("ABI encoded account in public inputs doesn't match the account on the proof");
6364
return false;
6465
}
6566

0 commit comments

Comments
 (0)