essential_check::solution

Function check_predicates

source
pub async fn check_predicates<SA, SB>(
    pre_state: &SA,
    post_state: &SB,
    solution: Arc<Solution>,
    get_predicate: impl Fn(&PredicateAddress) -> Arc<Predicate>,
    config: Arc<CheckPredicateConfig>,
) -> Result<Gas, PredicatesError<SA::Error>>
where SA: Clone + StateRead + Send + Sync + 'static, SB: Clone + StateRead<Error = SA::Error> + Send + Sync + 'static, SA::Future: Send, SB::Future: Send, SA::Error: Send,
Expand description

Checks all of a solution’s SolutionData against its associated predicates.

For each of the solution’s data elements, a single task is spawned that reads the pre and post state slots for the associated predicate with access to the given pre_state and post_state, then checks all constraints over the resulting pre and post state slots.

NOTE: This assumes that the given Solution and all Predicates have already been independently validated using solution::check and predicate::check respectively.

§Arguments

  • pre_state must provide access to state prior to mutations being applied.
  • post_state must provide access to state post mutations being applied.
  • get_predicate provides immediate access to a predicate associated with the given solution. Calls to predicate must complete immediately. All necessary predicates are assumed to have been read from storage and validated ahead of time.

Returns the total gas spent.