Skip to content

Commit

Permalink
chore: add safety bails on the protocol implementation (#273)
Browse files Browse the repository at this point in the history
Bailing is important so it doesn't look like everything was fine,
resulting on useless Lurk data being persisted.
  • Loading branch information
arthurpaulino authored Aug 30, 2024
1 parent 983e226 commit 03b1a45
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/lurk/cli/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,9 @@ impl<H: Chipset<F>> MetaCmd<F, H> {
let path_str = repl.zstore.fetch_string(path);

let (protocol, _) = repl.reduce_aux(&protocol_expr)?;
if protocol.tag == Tag::Err {
bail!("Error when evaluating the protocol");
}
let (vars_vec, &body) = Self::get_vars_vec_and_body(repl, &protocol)?;
let vars_vec = copy_inner(vars_vec);

Expand All @@ -953,7 +956,11 @@ impl<H: Chipset<F>> MetaCmd<F, H> {
let args_vec = copy_inner(args_vec);
let mut args_vec_reduced = Vec::with_capacity(args_vec.len());
for arg in args_vec.iter() {
args_vec_reduced.push(repl.reduce_aux(arg)?.0);
let (arg_reduced, _) = repl.reduce_aux(arg)?;
if arg_reduced.tag == Tag::Err {
bail!("Error when evaluating a protocol argument");
}
args_vec_reduced.push(arg_reduced);
}

let (&claim, &post_verify_predicate) = Self::get_claim_and_post_verify_predicade(
Expand Down Expand Up @@ -1008,6 +1015,9 @@ impl<H: Chipset<F>> MetaCmd<F, H> {
let path_str = repl.zstore.fetch_string(path);

let (protocol, _) = repl.reduce_aux(&protocol_expr)?;
if protocol.tag == Tag::Err {
bail!("Error when evaluating the protocol");
}
let (vars_vec, &body) = Self::get_vars_vec_and_body(repl, &protocol)?;
let vars_vec = copy_inner(vars_vec);

Expand Down

0 comments on commit 03b1a45

Please sign in to comment.