@@ -71,6 +71,7 @@ use commonware_codec::{
7171 Encode , EncodeSize , Error as CodecError , RangeCfg , Read , ReadExt as _, Write ,
7272} ;
7373use commonware_cryptography:: { Digest , Hasher } ;
74+ use commonware_parallel:: Strategy ;
7475use commonware_runtime:: { Buf , BufMut , Clock , Metrics , Storage } ;
7576use commonware_utils:: { sync:: AsyncRwLock , Array } ;
7677use std:: { future:: Future , num:: NonZeroU64 , sync:: Arc } ;
@@ -401,12 +402,13 @@ where
401402// historical tip proof and current frontier pins from the full source.
402403macro_rules! impl_compact_resolver_keyless {
403404 ( $db: ident, $op: ident, $val_bound: ident) => {
404- impl <F , E , V , H > Resolver for Arc <$db<F , E , V , H >>
405+ impl <F , E , V , H , S > Resolver for Arc <$db<F , E , V , H , S >>
405406 where
406407 F : Family ,
407408 E : crate :: Context ,
408409 V : $val_bound + Send + Sync + ' static ,
409410 H : Hasher ,
411+ S : Strategy ,
410412 {
411413 type Family = F ;
412414 type Digest = H :: Digest ;
@@ -438,12 +440,13 @@ macro_rules! impl_compact_resolver_keyless {
438440 }
439441 }
440442
441- impl <F , E , V , H > Resolver for Arc <AsyncRwLock <$db<F , E , V , H >>>
443+ impl <F , E , V , H , S > Resolver for Arc <AsyncRwLock <$db<F , E , V , H , S >>>
442444 where
443445 F : Family ,
444446 E : crate :: Context ,
445447 V : $val_bound + Send + Sync + ' static ,
446448 H : Hasher ,
449+ S : Strategy ,
447450 {
448451 type Family = F ;
449452 type Digest = H :: Digest ;
@@ -476,12 +479,13 @@ macro_rules! impl_compact_resolver_keyless {
476479 }
477480 }
478481
479- impl <F , E , V , H > Resolver for Arc <AsyncRwLock <Option <$db<F , E , V , H >>>>
482+ impl <F , E , V , H , S > Resolver for Arc <AsyncRwLock <Option <$db<F , E , V , H , S >>>>
480483 where
481484 F : Family ,
482485 E : crate :: Context ,
483486 V : $val_bound + Send + Sync + ' static ,
484487 H : Hasher ,
488+ S : Strategy ,
485489 {
486490 type Family = F ;
487491 type Digest = H :: Digest ;
@@ -521,7 +525,7 @@ macro_rules! impl_compact_resolver_keyless {
521525// translator parameters carried by immutable variants.
522526macro_rules! impl_compact_resolver_immutable {
523527 ( $db: ident, $op: ident, $val_bound: ident, $key_bound: path) => {
524- impl <F , E , K , V , H , T > Resolver for Arc <$db<F , E , K , V , H , T >>
528+ impl <F , E , K , V , H , T , S > Resolver for Arc <$db<F , E , K , V , H , T , S >>
525529 where
526530 F : Family ,
527531 E : crate :: Context ,
@@ -530,6 +534,7 @@ macro_rules! impl_compact_resolver_immutable {
530534 H : Hasher ,
531535 T : Translator + Send + Sync + ' static ,
532536 T :: Key : Send + Sync ,
537+ S : Strategy ,
533538 {
534539 type Family = F ;
535540 type Digest = H :: Digest ;
@@ -561,7 +566,7 @@ macro_rules! impl_compact_resolver_immutable {
561566 }
562567 }
563568
564- impl <F , E , K , V , H , T > Resolver for Arc <AsyncRwLock <$db<F , E , K , V , H , T >>>
569+ impl <F , E , K , V , H , T , S > Resolver for Arc <AsyncRwLock <$db<F , E , K , V , H , T , S >>>
565570 where
566571 F : Family ,
567572 E : crate :: Context ,
@@ -570,6 +575,7 @@ macro_rules! impl_compact_resolver_immutable {
570575 H : Hasher ,
571576 T : Translator + Send + Sync + ' static ,
572577 T :: Key : Send + Sync ,
578+ S : Strategy ,
573579 {
574580 type Family = F ;
575581 type Digest = H :: Digest ;
@@ -602,7 +608,7 @@ macro_rules! impl_compact_resolver_immutable {
602608 }
603609 }
604610
605- impl <F , E , K , V , H , T > Resolver for Arc <AsyncRwLock <Option <$db<F , E , K , V , H , T >>>>
611+ impl <F , E , K , V , H , T , S > Resolver for Arc <AsyncRwLock <Option <$db<F , E , K , V , H , T , S >>>>
606612 where
607613 F : Family ,
608614 E : crate :: Context ,
@@ -611,6 +617,7 @@ macro_rules! impl_compact_resolver_immutable {
611617 H : Hasher ,
612618 T : Translator + Send + Sync + ' static ,
613619 T :: Key : Send + Sync ,
620+ S : Strategy ,
614621 {
615622 type Family = F ;
616623 type Digest = H :: Digest ;
@@ -650,14 +657,15 @@ macro_rules! impl_compact_resolver_immutable {
650657// is just a target check over the current witness rather than reconstructing anything from history.
651658macro_rules! impl_compact_resolver_compact_keyless {
652659 ( $db: ident, $op: ident) => {
653- impl <F , E , V , H , C > Resolver for Arc <$db<F , E , V , H , C >>
660+ impl <F , E , V , H , C , S > Resolver for Arc <$db<F , E , V , H , C , S >>
654661 where
655662 F : Family ,
656663 E : crate :: Context ,
657664 V : ValueEncoding + Send + Sync + ' static ,
658665 H : Hasher ,
659666 $op<F , V >: Encode + Read <Cfg = C >,
660667 C : Clone + Send + Sync + ' static ,
668+ S : Strategy ,
661669 {
662670 type Family = F ;
663671 type Digest = H :: Digest ;
@@ -672,14 +680,15 @@ macro_rules! impl_compact_resolver_compact_keyless {
672680 }
673681 }
674682
675- impl <F , E , V , H , C > Resolver for Arc <AsyncRwLock <$db<F , E , V , H , C >>>
683+ impl <F , E , V , H , C , S > Resolver for Arc <AsyncRwLock <$db<F , E , V , H , C , S >>>
676684 where
677685 F : Family ,
678686 E : crate :: Context ,
679687 V : ValueEncoding + Send + Sync + ' static ,
680688 H : Hasher ,
681689 $op<F , V >: Encode + Read <Cfg = C >,
682690 C : Clone + Send + Sync + ' static ,
691+ S : Strategy ,
683692 {
684693 type Family = F ;
685694 type Digest = H :: Digest ;
@@ -695,14 +704,15 @@ macro_rules! impl_compact_resolver_compact_keyless {
695704 }
696705 }
697706
698- impl <F , E , V , H , C > Resolver for Arc <AsyncRwLock <Option <$db<F , E , V , H , C >>>>
707+ impl <F , E , V , H , C , S > Resolver for Arc <AsyncRwLock <Option <$db<F , E , V , H , C , S >>>>
699708 where
700709 F : Family ,
701710 E : crate :: Context ,
702711 V : ValueEncoding + Send + Sync + ' static ,
703712 H : Hasher ,
704713 $op<F , V >: Encode + Read <Cfg = C >,
705714 C : Clone + Send + Sync + ' static ,
715+ S : Strategy ,
706716 {
707717 type Family = F ;
708718 type Digest = H :: Digest ;
@@ -725,7 +735,7 @@ macro_rules! impl_compact_resolver_compact_keyless {
725735// persisted witness directly instead of rebuilding it from a full operation log.
726736macro_rules! impl_compact_resolver_compact_immutable {
727737 ( $db: ident, $op: ident) => {
728- impl <F , E , K , V , H , C > Resolver for Arc <$db<F , E , K , V , H , C >>
738+ impl <F , E , K , V , H , C , S > Resolver for Arc <$db<F , E , K , V , H , C , S >>
729739 where
730740 F : Family ,
731741 E : crate :: Context ,
@@ -734,6 +744,7 @@ macro_rules! impl_compact_resolver_compact_immutable {
734744 H : Hasher ,
735745 $op<F , K , V >: Encode + Read <Cfg = C >,
736746 C : Clone + Send + Sync + ' static ,
747+ S : Strategy ,
737748 {
738749 type Family = F ;
739750 type Digest = H :: Digest ;
@@ -748,7 +759,7 @@ macro_rules! impl_compact_resolver_compact_immutable {
748759 }
749760 }
750761
751- impl <F , E , K , V , H , C > Resolver for Arc <AsyncRwLock <$db<F , E , K , V , H , C >>>
762+ impl <F , E , K , V , H , C , S > Resolver for Arc <AsyncRwLock <$db<F , E , K , V , H , C , S >>>
752763 where
753764 F : Family ,
754765 E : crate :: Context ,
@@ -757,6 +768,7 @@ macro_rules! impl_compact_resolver_compact_immutable {
757768 H : Hasher ,
758769 $op<F , K , V >: Encode + Read <Cfg = C >,
759770 C : Clone + Send + Sync + ' static ,
771+ S : Strategy ,
760772 {
761773 type Family = F ;
762774 type Digest = H :: Digest ;
@@ -772,7 +784,7 @@ macro_rules! impl_compact_resolver_compact_immutable {
772784 }
773785 }
774786
775- impl <F , E , K , V , H , C > Resolver for Arc <AsyncRwLock <Option <$db<F , E , K , V , H , C >>>>
787+ impl <F , E , K , V , H , C , S > Resolver for Arc <AsyncRwLock <Option <$db<F , E , K , V , H , C , S >>>>
776788 where
777789 F : Family ,
778790 E : crate :: Context ,
@@ -781,6 +793,7 @@ macro_rules! impl_compact_resolver_compact_immutable {
781793 H : Hasher ,
782794 $op<F , K , V >: Encode + Read <Cfg = C >,
783795 C : Clone + Send + Sync + ' static ,
796+ S : Strategy ,
784797 {
785798 type Family = F ;
786799 type Digest = H :: Digest ;
@@ -811,8 +824,63 @@ impl_compact_resolver_immutable!(ImmutableVariableDb, ImmutableVariableOp, Varia
811824mod tests {
812825 use super :: Target ;
813826 use crate :: merkle:: mmr;
814- use commonware_codec:: { DecodeExt as _, Encode as _} ;
827+ use commonware_codec:: { DecodeExt as _, Encode as _, RangeCfg } ;
815828 use commonware_cryptography:: { sha256:: Digest , Hasher as _} ;
829+ use commonware_parallel:: Rayon ;
830+ use commonware_runtime:: deterministic;
831+ use commonware_utils:: sync:: AsyncRwLock ;
832+ use std:: sync:: Arc ;
833+
834+ macro_rules! assert_resolver_variants {
835+ ( $db: ty) => {
836+ assert_resolver:: <Arc <$db>>( ) ;
837+ assert_resolver:: <Arc <AsyncRwLock <$db>>>( ) ;
838+ assert_resolver:: <Arc <AsyncRwLock <Option <$db>>>>( ) ;
839+ } ;
840+ }
841+
842+ fn assert_resolver < R : super :: Resolver > ( ) { }
843+
844+ #[ test]
845+ fn test_all_compact_qmdb_variants_implement_strategy_resolvers ( ) {
846+ type KeylessFixedCompactDb = crate :: qmdb:: keyless:: fixed:: CompactDb <
847+ mmr:: Family ,
848+ deterministic:: Context ,
849+ Digest ,
850+ commonware_cryptography:: Sha256 ,
851+ Rayon ,
852+ > ;
853+ type KeylessVariableCompactDb = crate :: qmdb:: keyless:: variable:: CompactDb <
854+ mmr:: Family ,
855+ deterministic:: Context ,
856+ Vec < u8 > ,
857+ commonware_cryptography:: Sha256 ,
858+ ( RangeCfg < usize > , ( ) ) ,
859+ Rayon ,
860+ > ;
861+ type ImmutableFixedCompactDb = crate :: qmdb:: immutable:: fixed:: CompactDb <
862+ mmr:: Family ,
863+ deterministic:: Context ,
864+ Digest ,
865+ Digest ,
866+ commonware_cryptography:: Sha256 ,
867+ Rayon ,
868+ > ;
869+ type ImmutableVariableCompactDb = crate :: qmdb:: immutable:: variable:: CompactDb <
870+ mmr:: Family ,
871+ deterministic:: Context ,
872+ Digest ,
873+ Vec < u8 > ,
874+ commonware_cryptography:: Sha256 ,
875+ ( ( ) , ( RangeCfg < usize > , ( ) ) ) ,
876+ Rayon ,
877+ > ;
878+
879+ assert_resolver_variants ! ( KeylessFixedCompactDb ) ;
880+ assert_resolver_variants ! ( KeylessVariableCompactDb ) ;
881+ assert_resolver_variants ! ( ImmutableFixedCompactDb ) ;
882+ assert_resolver_variants ! ( ImmutableVariableCompactDb ) ;
883+ }
816884
817885 #[ test]
818886 fn test_target_decode_rejects_zero_leaf_count ( ) {
0 commit comments