mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-09 14:48:08 -05:00
runtime/smt: return early with SUCCESS (but give a warning) if the nullifiers list for changing the tree is empty.
This commit is contained in:
@@ -24,7 +24,7 @@ use darkfi_sdk::crypto::{
|
|||||||
};
|
};
|
||||||
use darkfi_serial::Decodable;
|
use darkfi_serial::Decodable;
|
||||||
use halo2_proofs::pasta::pallas;
|
use halo2_proofs::pasta::pallas;
|
||||||
use log::error;
|
use log::{error, warn};
|
||||||
use num_bigint::BigUint;
|
use num_bigint::BigUint;
|
||||||
use wasmer::{FunctionEnvMut, WasmPtr};
|
use wasmer::{FunctionEnvMut, WasmPtr};
|
||||||
|
|
||||||
@@ -158,6 +158,15 @@ pub(crate) fn sparse_merkle_insert_batch(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Nothing to do so just return here
|
||||||
|
if nullifiers.is_empty() {
|
||||||
|
warn!(
|
||||||
|
target: "runtime::smt::sparse_merkle_insert_batch",
|
||||||
|
"[WASM] [{}] sparse_merkle_insert_batch(): Nothing to add! Returning.", cid
|
||||||
|
);
|
||||||
|
return darkfi_sdk::entrypoint::SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure we've read the entire buffer
|
// Make sure we've read the entire buffer
|
||||||
if buf_reader.position() != (len as u64) {
|
if buf_reader.position() != (len as u64) {
|
||||||
error!(
|
error!(
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ fn zkvm_smt() -> Result<()> {
|
|||||||
// Use the leaf value as its position in the SMT
|
// Use the leaf value as its position in the SMT
|
||||||
// Therefore we need an additional constraint that leaf == pos
|
// Therefore we need an additional constraint that leaf == pos
|
||||||
let leaves: Vec<_> = leaves.into_iter().map(|l| (l, l)).collect();
|
let leaves: Vec<_> = leaves.into_iter().map(|l| (l, l)).collect();
|
||||||
smt.insert_batch(leaves.clone());
|
smt.insert_batch(leaves.clone()).unwrap();
|
||||||
|
|
||||||
let (pos, leaf) = leaves[2];
|
let (pos, leaf) = leaves[2];
|
||||||
assert_eq!(pos, leaf);
|
assert_eq!(pos, leaf);
|
||||||
|
|||||||
Reference in New Issue
Block a user