Refactor handling of prd update

This commit is contained in:
NicolasCantu 2025-03-04 14:47:50 +01:00
parent bac3e68400
commit 8d2c34b13b

View File

@ -878,26 +878,13 @@ fn handle_prd(
let commited_in = relevant_process.get_process_tip()?; let commited_in = relevant_process.get_process_tip()?;
// Extract the roles from the payload
let proposal_roles: BTreeMap<String, RoleDefinition> = serde_json::from_str(&prd.payload)?;
// TODO: check that the role in the prd has the right commitment
// TODO: now that roles is not part of the pcd anymore, we need to think of a way to secure it
// Take the roles from the last validated state
let mut roles = if let Some(last_state) = relevant_process.get_latest_commited_state() {
last_state.roles.clone()
} else {
// We don't have commited state yet, let's take the current roles
proposal_roles
};
let new_state = ProcessState { let new_state = ProcessState {
commited_in, commited_in,
pcd_commitment: prd.pcd_commitments, pcd_commitment: prd.pcd_commitments,
state_id: update_merkle_root.clone(), state_id: update_merkle_root.clone(),
keys: prd.keys, keys: prd.keys,
roles, roles: prd.roles,
public_data: prd.public_data,
..Default::default() ..Default::default()
}; };