From 3263dfc5e5a7449d2582d9813f32c77f2fd2ed94 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Wed, 31 Jul 2024 22:04:30 +0200 Subject: [PATCH] persistence: fix ordering of state extensions --- src/containers/consignment.rs | 2 ++ src/persistence/state.rs | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/containers/consignment.rs b/src/containers/consignment.rs index 3d149f3c..03cf2f13 100644 --- a/src/containers/consignment.rs +++ b/src/containers/consignment.rs @@ -383,6 +383,8 @@ impl Consignment { } // TODO: check attach ids from data containers are present in operations // TODO: validate sigs and remove untrusted + // TODO: Check that all extensions present in the consignment are used by state + // transitions if validity != Validity::Valid { Err((status, self)) diff --git a/src/persistence/state.rs b/src/persistence/state.rs index a77cc30d..319fe8d6 100644 --- a/src/persistence/state.rs +++ b/src/persistence/state.rs @@ -178,8 +178,7 @@ impl State

{ if input.prev_out.op == *id { *used = true; if let Some((_, witness_ord2)) = ordered_extensions.get_mut(id) { - // TODO: Double-check this ordering - if *witness_ord2 > witness_ord { + if *witness_ord2 < witness_ord { *witness_ord2 = witness_ord; } } else { @@ -197,7 +196,9 @@ impl State

{ .add_extension(extension, *witness_id, *witness_ord) .map_err(StateError::WriteProvider)?; } - // TODO: Do something otherwise + // Otherwise consignment includes state extensions which are not + // used in transaction graph. This must not be the case for the + // validated consignments. } Ok(())