Skip to content

Commit

Permalink
validation: fix excessive validation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Dec 25, 2023
1 parent 234a16f commit 1b4fbcd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/validation/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ pub enum Failure {
/// {1}. Details: {2}
SealsInvalid(BundleId, Txid, String),
/// single-use seals for the operation {0} were not validated, which
/// probably indicateds unanchored state transition.
/// probably indicates unanchored state transition.
SealsUnvalidated(OpId),
/// transition bundle {0} is not properly anchored to the witness
/// transaction {1}. Details: {2}
Expand Down
16 changes: 9 additions & 7 deletions src/validation/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ use super::status::{Failure, Warning};
use super::{CheckedConsignment, ConsignmentApi, Status, Validity, VirtualMachine};
use crate::vm::AluRuntime;
use crate::{
AltLayer1, AnchorSet, BundleId, ContractId, Layer1, OpId, OpRef, Operation, Opout, Schema,
SchemaId, SchemaRoot, Script, SubSchema, Transition, TransitionBundle, TypedAssigns, WitnessId,
XAnchor,
AltLayer1, AnchorSet, BundleId, ContractId, Layer1, OpId, OpRef, OpType, Operation, Opout,
Schema, SchemaId, SchemaRoot, Script, SubSchema, Transition, TransitionBundle, TypedAssigns,
WitnessId, XAnchor,
};

#[derive(Clone, Debug, Display, Error, From)]
Expand Down Expand Up @@ -243,13 +243,15 @@ impl<'consignment, 'resolver, C: ConsignmentApi, R: ResolveTx>
continue;
}

if !self.validated_op_seals.contains(&opid) {
if !self.validated_op_seals.contains(&opid) &&
operation.op_type() == OpType::StateTransition
{
self.status.add_failure(Failure::SealsUnvalidated(opid));
}
// [VALIDATION]: Verify operation against the schema and scripts
self.status += schema.validate_state(&self.consignment, operation, self.vm.as_ref());
if !self.validated_op_state.insert(opid) {
self.status.add_failure(Failure::CyclicGraph(opid));
if self.validated_op_state.insert(opid) {
self.status +=
schema.validate_state(&self.consignment, operation, self.vm.as_ref());
}

match operation {
Expand Down

0 comments on commit 1b4fbcd

Please sign in to comment.