Frontend: simplify custom predicates interfaces (#83)

* add comments detailing logic, migrate middleware::custom::tests to frontend::custom

* simplify custom predicate's frontend interfaces, making it less verbose to define Statement Template arguments

The main idea is that when defining the arguments at a statement
template, it can be done from 3 different inputs:
i. `(&str, literal)`: this is to set a POD and a field, ie. `(POD, literal("field")`)
ii. `(&str, &str)`: this is to define a origin-key wildcard pair, ie. `(src_origin, src_dest)`
iii. `Value`: this is to define a literal value, ie. `0`
This commit is contained in:
arnaucube 2025-02-25 05:15:08 +01:00 committed by GitHub
parent d3bc892906
commit 538353a701
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 351 additions and 273 deletions

View file

@ -115,6 +115,11 @@ fn fill_pad<T: Clone>(v: &mut Vec<T>, pad_value: T, len: usize) {
}
}
/// Inputs are sorted as:
/// - SignedPods
/// - MainPods
/// - private Statements
/// - public Statements
impl MockMainPod {
fn offset_input_signed_pods(&self) -> usize {
0
@ -136,6 +141,8 @@ impl MockMainPod {
fill_pad(&mut op.1, OperationArg::None, params.max_operation_args)
}
/// Returns the statements from the given MainPodInputs, padding to the
/// respective max lengths defined at the given Params.
fn layout_statements(params: &Params, inputs: &MainPodInputs) -> Vec<Statement> {
let mut statements = Vec::new();
@ -259,8 +266,10 @@ impl MockMainPod {
Ok(operations)
}
// NOTE: In this implementation public statements are always copies from previous statements,
// so we fill in the operations accordingly.
// NOTE: In this implementation public statements are always copies from
// previous statements, so we fill in the operations accordingly.
/// This method assumes that the given `statements` array has been padded to
/// `params.max_statements`.
fn process_public_statements_operations(
params: &Params,
statements: &[Statement],