Replace new_state_merkle_root with state_id in UserDiff

This commit is contained in:
NicolasCantu 2025-01-15 14:38:32 +01:00
parent 7d0aa89387
commit 6d82333a49
2 changed files with 5 additions and 5 deletions

View File

@ -91,7 +91,7 @@ pub enum DiffStatus {
#[allow(non_camel_case_types)]
pub struct UserDiff {
pub process_id: String,
pub new_state_merkle_root: String, // TODO add a merkle proof that the new_value belongs to that state
pub state_id: String, // TODO add a merkle proof that the new_value belongs to that state
pub value_commitment: String,
pub field: String,
pub description: Option<String>,
@ -734,7 +734,7 @@ fn create_diffs(process: &Process, new_state: &ProcessState) -> AnyhowResult<Vec
let previous_value = clear_prev_state.get(field.as_str()).unwrap().clone();
diffs.push(UserDiff {
process_id: process_id.clone(),
new_state_merkle_root: new_state_root.to_owned(),
state_id: new_state_root.to_owned(),
value_commitment: new_hash.as_str().unwrap().to_string(),
field: field.to_owned(),
description,
@ -758,7 +758,7 @@ fn create_diffs(process: &Process, new_state: &ProcessState) -> AnyhowResult<Vec
let need_validation = if (is_pairing && field.as_str() == "roles" && new_value != Value::Null) || fields_to_validate.contains(field) { true } else { false };
diffs.push(UserDiff {
process_id: process_id.clone(),
new_state_merkle_root: new_state_root.to_owned(),
state_id: new_state_root.to_owned(),
value_commitment: hash.as_str().unwrap().to_string(),
field: field.to_owned(),
description,

View File

@ -188,7 +188,7 @@ fn test_pairing() {
// Alice keeps track of the change she needs to validate
let create_process_diffs = updated_process.new_diffs;
let new_state_id = &create_process_diffs.get(0).unwrap().new_state_merkle_root;
let new_state_id = &create_process_diffs.get(0).unwrap().state_id;
alice_diff_cache.extend(create_process_diffs.iter());
@ -235,7 +235,7 @@ fn test_pairing() {
let state = process.get_state_for_id(&new_state_id).unwrap();
let hash2values: Map<String, Value> = bob_diff_cache.iter()
.filter(|diff| diff.new_state_merkle_root == *new_state_id)
.filter(|diff| diff.state_id == *new_state_id)
.map(|diff| {
let encrypted_value = state.encrypted_pcd.as_object().unwrap().get(&diff.field).unwrap();
(diff.value_commitment.clone(), encrypted_value.clone())