From 90c3b4da91273be0102374f3be7d46d2ee214607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Wed, 26 Oct 2022 09:45:41 +0200 Subject: [PATCH 01/41] xor, linear artifacts for groth16 and gm17 --- .../resources/gm17/linear_equation.proof.bytes | Bin 0 -> 192 bytes .../linear_equation.public_input.bytes} | Bin .../resources/gm17/linear_equation.vk.bytes | Bin 0 -> 440 bytes .../benchmarking/resources/gm17/xor.proof.bytes | Bin 0 -> 192 bytes .../resources/{ => gm17}/xor.public_input.bytes | Bin .../src/benchmarking/resources/gm17/xor.vk.bytes | Bin 0 -> 824 bytes .../resources/groth16/linear_equation.proof.bytes | 2 ++ .../groth16/linear_equation.public_input.bytes | Bin 0 -> 8 bytes .../linear_equation.vk.bytes} | Bin .../resources/groth16/xor.proof.bytes | 2 ++ .../resources/groth16/xor.public_input.bytes | Bin 0 -> 264 bytes .../resources/{ => groth16}/xor.vk.bytes | Bin .../resources/linear-equation.proof.bytes | 1 - .../src/benchmarking/resources/xor.proof.bytes | Bin 192 -> 0 bytes 14 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 pallets/snarcos/src/benchmarking/resources/gm17/linear_equation.proof.bytes rename pallets/snarcos/src/benchmarking/resources/{linear-equation.public_input.bytes => gm17/linear_equation.public_input.bytes} (100%) create mode 100644 pallets/snarcos/src/benchmarking/resources/gm17/linear_equation.vk.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/gm17/xor.proof.bytes rename pallets/snarcos/src/benchmarking/resources/{ => gm17}/xor.public_input.bytes (100%) create mode 100644 pallets/snarcos/src/benchmarking/resources/gm17/xor.vk.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/groth16/linear_equation.proof.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/groth16/linear_equation.public_input.bytes rename pallets/snarcos/src/benchmarking/resources/{linear-equation.vk.bytes => groth16/linear_equation.vk.bytes} (100%) create mode 100644 pallets/snarcos/src/benchmarking/resources/groth16/xor.proof.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/groth16/xor.public_input.bytes rename pallets/snarcos/src/benchmarking/resources/{ => groth16}/xor.vk.bytes (100%) delete mode 100644 pallets/snarcos/src/benchmarking/resources/linear-equation.proof.bytes delete mode 100644 pallets/snarcos/src/benchmarking/resources/xor.proof.bytes diff --git a/pallets/snarcos/src/benchmarking/resources/gm17/linear_equation.proof.bytes b/pallets/snarcos/src/benchmarking/resources/gm17/linear_equation.proof.bytes new file mode 100644 index 0000000000000000000000000000000000000000..f749913209a5d98d0e2daeaa49b442211fa62748 GIT binary patch literal 192 zcmV;x06+g>AOJ%A)+#ztRt=!OQzO$ohne5@rQ$dd3sm4AJu~*-6@`0b0)klZWaO#c z*x?m&vQ&ZAO(ixbV(P-ubCe6jE*b3BOe)1Nuh~|9dqe3hw*!vQH^{8aBo;htVoe#f zrag!u2fq6pg+<{i^0gV(f^>$8>Rt2z literal 0 HcmV?d00001 diff --git a/pallets/snarcos/src/benchmarking/resources/linear-equation.public_input.bytes b/pallets/snarcos/src/benchmarking/resources/gm17/linear_equation.public_input.bytes similarity index 100% rename from pallets/snarcos/src/benchmarking/resources/linear-equation.public_input.bytes rename to pallets/snarcos/src/benchmarking/resources/gm17/linear_equation.public_input.bytes diff --git a/pallets/snarcos/src/benchmarking/resources/gm17/linear_equation.vk.bytes b/pallets/snarcos/src/benchmarking/resources/gm17/linear_equation.vk.bytes new file mode 100644 index 0000000000000000000000000000000000000000..a8bccf620b96a66105350b8349aec4f716f924b2 GIT binary patch literal 440 zcmb={mNb)&{k*+V@VoE?<0()0Oirdbgt8q!`u2e*Pr|0Y;CcMUyWb=wN;IGOWIAOk z%ZsbQd-L4aJjttSG076{o~2flxIfTn%foN-txfhk+gaaz{@L%nJDK&PF2lQ=Ja-PE zN?Tz?;r5LmPi7Y*>Bsp@^<+Hp%0e7-})r`uofTM zQtsL@SwWC-)BUd1w@)A0W8php@}aG9kj}gG#Rjh%`6c9a4;rpm=;17;_rabk==fqE z7L^70))m_q?RDPplUd^3^Xyr#pS+#KW9xKuVMxrm1hbTX#J>=6yn8}c7iX1UEcmHN`+>PN64L-!59)6n*VzA6)`pY(Xc2Sa`ElXn&C zXJKPAXHma)wl@dsd{ipH|BCcpk-!s`WQPQfxKSL}x-G>~is)_%^0<^PeV>`^hwN_0 ui}`0yV5dU30xyi@{y8w5iVm=WIM4l6dGaxn?7hicVTy9*^33YGSki literal 0 HcmV?d00001 diff --git a/pallets/snarcos/src/benchmarking/resources/xor.public_input.bytes b/pallets/snarcos/src/benchmarking/resources/gm17/xor.public_input.bytes similarity index 100% rename from pallets/snarcos/src/benchmarking/resources/xor.public_input.bytes rename to pallets/snarcos/src/benchmarking/resources/gm17/xor.public_input.bytes diff --git a/pallets/snarcos/src/benchmarking/resources/gm17/xor.vk.bytes b/pallets/snarcos/src/benchmarking/resources/gm17/xor.vk.bytes new file mode 100644 index 0000000000000000000000000000000000000000..341011ac42daffdf426183c7800fceb62acbd6f6 GIT binary patch literal 824 zcmb={mNb)&{k*+V@VoE?<0()0Oirdbgt8q!`u2e*Pr|0Y;CcMUyWb=wN;IGOWIAOk z%ZsbQd-L4aJjttSG076{o~2flxIfTn%foN-txfhk+gaaz{@L%nJDK&PF2lQ=Ja-PE zN?Tz?;r5LmPi7Y*>Bsp@^<+Hp%0e7-})r`uofTM zQtsL@SwWC-)BUd1w@)A0W8php@}aG9kj}gG#Rjh%`6c9a4;rpm=;17;_rabk==fqE z7L^70))m_q?RDPplUd^3^Xyr#pS+#KW9xKuVMxrm1hbTX$2&F)2d#-q}O|y)*gOdl;Zn4xn+a(!l=OBUEUn3=7Q?S^xoZispXxtX;F3_Cv-}iCMmHoGl-+n!L+N_P?&Xbx~PgX4U)7$^f-a7E5xp3}`zd;B8Td$-%QdI vykxsMAC_|1Up~P1VUA$I(hTpZpZgodg0~!5{P$zA^6Y8LKWbf0DG~$#C7_h1 literal 0 HcmV?d00001 diff --git a/pallets/snarcos/src/benchmarking/resources/groth16/linear_equation.proof.bytes b/pallets/snarcos/src/benchmarking/resources/groth16/linear_equation.proof.bytes new file mode 100644 index 0000000000..7fab114a13 --- /dev/null +++ b/pallets/snarcos/src/benchmarking/resources/groth16/linear_equation.proof.bytes @@ -0,0 +1,2 @@ +~��ES�=z�|�$�0�ԇ��4���K�t���Ndg��ʌ�M7�$��/U3�Ll]1+��Y��_4��.�J�gdS VCV/�& �� +:��2b_�|��XTf�;��N���A�h�h"/�|��o+t����|�� �gIf���� �_;K��(����˛W��(^d{D�eBZy�βm*� �Nh`j=s� \ No newline at end of file diff --git a/pallets/snarcos/src/benchmarking/resources/groth16/linear_equation.public_input.bytes b/pallets/snarcos/src/benchmarking/resources/groth16/linear_equation.public_input.bytes new file mode 100644 index 0000000000000000000000000000000000000000..1b1cb4d44c57c2d7a5122870fa6ac3e62ff7e94e GIT binary patch literal 8 KcmZQzfB*mh2mk>9 literal 0 HcmV?d00001 diff --git a/pallets/snarcos/src/benchmarking/resources/linear-equation.vk.bytes b/pallets/snarcos/src/benchmarking/resources/groth16/linear_equation.vk.bytes similarity index 100% rename from pallets/snarcos/src/benchmarking/resources/linear-equation.vk.bytes rename to pallets/snarcos/src/benchmarking/resources/groth16/linear_equation.vk.bytes diff --git a/pallets/snarcos/src/benchmarking/resources/groth16/xor.proof.bytes b/pallets/snarcos/src/benchmarking/resources/groth16/xor.proof.bytes new file mode 100644 index 0000000000..818eb0cca9 --- /dev/null +++ b/pallets/snarcos/src/benchmarking/resources/groth16/xor.proof.bytes @@ -0,0 +1,2 @@ +��u��u��st|�\CF +ϕ�Y��9�8�� �H�04����BOo@�������5�H�ܜ��_m+_�h��q�k!�~��}%!]y\�ZU���F�?���B��Ȑ�%�e4����\�C� Wָ��E0����8�mU!X%usY#iH%vdGThJ_2leVCK}J>+RnrIcFXh`mO*O&j=^?}Ugz!%W2vCjo0k_?a3CqLTj8RRgoplVJK`Wzb u4MQ Date: Wed, 26 Oct 2022 09:46:53 +0200 Subject: [PATCH 02/41] they will grumble --- pallets/snarcos/src/benchmarking/import.rs | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 pallets/snarcos/src/benchmarking/import.rs diff --git a/pallets/snarcos/src/benchmarking/import.rs b/pallets/snarcos/src/benchmarking/import.rs new file mode 100644 index 0000000000..c847453b07 --- /dev/null +++ b/pallets/snarcos/src/benchmarking/import.rs @@ -0,0 +1,51 @@ +#[macro_export] +macro_rules! get_artifact { + ($(ProvingSystem::)?$system:tt, $(Relation::)?$relation:tt, $(Artifact::)?$artifact:tt $(,)?) => { + include_bytes!(concat!( + "resources/", + $crate::system!($system), + "/", + $crate::relation!($relation), + ".", + $crate::artifact!($artifact), + ".bytes" + )) + .to_vec() + }; +} + +#[macro_export] +macro_rules! system { + (Groth16) => { + "groth16" + }; + (Gm17) => { + "gm17" + }; +} + +#[macro_export] +macro_rules! relation { + (Xor) => { + "xor" + }; + (LinearEquation) => { + "linear_equation" + }; + (MerkleTree) => { + "merkle_tree" + }; +} + +#[macro_export] +macro_rules! artifact { + (VerifyingKey) => { + "vk" + }; + (Proof) => { + "proof" + }; + (PublicInput) => { + "public_input" + }; +} From cd7ddc09afa650c3b5d41ed7fd44ab330fe62359 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Wed, 26 Oct 2022 09:47:06 +0200 Subject: [PATCH 03/41] checkpoint --- pallets/snarcos/src/benchmarking/mod.rs | 31 ++++++++--------------- pallets/snarcos/src/benchmarking/suite.rs | 21 +++++++-------- 2 files changed, 20 insertions(+), 32 deletions(-) diff --git a/pallets/snarcos/src/benchmarking/mod.rs b/pallets/snarcos/src/benchmarking/mod.rs index 7385a2e627..9af69ac928 100644 --- a/pallets/snarcos/src/benchmarking/mod.rs +++ b/pallets/snarcos/src/benchmarking/mod.rs @@ -1,25 +1,16 @@ +mod import; mod suite; -fn xor_vk() -> &'static [u8] { - include_bytes!("resources/xor.vk.bytes") +#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] +enum Relation { + Xor, + LinearEquation, + MerkleTree, } -fn xor_proof() -> &'static [u8] { - include_bytes!("resources/xor.proof.bytes") -} - -fn xor_input() -> &'static [u8] { - include_bytes!("resources/xor.public_input.bytes") -} - -fn linear_vk() -> &'static [u8] { - include_bytes!("resources/linear-equation.vk.bytes") -} - -fn linear_proof() -> &'static [u8] { - include_bytes!("resources/linear-equation.proof.bytes") -} - -fn linear_input() -> &'static [u8] { - include_bytes!("resources/linear-equation.public_input.bytes") +#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] +enum Artifact { + VerifyingKey, + Proof, + PublicInput, } diff --git a/pallets/snarcos/src/benchmarking/suite.rs b/pallets/snarcos/src/benchmarking/suite.rs index 8e1bb8e512..83f2761ad5 100644 --- a/pallets/snarcos/src/benchmarking/suite.rs +++ b/pallets/snarcos/src/benchmarking/suite.rs @@ -2,10 +2,7 @@ use frame_benchmarking::{account, benchmarks, vec}; use frame_support::{traits::Get, BoundedVec}; use frame_system::RawOrigin; -use crate::{ - benchmarking::{linear_input, linear_proof, linear_vk, xor_input, xor_proof, xor_vk}, - *, -}; +use crate::{ProvingSystem::*, *}; const SEED: u32 = 41; @@ -21,9 +18,9 @@ benchmarks! { verify_xor { let caller = account("caller", 0, SEED); - let key = xor_vk().to_vec(); - let proof = xor_proof().to_vec(); - let input = xor_input().to_vec(); + let key = get_artifact!(Groth16, Xor, VerifyingKey); + let proof = get_artifact!(Groth16, Xor, Proof); + let input = get_artifact!(Groth16, Xor, PublicInput); let identifier = [0u8; 4]; let _ = VerificationKeys::::insert( @@ -31,14 +28,14 @@ benchmarks! { BoundedVec::try_from(key).unwrap() ); - } : verify(RawOrigin::Signed(caller), identifier, proof, input, ProvingSystem::Groth16) + } : verify(RawOrigin::Signed(caller), identifier, proof, input, Groth16) verify_linear_equation { let caller = account("caller", 0, SEED); - let key = linear_vk().to_vec(); - let proof = linear_proof().to_vec(); - let input = linear_input().to_vec(); + let key = get_artifact!(Groth16, LinearEquation, VerifyingKey); + let proof = get_artifact!(Groth16, LinearEquation, Proof); + let input = get_artifact!(Groth16, LinearEquation, PublicInput); let identifier = [0u8; 4]; let _ = VerificationKeys::::insert( @@ -46,6 +43,6 @@ benchmarks! { BoundedVec::try_from(key).unwrap() ); - } : verify(RawOrigin::Signed(caller), identifier, proof, input, ProvingSystem::Groth16) + } : verify(RawOrigin::Signed(caller), identifier, proof, input, Groth16) } From f5e9302a594c0591ce152b385d2d219dc7e10689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Wed, 26 Oct 2022 10:05:47 +0200 Subject: [PATCH 04/41] add merkle bytes --- .../resources/gm17/merkle_tree.proof.bytes | 3 +++ .../resources/gm17/merkle_tree.public_input.bytes | Bin 0 -> 296 bytes .../resources/gm17/merkle_tree.vk.bytes | Bin 0 -> 872 bytes .../resources/groth16/merkle_tree.proof.bytes | 3 +++ .../groth16/merkle_tree.public_input.bytes | Bin 0 -> 296 bytes .../resources/groth16/merkle_tree.vk.bytes | Bin 0 -> 824 bytes 6 files changed, 6 insertions(+) create mode 100644 pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree.proof.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree.public_input.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree.vk.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/groth16/merkle_tree.proof.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/groth16/merkle_tree.public_input.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/groth16/merkle_tree.vk.bytes diff --git a/pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree.proof.bytes b/pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree.proof.bytes new file mode 100644 index 0000000000..5e2d5bb0a3 --- /dev/null +++ b/pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree.proof.bytes @@ -0,0 +1,3 @@ +���E ���$�N�ĆL�c�5؍PY�>�T����{")�cvc͘ma5Z������O���é�Y���W +��P8�������zZl��m���X3���=4���"dx[*�覨 �W�VX�~��a�2�Rk�a�q�h)?���L䐤�K:�Оi�8.�� \ No newline at end of file diff --git a/pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree.public_input.bytes b/pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree.public_input.bytes new file mode 100644 index 0000000000000000000000000000000000000000..3059b838d14e467be56f3f9bd476d381d8214fa9 GIT binary patch literal 296 xcmd;NfPliI%RDx{xWcjQ$gYDF?%O4p-pvp!p1puhP5^?|l literal 0 HcmV?d00001 diff --git a/pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree.vk.bytes b/pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree.vk.bytes new file mode 100644 index 0000000000000000000000000000000000000000..1f4383af22f4d164e6692757724b927c2b672230 GIT binary patch literal 872 zcmb={mNb)&{k*+V@VoE?<0()0Oirdbgt8q!`u2e*Pr|0Y;CcMUyWb=wN;IGOWIAOk z%ZsbQd-L4aJjttSG076{o~2flxIfTn%foN-txfhk+gaaz{@L%nJDK&PF2lQ=Ja-PE zN?Tz?;r5LmPi7Y*>Bsp@^<+Hp%0e7-})r`uofTM zQtsL@SwWC-)BUd1w@)A0W8php@}aG9kj}gG#Rjh%`6c9a4;rpm=;17;_rabk==fqE z7L^70))m_q?RDPplUd^3^Xyr#pS+#KW9xKuVMxrm1hbTX9pTUTS>vM08T z3&P7!i?x>RlQ}o*Vo;>Zm-!CAuD$v!SUT1GLEx|ciG~gq_mbo!H+eUhn@CLwN$|>G z>z?vM+(D^mhD)LK*~fOv>Mkvsq3u~$xgx>2CCS|Gpx}h2?d?0u#iDOq4}JBdfbEEh z^7~JBzdzY=M=Zbjd(l}#-SbnXN}QY=aM52@sq*G;=e|Ra`t9clzqx01ZS#wphn9YDF?%O4p-pvp!p1puhP5^?|l literal 0 HcmV?d00001 diff --git a/pallets/snarcos/src/benchmarking/resources/groth16/merkle_tree.vk.bytes b/pallets/snarcos/src/benchmarking/resources/groth16/merkle_tree.vk.bytes new file mode 100644 index 0000000000000000000000000000000000000000..4ddd0e49501220dec72f70dbb637619323541663 GIT binary patch literal 824 zcmV-81IPSTA&U8BfpWEsgGSkf!uVQlkzn3MgjD7IgCy@jc)&4~wwWD`Q&)Fto9Sow z0Q-UMSo@Xqkr5fY1zhfQj*Qxu>^M)KhnTyUHl8@*Qnn1SL$CWH)z5DjmkZ7toQ4eN zyx8`jaJB+_cw4WG5)8wDq77y{fN_BqMwAcJ4sld^oq_oBTQx|PYt%#H98R35#A7KU{K_AZC34^Cxfs&5Gd@KVfe^w#8pyQEG zVy+EYFo?vHIj|LpjyHyc%wl@YToF@GKx84`jYrcHY#9{_0000000009KA?mUM**TCWX3zg zSrf*Adg(jvF9aIY0q~3fHk{pu=4;7F>T!R_4`Dp*RkwpRg%(bs>tZv&#ZCzZe_O)Y zC^^Q~!@kG;N7Z|ZWk8AVPFx_3XgDfMFE?iks?MT^w6qWBRmA*Tk!1)#_+$LMKa}^li`k_GEbA(mSZ6l#uUznca0ZIU-jIvz zC!hiYmq@wzaD(?8K-$G$Wn?JwpUT}9z2O$OMS5AyH_KFZ5Jp1c97E6o{OT3V C1(v}8 literal 0 HcmV?d00001 From dceada3350ee93c8921fda96f5fb7803b9ad215b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Wed, 26 Oct 2022 10:13:06 +0200 Subject: [PATCH 05/41] prepare separate weighting --- pallets/snarcos/src/lib.rs | 7 ++++++- pallets/snarcos/src/weights.rs | 10 ++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pallets/snarcos/src/lib.rs b/pallets/snarcos/src/lib.rs index 7d12ff601d..d4541fc3e0 100644 --- a/pallets/snarcos/src/lib.rs +++ b/pallets/snarcos/src/lib.rs @@ -122,7 +122,12 @@ pub mod pallet { /// system) /// - verifying procedure fails (e.g. incompatible verification key and proof) /// - proof is incorrect - #[pallet::weight(T::WeightInfo::verify())] + #[pallet::weight( + match system { + ProvingSystem::Groth16 => T::WeightInfo::verify_groth16(), + ProvingSystem::Gm17 => T::WeightInfo::verify_gm17(), + } + )] pub fn verify( _origin: OriginFor, verification_key_identifier: VerificationKeyIdentifier, diff --git a/pallets/snarcos/src/weights.rs b/pallets/snarcos/src/weights.rs index 5402bdcaee..873f56c45e 100644 --- a/pallets/snarcos/src/weights.rs +++ b/pallets/snarcos/src/weights.rs @@ -28,7 +28,8 @@ use sp_std::marker::PhantomData; /// Weight functions needed for pallet_snarcos. pub trait WeightInfo { fn store_key(key_length: u32) -> Weight; - fn verify() -> Weight; + fn verify_groth16() -> Weight; + fn verify_gm17() -> Weight; } impl WeightInfo for I { @@ -36,7 +37,12 @@ impl WeightInfo for I { ::store_key(key_length) } - fn verify() -> Weight { + fn verify_groth16() -> Weight { + ::verify_xor() + .max(::verify_linear_equation()) + } + + fn verify_gm17() -> Weight { ::verify_xor() .max(::verify_linear_equation()) } From 11750431b2edb2a8c1f385e69f37ac4e43cd95ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Wed, 26 Oct 2022 10:41:02 +0200 Subject: [PATCH 06/41] simplify caller and identifier --- pallets/snarcos/src/benchmarking/suite.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/pallets/snarcos/src/benchmarking/suite.rs b/pallets/snarcos/src/benchmarking/suite.rs index 83f2761ad5..c7e5d803a2 100644 --- a/pallets/snarcos/src/benchmarking/suite.rs +++ b/pallets/snarcos/src/benchmarking/suite.rs @@ -5,44 +5,41 @@ use frame_system::RawOrigin; use crate::{ProvingSystem::*, *}; const SEED: u32 = 41; +const IDENTIFIER: VerificationKeyIdentifier = [0; 4]; + +fn caller() -> RawOrigin<::AccountId> { + RawOrigin::Signed(account("caller", 0, SEED)) +} benchmarks! { store_key { - let caller = account("caller", 0, SEED); - let identifier = [0u8; 4]; let l in 1 .. T::MaximumVerificationKeyLength::get(); let key = vec![0u8; l as usize]; - } : _(RawOrigin::Signed(caller), identifier, key.clone()) + } : _(caller::(), IDENTIFIER, key) verify_xor { - let caller = account("caller", 0, SEED); - let key = get_artifact!(Groth16, Xor, VerifyingKey); let proof = get_artifact!(Groth16, Xor, Proof); let input = get_artifact!(Groth16, Xor, PublicInput); - let identifier = [0u8; 4]; let _ = VerificationKeys::::insert( - identifier.clone(), + IDENTIFIER, BoundedVec::try_from(key).unwrap() ); - } : verify(RawOrigin::Signed(caller), identifier, proof, input, Groth16) + } : verify(caller::(), IDENTIFIER, proof, input, Groth16) verify_linear_equation { - let caller = account("caller", 0, SEED); - let key = get_artifact!(Groth16, LinearEquation, VerifyingKey); let proof = get_artifact!(Groth16, LinearEquation, Proof); let input = get_artifact!(Groth16, LinearEquation, PublicInput); - let identifier = [0u8; 4]; let _ = VerificationKeys::::insert( - identifier.clone(), + IDENTIFIER, BoundedVec::try_from(key).unwrap() ); - } : verify(RawOrigin::Signed(caller), identifier, proof, input, Groth16) + } : verify(caller::(), IDENTIFIER, proof, input, Groth16) } From 287719d69e697f332a17c9409fb7203f421705d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Wed, 26 Oct 2022 11:00:52 +0200 Subject: [PATCH 07/41] simplify further --- pallets/snarcos/src/benchmarking/import.rs | 19 ++++++++++++++ pallets/snarcos/src/benchmarking/suite.rs | 30 ++++++++-------------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/pallets/snarcos/src/benchmarking/import.rs b/pallets/snarcos/src/benchmarking/import.rs index c847453b07..eca3150023 100644 --- a/pallets/snarcos/src/benchmarking/import.rs +++ b/pallets/snarcos/src/benchmarking/import.rs @@ -1,3 +1,22 @@ +use frame_benchmarking::Vec; + +pub(super) struct Artifacts { + pub key: Vec, + pub proof: Vec, + pub input: Vec, +} + +#[macro_export] +macro_rules! get_artifacts { + ($(ProvingSystem::)?$system:tt, $(Relation::)?$relation:tt $(,)?) => {{ + let key = $crate::get_artifact!($system, $relation, VerifyingKey); + let proof = $crate::get_artifact!($system, $relation, Proof); + let input = $crate::get_artifact!($system, $relation, PublicInput); + + $crate::benchmarking::import::Artifacts { key, proof, input } + }}; +} + #[macro_export] macro_rules! get_artifact { ($(ProvingSystem::)?$system:tt, $(Relation::)?$relation:tt, $(Artifact::)?$artifact:tt $(,)?) => { diff --git a/pallets/snarcos/src/benchmarking/suite.rs b/pallets/snarcos/src/benchmarking/suite.rs index c7e5d803a2..7e5481acff 100644 --- a/pallets/snarcos/src/benchmarking/suite.rs +++ b/pallets/snarcos/src/benchmarking/suite.rs @@ -1,8 +1,8 @@ -use frame_benchmarking::{account, benchmarks, vec}; +use frame_benchmarking::{account, benchmarks, vec, Vec}; use frame_support::{traits::Get, BoundedVec}; use frame_system::RawOrigin; -use crate::{ProvingSystem::*, *}; +use crate::{benchmarking::import::Artifacts, ProvingSystem::*, *}; const SEED: u32 = 41; const IDENTIFIER: VerificationKeyIdentifier = [0; 4]; @@ -11,6 +11,10 @@ fn caller() -> RawOrigin<::AccountId> { RawOrigin::Signed(account("caller", 0, SEED)) } +fn insert_key(key: Vec) { + VerificationKeys::::insert(IDENTIFIER, BoundedVec::try_from(key).unwrap()); +} + benchmarks! { store_key { @@ -19,27 +23,13 @@ benchmarks! { } : _(caller::(), IDENTIFIER, key) verify_xor { - let key = get_artifact!(Groth16, Xor, VerifyingKey); - let proof = get_artifact!(Groth16, Xor, Proof); - let input = get_artifact!(Groth16, Xor, PublicInput); - - let _ = VerificationKeys::::insert( - IDENTIFIER, - BoundedVec::try_from(key).unwrap() - ); - + let Artifacts { key, proof, input } = get_artifacts!(Groth16, Xor); + let _ = insert_key::(key); } : verify(caller::(), IDENTIFIER, proof, input, Groth16) verify_linear_equation { - let key = get_artifact!(Groth16, LinearEquation, VerifyingKey); - let proof = get_artifact!(Groth16, LinearEquation, Proof); - let input = get_artifact!(Groth16, LinearEquation, PublicInput); - - let _ = VerificationKeys::::insert( - IDENTIFIER, - BoundedVec::try_from(key).unwrap() - ); - + let Artifacts { key, proof, input } = get_artifacts!(Groth16, Xor); + let _ = insert_key::(key); } : verify(caller::(), IDENTIFIER, proof, input, Groth16) } From 1061e47bf5de57c5695d94edb21d8a7aafabc377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Wed, 26 Oct 2022 11:21:45 +0200 Subject: [PATCH 08/41] compile results --- pallets/snarcos/src/benchmarking/suite.rs | 30 +++++++- pallets/snarcos/src/weights.rs | 90 ++++++++++++++++++----- 2 files changed, 97 insertions(+), 23 deletions(-) diff --git a/pallets/snarcos/src/benchmarking/suite.rs b/pallets/snarcos/src/benchmarking/suite.rs index 7e5481acff..592c791c52 100644 --- a/pallets/snarcos/src/benchmarking/suite.rs +++ b/pallets/snarcos/src/benchmarking/suite.rs @@ -22,14 +22,38 @@ benchmarks! { let key = vec![0u8; l as usize]; } : _(caller::(), IDENTIFIER, key) - verify_xor { + // Groth16 benchmarks + + verify_groth16_xor { let Artifacts { key, proof, input } = get_artifacts!(Groth16, Xor); let _ = insert_key::(key); } : verify(caller::(), IDENTIFIER, proof, input, Groth16) - verify_linear_equation { - let Artifacts { key, proof, input } = get_artifacts!(Groth16, Xor); + verify_groth16_linear_equation { + let Artifacts { key, proof, input } = get_artifacts!(Groth16, LinearEquation); + let _ = insert_key::(key); + } : verify(caller::(), IDENTIFIER, proof, input, Groth16) + + verify_groth16_merkle_tree { + let Artifacts { key, proof, input } = get_artifacts!(Groth16, MerkleTree); let _ = insert_key::(key); } : verify(caller::(), IDENTIFIER, proof, input, Groth16) + // GM17 benchmarks + + verify_gm17_xor { + let Artifacts { key, proof, input } = get_artifacts!(Gm17, Xor); + let _ = insert_key::(key); + } : verify(caller::(), IDENTIFIER, proof, input, Gm17) + + verify_gm17_linear_equation { + let Artifacts { key, proof, input } = get_artifacts!(Gm17, LinearEquation); + let _ = insert_key::(key); + } : verify(caller::(), IDENTIFIER, proof, input, Gm17) + + verify_gm17_merkle_tree { + let Artifacts { key, proof, input } = get_artifacts!(Gm17, MerkleTree); + let _ = insert_key::(key); + } : verify(caller::(), IDENTIFIER, proof, input, Gm17) + } diff --git a/pallets/snarcos/src/weights.rs b/pallets/snarcos/src/weights.rs index 873f56c45e..c7ccca1134 100644 --- a/pallets/snarcos/src/weights.rs +++ b/pallets/snarcos/src/weights.rs @@ -1,7 +1,7 @@ //! Autogenerated weights for pallet_snarcos //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-10-24, STEPS: `20`, REPEAT: 50, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-26, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("/tmp/chainspec.json"), DB CACHE: 1024 // Executed Command: @@ -12,7 +12,7 @@ // --pallet=pallet_snarcos // --extrinsic=* // --steps=20 -// --repeat=50 +// --repeat=10 // --template=.maintain/pallet-weight-template.hbs // --execution=wasm // --wasm-execution=compiled @@ -38,40 +38,68 @@ impl WeightInfo for I { } fn verify_groth16() -> Weight { - ::verify_xor() - .max(::verify_linear_equation()) + ::verify_groth16_xor() + .max(::verify_groth16_linear_equation()) + .max(::verify_groth16_merkle_tree()) } fn verify_gm17() -> Weight { - ::verify_xor() - .max(::verify_linear_equation()) + ::verify_gm17_xor() + .max(::verify_gm17_linear_equation()) + .max(::verify_gm17_merkle_tree()) } } /// Benchmark results for pallet_snarcos. trait BenchmarkInfo { fn store_key(l: u32, ) -> Weight; - fn verify_xor() -> Weight; - fn verify_linear_equation() -> Weight; + fn verify_groth16_xor() -> Weight; + fn verify_groth16_linear_equation() -> Weight; + fn verify_groth16_merkle_tree() -> Weight; + fn verify_gm17_xor() -> Weight; + fn verify_gm17_linear_equation() -> Weight; + fn verify_gm17_merkle_tree() -> Weight; } /// Weights for pallet_snarcos using the Substrate node and recommended hardware. pub struct AlephWeight(PhantomData); impl BenchmarkInfo for AlephWeight { // Storage: Snarcos VerificationKeys (r:1 w:1) - fn store_key(_l: u32, ) -> Weight { - (11_155_000 as Weight) + fn store_key(l: u32, ) -> Weight { + (13_481_000 as Weight) + // Standard Error: 0 + .saturating_add((1_000 as Weight).saturating_mul(l as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) - fn verify_xor() -> Weight { - (39_674_705_000 as Weight) + fn verify_groth16_xor() -> Weight { + (44_472_517_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) - fn verify_linear_equation() -> Weight { - (31_270_334_000 as Weight) + fn verify_groth16_linear_equation() -> Weight { + (34_476_501_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_groth16_merkle_tree() -> Weight { + (46_305_240_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_gm17_xor() -> Weight { + (49_696_284_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_gm17_linear_equation() -> Weight { + (39_640_711_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_gm17_merkle_tree() -> Weight { + (51_937_767_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } } @@ -79,19 +107,41 @@ impl BenchmarkInfo for AlephWeight { // For backwards compatibility and tests impl BenchmarkInfo for () { // Storage: Snarcos VerificationKeys (r:1 w:1) - fn store_key(_l: u32, ) -> Weight { - (11_155_000 as Weight) + fn store_key(l: u32, ) -> Weight { + (13_481_000 as Weight) + // Standard Error: 0 + .saturating_add((1_000 as Weight).saturating_mul(l as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) - fn verify_xor() -> Weight { - (39_674_705_000 as Weight) + fn verify_groth16_xor() -> Weight { + (44_472_517_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_groth16_linear_equation() -> Weight { + (34_476_501_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_groth16_merkle_tree() -> Weight { + (46_305_240_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_gm17_xor() -> Weight { + (49_696_284_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_gm17_linear_equation() -> Weight { + (39_640_711_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) - fn verify_linear_equation() -> Weight { - (31_270_334_000 as Weight) + fn verify_gm17_merkle_tree() -> Weight { + (51_937_767_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } } From f019d75f78fa910c2506fccdb1a104e1bdbe8868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Wed, 26 Oct 2022 11:33:38 +0200 Subject: [PATCH 09/41] 50 repeats --- pallets/snarcos/src/benchmarking/mod.rs | 14 --------- pallets/snarcos/src/weights.rs | 40 +++++++++++-------------- 2 files changed, 18 insertions(+), 36 deletions(-) diff --git a/pallets/snarcos/src/benchmarking/mod.rs b/pallets/snarcos/src/benchmarking/mod.rs index 9af69ac928..60b49ac29e 100644 --- a/pallets/snarcos/src/benchmarking/mod.rs +++ b/pallets/snarcos/src/benchmarking/mod.rs @@ -1,16 +1,2 @@ mod import; mod suite; - -#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] -enum Relation { - Xor, - LinearEquation, - MerkleTree, -} - -#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] -enum Artifact { - VerifyingKey, - Proof, - PublicInput, -} diff --git a/pallets/snarcos/src/weights.rs b/pallets/snarcos/src/weights.rs index c7ccca1134..d27d21a188 100644 --- a/pallets/snarcos/src/weights.rs +++ b/pallets/snarcos/src/weights.rs @@ -1,7 +1,7 @@ //! Autogenerated weights for pallet_snarcos //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-10-26, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-26, STEPS: `20`, REPEAT: 50, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("/tmp/chainspec.json"), DB CACHE: 1024 // Executed Command: @@ -12,7 +12,7 @@ // --pallet=pallet_snarcos // --extrinsic=* // --steps=20 -// --repeat=10 +// --repeat=50 // --template=.maintain/pallet-weight-template.hbs // --execution=wasm // --wasm-execution=compiled @@ -65,41 +65,39 @@ trait BenchmarkInfo { pub struct AlephWeight(PhantomData); impl BenchmarkInfo for AlephWeight { // Storage: Snarcos VerificationKeys (r:1 w:1) - fn store_key(l: u32, ) -> Weight { - (13_481_000 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(l as Weight)) + fn store_key(_l: u32, ) -> Weight { + (12_480_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_groth16_xor() -> Weight { - (44_472_517_000 as Weight) + (43_929_123_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_groth16_linear_equation() -> Weight { - (34_476_501_000 as Weight) + (34_691_340_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_groth16_merkle_tree() -> Weight { - (46_305_240_000 as Weight) + (46_342_466_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_gm17_xor() -> Weight { - (49_696_284_000 as Weight) + (49_259_696_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_gm17_linear_equation() -> Weight { - (39_640_711_000 as Weight) + (35_873_791_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_gm17_merkle_tree() -> Weight { - (51_937_767_000 as Weight) + (47_035_076_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } } @@ -107,41 +105,39 @@ impl BenchmarkInfo for AlephWeight { // For backwards compatibility and tests impl BenchmarkInfo for () { // Storage: Snarcos VerificationKeys (r:1 w:1) - fn store_key(l: u32, ) -> Weight { - (13_481_000 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(l as Weight)) + fn store_key(_l: u32, ) -> Weight { + (12_480_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_groth16_xor() -> Weight { - (44_472_517_000 as Weight) + (43_929_123_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_groth16_linear_equation() -> Weight { - (34_476_501_000 as Weight) + (34_691_340_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_groth16_merkle_tree() -> Weight { - (46_305_240_000 as Weight) + (46_342_466_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_gm17_xor() -> Weight { - (49_696_284_000 as Weight) + (49_259_696_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_gm17_linear_equation() -> Weight { - (39_640_711_000 as Weight) + (35_873_791_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_gm17_merkle_tree() -> Weight { - (51_937_767_000 as Weight) + (47_035_076_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } } From 2a08635f497a214104f7d274764adfac0e5c0c06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Wed, 26 Oct 2022 11:49:39 +0200 Subject: [PATCH 10/41] big trees --- .../gm17/merkle_tree_1024.proof.bytes | Bin 0 -> 192 bytes .../gm17/merkle_tree_1024.public_input.bytes | Bin 0 -> 296 bytes .../resources/gm17/merkle_tree_1024.vk.bytes | Bin 0 -> 872 bytes .../resources/gm17/merkle_tree_64.proof.bytes | 1 + .../gm17/merkle_tree_64.public_input.bytes | Bin 0 -> 296 bytes .../resources/gm17/merkle_tree_64.vk.bytes | Bin 0 -> 872 bytes ....proof.bytes => merkle_tree_8.proof.bytes} | 0 ...bytes => merkle_tree_8.public_input.bytes} | Bin ...e_tree.vk.bytes => merkle_tree_8.vk.bytes} | Bin .../groth16/merkle_tree_1024.proof.bytes | Bin 0 -> 192 bytes .../merkle_tree_1024.public_input.bytes | Bin 0 -> 296 bytes .../groth16/merkle_tree_1024.vk.bytes | Bin 0 -> 824 bytes .../groth16/merkle_tree_64.proof.bytes | Bin 0 -> 192 bytes .../groth16/merkle_tree_64.public_input.bytes | Bin 0 -> 296 bytes .../resources/groth16/merkle_tree_64.vk.bytes | Bin 0 -> 824 bytes ....proof.bytes => merkle_tree_8.proof.bytes} | 0 ...bytes => merkle_tree_8.public_input.bytes} | Bin ...e_tree.vk.bytes => merkle_tree_8.vk.bytes} | Bin pallets/snarcos/src/benchmarking/suite.rs | 28 +++++- pallets/snarcos/src/weights.rs | 92 +++++++++++++----- 20 files changed, 95 insertions(+), 26 deletions(-) create mode 100644 pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree_1024.proof.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree_1024.public_input.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree_1024.vk.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree_64.proof.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree_64.public_input.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree_64.vk.bytes rename pallets/snarcos/src/benchmarking/resources/gm17/{merkle_tree.proof.bytes => merkle_tree_8.proof.bytes} (100%) rename pallets/snarcos/src/benchmarking/resources/gm17/{merkle_tree.public_input.bytes => merkle_tree_8.public_input.bytes} (100%) rename pallets/snarcos/src/benchmarking/resources/gm17/{merkle_tree.vk.bytes => merkle_tree_8.vk.bytes} (100%) create mode 100644 pallets/snarcos/src/benchmarking/resources/groth16/merkle_tree_1024.proof.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/groth16/merkle_tree_1024.public_input.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/groth16/merkle_tree_1024.vk.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/groth16/merkle_tree_64.proof.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/groth16/merkle_tree_64.public_input.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/groth16/merkle_tree_64.vk.bytes rename pallets/snarcos/src/benchmarking/resources/groth16/{merkle_tree.proof.bytes => merkle_tree_8.proof.bytes} (100%) rename pallets/snarcos/src/benchmarking/resources/groth16/{merkle_tree.public_input.bytes => merkle_tree_8.public_input.bytes} (100%) rename pallets/snarcos/src/benchmarking/resources/groth16/{merkle_tree.vk.bytes => merkle_tree_8.vk.bytes} (100%) diff --git a/pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree_1024.proof.bytes b/pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree_1024.proof.bytes new file mode 100644 index 0000000000000000000000000000000000000000..35d56bcb956e4442a56fc4a1dab09aa2726aa9bf GIT binary patch literal 192 zcmV;x06+h&(VJXxWmS8&#mt$Pfc&u}QS^^JB(97i_tMY>0||ayb+MZh9ASKB?!w07 zIK7#1SJm+NQeISeac12(%Ly55Fh1}lMHKGE`jF{9iV<_0B@xPM|%K-p* uk0GdehhU#-F8TS-a~7EuIp*p$a02ic#*g<3UqX%2tQYAshPNEEQ|JUO@?;|b literal 0 HcmV?d00001 diff --git a/pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree_1024.public_input.bytes b/pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree_1024.public_input.bytes new file mode 100644 index 0000000000000000000000000000000000000000..76dd2df03ee3907be8bf595e61e49b91f8170f4f GIT binary patch literal 296 xcmd;NfB?lK_vW2B6MVzWXXmbh(CS}i?9ZQnvfB8p+)DTOxwrCqP-P>Q0ssik5!e6# literal 0 HcmV?d00001 diff --git a/pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree_1024.vk.bytes b/pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree_1024.vk.bytes new file mode 100644 index 0000000000000000000000000000000000000000..30d174d9a52298d37a1dbfd895e648c847d33013 GIT binary patch literal 872 zcmb={mNb)&{k*+V@VoE?<0()0Oirdbgt8q!`u2e*Pr|0Y;CcMUyWb=wN;IGOWIAOk z%ZsbQd-L4aJjttSG076{o~2flxIfTn%foN-txfhk+gaaz{@L%nJDK&PF2lQ=Ja-PE zN?Tz?;r5LmPi7Y*>Bsp@^<+Hp%0e7-})r`uofTM zQtsL@SwWC-)BUd1w@)A0W8php@}aG9kj}gG#Rjh%`6c9a4;rpm=;17;_rabk==fqE z7L^70))m_q?RDPplUd^3^Xyr#pS+#KW9xKuVMxrm1hbTXU6WSP$W-p%9qiA`0oz9mco0-ne{PQ-8@}(SXNy@j>Q?YAk z>|Jj9fPwv#a%SjKYu`)3#dBqKkJ*Iv7xeLpO<8i7sqNiuRsO4YVirC~oT2X--F8LJ z((8M+`f};l4F+d7iq$!rjYXx!6bw_E+S#k~uzE7I>?SIRn}Z}231oubr%Y^7k4sN z6szgg&#_Cr?D?Q?-{kz*>nC4c`&4&*?`|��EÞ��WWo ���_[W����� \ No newline at end of file diff --git a/pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree_64.public_input.bytes b/pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree_64.public_input.bytes new file mode 100644 index 0000000000000000000000000000000000000000..594ec284a1120a6379bbaac36928f16870577f3e GIT binary patch literal 296 xcmd;NfPhC|4s+iZQ{J<8+wX#97mL3J*zWMV;_s)~lI{K`efOP0sIn1D0RS_Q5&ZxF literal 0 HcmV?d00001 diff --git a/pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree_64.vk.bytes b/pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree_64.vk.bytes new file mode 100644 index 0000000000000000000000000000000000000000..e7cfea64a648579724464934619ce384b0c44444 GIT binary patch literal 872 zcmb={mNb)&{k*+V@VoE?<0()0Oirdbgt8q!`u2e*Pr|0Y;CcMUyWb=wN;IGOWIAOk z%ZsbQd-L4aJjttSG076{o~2flxIfTn%foN-txfhk+gaaz{@L%nJDK&PF2lQ=Ja-PE zN?Tz?;r5LmPi7Y*>Bsp@^<+Hp%0e7-})r`uofTM zQtsL@SwWC-)BUd1w@)A0W8php@}aG9kj}gG#Rjh%`6c9a4;rpm=;17;_rabk==fqE z7L^70))m_q?RDPplUd^3^Xyr#pS+#KW9xKuVMxrm1hbTXXzY;_U6lqqr|xEYoyei+74j_Q`u-z_;CcGOyeu-lQ46=^hgqw_om>_25!nwZW%L z`3%Mn@2P8FdHABIV|Vhj0QcW(uRK*dQgkH3;1grh8v+%lLEPgduCkq`AuqWj5H)c%c3K*2H9iSlcSs>HG?| zb24LZ^zT2-Uzm5X|MS;ha*JnX?^?X(Z{N53lcBZ! ryjeRut7a>3e~+)5F72@7aIfD-rW<}NFO%nU|JavdV)JHEZ?OabY|f?d literal 0 HcmV?d00001 diff --git a/pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree.proof.bytes b/pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree_8.proof.bytes similarity index 100% rename from pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree.proof.bytes rename to pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree_8.proof.bytes diff --git a/pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree.public_input.bytes b/pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree_8.public_input.bytes similarity index 100% rename from pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree.public_input.bytes rename to pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree_8.public_input.bytes diff --git a/pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree.vk.bytes b/pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree_8.vk.bytes similarity index 100% rename from pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree.vk.bytes rename to pallets/snarcos/src/benchmarking/resources/gm17/merkle_tree_8.vk.bytes diff --git a/pallets/snarcos/src/benchmarking/resources/groth16/merkle_tree_1024.proof.bytes b/pallets/snarcos/src/benchmarking/resources/groth16/merkle_tree_1024.proof.bytes new file mode 100644 index 0000000000000000000000000000000000000000..e2649f744c63651b45360e9c9a1f8697245d68e8 GIT binary patch literal 192 zcmV;x06+g1_*(=|BjA*eva%D|7E;OoHo_qJ<^-ql8Hm7K`YGe$p7G}D{p3(i+|wzf zvNa5MlF~P*6fimDTUsDUd2_Nxbe>k6Uc+66-J_!#YUozZoXJ(bBT+hcs1qbVD%Sua zO1CY{_^SaVgCXUunTnwib)g2S+)2IZ4!Ikg)4rBeCV|*y#Isq1XuMh*zt;$W>4%O@ u^a^qa=K$}9T)`PKV9v6^wiz=bNI9%_#4W%&m~O14Q0ssik5!e6# literal 0 HcmV?d00001 diff --git a/pallets/snarcos/src/benchmarking/resources/groth16/merkle_tree_1024.vk.bytes b/pallets/snarcos/src/benchmarking/resources/groth16/merkle_tree_1024.vk.bytes new file mode 100644 index 0000000000000000000000000000000000000000..1fa59e9404e077a01b6460dadaae901adcd5b93b GIT binary patch literal 824 zcmV-81IPSTA&U8BfpWEsgGSkf!uVQlkzn3MgjD7IgCy@jc)&4~wwWD`Q&)Fto9Sow z0Q-UMSo@Xqkr5fY1zhfQj*Qxu>^M)KhnTyUHl8@*Qnn1SL$CWH)z5DjmkZ7toQ4eN zyx8`jaJB+_cw4WG5)8wDq77y{fN_BqMwAcJ4sld^oq_oBTQx|PYt%#H98R35#A7KU{K_AZC34^Cxfs&5Gd@KVfe^w#8pyQEG zVy+EYFo?vHIj|LpjyHyc%wl@YToF@GKx84`jYrcHY#9{_000000001JalH9l(HUX5Oiw?N zX_}^P`Nhw?)csxYas%^uIimfky@jGxW-48eU#-~1@GG8ATi>RHN;t- zf^7wHkOQX-%TGG;tFiOl{c;7qKGkr##l%@tyS_y}rI`@F2S7yC?jwE}R!}RA5IV>P%RlR~RotpD$|nl+A9wU=_lhYYAl0zFp`Xv&}q) zI=ca2BZaQ@*y4wjU%sI32`l&nknH?c=4l@{4;^M)KhnTyUHl8@*Qnn1SL$CWH)z5DjmkZ7toQ4eN zyx8`jaJB+_cw4WG5)8wDq77y{fN_BqMwAcJ4sld^oq_oBTQx|PYt%#H98R35#A7KU{K_AZC34^Cxfs&5Gd@KVfe^w#8pyQEG zVy+EYFo?vHIj|LpjyHyc%wl@YToF@GKx84`jYrcHY#9{_000000002lO_*CPSz=gV8n)Mq z^d)PlWz71fYpRdlSC8HL3y6+ zE>;VAp%o~q{`OGSOO?bpzlu0v&fS3^ zUTgSlE}}btjM>kVu^^D<(OA>KpI134$1?={-m(lljM9Ivk0TQPMtGKf73-|gk6kbP zeg~X3jlK59bqA4L6z5?a zDY3RdQMkLMm*kGHucM9&hBqJ_RNKFs1~^2p51H4K9yk(zYJ3zv7iJpIJEQVbN-Ioe zyR2OX-*lAaNn1iIPE35vdK`8mZ|E?LCE)m^`fjrSu`~3&EK}9#xqKEG>B9?%SFWK= zik_Is*T_zpI8Q`{Gz~=$rBK645o@aTnlrkfLjnZn{u@(key); } : verify(caller::(), IDENTIFIER, proof, input, Groth16) - verify_groth16_merkle_tree { - let Artifacts { key, proof, input } = get_artifacts!(Groth16, MerkleTree); + verify_groth16_merkle_tree_8 { + let Artifacts { key, proof, input } = get_artifacts!(Groth16, MerkleTree8); + let _ = insert_key::(key); + } : verify(caller::(), IDENTIFIER, proof, input, Groth16) + + verify_groth16_merkle_tree_64 { + let Artifacts { key, proof, input } = get_artifacts!(Groth16, MerkleTree64); + let _ = insert_key::(key); + } : verify(caller::(), IDENTIFIER, proof, input, Groth16) + + verify_groth16_merkle_tree_1024 { + let Artifacts { key, proof, input } = get_artifacts!(Groth16, MerkleTree1024); let _ = insert_key::(key); } : verify(caller::(), IDENTIFIER, proof, input, Groth16) @@ -51,8 +61,18 @@ benchmarks! { let _ = insert_key::(key); } : verify(caller::(), IDENTIFIER, proof, input, Gm17) - verify_gm17_merkle_tree { - let Artifacts { key, proof, input } = get_artifacts!(Gm17, MerkleTree); + verify_gm17_merkle_tree_8 { + let Artifacts { key, proof, input } = get_artifacts!(Gm17, MerkleTree8); + let _ = insert_key::(key); + } : verify(caller::(), IDENTIFIER, proof, input, Gm17) + + verify_gm17_merkle_tree_64 { + let Artifacts { key, proof, input } = get_artifacts!(Gm17, MerkleTree64); + let _ = insert_key::(key); + } : verify(caller::(), IDENTIFIER, proof, input, Gm17) + + verify_gm17_merkle_tree_1024 { + let Artifacts { key, proof, input } = get_artifacts!(Gm17, MerkleTree1024); let _ = insert_key::(key); } : verify(caller::(), IDENTIFIER, proof, input, Gm17) diff --git a/pallets/snarcos/src/weights.rs b/pallets/snarcos/src/weights.rs index d27d21a188..b819d4f425 100644 --- a/pallets/snarcos/src/weights.rs +++ b/pallets/snarcos/src/weights.rs @@ -40,13 +40,17 @@ impl WeightInfo for I { fn verify_groth16() -> Weight { ::verify_groth16_xor() .max(::verify_groth16_linear_equation()) - .max(::verify_groth16_merkle_tree()) + .max(::verify_groth16_merkle_tree_8()) + .max(::verify_groth16_merkle_tree_64()) + .max(::verify_groth16_merkle_tree_1024()) } fn verify_gm17() -> Weight { ::verify_gm17_xor() .max(::verify_gm17_linear_equation()) - .max(::verify_gm17_merkle_tree()) + .max(::verify_gm17_merkle_tree_8()) + .max(::verify_gm17_merkle_tree_64()) + .max(::verify_gm17_merkle_tree_1024()) } } @@ -55,10 +59,14 @@ trait BenchmarkInfo { fn store_key(l: u32, ) -> Weight; fn verify_groth16_xor() -> Weight; fn verify_groth16_linear_equation() -> Weight; - fn verify_groth16_merkle_tree() -> Weight; + fn verify_groth16_merkle_tree_8() -> Weight; + fn verify_groth16_merkle_tree_64() -> Weight; + fn verify_groth16_merkle_tree_1024() -> Weight; fn verify_gm17_xor() -> Weight; fn verify_gm17_linear_equation() -> Weight; - fn verify_gm17_merkle_tree() -> Weight; + fn verify_gm17_merkle_tree_8() -> Weight; + fn verify_gm17_merkle_tree_64() -> Weight; + fn verify_gm17_merkle_tree_1024() -> Weight; } /// Weights for pallet_snarcos using the Substrate node and recommended hardware. @@ -66,38 +74,58 @@ pub struct AlephWeight(PhantomData); impl BenchmarkInfo for AlephWeight { // Storage: Snarcos VerificationKeys (r:1 w:1) fn store_key(_l: u32, ) -> Weight { - (12_480_000 as Weight) + (11_740_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_groth16_xor() -> Weight { - (43_929_123_000 as Weight) + (44_383_443_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_groth16_linear_equation() -> Weight { - (34_691_340_000 as Weight) + (31_830_540_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) - fn verify_groth16_merkle_tree() -> Weight { - (46_342_466_000 as Weight) + fn verify_groth16_merkle_tree_8() -> Weight { + (41_938_960_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_groth16_merkle_tree_64() -> Weight { + (42_613_088_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_groth16_merkle_tree_1024() -> Weight { + (41_989_457_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_gm17_xor() -> Weight { - (49_259_696_000 as Weight) + (44_472_591_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_gm17_linear_equation() -> Weight { - (35_873_791_000 as Weight) + (36_445_886_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_gm17_merkle_tree_8() -> Weight { + (47_406_311_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_gm17_merkle_tree_64() -> Weight { + (52_658_318_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) - fn verify_gm17_merkle_tree() -> Weight { - (47_035_076_000 as Weight) + fn verify_gm17_merkle_tree_1024() -> Weight { + (52_424_591_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } } @@ -106,38 +134,58 @@ impl BenchmarkInfo for AlephWeight { impl BenchmarkInfo for () { // Storage: Snarcos VerificationKeys (r:1 w:1) fn store_key(_l: u32, ) -> Weight { - (12_480_000 as Weight) + (11_740_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_groth16_xor() -> Weight { - (43_929_123_000 as Weight) + (44_383_443_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_groth16_linear_equation() -> Weight { - (34_691_340_000 as Weight) + (31_830_540_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) - fn verify_groth16_merkle_tree() -> Weight { - (46_342_466_000 as Weight) + fn verify_groth16_merkle_tree_8() -> Weight { + (41_938_960_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_groth16_merkle_tree_64() -> Weight { + (42_613_088_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_groth16_merkle_tree_1024() -> Weight { + (41_989_457_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_gm17_xor() -> Weight { - (49_259_696_000 as Weight) + (44_472_591_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_gm17_linear_equation() -> Weight { - (35_873_791_000 as Weight) + (36_445_886_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_gm17_merkle_tree_8() -> Weight { + (47_406_311_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_gm17_merkle_tree_64() -> Weight { + (52_658_318_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) - fn verify_gm17_merkle_tree() -> Weight { - (47_035_076_000 as Weight) + fn verify_gm17_merkle_tree_1024() -> Weight { + (52_424_591_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } } From 80805692c82c9bd6b82dc7149b0977e0e1807eea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Wed, 26 Oct 2022 11:56:12 +0200 Subject: [PATCH 11/41] docstrings --- pallets/snarcos/src/benchmarking/import.rs | 34 +++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/pallets/snarcos/src/benchmarking/import.rs b/pallets/snarcos/src/benchmarking/import.rs index eca3150023..a2be2adc1b 100644 --- a/pallets/snarcos/src/benchmarking/import.rs +++ b/pallets/snarcos/src/benchmarking/import.rs @@ -6,9 +6,20 @@ pub(super) struct Artifacts { pub input: Vec, } +/// Returns `Artifacts` object built from the resources described with `system` and `relation` +/// arguments. +/// +/// Example of usage: +/// ```rust +/// # use pallet_snarcos::get_artifacts; +/// +/// let Artifacts { key, proof, input } = get_artifacts!(Groth16, LinearEquation); +/// ``` +/// +/// #[macro_export] macro_rules! get_artifacts { - ($(ProvingSystem::)?$system:tt, $(Relation::)?$relation:tt $(,)?) => {{ + ($system:tt, $relation:tt $(,)?) => {{ let key = $crate::get_artifact!($system, $relation, VerifyingKey); let proof = $crate::get_artifact!($system, $relation, Proof); let input = $crate::get_artifact!($system, $relation, PublicInput); @@ -17,9 +28,15 @@ macro_rules! get_artifacts { }}; } +/// Returns a resource as `Vec`. The retrieval is done in compilation time +/// (with `include_bytes!`). +/// +/// Since `include_bytes!` accepts only string literals, in order to achieve some kind of brevity, +/// we had to wrap it with light macros (see `system!`, `relation!` and `artifact!` defined in this +/// module). #[macro_export] macro_rules! get_artifact { - ($(ProvingSystem::)?$system:tt, $(Relation::)?$relation:tt, $(Artifact::)?$artifact:tt $(,)?) => { + ($system:tt, $relation:tt, $artifact:tt $(,)?) => { include_bytes!(concat!( "resources/", $crate::system!($system), @@ -33,6 +50,7 @@ macro_rules! get_artifact { }; } +/// Converts system identifier to a `&static str` that describes corresponding resources directory. #[macro_export] macro_rules! system { (Groth16) => { @@ -43,6 +61,7 @@ macro_rules! system { }; } +/// Converts relation identifier to a `&static str` that is used in the filename pattern. #[macro_export] macro_rules! relation { (Xor) => { @@ -51,11 +70,18 @@ macro_rules! relation { (LinearEquation) => { "linear_equation" }; - (MerkleTree) => { - "merkle_tree" + (MerkleTree8) => { + "merkle_tree_8" + }; + (MerkleTree64) => { + "merkle_tree_64" + }; + (MerkleTree1024) => { + "merkle_tree_1024" }; } +/// Converts artifact identifier to a `&static str` that is used in the filename pattern. #[macro_export] macro_rules! artifact { (VerifyingKey) => { From 551b062dcbf595d428f4d28cd4b102875bbe8c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 07:57:23 +0100 Subject: [PATCH 12/41] Charing in ChainExtension --- bin/runtime/src/chain_extension/mod.rs | 27 ++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/bin/runtime/src/chain_extension/mod.rs b/bin/runtime/src/chain_extension/mod.rs index 19063dcf1e..3a8167e35d 100644 --- a/bin/runtime/src/chain_extension/mod.rs +++ b/bin/runtime/src/chain_extension/mod.rs @@ -1,5 +1,5 @@ use codec::Decode; -use frame_support::log::error; +use frame_support::{log::error, pallet_prelude::Weight}; use pallet_contracts::chain_extension::{ ChainExtension, Environment, Ext, InitState, RetVal, SysConfig, }; @@ -123,6 +123,23 @@ impl SnarcosChainExtension { Ok(RetVal::Converging(return_status)) } + fn weight_of_verify(system: Option) -> Weight { + match system { + Some(ProvingSystem::Groth16) => { + <::WeightInfo as WeightInfo>::verify_groth16() + } + Some(ProvingSystem::Gm17) => { + <::WeightInfo as WeightInfo>::verify_gm17() + } + Some(ProvingSystem::Marlin) => { + <::WeightInfo as WeightInfo>::verify_marlin() + } + None => Self::weight_of_verify(Some(ProvingSystem::Groth16)) + .max(Self::weight_of_verify(Some(ProvingSystem::Gm17))) + .max(Self::weight_of_verify(Some(ProvingSystem::Marlin))), + } + } + fn snarcos_verify(env: Environment) -> Result where ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>, @@ -131,15 +148,15 @@ impl SnarcosChainExtension { let mut env = env.buf_in_buf_out(); // We charge optimistically, i.e. assuming that decoding succeeds and the verification - // key is present. + // key is present. However, since we don't know the system yet, we have to charge maximal + // possible fee. We will adjust it as soon as possible. // // Currently, we cannot do more in terms of charging due to insufficiently flexible // weighting (`pallet_snarcos::WeightInfo` API). Once we have functions like // `pallet_snarcos::WeightInfo::verify_decoding_failure`, we can both charge less here // (with further `env.adjust_weight`) and in the pallet itself (returning // `DispatchErrorWithPostInfo` reducing actual fee and the block weight). - let _pre_charge = - env.charge_weight(<::WeightInfo as WeightInfo>::verify())?; + let pre_charge = env.charge_weight(Self::weight_of_verify(None))?; // Parsing is done here for similar reasons as in `Self::snarcos_store_key`. let bytes = env.read(env.in_len())?; @@ -147,6 +164,8 @@ impl SnarcosChainExtension { let args: VerifyArgs = VerifyArgs::decode(&mut &*bytes) .map_err(|_| DispatchError::Other("Failed to decode arguments"))?; + env.adjust_weight(pre_charge, Self::weight_of_verify(Some(args.system))); + let result = Snarcos::::bare_verify(args.identifier, args.proof, args.input, args.system); From 4841d6fac37e40d7ab757abb0b718b46ada4b27f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 08:13:24 +0100 Subject: [PATCH 13/41] Instructions --- pallets/snarcos/src/benchmarking/mod.rs | 25 +++++++++++++++++++++++++ pallets/snarcos/src/weights.rs | 4 ++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/pallets/snarcos/src/benchmarking/mod.rs b/pallets/snarcos/src/benchmarking/mod.rs index 60b49ac29e..ff147bec93 100644 --- a/pallets/snarcos/src/benchmarking/mod.rs +++ b/pallets/snarcos/src/benchmarking/mod.rs @@ -1,2 +1,27 @@ +//! To benchmark pallet on your machine, run: +//! ```shell +//! export NODE_ID=5D34dL5prEUaGNQtPPZ3yN5Y6BnkfXunKXXz6fo7ZJbLwRRH +//! +//! cargo run --release -p aleph-node --features runtime-benchmarks -- bootstrap-chain \ +//! --base-path /tmp/ \ +//! --account-ids $NODE_ID \ +//! --sudo-account-id $NODE_ID \ +//! --chain-id a0snarknet \ +//! --token-symbol SNRKZERO \ +//! --chain-name 'Aleph Zero Snarknet' \ +//! > ./chainspec.json +//! +//! cargo run --release -p aleph-node --features runtime-benchmarks -- benchmark pallet \ +//! --chain=chainspec.json \ +//! --pallet=pallet_snarcos \ +//! --extrinsic=* \ +//! --steps=20 \ +//! --repeat=50 \ +//! --template=.maintain/pallet-weight-template.hbs \ +//! --execution=wasm \ +//! --wasm-execution=compiled \ +//! --output=pallets/snarcos/src/weights.rs +//! ``` + mod import; mod suite; diff --git a/pallets/snarcos/src/weights.rs b/pallets/snarcos/src/weights.rs index ded3d3aca7..0f6825dea5 100644 --- a/pallets/snarcos/src/weights.rs +++ b/pallets/snarcos/src/weights.rs @@ -5,10 +5,10 @@ //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("/tmp/chainspec.json"), DB CACHE: 1024 // Executed Command: -// ./target/release/aleph-node +// target/release/aleph-node // benchmark // pallet -// --chain=/tmp/chainspec.json +// --chain=chainspec.json // --pallet=pallet_snarcos // --extrinsic=* // --steps=20 From f17c97afb0f26accb0cd716b83098c87ee4068f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 09:37:24 +0100 Subject: [PATCH 14/41] Add Marlin bytes --- .../resources/marlin/linear_equation.proof.bytes | Bin 0 -> 951 bytes .../marlin/linear_equation.public_input.bytes | Bin 0 -> 8 bytes .../resources/marlin/linear_equation.vk.bytes | Bin 0 -> 1053 bytes .../marlin/merkle_tree_1024.proof.bytes | Bin 0 -> 951 bytes .../marlin/merkle_tree_1024.public_input.bytes | Bin 0 -> 296 bytes .../resources/marlin/merkle_tree_1024.vk.bytes | Bin 0 -> 997 bytes .../resources/marlin/merkle_tree_64.proof.bytes | Bin 0 -> 951 bytes .../marlin/merkle_tree_64.public_input.bytes | Bin 0 -> 296 bytes .../resources/marlin/merkle_tree_64.vk.bytes | Bin 0 -> 997 bytes .../resources/marlin/merkle_tree_8.proof.bytes | Bin 0 -> 951 bytes .../marlin/merkle_tree_8.public_input.bytes | Bin 0 -> 296 bytes .../resources/marlin/merkle_tree_8.vk.bytes | Bin 0 -> 997 bytes .../resources/marlin/xor.proof.bytes | Bin 0 -> 951 bytes .../resources/marlin/xor.public_input.bytes | Bin 0 -> 264 bytes .../benchmarking/resources/marlin/xor.vk.bytes | Bin 0 -> 1053 bytes 15 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 pallets/snarcos/src/benchmarking/resources/marlin/linear_equation.proof.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/marlin/linear_equation.public_input.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/marlin/linear_equation.vk.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/marlin/merkle_tree_1024.proof.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/marlin/merkle_tree_1024.public_input.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/marlin/merkle_tree_1024.vk.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/marlin/merkle_tree_64.proof.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/marlin/merkle_tree_64.public_input.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/marlin/merkle_tree_64.vk.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/marlin/merkle_tree_8.proof.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/marlin/merkle_tree_8.public_input.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/marlin/merkle_tree_8.vk.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/marlin/xor.proof.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/marlin/xor.public_input.bytes create mode 100644 pallets/snarcos/src/benchmarking/resources/marlin/xor.vk.bytes diff --git a/pallets/snarcos/src/benchmarking/resources/marlin/linear_equation.proof.bytes b/pallets/snarcos/src/benchmarking/resources/marlin/linear_equation.proof.bytes new file mode 100644 index 0000000000000000000000000000000000000000..9d1b870a2b9ddbd93c5e0adc1607c109eb5160ce GIT binary patch literal 951 zcmV;o14#S>0000000004000000002CF|(bu+*$vz3Aideczz`n7~%3|po(6%3uaVf zlf;iy1mm{dYfLLdRW1}~;g6C4c^xIUzaXO%VKQ{musgGGM_i4l#2+6X7*R_zW4H=%k5KyeomUnQn7u8L4G>!!@Et{3 z+U2{y-~cv@=C_85Fs2ItRZzyxa*XnQQTr~30qa3MO7siH1e4|9!bXV`A2-hT?gVbA zgOi3FQFyec*6#}e0W~JtpHh%~?)!hpz4A~E7$M<9Z5pz4*Xw<*Q=#SL1fWM|b|b@+ zxjgWqQ(~R}7X&%5g-rV~-i{UEgYIos60+K<7~RYp;g|);F@$RN*I7X^E>EhrN~d4y zG2W~C3;+TE00000003FfILKo>c&jx|Q(>uteo7EH<}~*Ji*GCQwo&lS-W_`3`XHSa zIt!r-Xu_bDUg(IG<;x_c3o==cQSUU;kYOztFvjgP=9@G&9@1us+^-> z(t(Bm2LJ#700000da7&_!N)HSr?L*E1Ic-$DcQODKBC)@jvj6^$2smj@ffJ<^|*5p zDHdedG0*p+9AI;E+7)E;U26~aWX{Y9RmZM5?J8EAIa!h^Y=Yvz^+rf9#%ABvsUZCNLd~ zR_HVX^4l)3HAlgjX*szU$avK!Mle4qi3q@kL`iYWblbG%?7`C%aGWSBUfXvohtZOo Z(*`1YhAZ$&sB3SdH`=}3!2@>;005ampIra| literal 0 HcmV?d00001 diff --git a/pallets/snarcos/src/benchmarking/resources/marlin/linear_equation.public_input.bytes b/pallets/snarcos/src/benchmarking/resources/marlin/linear_equation.public_input.bytes new file mode 100644 index 0000000000000000000000000000000000000000..1b1cb4d44c57c2d7a5122870fa6ac3e62ff7e94e GIT binary patch literal 8 KcmZQzfB*mh2mk>9 literal 0 HcmV?d00001 diff --git a/pallets/snarcos/src/benchmarking/resources/marlin/linear_equation.vk.bytes b/pallets/snarcos/src/benchmarking/resources/marlin/linear_equation.vk.bytes new file mode 100644 index 0000000000000000000000000000000000000000..f9d597b5c5b8c093c5c89f1f663a2913e0b76d28 GIT binary patch literal 1053 zcmYdhfPiEuy&Ot2LTMf-E&C#S{@iOu?~}K%WJnmzG$?6*P*KTMQxx$pQ)1x^`9zH@ zk@U@HYJ*Ex_c*)VR_iOSjEzOW|e$QO5+soLUmdmeR*zTT~ZO7D76{E0d&5F#Y z(#PdaJM3ZYEHdH=;9}VNvovYC?GC>Z?Xw?U_c=JVmiT)woOgaxB#SP;P|_lC^=_{< zJJZixPi6MHpZA`rk0GSCNOb4pm$I3^r-?`@KE9r?E7xU@O+N4Hi-%erTYA&$E}lH| zNkVtK>)-TaKN*c07$RaCkIud&JNf>mg2=0aY-YX9E)4t*{}yH)T zlkfaJ64vdh&cMTP$p2uqD`)=#-4stN`w35;3I}rXe@-elRIanzJbCHP-15EsMF!Vz ztZF{gBe&r6Dn16s=Vy1HYpPe7HK#gqMivvpnfzuQ;hOZ78;brV9%bHM_Elqogvg{u zH{R-YpCh3%Vhm1E%|#U^$IW$2F6?jdH~J=FR299sr>mxYZdd6G&Lcl{GF~4o`8>bw zgI11?>LXWnhU?<t+SqoGHWP5qz@I zYSrA^Ny=gz3>E9t3lDo;YFzdCtGkwdq^~AA8m{t8cSC!{tKK_Pb5g`VscEpirev zAibaYUQZLlw|!yzd+ct7JkyiNkbbpGt$Т*sOAI0;A+D%xvpI@uw=k^~zN;-Kh zzU~!WY}uD6J;iA4^%lwI3C}yLCh%VONU5EzFQoRMWs|&Kk&biKZON&t*aO(t>#cd; zc{8Am-+MyTnWz|9nw<^e2nwThba`e#IaA9=Lsqb=knZ>9jD1=gns-i&Jh_&M}%QnDOF` zqtNXqum2{mlh}1%V2+V+)X{lAKW^N-s_w9>Uz22P#_pge57&E&SgsRQ&Pz2|dvxhF zmfdf6q~AK%`%czoUJv6$6Bb#|Y5O)7$*fzgR<-BGXVD+q`dw%3-kEr2Cd(AjpP|j| zj7-o>R|lnE?J#x+4YZoxZ{Ms(5dF)DNl<$uqjpn5}J=d2t@y^{X UT&Hs4L{Q`Z|Eyr0f1wTl04YPz*8l(j literal 0 HcmV?d00001 diff --git a/pallets/snarcos/src/benchmarking/resources/marlin/merkle_tree_1024.proof.bytes b/pallets/snarcos/src/benchmarking/resources/marlin/merkle_tree_1024.proof.bytes new file mode 100644 index 0000000000000000000000000000000000000000..f24d8b452b777adc048d14e442a6725fc68e790d GIT binary patch literal 951 zcmV;o14#S>0000000004000000001It=9!EnHs|#Z|g}zM=4o^#=Jn_s4JS)dlo^= z>8KoK(5(TbQWEiIzvR+WecpxurpisY&SGq?%7qchpegWMcOgN;4NEJ<3&}yLPLhzZ zlxJFbqPpp(g}dktm}QlT04TG$LXLH;8>rJxfQ$F^{tR)Pu=BJuy${$A!h>=Lau zXGth%R*}tAWBQ-Pg#eIje$*LATu5;0k1Fz9;n|}5XfqmLtKe4t04;r@MR#yN|7G)z zY815n20d%dzySaQ000000001MtAZ!R?rrLk=EI$Z!yVVS*_n2xmW^e`)fPOP5@W02 zGCRmlt{^(d>cJd{;a`&g2c2o0`W`Kr0n;?I^`SQA+fD^M%N2Cu@b1Of3u4%>X(fi+ zOV=BlzH_Z_l5{i)0j7Z@77{wf8jl7MeKLd^C;VCj@AxsUu?x%vSNaqn@b5{70BV!6 zui3-en<9X3hKSvy1i>d_Mk^#gkHAql2{2sEFB3iDCrWT*^@l@UMw0+$-f)dYfDYAT zW&iJu6#xPN00000000NC4_M{@C&9adK=oj*xXvl2haV(RfZZ2}CYyS%z{Gy_Q^VrHpUKYOf0N@PYs(s`zL#94B zs>qoFyUmMJh?!vfL{<4O1V(td9&EgwLJiJurJvgcS=id?tB;oekb6@{bv%#nZ^cTk z*(?SC2LJ#700000)|earSs5pttUnfw8A$XL=i;ZV%Cd63dBHL9$>cU$1Pc{9+qHw8 zS61LwM9L{+txXuOCXbWLI-mPOVz*Q=8l^#l9I?^G`_AO=B(W|On0t=1Emrx;7(97> zz425~#K(yv09bgr{K&)a=2aA!4Z3o6iQdp7C^b=OYYT8Dj^M_Jqu+>Oi&0t#Vbb4{ zxpjScdibrCD6T4|Y4#dd{q9RwSirjGOO;fr&*ivjc@6Wr#nl}96%+~U-c(N&lzuoh zmWJMzGCO;gKNC%(kt65z;knxcw!bck%Q@Rz0{{R30000000002000000000b@zZIh z_vljuwF}=$>Qh7w?%%LugkV0ufCzv_FCtfCxSllwW$(|Dwhgi~tYm@#Ba+!3K?0V` zE|~eUE))VVElQUnsQsOhKN91U>XXAO)q5%K7PB%NPaaWyZ`9i}-uQoW|Bom7YVV7b Z?ou+|H7<7C|I{t~D?$99@yE;=006DYy5|4@ literal 0 HcmV?d00001 diff --git a/pallets/snarcos/src/benchmarking/resources/marlin/merkle_tree_1024.public_input.bytes b/pallets/snarcos/src/benchmarking/resources/marlin/merkle_tree_1024.public_input.bytes new file mode 100644 index 0000000000000000000000000000000000000000..76dd2df03ee3907be8bf595e61e49b91f8170f4f GIT binary patch literal 296 xcmd;NfB?lK_vW2B6MVzWXXmbh(CS}i?9ZQnvfB8p+)DTOxwrCqP-P>Q0ssik5!e6# literal 0 HcmV?d00001 diff --git a/pallets/snarcos/src/benchmarking/resources/marlin/merkle_tree_1024.vk.bytes b/pallets/snarcos/src/benchmarking/resources/marlin/merkle_tree_1024.vk.bytes new file mode 100644 index 0000000000000000000000000000000000000000..a73b1025b4e9bf218013d36573867bdd50b6d065 GIT binary patch literal 997 zcmVzyJUM0000G000000000C000000000hi_`Ee z1wp#C+xX^o-2`fw3N=6w5bbU^lxX#UBvI5tY^G!wu6xXc)2a!QtqGX`F2inJ0GFB# zHu+Dz;`ixN?$aIvn#RjORnsB(npgW|%lVo z<8<=zijPH2tE@b+0LTq*naISv|ImV?o1ulZ3#o3P>}5iN zuk1wuPr*o-7`-bUq~_fFYVd`wtA*nZj{w85#GJz?0W;VrER^MKYp2S8B(YL>v^FdG zp(4eg6d^h&mdl4mu_e&oVsXNu9}NH!hX{~cjR~K6X8k(%L8tga2{2r5^i3JNz9GE(#T~qe1RkW=Z5_JZP?FO@~Ln zHAi)3S&{%x%Zat><{(@U0AE$=l-Jw($p&%i2>lS_AK9lw26T|aF}gaExo30_Di_$rPShHE&o2jgW)%&T|9QG{hGo`r@RD^7cWW1zrH zt<*8!e$hftP7VO}zE;1CKH5~~E*NMV>bfS6tPtLsZo}eV4OKpnp}!9*bosaV_;iU4 zIQ6|1qdAUY8k;vL7yTEJJ$R8I`IBPzSFrtnZ20 zP=*gnkXr1-*#PtPDqW9U)jEwuJR-eidm4ALy!ed#a%_nB1qx9N*r3G+SB)4yajXE4 zWwI%${PZT`{AvvLVyrC>A^5)FM)F-munV%w69`G!<|LzJ+j*Qal@Vy@>_HOS%o zt{A%C5S%g-TE(9E@v*b2e#1phf*D0000000004000000000n3+r@$*x>1T3jMS-DCqnWHD|9xcDrygW9~DwWYu6 z(3!-o?Q49YQPk6Zr|0{V07LN7uar=r!GU*2l7Syksx&bdBzPRxzDuo000000000ri1H(Rbbdf^WVjWx)aFF)m#_Md-d=FNrVQUab6WbX zCe4~2-Xszyq2{qkwKf3&n_8C_Xw7~OO3U`a=PLghNc_@RHWz~`)1XXAv7f3`7rjS5 z9?w|lVnRmt3f zx*$jRI*1Z=kYM+=JaXTS>K1sXbiG95+7}dq_al<%2P@^x4Yk-^hTUoEOPi>!501EH2~M(|b2;o)Y?O==v5=kWaS= zEGvnmBU~(r(2D`NbKu%WS>{ngYx$27)^$VDA6B9AMAMUFbbsRFy%kj%3N-ph+J0hlrsz(X7B zyRMP|2LJ#700000LW-(lV;wW`VYbMCfI>dw+mv;W&E=2=EcW#B+8uA!|>_i6VcTE-aIX@ePxWVylC#nI{GhokX8pVnfe00v{N4+Uobnc^V$IK zcnUnw1o8U5&QPhu&4L3T_44jtA-Ucg;9m1H0`J3a^gg6b!Ce<$Kym&F{Tr1(pFL4i zxaMJ;xAD9ZOI{+j$CgtZ;y$)mcWQMAlwZdJ0{{R30000000002000000001$dWU@k zKiSxZ{g4+RTU}Acst!?j-P(YVAAD?I%=>nL`#XbZ(q`ccV~P8|*zXnr%t6mC(0b~O zpvU?aL6n*NKQ~CJ%c+%Vzrn7kRhPy*_%Ej<(093Sprmb5S20JIMQ|84QYBlQD%P0049f!j%93 literal 0 HcmV?d00001 diff --git a/pallets/snarcos/src/benchmarking/resources/marlin/merkle_tree_64.public_input.bytes b/pallets/snarcos/src/benchmarking/resources/marlin/merkle_tree_64.public_input.bytes new file mode 100644 index 0000000000000000000000000000000000000000..594ec284a1120a6379bbaac36928f16870577f3e GIT binary patch literal 296 xcmd;NfPhC|4s+iZQ{J<8+wX#97mL3J*zWMV;_s)~lI{K`efOP0sIn1D0RS_Q5&ZxF literal 0 HcmV?d00001 diff --git a/pallets/snarcos/src/benchmarking/resources/marlin/merkle_tree_64.vk.bytes b/pallets/snarcos/src/benchmarking/resources/marlin/merkle_tree_64.vk.bytes new file mode 100644 index 0000000000000000000000000000000000000000..2c21e02cc30aeae09c57e8c0937b4343f33a375f GIT binary patch literal 997 zcmVnkV;Wz3(H3v;Sxq@kRy>Gh|o2J)t;H7IGF*(>L0C~gV>FS0iOJ8dY~ zysh50!%Si!J!n73&tHWV6L1B%s5f7$#28Z$C>GUr9QA{$csfLo0AfoSq`UxBBRt=m zr?_Y+cAZVxr(W|PknEudO{(^Xa3V!ny&F#Q6|;mxjeS<#1ptUOFeBYxe(=ThMihAG zv!xe7wQtJc(L)l4d{(%V3{h5*}$pB(lcf-~1!*(Zi9>UzaWg=wj}V(!?t zdfPs)Di98JOWg8--!!T*4UbSnPyqnvHy9%;u9+WbNG0TwLbb4MP6FyMMhe#0knB0( zS6qQTloPLQYT2(#w0wyaK8?CJ?9dwqv?TM zk+?Qz>bCa%eFXsazE;1CKH5~~E*NMV>bfS6tPtLsZo}eV4OKpnp}!9*bosaV_;iU4 zIQ6|1qdAUY8k;vL7yTEJJ$R8I`IBPzSFrtnZ20 zP=*gnkXr1-*#PtPDqW9U)jEwuJR-eidm4ALy!ed#a%_nB1qx9N*r3G+SB)4yajXE4 zWwI%${PZT`{AvvLVyrC>A^5)FM)F-munV%w69`G!<|LzJ+j*Qal@Vy@>_HOS%o zt{A%C5S%g-TE(9E@v*b2e#1phf*D0000000004000000002t^_C>Yg=|LQDw=GrQa!T@>v5&~pNS9zl`z-* z&c`FL1y|##-KlH%myk=iqx^sX=C1MgtMY@BP;%{f#pIhbM}~Q&h}KRp77B|FMNi_W z%S5!^EopgJTb%{!|B{Li09dhni`fRyfU3Z=aOD~U);^(Z%TUnvgLJEFOj8nlfAi^w zQ)=`fHRvx;4=~Y10su#-|HW#b-XNBSHe%K=d|2XDp6DrOp$qw0%TWU@+4cYd1uX4% zxhdB~CO<%%of!ZF000000000}@{TV#)KNBdDiXgcC`H$houN~f1!f|`ap86*k$yuu zT$Y>qcGs9cs*&Mq%?*VB7jTp!vtR^_S0Siy(mI)N`Dn<|~H}4xHH~R37ps?Zd(X7a#|C@P7c8*U~KVjBa zA`X4;x^zO|1SiAaDwkbkE!gw1H^=*fe24`guE8t|Tc`X(Nh{xe?^d%4R8lkFBuIY{ zvXPwdg#ZEo00000002s!{y0(HZXK0TOSKjlfg0Aa_h7|#{^fAcjXObDJ|6fsAFZc5 zU+oS62LJ#700000`AC_CJatjSSg9uWqKu%0gPX>V(TU`N78}nuUwMOI@B0K~W4y z%-|(P3^17gRZXoFkb1uji?LFoVfu^v(4=k=>q=vhID|?YKwi*ORKgp8vw5)v=xEI? z^z!$JqZdJ|-9Ih7M@>RWsxd!zWY0wz~h*8|YNl{XG zb$hP+`u;q>D(OFThu_J<;PAoT8Bo*@iB%omdh4^eyksx>@g4RPw&c$tW;lP Z&VYDF?%O4p-pvp!p1puhP5^?|l literal 0 HcmV?d00001 diff --git a/pallets/snarcos/src/benchmarking/resources/marlin/merkle_tree_8.vk.bytes b/pallets/snarcos/src/benchmarking/resources/marlin/merkle_tree_8.vk.bytes new file mode 100644 index 0000000000000000000000000000000000000000..569c9dd8d7a90d25ca715914e8d54ea86b80f50e GIT binary patch literal 997 zcmVv;qKQsPUP!PdE8 z3fn0-XIgm&_0dsh0UpTIg)H}+Pl{l`{1M`ad6x!2!y^kuuru8T04|hpUqy=sI&bn@ zYfglJ%1bk!4&gTqls7p5yrc~|$*&Q%PrhJWul~3m;8B*W1OT;yi>FI36L>k|QW{?V zu43EdqrqVn6HJ>2OrmJJ`I|sA@nV)3H|4DINa0@~#0dbYr=X_8#vlAeK!kW`VU%2Y z6^w_H;)>rQtpEb8quBjr`Ur@(J)-W2^d3sEXEzi8R}4+8{BAP{6Kc>#SGlBatVLi* z%arJ+O?~X{EQRe2ML<+gk-dCUZKf7#KVJ@$um zR$SptXBQ&svY^fi?s#%Kb9FgcCHPgo6aaRQ{w-#;viBLe(z_lo@9j+$ZdM|(jFt%{bjC4w!KBCz3GkL{O(VX@ph^^f!a+J zMtcwZgBez*@q_^OzE;1CKH5~~E*NMV>bfS6tPtLsZo}eV4OKpnp}!9*bosaV_;iU4 zIQ6|1qdAUY8k;vL7yTEJJ$R8I`IBPzSFrtnZ20 zP=*gnkXr1-*#PtPDqW9U)jEwuJR-eidm4ALy!ed#a%_nB1qx9N*r3G+SB)4yajXE4 zWwI%${PZT`{AvvLVyrC>A^5)FM)F-munV%w69`G!<|LzJ+j*Qal@Vy@>_HOS%o zt{A%C5S%g-TE(9E@v*b2e#1phf*DmB1RnDzd-xmWX1M7ZrVJ+e-q=8qIA^VPt&N7 T|NjL500000|GxkL00000v=G>p literal 0 HcmV?d00001 diff --git a/pallets/snarcos/src/benchmarking/resources/marlin/xor.proof.bytes b/pallets/snarcos/src/benchmarking/resources/marlin/xor.proof.bytes new file mode 100644 index 0000000000000000000000000000000000000000..07d3dd368cb4e76e3f3977d60b1b31f691db75e0 GIT binary patch literal 951 zcmV;o14#S>0000000004000000000`8`AdGc9t;sl*WkXTn{wk@(SW~(HN+GJ4AuM zb1MBt?fXQ5ieHRJ_R^}xmuratg=FlF3jom*i^Sx`{YP#P9vYeHX-pOTtei8?g#O*K zi@^Go0ahR9jX?^|@51nb07|mkM0EX)Ynk*GxXG;hv6kVvlLp&NpA-yWn!jzPcDwA6-G8;+C2 zu~x-))hW4T4T=B*000000000iUT()H)xSrRCYU!;{=A`|m#C&;H?e&VUB&O0QcjI^ zr&3p8mWeA(N3nl%msN-WN|A~IS?T?h-IOQCnHn#aAnXqWn!l5XHUnpmahhdYYq1E1}1tGObdVj`kwa z*OkK&HaH*yg}kX}zHkj;gylQ%cEi|)YC&MezoUb5Q6+E4gtJAskKMaYVC3;o>fb3l z8#js5iOdffvbdDh45u`kTg;hxFY=oE@o`g2LJ#700000LVPLv%k&B@%ND}5{7-df{c5E{UqG`dn$M!rG>;xPGJ^-!$N{z^ z1s{=jB;?J)U{dqeYQgst`gY~#mi$%)WmusTInny^KM?E`ajKN=S6nYRu6Iq(k-zvQ znFH+vt7zQmnXQxWE%~PUr2=5)5(4?dU^|;)yQ{D`pABwOygS_ zD5=fEW(IM zYw#X%wCUnPu{KHUF@II=)Es92d*{JZd3hEb&D+W!t7jlJw?o8P{~7=RVH)DmM8ki+ zSlomM!GUZbS?Tpyn%lwq4sT^&WC3FV!`ZbqZB;N8GoGG9|D==N1Vrp6$+bjlO}dNL Zjy+vZ4)NK$8IAfj?o3alV~Mtx003=DwyOXD literal 0 HcmV?d00001 diff --git a/pallets/snarcos/src/benchmarking/resources/marlin/xor.public_input.bytes b/pallets/snarcos/src/benchmarking/resources/marlin/xor.public_input.bytes new file mode 100644 index 0000000000000000000000000000000000000000..bd66ea8e575cb6ff80aaf1c601da14d88db570cf GIT binary patch literal 264 Rcmd;JAPz7Rr)2n^_kWuawfyY)xsOUtKl{6LK;ul>ioo^ui+&1{&WDK#6B3 zb7RjOyB$y)12T`i1bMzx59;mo5J{i5cC#U%I~+P%P7(k%d9jy+4F6}z&l9|$mfUWK zo1p}LF{fFHslDEk6d|(?e2(mt0)!#=m~yRvACv|F;m7oYf8vj3UA}-k&9}6VyaMoD z44iSDjN8F%=&AZx{JQ(_B$z$hf>OKpz*>?30OiW8envKpK!`D`Z}0Ow6La5SZS2gX zGW!xM@Ie)HX)M>eQ0Mgg#FyC9$6&G43jp99k(x>}0lh!%FbKHGKMr_4B~dw522{beI&>b&ON zA%}r}{HT}G?ds820{~>X37{H87B?*M<{28Ad0)Pi^m2HGPga6%rx7Q)lJAh>Qh4VO z7^O0MJGg~XzJLJszE;1CKH5~~E*NMV>bfS6tPtLsZo}eV4OKpnp}!9*bosaV_;iU4 zIQ6|1qdAUY8k;vL7yTEJJ$R8I`IBPzSFrtnZ20 zP=*gnkXr1-*#PtPDqW9U)jEwuJR-eidm4ALy!ed#a%_nB1qx9N*r3G+SB)4yajXE4 zWwI%${PZT`{AvvLVyrC>A^5)FM)F-munV%w69`G!<|LzJ+j*Qal@Vy@>_HOS%o zt{A%C5S%g-TE(9E@v*b2e#1phf*Dn5mc6uE6-aO+MjdM|x-(1lE{b|YL!GaT*;oiXEII@44 zJ^%m!000003ujL{sFFGJq Date: Fri, 4 Nov 2022 09:48:07 +0100 Subject: [PATCH 15/41] Benchmark --- pallets/snarcos/src/benchmarking/import.rs | 3 + pallets/snarcos/src/benchmarking/suite.rs | 27 +++++ pallets/snarcos/src/weights.rs | 117 ++++++++++++++++----- 3 files changed, 120 insertions(+), 27 deletions(-) diff --git a/pallets/snarcos/src/benchmarking/import.rs b/pallets/snarcos/src/benchmarking/import.rs index a2be2adc1b..7668651a66 100644 --- a/pallets/snarcos/src/benchmarking/import.rs +++ b/pallets/snarcos/src/benchmarking/import.rs @@ -59,6 +59,9 @@ macro_rules! system { (Gm17) => { "gm17" }; + (Marlin) => { + "marlin" + }; } /// Converts relation identifier to a `&static str` that is used in the filename pattern. diff --git a/pallets/snarcos/src/benchmarking/suite.rs b/pallets/snarcos/src/benchmarking/suite.rs index 28bdae984a..16a96809ec 100644 --- a/pallets/snarcos/src/benchmarking/suite.rs +++ b/pallets/snarcos/src/benchmarking/suite.rs @@ -76,4 +76,31 @@ benchmarks! { let _ = insert_key::(key); } : verify(caller::(), IDENTIFIER, proof, input, Gm17) + // Marlin benchmarks + + verify_marlin_xor { + let Artifacts { key, proof, input } = get_artifacts!(Marlin, Xor); + let _ = insert_key::(key); + } : verify(caller::(), IDENTIFIER, proof, input, Marlin) + + verify_marlin_linear_equation { + let Artifacts { key, proof, input } = get_artifacts!(Marlin, LinearEquation); + let _ = insert_key::(key); + } : verify(caller::(), IDENTIFIER, proof, input, Marlin) + + verify_marlin_merkle_tree_8 { + let Artifacts { key, proof, input } = get_artifacts!(Marlin, MerkleTree8); + let _ = insert_key::(key); + } : verify(caller::(), IDENTIFIER, proof, input, Marlin) + + verify_marlin_merkle_tree_64 { + let Artifacts { key, proof, input } = get_artifacts!(Marlin, MerkleTree64); + let _ = insert_key::(key); + } : verify(caller::(), IDENTIFIER, proof, input, Marlin) + + verify_marlin_merkle_tree_1024 { + let Artifacts { key, proof, input } = get_artifacts!(Marlin, MerkleTree1024); + let _ = insert_key::(key); + } : verify(caller::(), IDENTIFIER, proof, input, Marlin) + } diff --git a/pallets/snarcos/src/weights.rs b/pallets/snarcos/src/weights.rs index 0f6825dea5..b20f8fc330 100644 --- a/pallets/snarcos/src/weights.rs +++ b/pallets/snarcos/src/weights.rs @@ -1,8 +1,8 @@ //! Autogenerated weights for pallet_snarcos //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-10-26, STEPS: `20`, REPEAT: 50, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("/tmp/chainspec.json"), DB CACHE: 1024 +//! DATE: 2022-11-04, STEPS: `20`, REPEAT: 50, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("chainspec.json"), DB CACHE: 1024 // Executed Command: // target/release/aleph-node @@ -55,7 +55,11 @@ impl WeightInfo for I { } fn verify_marlin() -> Weight { - todo!() + ::verify_marlin_xor() + .max(::verify_marlin_linear_equation()) + .max(::verify_marlin_merkle_tree_8()) + .max(::verify_marlin_merkle_tree_64()) + .max(::verify_marlin_merkle_tree_1024()) } } @@ -72,65 +76,97 @@ trait BenchmarkInfo { fn verify_gm17_merkle_tree_8() -> Weight; fn verify_gm17_merkle_tree_64() -> Weight; fn verify_gm17_merkle_tree_1024() -> Weight; + fn verify_marlin_xor() -> Weight; + fn verify_marlin_linear_equation() -> Weight; + fn verify_marlin_merkle_tree_8() -> Weight; + fn verify_marlin_merkle_tree_64() -> Weight; + fn verify_marlin_merkle_tree_1024() -> Weight; } /// Weights for pallet_snarcos using the Substrate node and recommended hardware. pub struct AlephWeight(PhantomData); impl BenchmarkInfo for AlephWeight { // Storage: Snarcos VerificationKeys (r:1 w:1) - fn store_key(_l: u32, ) -> Weight { - (11_740_000 as Weight) + fn store_key(l: u32, ) -> Weight { + (13_215_000 as Weight) + // Standard Error: 0 + .saturating_add((1_000 as Weight).saturating_mul(l as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_groth16_xor() -> Weight { - (44_383_443_000 as Weight) + (40_447_811_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_groth16_linear_equation() -> Weight { - (31_830_540_000 as Weight) + (31_871_256_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_groth16_merkle_tree_8() -> Weight { - (41_938_960_000 as Weight) + (42_480_128_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_groth16_merkle_tree_64() -> Weight { - (42_613_088_000 as Weight) + (42_398_453_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_groth16_merkle_tree_1024() -> Weight { - (41_989_457_000 as Weight) + (42_378_163_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_gm17_xor() -> Weight { - (44_472_591_000 as Weight) + (44_981_563_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_gm17_linear_equation() -> Weight { - (36_445_886_000 as Weight) + (36_357_503_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_gm17_merkle_tree_8() -> Weight { - (47_406_311_000 as Weight) + (47_051_568_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_gm17_merkle_tree_64() -> Weight { - (52_658_318_000 as Weight) + (47_014_891_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_gm17_merkle_tree_1024() -> Weight { - (52_424_591_000 as Weight) + (47_116_162_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_marlin_xor() -> Weight { + (72_137_828_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_marlin_linear_equation() -> Weight { + (71_774_309_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_marlin_merkle_tree_8() -> Weight { + (70_744_544_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_marlin_merkle_tree_64() -> Weight { + (71_259_014_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_marlin_merkle_tree_1024() -> Weight { + (71_051_023_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } } @@ -138,59 +174,86 @@ impl BenchmarkInfo for AlephWeight { // For backwards compatibility and tests impl BenchmarkInfo for () { // Storage: Snarcos VerificationKeys (r:1 w:1) - fn store_key(_l: u32, ) -> Weight { - (11_740_000 as Weight) + fn store_key(l: u32, ) -> Weight { + (13_215_000 as Weight) + // Standard Error: 0 + .saturating_add((1_000 as Weight).saturating_mul(l as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_groth16_xor() -> Weight { - (44_383_443_000 as Weight) + (40_447_811_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_groth16_linear_equation() -> Weight { - (31_830_540_000 as Weight) + (31_871_256_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_groth16_merkle_tree_8() -> Weight { - (41_938_960_000 as Weight) + (42_480_128_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_groth16_merkle_tree_64() -> Weight { - (42_613_088_000 as Weight) + (42_398_453_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_groth16_merkle_tree_1024() -> Weight { - (41_989_457_000 as Weight) + (42_378_163_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_gm17_xor() -> Weight { - (44_472_591_000 as Weight) + (44_981_563_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_gm17_linear_equation() -> Weight { - (36_445_886_000 as Weight) + (36_357_503_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_gm17_merkle_tree_8() -> Weight { - (47_406_311_000 as Weight) + (47_051_568_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_gm17_merkle_tree_64() -> Weight { - (52_658_318_000 as Weight) + (47_014_891_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Snarcos VerificationKeys (r:1 w:0) fn verify_gm17_merkle_tree_1024() -> Weight { - (52_424_591_000 as Weight) + (47_116_162_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_marlin_xor() -> Weight { + (72_137_828_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_marlin_linear_equation() -> Weight { + (71_774_309_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_marlin_merkle_tree_8() -> Weight { + (70_744_544_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_marlin_merkle_tree_64() -> Weight { + (71_259_014_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + } + // Storage: Snarcos VerificationKeys (r:1 w:0) + fn verify_marlin_merkle_tree_1024() -> Weight { + (71_051_023_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } } From b61d826474060245296da4ff1e343659c387871a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 12:19:21 +0100 Subject: [PATCH 16/41] Merge remote-tracking branch 'origin/snarkeling' into benchmarks --- bin/cliain/Cargo.lock | 4431 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 4431 insertions(+) create mode 100644 bin/cliain/Cargo.lock diff --git a/bin/cliain/Cargo.lock b/bin/cliain/Cargo.lock new file mode 100644 index 0000000000..c3f34d8a5c --- /dev/null +++ b/bin/cliain/Cargo.lock @@ -0,0 +1,4431 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + +[[package]] +name = "ac-compose-macros" +version = "0.1.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate-api-client.git?branch=liminal#8599a57d5298a2bec8d85036240e0060b0324620" +dependencies = [ + "ac-primitives", + "log", + "parity-scale-codec", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "ac-node-api" +version = "0.1.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate-api-client.git?branch=liminal#8599a57d5298a2bec8d85036240e0060b0324620" +dependencies = [ + "ac-primitives", + "frame-metadata", + "frame-support", + "frame-system", + "hex", + "log", + "parity-scale-codec", + "scale-info", + "serde", + "serde_json", + "sp-core 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "thiserror", +] + +[[package]] +name = "ac-primitives" +version = "0.1.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate-api-client.git?branch=liminal#8599a57d5298a2bec8d85036240e0060b0324620" +dependencies = [ + "hex", + "parity-scale-codec", + "sp-core 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "addr2line" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom 0.2.8", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "0.7.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" +dependencies = [ + "memchr", +] + +[[package]] +name = "aleph_client" +version = "1.5.2" +dependencies = [ + "ac-primitives", + "anyhow", + "frame-support", + "hex", + "log", + "pallet-aleph", + "pallet-balances", + "pallet-elections", + "pallet-multisig", + "pallet-staking", + "pallet-treasury", + "pallet-vesting", + "parity-scale-codec", + "primitives", + "rayon", + "serde_json", + "sp-core 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "substrate-api-client", + "thiserror", +] + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi 0.3.9", +] + +[[package]] +name = "anyhow" +version = "1.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" + +[[package]] +name = "approx" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6" +dependencies = [ + "num-traits", +] + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" +dependencies = [ + "nodrop", +] + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + +[[package]] +name = "arrayvec" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" + +[[package]] +name = "async-trait" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e805d94e6b5001b651426cf4cd446b1ab5f319d27bab5c644f61de0a804360c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "backtrace" +version = "0.3.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" +dependencies = [ + "addr2line", + "cc", + "cfg-if 1.0.0", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + +[[package]] +name = "base58" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6107fe1be6682a68940da878d9e9f5e90ca5745b3dec9fd1bb393c8777d4f581" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "blake2" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9cf849ee05b2ee5fba5e36f97ff8ec2533916700fc0758d40d92136a42f3388" +dependencies = [ + "digest 0.10.5", +] + +[[package]] +name = "blake2-rfc" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" +dependencies = [ + "arrayvec 0.4.12", + "constant_time_eq", +] + +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +dependencies = [ + "block-padding", + "byte-tools", + "byteorder", + "generic-array 0.12.4", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array 0.14.6", +] + +[[package]] +name = "block-buffer" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +dependencies = [ + "generic-array 0.14.6", +] + +[[package]] +name = "block-padding" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +dependencies = [ + "byte-tools", +] + +[[package]] +name = "brownstone" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "030ea61398f34f1395ccbeb046fb68c87b631d1f34567fed0f0f11fa35d18d8d" +dependencies = [ + "arrayvec 0.7.2", +] + +[[package]] +name = "bumpalo" +version = "3.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" + +[[package]] +name = "byte-slice-cast" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" +dependencies = [ + "byteorder", + "iovec", +] + +[[package]] +name = "cc" +version = "1.0.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581f5dba903aac52ea3feb5ec4810848460ee833876f1f9b0fdeab1f19091574" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1" +dependencies = [ + "iana-time-zone", + "num-integer", + "num-traits", + "winapi 0.3.9", +] + +[[package]] +name = "clap" +version = "3.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" +dependencies = [ + "atty", + "bitflags", + "clap_derive", + "clap_lex", + "indexmap", + "once_cell", + "strsim", + "termcolor", + "textwrap", +] + +[[package]] +name = "clap_derive" +version = "3.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "cliain" +version = "0.5.1" +dependencies = [ + "aleph_client", + "anyhow", + "clap", + "contract-metadata 0.6.0 (git+https://github.com/paritytech/cargo-contract.git?tag=v1.4.0)", + "contract-transcode", + "dialoguer", + "env_logger 0.8.4", + "ink_metadata", + "log", + "pallet-staking", + "parity-scale-codec", + "primitives", + "serde", + "serde_json", + "sp-core 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "substrate-api-client", +] + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[package]] +name = "console" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c050367d967ced717c04b65d8c619d863ef9292ce0c5760028655a2fb298718c" +dependencies = [ + "encode_unicode", + "lazy_static", + "libc", + "terminal_size", + "unicode-width", + "winapi 0.3.9", +] + +[[package]] +name = "const-oid" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3" + +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + +[[package]] +name = "contract-metadata" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36318b44d658ee23a2daf66811822bdf6ac686aa534ea87eb9e16e7430ca6928" +dependencies = [ + "impl-serde", + "semver", + "serde", + "serde_json", + "url", +] + +[[package]] +name = "contract-metadata" +version = "0.6.0" +source = "git+https://github.com/paritytech/cargo-contract.git?tag=v1.4.0#4e3a1981012999d310bd6e171aba4c5ffc7beaca" +dependencies = [ + "impl-serde", + "semver", + "serde", + "serde_json", + "url", +] + +[[package]] +name = "contract-transcode" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfa6db9d18dd5ef92d29c52d30c8503c857d390d9e4043e12466f1490c43c05e" +dependencies = [ + "anyhow", + "contract-metadata 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.9.1", + "escape8259", + "hex", + "indexmap", + "ink_env", + "ink_metadata", + "itertools", + "log", + "nom", + "nom-supreme", + "parity-scale-codec", + "scale-info", + "serde", + "serde_json", + "sp-core 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f916dfc5d356b0ed9dae65f1db9fc9770aa2851d2662b988ccf4fe3516e86348" +dependencies = [ + "autocfg", + "cfg-if 1.0.0", + "crossbeam-utils", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-bigint" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21" +dependencies = [ + "generic-array 0.14.6", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array 0.14.6", + "typenum", +] + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array 0.14.6", + "subtle", +] + +[[package]] +name = "crypto-mac" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +dependencies = [ + "generic-array 0.14.6", + "subtle", +] + +[[package]] +name = "curve25519-dalek" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b85542f99a2dfa2a1b8e192662741c9859a846b296bef1c92ef9b58b5a216" +dependencies = [ + "byteorder", + "digest 0.8.1", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + +[[package]] +name = "cxx" +version = "1.0.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b7d4e43b25d3c994662706a1d4fcfc32aaa6afd287502c111b237093bb23f3a" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84f8829ddc213e2c1368e51a2564c552b65a8cb6a28f31e576270ac81d5e5827" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e72537424b474af1460806647c41d4b6d35d09ef7fe031c5c2fa5766047cc56a" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "309e4fb93eed90e1e14bea0da16b209f81813ba9fc7830c20ed151dd7bc0a4d7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "der" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c" +dependencies = [ + "const-oid", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dialoguer" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92e7e37ecef6857fdc0c0c5d42fd5b0938e46590c2183cc92dd310a6d078eb1" +dependencies = [ + "console", + "tempfile", + "zeroize", +] + +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array 0.12.4", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array 0.14.6", +] + +[[package]] +name = "digest" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" +dependencies = [ + "block-buffer 0.10.3", + "crypto-common", + "subtle", +] + +[[package]] +name = "downcast-rs" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" + +[[package]] +name = "dyn-clonable" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e9232f0e607a262ceb9bd5141a3dfb3e4db6994b31989bbfd845878cba59fd4" +dependencies = [ + "dyn-clonable-impl", + "dyn-clone", +] + +[[package]] +name = "dyn-clonable-impl" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "558e40ea573c374cf53507fd240b7ee2f5477df7cfebdb97323ec61c719399c5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dyn-clone" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2" + +[[package]] +name = "ecdsa" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0d69ae62e0ce582d56380743515fefaf1a8c70cec685d9677636d7e30ae9dc9" +dependencies = [ + "der", + "elliptic-curve", + "rfc6979", + "signature", +] + +[[package]] +name = "ed25519" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9c280362032ea4203659fc489832d0204ef09f247a0506f170dafcac08c369" +dependencies = [ + "signature", +] + +[[package]] +name = "ed25519-dalek" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" +dependencies = [ + "curve25519-dalek 3.2.0", + "ed25519", + "rand 0.7.3", + "serde", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "either" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" + +[[package]] +name = "elliptic-curve" +version = "0.11.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25b477563c2bfed38a3b7a60964c49e058b2510ad3f12ba3483fd8f62c2306d6" +dependencies = [ + "base16ct", + "crypto-bigint", + "der", + "ff", + "generic-array 0.14.6", + "group", + "rand_core 0.6.4", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + +[[package]] +name = "env_logger" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "env_logger" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c90bf5f19754d10198ccb95b70664fc925bd1fc090a0fd9a6ebc54acc8cd6272" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "environmental" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68b91989ae21441195d7d9b9993a2f9295c7e1a8c96255d8b729accddc124797" + +[[package]] +name = "escape8259" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba4f4911e3666fcd7826997b4745c8224295a6f3072f1418c3067b97a67557ee" +dependencies = [ + "rustversion", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + +[[package]] +name = "fastrand" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", +] + +[[package]] +name = "ff" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "131655483be284720a17d74ff97592b8e76576dc25563148601df2d7c9080924" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "fixed-hash" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" +dependencies = [ + "byteorder", + "rand 0.8.5", + "rustc-hex", + "static_assertions", +] + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "frame-benchmarking" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "frame-support", + "frame-system", + "linregress", + "log", + "parity-scale-codec", + "paste", + "scale-info", + "serde", + "sp-api", + "sp-application-crypto 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-io 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-runtime-interface 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-storage 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "frame-election-provider-solution-type" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "frame-election-provider-support" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "frame-election-provider-solution-type", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-arithmetic 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-npos-elections", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "frame-metadata" +version = "15.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df6bb8542ef006ef0de09a5c4420787d79823c0ed7924225822362fd2bf2ff2d" +dependencies = [ + "cfg-if 1.0.0", + "parity-scale-codec", + "scale-info", + "serde", +] + +[[package]] +name = "frame-support" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "bitflags", + "frame-metadata", + "frame-support-procedural", + "impl-trait-for-tuples", + "k256", + "log", + "once_cell", + "parity-scale-codec", + "paste", + "scale-info", + "serde", + "smallvec", + "sp-arithmetic 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-core 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-core-hashing-proc-macro", + "sp-inherents", + "sp-io 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-staking", + "sp-state-machine 0.12.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-tracing 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "tt-call", +] + +[[package]] +name = "frame-support-procedural" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "Inflector", + "frame-support-procedural-tools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "frame-support-procedural-tools" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "frame-support-procedural-tools-derive", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "frame-support-procedural-tools-derive" +version = "3.0.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "frame-system" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "frame-support", + "log", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-io 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-version", +] + +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +dependencies = [ + "bitflags", + "fuchsia-zircon-sys", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" + +[[package]] +name = "futures-executor" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", + "num_cpus", +] + +[[package]] +name = "futures-io" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" + +[[package]] +name = "futures-macro" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" + +[[package]] +name = "futures-task" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" + +[[package]] +name = "futures-timer" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" + +[[package]] +name = "futures-util" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if 1.0.0", + "js-sys", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "gimli" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" + +[[package]] +name = "group" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5ac374b108929de78460075f3dc439fa66df9d8fc77e8f12caa5165fcf0c89" +dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "hash-db" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" + +[[package]] +name = "hash256-std-hasher" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92c171d55b98633f4ed3860808f004099b36c1cc29c42cfc53aa8591b21efcf2" +dependencies = [ + "crunchy", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" +dependencies = [ + "crypto-mac 0.8.0", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +dependencies = [ + "crypto-mac 0.11.1", + "digest 0.9.0", +] + +[[package]] +name = "hmac-drbg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" +dependencies = [ + "digest 0.9.0", + "generic-array 0.14.6", + "hmac 0.8.1", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "iana-time-zone" +version = "0.1.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "winapi 0.3.9", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "impl-codec" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" +dependencies = [ + "parity-scale-codec", +] + +[[package]] +name = "impl-serde" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4551f042f3438e64dbd6226b20527fc84a6e1fe65688b58746a2f53623f25f5c" +dependencies = [ + "serde", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "indent_write" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cfe9645a18782869361d9c8732246be7b410ad4e919d3609ebabdac00ba12c3" + +[[package]] +name = "indexmap" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "ink_allocator" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c9588a59a0e8997c0b2153cd11b5aaa77c06a0537a6b18f3811d1f1aa098b12" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "ink_engine" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "487c3b390b7feb0620496b0cd38683433c7d7e6946b1caabda51e1f23eb24b30" +dependencies = [ + "blake2", + "derive_more", + "parity-scale-codec", + "rand 0.8.5", + "secp256k1 0.24.1", + "sha2 0.10.6", + "sha3", +] + +[[package]] +name = "ink_env" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a891d34301a3dbb1c7b7424c49ae184282b163491c54f9acd17fcbe14a80447b" +dependencies = [ + "arrayref", + "blake2", + "cfg-if 1.0.0", + "derive_more", + "ink_allocator", + "ink_engine", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "num-traits", + "parity-scale-codec", + "paste", + "rand 0.8.5", + "rlibc", + "scale-info", + "secp256k1 0.24.1", + "sha2 0.10.6", + "sha3", + "static_assertions", +] + +[[package]] +name = "ink_metadata" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74913aaed5751f5615af4631b7559328b8ed56c9cb821b89e14af0706176e849" +dependencies = [ + "derive_more", + "impl-serde", + "ink_prelude", + "ink_primitives", + "scale-info", + "serde", +] + +[[package]] +name = "ink_prelude" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f031e6b8495594a7288b089bf4122e76c26b994959d1b2b693bdfe846b14c0e" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "ink_primitives" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12cf42dce81d060401c7cec95a392ad6d3c2f18661fa3083f619ce135133c33" +dependencies = [ + "cfg-if 1.0.0", + "ink_prelude", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "integer-sqrt" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" +dependencies = [ + "num-traits", +] + +[[package]] +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +dependencies = [ + "libc", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" + +[[package]] +name = "joinery" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72167d68f5fce3b8655487b8038691a3c9984ee769590f93f2a631f4ad64e4f5" + +[[package]] +name = "js-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "k256" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19c3a5e0a0b8450278feda242592512e09f61c72e018b8cd5c859482802daf2d" +dependencies = [ + "cfg-if 1.0.0", + "ecdsa", + "elliptic-curve", + "sec1", +] + +[[package]] +name = "keccak" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" + +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "libc" +version = "0.2.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" + +[[package]] +name = "libm" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "292a948cd991e376cf75541fe5b97a1081d713c618b4f1b9500f8844e49eb565" + +[[package]] +name = "libsecp256k1" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95b09eff1b35ed3b33b877ced3a691fc7a481919c7e29c53c906226fcf55e2a1" +dependencies = [ + "arrayref", + "base64", + "digest 0.9.0", + "hmac-drbg", + "libsecp256k1-core", + "libsecp256k1-gen-ecmult", + "libsecp256k1-gen-genmult", + "rand 0.8.5", + "serde", + "sha2 0.9.9", + "typenum", +] + +[[package]] +name = "libsecp256k1-core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be9b9bb642d8522a44d533eab56c16c738301965504753b03ad1de3425d5451" +dependencies = [ + "crunchy", + "digest 0.9.0", + "subtle", +] + +[[package]] +name = "libsecp256k1-gen-ecmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3038c808c55c87e8a172643a7d87187fc6c4174468159cb3090659d55bcb4809" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "libsecp256k1-gen-genmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db8d6ba2cec9eacc40e6e8ccc98931840301f1006e95647ceb2dd5c3aa06f7c" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "link-cplusplus" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" +dependencies = [ + "cc", +] + +[[package]] +name = "linregress" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6c601a85f5ecd1aba625247bca0031585fb1c446461b142878a16f8245ddeb8" +dependencies = [ + "nalgebra", + "statrs", +] + +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "matchers" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "matrixmultiply" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "add85d4dd35074e6fedc608f8c8f513a3548619a9024b751949ef0e8e45a4d84" +dependencies = [ + "rawpointer", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "memory-db" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6566c70c1016f525ced45d7b7f97730a2bafb037c788211d0c186ef5b2189f0a" +dependencies = [ + "hash-db", + "hashbrown", + "parity-util-mem", +] + +[[package]] +name = "memory_units" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" + +[[package]] +name = "merlin" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e261cf0f8b3c42ded9f7d2bb59dea03aa52bc8a1cbc7482f9fc3fd1229d3b42" +dependencies = [ + "byteorder", + "keccak", + "rand_core 0.5.1", + "zeroize", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.6.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" +dependencies = [ + "cfg-if 0.1.10", + "fuchsia-zircon", + "fuchsia-zircon-sys", + "iovec", + "kernel32-sys", + "libc", + "log", + "miow", + "net2", + "slab", + "winapi 0.2.8", +] + +[[package]] +name = "mio-extras" +version = "2.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" +dependencies = [ + "lazycell", + "log", + "mio", + "slab", +] + +[[package]] +name = "miow" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" +dependencies = [ + "kernel32-sys", + "net2", + "winapi 0.2.8", + "ws2_32-sys", +] + +[[package]] +name = "nalgebra" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "462fffe4002f4f2e1f6a9dcf12cc1a6fc0e15989014efc02a941d3e0f5dc2120" +dependencies = [ + "approx", + "matrixmultiply", + "nalgebra-macros", + "num-complex", + "num-rational 0.4.1", + "num-traits", + "rand 0.8.5", + "rand_distr", + "simba", + "typenum", +] + +[[package]] +name = "nalgebra-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01fcc0b8149b4632adc89ac3b7b31a12fb6099a0317a4eb2ebff574ef7de7218" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "net2" +version = "0.2.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d0df99cfcd2530b2e694f6e17e7f37b8e26bb23983ac530c0c97408837c631" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "nodrop" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" + +[[package]] +name = "nom" +version = "7.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "nom-supreme" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f909b25a8371ad5c054abc2c48205d677231e6a2dcbf83704ed57bb147f30e0" +dependencies = [ + "brownstone", + "indent_write", + "joinery", + "memchr", + "nom", +] + +[[package]] +name = "num-bigint" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ae39348c8bc5fbd7f40c727a9925f03517afd2ab27d46702108b6a7e5414c19" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-format" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54b862ff8df690cf089058c98b183676a7ed0f974cc08b426800093227cbff3b" +dependencies = [ + "arrayvec 0.7.2", + "itoa", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "num_cpus" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "openssl" +version = "0.10.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12fc0523e3bd51a692c8850d075d74dc062ccf251c0110668cbd921917118a13" +dependencies = [ + "bitflags", + "cfg-if 1.0.0", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-sys" +version = "0.9.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b03b84c3b2d099b81f0953422b4d4ad58761589d0229b5506356afca05a3670a" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "os_str_bytes" +version = "6.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3baf96e39c5359d2eb0dd6ccb42c62b91d9678aa68160d261b9e0ccbf9e9dea9" + +[[package]] +name = "pallet-aleph" +version = "0.5.0" +dependencies = [ + "frame-support", + "frame-system", + "pallet-balances", + "pallet-session", + "pallets-support", + "parity-scale-codec", + "primitives", + "scale-info", + "serde", + "sp-io 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "pallet-authorship" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "parity-scale-codec", + "scale-info", + "sp-authorship", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "pallet-balances" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "pallet-elections" +version = "0.4.0" +dependencies = [ + "frame-election-provider-support", + "frame-support", + "frame-system", + "pallet-authorship", + "pallet-balances", + "pallet-session", + "pallet-staking", + "pallets-support", + "parity-scale-codec", + "primitives", + "scale-info", + "sp-core 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-io 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-staking", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "pallet-multisig" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-io 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "pallet-session" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "log", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "sp-core 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-io 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-session", + "sp-staking", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-trie 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "pallet-staking" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "pallet-authorship", + "pallet-session", + "parity-scale-codec", + "scale-info", + "serde", + "sp-application-crypto 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-io 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-staking", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "pallet-timestamp" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-inherents", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-timestamp", +] + +[[package]] +name = "pallet-transaction-payment" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-io 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "pallet-treasury" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "pallet-balances", + "parity-scale-codec", + "scale-info", + "serde", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "pallet-vesting" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "pallets-support" +version = "0.1.0" +dependencies = [ + "frame-support", +] + +[[package]] +name = "parity-scale-codec" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "366e44391a8af4cfd6002ef6ba072bae071a96aafca98d7d448a34c5dca38b6a" +dependencies = [ + "arrayvec 0.7.2", + "bitvec", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9299338969a3d2f491d65f140b00ddec470858402f888af98e8642fb5e8965cd" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "parity-util-mem" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c32561d248d352148124f036cac253a644685a21dc9fea383eb4907d7bd35a8f" +dependencies = [ + "cfg-if 1.0.0", + "hashbrown", + "impl-trait-for-tuples", + "parity-util-mem-derive", + "parking_lot", + "primitive-types", + "winapi 0.3.9", +] + +[[package]] +name = "parity-util-mem-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" +dependencies = [ + "proc-macro2", + "syn", + "synstructure", +] + +[[package]] +name = "parity-wasm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", +] + +[[package]] +name = "paste" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" + +[[package]] +name = "pbkdf2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "216eaa586a190f0a738f2f918511eecfa90f13295abec0e457cdebcceda80cbd" +dependencies = [ + "crypto-mac 0.8.0", +] + +[[package]] +name = "pbkdf2" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" +dependencies = [ + "crypto-mac 0.11.1", +] + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" + +[[package]] +name = "ppv-lite86" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" + +[[package]] +name = "primitive-types" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28720988bff275df1f51b171e1b2a18c30d194c4d2b61defdacecd625a5d94a" +dependencies = [ + "fixed-hash", + "impl-codec", + "impl-serde", + "scale-info", + "uint", +] + +[[package]] +name = "primitives" +version = "0.4.1" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "sp-api", + "sp-application-crypto 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-core 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-staking", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "proc-macro-crate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" +dependencies = [ + "once_cell", + "thiserror", + "toml", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", + "rand_pcg", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.8", +] + +[[package]] +name = "rand_distr" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31" +dependencies = [ + "num-traits", + "rand 0.8.5", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rand_pcg" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rawpointer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" + +[[package]] +name = "rayon" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" +dependencies = [ + "autocfg", + "crossbeam-deque", + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "num_cpus", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "ref-cast" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53b15debb4f9d60d767cd8ca9ef7abb2452922f3214671ff052defc7f3502c44" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abfa8511e9e94fd3de6585a3d3cd00e01ed556dc9814829280af0e8dc72a8f36" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "regex" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi 0.3.9", +] + +[[package]] +name = "rfc6979" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96ef608575f6392792f9ecf7890c00086591d29a83910939d430753f7c050525" +dependencies = [ + "crypto-bigint", + "hmac 0.11.0", + "zeroize", +] + +[[package]] +name = "rlibc" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc874b127765f014d792f16763a81245ab80500e2ad921ed4ee9e82481ee08fe" + +[[package]] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "rustversion" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" + +[[package]] +name = "ryu" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" + +[[package]] +name = "scale-info" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d8a765117b237ef233705cc2cc4c6a27fccd46eea6ef0c8c6dae5f3ef407f8" +dependencies = [ + "bitvec", + "cfg-if 1.0.0", + "derive_more", + "parity-scale-codec", + "scale-info-derive", + "serde", +] + +[[package]] +name = "scale-info-derive" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdcd47b380d8c4541044e341dcd9475f55ba37ddc50c908d945fc036a8642496" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "schnorrkel" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "021b403afe70d81eea68f6ea12f6b3c9588e5d536a94c3bf80f15e7faa267862" +dependencies = [ + "arrayref", + "arrayvec 0.5.2", + "curve25519-dalek 2.1.3", + "getrandom 0.1.16", + "merlin", + "rand 0.7.3", + "rand_core 0.5.1", + "sha2 0.8.2", + "subtle", + "zeroize", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "scratch" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" + +[[package]] +name = "sec1" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1" +dependencies = [ + "der", + "generic-array 0.14.6", + "subtle", + "zeroize", +] + +[[package]] +name = "secp256k1" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c42e6f1735c5f00f51e43e28d6634141f2bcad10931b2609ddd74a86d751260" +dependencies = [ + "secp256k1-sys 0.4.2", +] + +[[package]] +name = "secp256k1" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff55dc09d460954e9ef2fa8a7ced735a964be9981fd50e870b2b3b0705e14964" +dependencies = [ + "secp256k1-sys 0.6.1", +] + +[[package]] +name = "secp256k1-sys" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957da2573cde917463ece3570eab4a0b3f19de6f1646cde62e6fd3868f566036" +dependencies = [ + "cc", +] + +[[package]] +name = "secp256k1-sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b" +dependencies = [ + "cc", +] + +[[package]] +name = "secrecy" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" +dependencies = [ + "zeroize", +] + +[[package]] +name = "semver" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" +dependencies = [ + "serde", +] + +[[package]] +name = "serde" +version = "1.0.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha-1" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" +dependencies = [ + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug 0.2.3", +] + +[[package]] +name = "sha2" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" +dependencies = [ + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug 0.2.3", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.9.0", + "opaque-debug 0.3.0", +] + +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.10.5", +] + +[[package]] +name = "sha3" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" +dependencies = [ + "digest 0.10.5", + "keccak", +] + +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "signature" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02658e48d89f2bec991f9a78e69cfa4c316f8d6a6c4ec12fae1aeb263d486788" +dependencies = [ + "digest 0.9.0", + "rand_core 0.6.4", +] + +[[package]] +name = "simba" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e82063457853d00243beda9952e910b82593e4b07ae9f721b9278a99a0d3d5c" +dependencies = [ + "approx", + "num-complex", + "num-traits", + "paste", +] + +[[package]] +name = "slab" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "sp-api" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "hash-db", + "log", + "parity-scale-codec", + "sp-api-proc-macro", + "sp-core 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-state-machine 0.12.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-version", + "thiserror", +] + +[[package]] +name = "sp-api-proc-macro" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "blake2", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sp-application-crypto" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acb4490364cb3b097a6755343e552495b0013778152300714be4647d107e9a2e" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "sp-core 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-io 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "sp-application-crypto" +version = "6.0.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "sp-core 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-io 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "sp-arithmetic" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31ef21f82cc10f75ed046b65e2f8048080ee76e59f1b8aed55c7150daebfd35b" +dependencies = [ + "integer-sqrt", + "num-traits", + "parity-scale-codec", + "scale-info", + "serde", + "sp-debug-derive 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "static_assertions", +] + +[[package]] +name = "sp-arithmetic" +version = "5.0.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "integer-sqrt", + "num-traits", + "parity-scale-codec", + "scale-info", + "serde", + "sp-debug-derive 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "static_assertions", +] + +[[package]] +name = "sp-authorship" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "async-trait", + "parity-scale-codec", + "sp-inherents", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "sp-core" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77963e2aa8fadb589118c3aede2e78b6c4bcf1c01d588fbf33e915b390825fbd" +dependencies = [ + "base58", + "bitflags", + "blake2-rfc", + "byteorder", + "dyn-clonable", + "ed25519-dalek", + "futures", + "hash-db", + "hash256-std-hasher", + "hex", + "impl-serde", + "lazy_static", + "libsecp256k1", + "log", + "merlin", + "num-traits", + "parity-scale-codec", + "parity-util-mem", + "parking_lot", + "primitive-types", + "rand 0.7.3", + "regex", + "scale-info", + "schnorrkel", + "secp256k1 0.21.3", + "secrecy", + "serde", + "sp-core-hashing 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-debug-derive 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-externalities 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime-interface 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-storage 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ss58-registry", + "substrate-bip39", + "thiserror", + "tiny-bip39", + "wasmi", + "zeroize", +] + +[[package]] +name = "sp-core" +version = "6.0.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "base58", + "bitflags", + "blake2-rfc", + "byteorder", + "dyn-clonable", + "ed25519-dalek", + "futures", + "hash-db", + "hash256-std-hasher", + "hex", + "impl-serde", + "lazy_static", + "libsecp256k1", + "log", + "merlin", + "num-traits", + "parity-scale-codec", + "parity-util-mem", + "parking_lot", + "primitive-types", + "rand 0.7.3", + "regex", + "scale-info", + "schnorrkel", + "secp256k1 0.21.3", + "secrecy", + "serde", + "sp-core-hashing 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-debug-derive 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-externalities 0.12.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-runtime-interface 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-storage 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "ss58-registry", + "substrate-bip39", + "thiserror", + "tiny-bip39", + "wasmi", + "zeroize", +] + +[[package]] +name = "sp-core-hashing" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec864a6a67249f0c8dd3d5acab43623a61677e85ff4f2f9b04b802d2fe780e83" +dependencies = [ + "blake2-rfc", + "byteorder", + "sha2 0.9.9", + "sp-std 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tiny-keccak", + "twox-hash", +] + +[[package]] +name = "sp-core-hashing" +version = "4.0.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "blake2", + "byteorder", + "digest 0.10.5", + "sha2 0.10.6", + "sha3", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "twox-hash", +] + +[[package]] +name = "sp-core-hashing-proc-macro" +version = "5.0.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "proc-macro2", + "quote", + "sp-core-hashing 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "syn", +] + +[[package]] +name = "sp-debug-derive" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d676664972e22a0796176e81e7bec41df461d1edf52090955cdab55f2c956ff2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sp-debug-derive" +version = "4.0.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sp-externalities" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fcfd91f92a2a59224230a77c4a5d6f51709620c0aab4e51f108ccece6adc56f" +dependencies = [ + "environmental", + "parity-scale-codec", + "sp-std 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-storage 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "sp-externalities" +version = "0.12.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "environmental", + "parity-scale-codec", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-storage 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "sp-inherents" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "async-trait", + "impl-trait-for-tuples", + "parity-scale-codec", + "sp-core 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "thiserror", +] + +[[package]] +name = "sp-io" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "935fd3c71bad6811a7984cabb74d323b8ca3107024024c3eabb610e0182ba8d3" +dependencies = [ + "futures", + "hash-db", + "libsecp256k1", + "log", + "parity-scale-codec", + "parking_lot", + "secp256k1 0.21.3", + "sp-core 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-externalities 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-keystore 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime-interface 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-state-machine 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-tracing 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-trie 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-wasm-interface 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tracing", + "tracing-core", +] + +[[package]] +name = "sp-io" +version = "6.0.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "futures", + "hash-db", + "libsecp256k1", + "log", + "parity-scale-codec", + "parking_lot", + "secp256k1 0.21.3", + "sp-core 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-externalities 0.12.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-keystore 0.12.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-runtime-interface 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-state-machine 0.12.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-tracing 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-trie 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-wasm-interface 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "tracing", + "tracing-core", +] + +[[package]] +name = "sp-keystore" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3261eddca8c8926e3e1de136a7980cb3afc3455247d9d6f3119d9b292f73aaee" +dependencies = [ + "async-trait", + "futures", + "merlin", + "parity-scale-codec", + "parking_lot", + "schnorrkel", + "sp-core 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-externalities 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror", +] + +[[package]] +name = "sp-keystore" +version = "0.12.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "async-trait", + "futures", + "merlin", + "parity-scale-codec", + "parking_lot", + "schnorrkel", + "sp-core 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-externalities 0.12.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "thiserror", +] + +[[package]] +name = "sp-npos-elections" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "sp-arithmetic 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-core 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "sp-panic-handler" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2101f3c555fceafcfcfb0e61c55ea9ed80dc60bd77d54d9f25b369edb029e9a4" +dependencies = [ + "backtrace", + "lazy_static", + "regex", +] + +[[package]] +name = "sp-panic-handler" +version = "4.0.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "backtrace", + "lazy_static", + "regex", +] + +[[package]] +name = "sp-rpc" +version = "6.0.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "rustc-hash", + "serde", + "sp-core 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "sp-runtime" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb7d8a8d5ab5d349c6cf9300af1721b7b6446ba63401dbb11c10a1d65197aa5f" +dependencies = [ + "either", + "hash256-std-hasher", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "parity-util-mem", + "paste", + "rand 0.7.3", + "scale-info", + "serde", + "sp-application-crypto 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-arithmetic 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-io 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "sp-runtime" +version = "6.0.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "either", + "hash256-std-hasher", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "parity-util-mem", + "paste", + "rand 0.7.3", + "scale-info", + "serde", + "sp-application-crypto 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-arithmetic 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-core 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-io 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "sp-runtime-interface" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "158bf0305c75a50fc0e334b889568f519a126e32b87900c3f4251202dece7b4b" +dependencies = [ + "impl-trait-for-tuples", + "parity-scale-codec", + "primitive-types", + "sp-externalities 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime-interface-proc-macro 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-storage 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-tracing 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-wasm-interface 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "static_assertions", +] + +[[package]] +name = "sp-runtime-interface" +version = "6.0.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "impl-trait-for-tuples", + "parity-scale-codec", + "primitive-types", + "sp-externalities 0.12.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-runtime-interface-proc-macro 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-storage 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-tracing 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-wasm-interface 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "static_assertions", +] + +[[package]] +name = "sp-runtime-interface-proc-macro" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ecb916b9664ed9f90abef0ff5a3e61454c1efea5861b2997e03f39b59b955f" +dependencies = [ + "Inflector", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sp-runtime-interface-proc-macro" +version = "5.0.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "Inflector", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sp-session" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-core 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-staking", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "sp-staking" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "parity-scale-codec", + "scale-info", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "sp-state-machine" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecee3b33eb78c99997676a571656bcc35db6886abecfddd13e76a73b5871c6c1" +dependencies = [ + "hash-db", + "log", + "num-traits", + "parity-scale-codec", + "parking_lot", + "rand 0.7.3", + "smallvec", + "sp-core 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-externalities 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-panic-handler 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-trie 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror", + "tracing", + "trie-db", + "trie-root", +] + +[[package]] +name = "sp-state-machine" +version = "0.12.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "hash-db", + "log", + "num-traits", + "parity-scale-codec", + "parking_lot", + "rand 0.7.3", + "smallvec", + "sp-core 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-externalities 0.12.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-panic-handler 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-trie 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "thiserror", + "tracing", + "trie-root", +] + +[[package]] +name = "sp-std" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14804d6069ee7a388240b665f17908d98386ffb0b5d39f89a4099fc7a2a4c03f" + +[[package]] +name = "sp-std" +version = "4.0.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" + +[[package]] +name = "sp-storage" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dab53af846068e3e0716d3ccc70ea0db44035c79b2ed5821aaa6635039efa37" +dependencies = [ + "impl-serde", + "parity-scale-codec", + "ref-cast", + "serde", + "sp-debug-derive 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "sp-storage" +version = "6.0.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "impl-serde", + "parity-scale-codec", + "ref-cast", + "serde", + "sp-debug-derive 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", +] + +[[package]] +name = "sp-timestamp" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "async-trait", + "futures-timer", + "log", + "parity-scale-codec", + "sp-api", + "sp-inherents", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "thiserror", +] + +[[package]] +name = "sp-tracing" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69a67e555d171c4238bd223393cda747dd20ec7d4f5fe5c042c056cb7fde9eda" +dependencies = [ + "parity-scale-codec", + "sp-std 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tracing", + "tracing-core", + "tracing-subscriber", +] + +[[package]] +name = "sp-tracing" +version = "5.0.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "parity-scale-codec", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "tracing", + "tracing-core", + "tracing-subscriber", +] + +[[package]] +name = "sp-trie" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6fc34f4f291886914733e083b62708d829f3e6b8d7a7ca7fa8a55a3d7640b0b" +dependencies = [ + "hash-db", + "memory-db", + "parity-scale-codec", + "scale-info", + "sp-core 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db", + "trie-root", +] + +[[package]] +name = "sp-trie" +version = "6.0.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "hash-db", + "memory-db", + "parity-scale-codec", + "scale-info", + "sp-core 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "thiserror", + "trie-db", + "trie-root", +] + +[[package]] +name = "sp-version" +version = "5.0.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "impl-serde", + "parity-scale-codec", + "parity-wasm", + "scale-info", + "serde", + "sp-core-hashing-proc-macro", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-version-proc-macro", + "thiserror", +] + +[[package]] +name = "sp-version-proc-macro" +version = "4.0.0-dev" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "parity-scale-codec", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sp-wasm-interface" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10d88debe690c2b24eaa9536a150334fcef2ae184c21a0e5b3e80135407a7d52" +dependencies = [ + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "sp-std 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi", +] + +[[package]] +name = "sp-wasm-interface" +version = "6.0.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal#d6a5cc42cfe07b8002759caf3bb6b307f446abd3" +dependencies = [ + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "wasmi", +] + +[[package]] +name = "ss58-registry" +version = "1.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ab7554f8a8b6f8d71cd5a8e6536ef116e2ce0504cf97ebf16311d58065dc8a6" +dependencies = [ + "Inflector", + "num-format", + "proc-macro2", + "quote", + "serde", + "serde_json", + "unicode-xid", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "statrs" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05bdbb8e4e78216a85785a85d3ec3183144f98d0097b9281802c019bb07a6f05" +dependencies = [ + "approx", + "lazy_static", + "nalgebra", + "num-traits", + "rand 0.8.5", +] + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "substrate-api-client" +version = "0.6.0" +source = "git+https://github.com/Cardinal-Cryptography/substrate-api-client.git?branch=liminal#8599a57d5298a2bec8d85036240e0060b0324620" +dependencies = [ + "ac-compose-macros", + "ac-node-api", + "ac-primitives", + "frame-metadata", + "frame-support", + "frame-system", + "hex", + "log", + "pallet-balances", + "pallet-staking", + "pallet-transaction-payment", + "parity-scale-codec", + "primitive-types", + "serde", + "serde_json", + "sp-application-crypto 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-core 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-rpc", + "sp-runtime 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-std 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=liminal)", + "sp-version", + "thiserror", + "ws", +] + +[[package]] +name = "substrate-bip39" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49eee6965196b32f882dd2ee85a92b1dbead41b04e53907f269de3b0dc04733c" +dependencies = [ + "hmac 0.11.0", + "pbkdf2 0.8.0", + "schnorrkel", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tempfile" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +dependencies = [ + "cfg-if 1.0.0", + "fastrand", + "libc", + "redox_syscall", + "remove_dir_all", + "winapi 0.3.9", +] + +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "terminal_size" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" +dependencies = [ + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "textwrap" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" + +[[package]] +name = "thiserror" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +dependencies = [ + "once_cell", +] + +[[package]] +name = "tiny-bip39" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffc59cb9dfc85bb312c3a78fd6aa8a8582e310b0fa885d5bb877f6dcc601839d" +dependencies = [ + "anyhow", + "hmac 0.8.1", + "once_cell", + "pbkdf2 0.4.0", + "rand 0.7.3", + "rustc-hash", + "sha2 0.9.9", + "thiserror", + "unicode-normalization", + "wasm-bindgen", + "zeroize", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "toml" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +dependencies = [ + "serde", +] + +[[package]] +name = "tracing" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0ecdcb44a79f0fe9844f0c4f33a342cbcbb5117de8001e6ba0dc2351327d09" +dependencies = [ + "cfg-if 1.0.0", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f54c8ca710e81886d498c2fd3331b56c93aa248d49de2222ad2742247c60072f" +dependencies = [ + "lazy_static", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-serde" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" +dependencies = [ + "serde", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71" +dependencies = [ + "ansi_term", + "chrono", + "lazy_static", + "matchers", + "regex", + "serde", + "serde_json", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", + "tracing-serde", +] + +[[package]] +name = "trie-db" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d32d034c0d3db64b43c31de38e945f15b40cd4ca6d2dcfc26d4798ce8de4ab83" +dependencies = [ + "hash-db", + "hashbrown", + "log", + "rustc-hex", + "smallvec", +] + +[[package]] +name = "trie-root" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a36c5ca3911ed3c9a5416ee6c679042064b93fc637ded67e25f92e68d783891" +dependencies = [ + "hash-db", +] + +[[package]] +name = "tt-call" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e66dcbec4290c69dd03c57e76c2469ea5c7ce109c6dd4351c13055cf71ea055" + +[[package]] +name = "twox-hash" +version = "1.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" +dependencies = [ + "cfg-if 1.0.0", + "digest 0.10.5", + "rand 0.8.5", + "static_assertions", +] + +[[package]] +name = "typenum" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" + +[[package]] +name = "uint" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a45526d29728d135c2900b0d30573fe3ee79fceb12ef534c7bb30e810a91b601" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" + +[[package]] +name = "unicode-ident" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" + +[[package]] +name = "wasmi" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca00c5147c319a8ec91ec1a0edbec31e566ce2c9cc93b3f9bb86a9efd0eb795d" +dependencies = [ + "downcast-rs", + "libc", + "memory_units", + "num-rational 0.2.4", + "num-traits", + "parity-wasm", + "wasmi-validation", +] + +[[package]] +name = "wasmi-validation" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "165343ecd6c018fc09ebcae280752702c9a2ef3e6f8d02f1cfcbdb53ef6d7937" +dependencies = [ + "parity-wasm", +] + +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi 0.3.9", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" + +[[package]] +name = "ws" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25fe90c75f236a0a00247d5900226aea4f2d7b05ccc34da9e7a8880ff59b5848" +dependencies = [ + "byteorder", + "bytes", + "httparse", + "log", + "mio", + "mio-extras", + "openssl", + "rand 0.7.3", + "sha-1", + "slab", + "url", +] + +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + +[[package]] +name = "wyz" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b31594f29d27036c383b53b59ed3476874d518f0efb151b27a4c275141390e" +dependencies = [ + "tap", +] + +[[package]] +name = "zeroize" +version = "1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f8f187641dad4f680d25c4bfc4225b418165984179f26ca76ec4fb6441d3a17" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] From 3335b414896c3fa6dd0d1c2cda19a1126b0059b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 11:23:55 +0100 Subject: [PATCH 17/41] Abstract environment --- bin/runtime/src/chain_extension/mod.rs | 69 ++++++++++++++++++-------- 1 file changed, 49 insertions(+), 20 deletions(-) diff --git a/bin/runtime/src/chain_extension/mod.rs b/bin/runtime/src/chain_extension/mod.rs index 3a8167e35d..3e01de79be 100644 --- a/bin/runtime/src/chain_extension/mod.rs +++ b/bin/runtime/src/chain_extension/mod.rs @@ -1,7 +1,11 @@ use codec::Decode; -use frame_support::{log::error, pallet_prelude::Weight}; -use pallet_contracts::chain_extension::{ - ChainExtension, Environment, Ext, InitState, RetVal, SysConfig, +use frame_support::{log::error, weights::Weight}; +use pallet_contracts::{ + chain_extension::{ + BufInBufOutState, ChainExtension, Environment as SubstrateEnvironment, Ext, InitState, + RetVal, SysConfig, + }, + ChargedAmount, }; use pallet_snarcos::{ Config, Error, Pallet as Snarcos, ProvingSystem, VerificationKeyIdentifier, WeightInfo, @@ -35,13 +39,16 @@ pub const SNARCOS_VERIFY_ERROR_UNKNOWN: u32 = 11_007; pub struct SnarcosChainExtension; impl ChainExtension for SnarcosChainExtension { - fn call(func_id: u32, env: Environment) -> Result + fn call( + func_id: u32, + env: SubstrateEnvironment, + ) -> Result where ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>, { match func_id { - SNARCOS_STORE_KEY_FUNC_ID => Self::snarcos_store_key(env), - SNARCOS_VERIFY_FUNC_ID => Self::snarcos_verify(env), + SNARCOS_STORE_KEY_FUNC_ID => Self::snarcos_store_key(env.buf_in_buf_out()), + SNARCOS_VERIFY_FUNC_ID => Self::snarcos_verify(env.buf_in_buf_out()), _ => { error!("Called an unregistered `func_id`: {}", func_id); Err(DispatchError::Other("Unimplemented func_id")) @@ -52,6 +59,40 @@ impl ChainExtension for SnarcosChainExtension { pub type ByteCount = u32; +/// Abstraction around `pallet_contracts::chain_extension::Environment`. Makes testing easier. +/// +/// Gathers all the methods that are used by `SnarcosChainExtension`. For now all operations are +/// performed in `BufInBufOut` mode, so we don't have to take care of other modes. +trait Environment: Sized { + fn in_len(&self) -> ByteCount; + fn read(&self, max_len: u32) -> Result, DispatchError>; + + fn charge_weight(&mut self, amount: Weight) -> Result; + fn adjust_weight(&mut self, charged: ChargedAmount, actual_weight: Weight); +} + +/// Transparent delegation. +impl Environment for SubstrateEnvironment<'_, '_, E, BufInBufOutState> +where + ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>, +{ + fn in_len(&self) -> ByteCount { + self.in_len() + } + + fn read(&self, max_len: u32) -> Result, DispatchError> { + self.read(max_len) + } + + fn charge_weight(&mut self, amount: Weight) -> Result { + self.charge_weight(amount) + } + + fn adjust_weight(&mut self, charged: ChargedAmount, actual_weight: Weight) { + self.adjust_weight(charged, actual_weight) + } +} + /// Struct to be decoded from a byte slice passed from the contract. /// /// Notice, that contract can pass these arguments one by one, not necessarily as such struct. Only @@ -79,13 +120,7 @@ struct VerifyArgs { } impl SnarcosChainExtension { - fn snarcos_store_key(env: Environment) -> Result - where - ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>, - { - // We need to read input as plain bytes (encoded args). - let mut env = env.buf_in_buf_out(); - + fn snarcos_store_key(mut env: Env) -> Result { // Check if it makes sense to read and decode data. let key_length = env .in_len() @@ -140,13 +175,7 @@ impl SnarcosChainExtension { } } - fn snarcos_verify(env: Environment) -> Result - where - ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>, - { - // We need to read input as plain bytes (encoded args). - let mut env = env.buf_in_buf_out(); - + fn snarcos_verify(mut env: Env) -> Result { // We charge optimistically, i.e. assuming that decoding succeeds and the verification // key is present. However, since we don't know the system yet, we have to charge maximal // possible fee. We will adjust it as soon as possible. From d0e34d41128f16e044e241cc8e2499bbe3ef9ee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 12:25:57 +0100 Subject: [PATCH 18/41] Extract `weight_of_verify` --- bin/runtime/src/chain_extension/mod.rs | 38 +++++++++++++------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/bin/runtime/src/chain_extension/mod.rs b/bin/runtime/src/chain_extension/mod.rs index 3e01de79be..66531a814d 100644 --- a/bin/runtime/src/chain_extension/mod.rs +++ b/bin/runtime/src/chain_extension/mod.rs @@ -119,6 +119,23 @@ struct VerifyArgs { pub system: ProvingSystem, } +/// Provides a weight of `verify` dispatchable depending on the `ProvingSystem`. In case no system +/// is passed, we return maximal amongst all the systems. +fn weight_of_verify(system: Option) -> Weight { + match system { + Some(ProvingSystem::Groth16) => { + <::WeightInfo as WeightInfo>::verify_groth16() + } + Some(ProvingSystem::Gm17) => <::WeightInfo as WeightInfo>::verify_gm17(), + Some(ProvingSystem::Marlin) => { + <::WeightInfo as WeightInfo>::verify_marlin() + } + None => weight_of_verify(Some(ProvingSystem::Groth16)) + .max(weight_of_verify(Some(ProvingSystem::Gm17))) + .max(weight_of_verify(Some(ProvingSystem::Marlin))), + } +} + impl SnarcosChainExtension { fn snarcos_store_key(mut env: Env) -> Result { // Check if it makes sense to read and decode data. @@ -158,23 +175,6 @@ impl SnarcosChainExtension { Ok(RetVal::Converging(return_status)) } - fn weight_of_verify(system: Option) -> Weight { - match system { - Some(ProvingSystem::Groth16) => { - <::WeightInfo as WeightInfo>::verify_groth16() - } - Some(ProvingSystem::Gm17) => { - <::WeightInfo as WeightInfo>::verify_gm17() - } - Some(ProvingSystem::Marlin) => { - <::WeightInfo as WeightInfo>::verify_marlin() - } - None => Self::weight_of_verify(Some(ProvingSystem::Groth16)) - .max(Self::weight_of_verify(Some(ProvingSystem::Gm17))) - .max(Self::weight_of_verify(Some(ProvingSystem::Marlin))), - } - } - fn snarcos_verify(mut env: Env) -> Result { // We charge optimistically, i.e. assuming that decoding succeeds and the verification // key is present. However, since we don't know the system yet, we have to charge maximal @@ -185,7 +185,7 @@ impl SnarcosChainExtension { // `pallet_snarcos::WeightInfo::verify_decoding_failure`, we can both charge less here // (with further `env.adjust_weight`) and in the pallet itself (returning // `DispatchErrorWithPostInfo` reducing actual fee and the block weight). - let pre_charge = env.charge_weight(Self::weight_of_verify(None))?; + let pre_charge = env.charge_weight(weight_of_verify(None))?; // Parsing is done here for similar reasons as in `Self::snarcos_store_key`. let bytes = env.read(env.in_len())?; @@ -193,7 +193,7 @@ impl SnarcosChainExtension { let args: VerifyArgs = VerifyArgs::decode(&mut &*bytes) .map_err(|_| DispatchError::Other("Failed to decode arguments"))?; - env.adjust_weight(pre_charge, Self::weight_of_verify(Some(args.system))); + env.adjust_weight(pre_charge, weight_of_verify(Some(args.system))); let result = Snarcos::::bare_verify(args.identifier, args.proof, args.input, args.system); From 9e36e009c413b0aa24431891d091a7b0fc241c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 13:15:35 +0100 Subject: [PATCH 19/41] First test --- bin/runtime/src/chain_extension/mod.rs | 72 +++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/bin/runtime/src/chain_extension/mod.rs b/bin/runtime/src/chain_extension/mod.rs index 66531a814d..b782121ccf 100644 --- a/bin/runtime/src/chain_extension/mod.rs +++ b/bin/runtime/src/chain_extension/mod.rs @@ -64,11 +64,13 @@ pub type ByteCount = u32; /// Gathers all the methods that are used by `SnarcosChainExtension`. For now all operations are /// performed in `BufInBufOut` mode, so we don't have to take care of other modes. trait Environment: Sized { + type ChargedAmount; + fn in_len(&self) -> ByteCount; fn read(&self, max_len: u32) -> Result, DispatchError>; - fn charge_weight(&mut self, amount: Weight) -> Result; - fn adjust_weight(&mut self, charged: ChargedAmount, actual_weight: Weight); + fn charge_weight(&mut self, amount: Weight) -> Result; + fn adjust_weight(&mut self, charged: Self::ChargedAmount, actual_weight: Weight); } /// Transparent delegation. @@ -76,6 +78,8 @@ impl Environment for SubstrateEnvironment<'_, '_, E, BufInBufOutState> where ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>, { + type ChargedAmount = ChargedAmount; + fn in_len(&self) -> ByteCount { self.in_len() } @@ -213,3 +217,67 @@ impl SnarcosChainExtension { Ok(RetVal::Converging(return_status)) } } + +#[cfg(test)] +mod tests { + use std::{ + iter::Rev, + ops::Neg, + sync::mpsc::{channel, Receiver, Sender}, + }; + + use super::*; + + type RevertibleWeight = i64; + + fn charged(charging_listener: Receiver) -> RevertibleWeight { + charging_listener.into_iter().sum() + } + + /// Signals that there is something to read, but no read can succeed. + struct InputCorruptedEnvironment { + charging_channel: Sender, + } + + impl InputCorruptedEnvironment { + pub fn new() -> (Self, Receiver) { + let (sender, receiver) = channel(); + ( + Self { + charging_channel: sender, + }, + receiver, + ) + } + } + + impl Environment for InputCorruptedEnvironment { + type ChargedAmount = Weight; + + fn in_len(&self) -> ByteCount { + 41 + } + + fn read(&self, _max_len: u32) -> Result, DispatchError> { + Err(DispatchError::Other("Some error")) + } + + fn charge_weight(&mut self, amount: Weight) -> Result { + self.charging_channel + .send(amount as RevertibleWeight) + .unwrap(); + Ok(amount) + } + + fn adjust_weight(&mut self, charged: Weight, actual_weight: Weight) { + self.charging_channel + .send(((charged - actual_weight) as RevertibleWeight).neg()) + .unwrap(); + } + } + + #[test] + fn extension_is_enabled() { + assert!(SnarcosChainExtension::enabled()) + } +} From dc8f334b8fa22de559d78561f9d01aa1923960b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 13:26:53 +0100 Subject: [PATCH 20/41] Charging before reading --- bin/runtime/src/chain_extension/mod.rs | 49 ++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/bin/runtime/src/chain_extension/mod.rs b/bin/runtime/src/chain_extension/mod.rs index b782121ccf..2b404d8e9f 100644 --- a/bin/runtime/src/chain_extension/mod.rs +++ b/bin/runtime/src/chain_extension/mod.rs @@ -123,6 +123,11 @@ struct VerifyArgs { pub system: ProvingSystem, } +/// Provides a weight of `store_key` dispatchable. +fn weight_of_store_key(key_length: ByteCount) -> Weight { + <::WeightInfo as WeightInfo>::store_key(key_length) +} + /// Provides a weight of `verify` dispatchable depending on the `ProvingSystem`. In case no system /// is passed, we return maximal amongst all the systems. fn weight_of_verify(system: Option) -> Weight { @@ -152,9 +157,7 @@ impl SnarcosChainExtension { // We charge now - even if decoding fails and we shouldn't touch storage, we have to incur // fee for reading memory. - env.charge_weight(<::WeightInfo as WeightInfo>::store_key( - key_length, - ))?; + env.charge_weight(weight_of_store_key(key_length))?; // Parsing will have to be done here. This is due to the fact that methods // `Environment<_,_,_,S: BufIn>::read*` don't move starting pointer and thus we can make @@ -221,7 +224,6 @@ impl SnarcosChainExtension { #[cfg(test)] mod tests { use std::{ - iter::Rev, ops::Neg, sync::mpsc::{channel, Receiver, Sender}, }; @@ -234,28 +236,36 @@ mod tests { charging_listener.into_iter().sum() } - /// Signals that there is something to read, but no read can succeed. + /// May signal that there is something to read, but no read can succeed. struct InputCorruptedEnvironment { + in_len: ByteCount, charging_channel: Sender, } impl InputCorruptedEnvironment { - pub fn new() -> (Self, Receiver) { + pub fn new(in_len: ByteCount) -> (Self, Receiver) { let (sender, receiver) = channel(); ( Self { + in_len, charging_channel: sender, }, receiver, ) } + + /// Returns how many bytes the verifying key would have taken, if this environment was + /// used for `store_key` call. + pub fn key_len(&self) -> ByteCount { + self.in_len - (size_of::() as ByteCount) + } } impl Environment for InputCorruptedEnvironment { type ChargedAmount = Weight; fn in_len(&self) -> ByteCount { - 41 + self.in_len } fn read(&self, _max_len: u32) -> Result, DispatchError> { @@ -280,4 +290,29 @@ mod tests { fn extension_is_enabled() { assert!(SnarcosChainExtension::enabled()) } + + #[test] + #[allow(non_snake_case)] + fn store_key__charges_before_reading() { + let (env, charging_listener) = InputCorruptedEnvironment::new(41); + let key_length = env.key_len(); + let result = SnarcosChainExtension::snarcos_store_key(env); + assert!(matches!(result, Err(_))); + assert_eq!( + charged(charging_listener), + weight_of_store_key(key_length) as RevertibleWeight + ); + } + + #[test] + #[allow(non_snake_case)] + fn verify__charges_before_reading() { + let (env, charging_listener) = InputCorruptedEnvironment::new(41); + let result = SnarcosChainExtension::snarcos_verify(env); + assert!(matches!(result, Err(_))); + assert_eq!( + charged(charging_listener), + weight_of_verify(None) as RevertibleWeight + ); + } } From 3c69ce8c11c04a35149c0d583132cb1b1c7879ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 13:29:00 +0100 Subject: [PATCH 21/41] Separate module for environments --- bin/runtime/src/chain_extension/mod.rs | 91 ++++++++++++++------------ 1 file changed, 49 insertions(+), 42 deletions(-) diff --git a/bin/runtime/src/chain_extension/mod.rs b/bin/runtime/src/chain_extension/mod.rs index 2b404d8e9f..54eb516a86 100644 --- a/bin/runtime/src/chain_extension/mod.rs +++ b/bin/runtime/src/chain_extension/mod.rs @@ -223,12 +223,10 @@ impl SnarcosChainExtension { #[cfg(test)] mod tests { - use std::{ - ops::Neg, - sync::mpsc::{channel, Receiver, Sender}, - }; + use std::sync::mpsc::Receiver; use super::*; + use crate::chain_extension::tests::environments::InputCorruptedEnvironment; type RevertibleWeight = i64; @@ -236,53 +234,62 @@ mod tests { charging_listener.into_iter().sum() } - /// May signal that there is something to read, but no read can succeed. - struct InputCorruptedEnvironment { - in_len: ByteCount, - charging_channel: Sender, - } + mod environments { + use std::{ + ops::Neg, + sync::mpsc::{channel, Sender}, + }; - impl InputCorruptedEnvironment { - pub fn new(in_len: ByteCount) -> (Self, Receiver) { - let (sender, receiver) = channel(); - ( - Self { - in_len, - charging_channel: sender, - }, - receiver, - ) - } + use super::*; - /// Returns how many bytes the verifying key would have taken, if this environment was - /// used for `store_key` call. - pub fn key_len(&self) -> ByteCount { - self.in_len - (size_of::() as ByteCount) + /// May signal that there is something to read, but no read can succeed. + pub struct InputCorruptedEnvironment { + in_len: ByteCount, + charging_channel: Sender, } - } - impl Environment for InputCorruptedEnvironment { - type ChargedAmount = Weight; + impl InputCorruptedEnvironment { + pub fn new(in_len: ByteCount) -> (Self, Receiver) { + let (sender, receiver) = channel(); + ( + Self { + in_len, + charging_channel: sender, + }, + receiver, + ) + } - fn in_len(&self) -> ByteCount { - self.in_len + /// Returns how many bytes the verifying key would have taken, if this environment was + /// used for `store_key` call. + pub fn key_len(&self) -> ByteCount { + self.in_len - (size_of::() as ByteCount) + } } - fn read(&self, _max_len: u32) -> Result, DispatchError> { - Err(DispatchError::Other("Some error")) - } + impl Environment for InputCorruptedEnvironment { + type ChargedAmount = Weight; - fn charge_weight(&mut self, amount: Weight) -> Result { - self.charging_channel - .send(amount as RevertibleWeight) - .unwrap(); - Ok(amount) - } + fn in_len(&self) -> ByteCount { + self.in_len + } + + fn read(&self, _max_len: u32) -> Result, DispatchError> { + Err(DispatchError::Other("Some error")) + } - fn adjust_weight(&mut self, charged: Weight, actual_weight: Weight) { - self.charging_channel - .send(((charged - actual_weight) as RevertibleWeight).neg()) - .unwrap(); + fn charge_weight(&mut self, amount: Weight) -> Result { + self.charging_channel + .send(amount as RevertibleWeight) + .unwrap(); + Ok(amount) + } + + fn adjust_weight(&mut self, charged: Weight, actual_weight: Weight) { + self.charging_channel + .send(((charged - actual_weight) as RevertibleWeight).neg()) + .unwrap(); + } } } From e64cce3015a8a29382ca1df1797f0a26d2a32f5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 13:35:47 +0100 Subject: [PATCH 22/41] Different API for different modes --- bin/runtime/src/chain_extension/mod.rs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/bin/runtime/src/chain_extension/mod.rs b/bin/runtime/src/chain_extension/mod.rs index 54eb516a86..4d5c853130 100644 --- a/bin/runtime/src/chain_extension/mod.rs +++ b/bin/runtime/src/chain_extension/mod.rs @@ -225,8 +225,9 @@ impl SnarcosChainExtension { mod tests { use std::sync::mpsc::Receiver; + use environments::{InputCorruptedEnvironment, StoreKeyMode, VerifyMode}; + use super::*; - use crate::chain_extension::tests::environments::InputCorruptedEnvironment; type RevertibleWeight = i64; @@ -236,38 +237,47 @@ mod tests { mod environments { use std::{ + marker::PhantomData, ops::Neg, sync::mpsc::{channel, Sender}, }; use super::*; + pub trait Mode {} + pub enum StoreKeyMode {} + pub enum VerifyMode {} + impl Mode for StoreKeyMode {} + impl Mode for VerifyMode {} + /// May signal that there is something to read, but no read can succeed. - pub struct InputCorruptedEnvironment { + pub struct InputCorruptedEnvironment { in_len: ByteCount, charging_channel: Sender, + _phantom: PhantomData, } - impl InputCorruptedEnvironment { + impl InputCorruptedEnvironment { pub fn new(in_len: ByteCount) -> (Self, Receiver) { let (sender, receiver) = channel(); ( Self { in_len, charging_channel: sender, + _phantom: Default::default(), }, receiver, ) } + } - /// Returns how many bytes the verifying key would have taken, if this environment was - /// used for `store_key` call. + impl InputCorruptedEnvironment { pub fn key_len(&self) -> ByteCount { self.in_len - (size_of::() as ByteCount) } } - impl Environment for InputCorruptedEnvironment { + impl Environment for InputCorruptedEnvironment { type ChargedAmount = Weight; fn in_len(&self) -> ByteCount { @@ -301,7 +311,7 @@ mod tests { #[test] #[allow(non_snake_case)] fn store_key__charges_before_reading() { - let (env, charging_listener) = InputCorruptedEnvironment::new(41); + let (env, charging_listener) = InputCorruptedEnvironment::::new(41); let key_length = env.key_len(); let result = SnarcosChainExtension::snarcos_store_key(env); assert!(matches!(result, Err(_))); @@ -314,7 +324,7 @@ mod tests { #[test] #[allow(non_snake_case)] fn verify__charges_before_reading() { - let (env, charging_listener) = InputCorruptedEnvironment::new(41); + let (env, charging_listener) = InputCorruptedEnvironment::::new(41); let result = SnarcosChainExtension::snarcos_verify(env); assert!(matches!(result, Err(_))); assert_eq!( From 9c6ce3408666b873d74b6fa884f21fde99a7923a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 13:43:01 +0100 Subject: [PATCH 23/41] Add bytes --- .../test_resources/xor.proof.bytes | 2 ++ .../test_resources/xor.public_input.bytes | Bin 0 -> 264 bytes .../chain_extension/test_resources/xor.vk.bytes | Bin 0 -> 776 bytes 3 files changed, 2 insertions(+) create mode 100644 bin/runtime/src/chain_extension/test_resources/xor.proof.bytes create mode 100644 bin/runtime/src/chain_extension/test_resources/xor.public_input.bytes create mode 100644 bin/runtime/src/chain_extension/test_resources/xor.vk.bytes diff --git a/bin/runtime/src/chain_extension/test_resources/xor.proof.bytes b/bin/runtime/src/chain_extension/test_resources/xor.proof.bytes new file mode 100644 index 0000000000..818eb0cca9 --- /dev/null +++ b/bin/runtime/src/chain_extension/test_resources/xor.proof.bytes @@ -0,0 +1,2 @@ +��u��u��st|�\CF +ϕ�Y��9�8�� �H�04����BOo@�������5�H�ܜ��_m+_�h��q�k!�~��}%!]y\�ZU���F�?���B��Ȑ�%�e4����\�C� Wָ��E0����8�^M)KhnTyUHl8@*Qnn1SL$CWH)z5DjmkZ7toQ4eN zyx8`jaJB+_cw4WG5)8wDq77y{fN_BqMwAcJ4sld^oq_oBTQx|PYt%#H98R35#A7KU{K_AZC34^Cxfs&5Gd@KVfe^w#8pyQEG zVy+EYFo?vHIj|LpjyHyc%wl@YToF@GKx84`jYrcHY#9{^000000001<0DkKBW9iq!^&0sv z9mLb}ZXD@XU?uq3mjzPwoggi&t&>K&&nN!-H!Bo{e|{2%_~fJczm9L05}sjdaJ3g8 zv_m6qRYUOj8+xr2W-!(;8HjI?$zK=>58)C{MTP)b{PdNK5;#oHAILtfn&IQV=76_wDLbvF zNi<+t-4^`jIRLV1g4V20>)jQc!}>!U_biUp$-%)YIleF^GQ5 zb~}H7m1tVkm3WF}Uj1gFs4^Hc`*y$hkFCGwdq`_z=a2x^nR!|)#jmbZ+)`0R4X8IW z>8~?7o4Jp>Mt)CWh*|J5O#WM;G2BnSlwTs<&)H1snkzB0CSTcgqj2((S&JW7@SiL1 GeoYkj8h)t& literal 0 HcmV?d00001 From a49840ba317bd064f2260818af3669e1ad5b87ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 13:49:00 +0100 Subject: [PATCH 24/41] Reorganize modules --- bin/runtime/src/chain_extension/mod.rs | 116 +----------------- .../src/chain_extension/tests/environments.rs | 67 ++++++++++ bin/runtime/src/chain_extension/tests/mod.rs | 55 +++++++++ .../resources}/xor.proof.bytes | 0 .../resources}/xor.public_input.bytes | Bin .../resources}/xor.vk.bytes | Bin 6 files changed, 125 insertions(+), 113 deletions(-) create mode 100644 bin/runtime/src/chain_extension/tests/environments.rs create mode 100644 bin/runtime/src/chain_extension/tests/mod.rs rename bin/runtime/src/chain_extension/{test_resources => tests/resources}/xor.proof.bytes (100%) rename bin/runtime/src/chain_extension/{test_resources => tests/resources}/xor.public_input.bytes (100%) rename bin/runtime/src/chain_extension/{test_resources => tests/resources}/xor.vk.bytes (100%) diff --git a/bin/runtime/src/chain_extension/mod.rs b/bin/runtime/src/chain_extension/mod.rs index 4d5c853130..9ab23dfe2b 100644 --- a/bin/runtime/src/chain_extension/mod.rs +++ b/bin/runtime/src/chain_extension/mod.rs @@ -17,6 +17,9 @@ use Error::*; use crate::{MaximumVerificationKeyLength, Runtime}; +#[cfg(test)] +mod tests; + pub const SNARCOS_STORE_KEY_FUNC_ID: u32 = 41; pub const SNARCOS_VERIFY_FUNC_ID: u32 = 42; @@ -220,116 +223,3 @@ impl SnarcosChainExtension { Ok(RetVal::Converging(return_status)) } } - -#[cfg(test)] -mod tests { - use std::sync::mpsc::Receiver; - - use environments::{InputCorruptedEnvironment, StoreKeyMode, VerifyMode}; - - use super::*; - - type RevertibleWeight = i64; - - fn charged(charging_listener: Receiver) -> RevertibleWeight { - charging_listener.into_iter().sum() - } - - mod environments { - use std::{ - marker::PhantomData, - ops::Neg, - sync::mpsc::{channel, Sender}, - }; - - use super::*; - - pub trait Mode {} - pub enum StoreKeyMode {} - pub enum VerifyMode {} - impl Mode for StoreKeyMode {} - impl Mode for VerifyMode {} - - /// May signal that there is something to read, but no read can succeed. - pub struct InputCorruptedEnvironment { - in_len: ByteCount, - charging_channel: Sender, - _phantom: PhantomData, - } - - impl InputCorruptedEnvironment { - pub fn new(in_len: ByteCount) -> (Self, Receiver) { - let (sender, receiver) = channel(); - ( - Self { - in_len, - charging_channel: sender, - _phantom: Default::default(), - }, - receiver, - ) - } - } - - impl InputCorruptedEnvironment { - pub fn key_len(&self) -> ByteCount { - self.in_len - (size_of::() as ByteCount) - } - } - - impl Environment for InputCorruptedEnvironment { - type ChargedAmount = Weight; - - fn in_len(&self) -> ByteCount { - self.in_len - } - - fn read(&self, _max_len: u32) -> Result, DispatchError> { - Err(DispatchError::Other("Some error")) - } - - fn charge_weight(&mut self, amount: Weight) -> Result { - self.charging_channel - .send(amount as RevertibleWeight) - .unwrap(); - Ok(amount) - } - - fn adjust_weight(&mut self, charged: Weight, actual_weight: Weight) { - self.charging_channel - .send(((charged - actual_weight) as RevertibleWeight).neg()) - .unwrap(); - } - } - } - - #[test] - fn extension_is_enabled() { - assert!(SnarcosChainExtension::enabled()) - } - - #[test] - #[allow(non_snake_case)] - fn store_key__charges_before_reading() { - let (env, charging_listener) = InputCorruptedEnvironment::::new(41); - let key_length = env.key_len(); - let result = SnarcosChainExtension::snarcos_store_key(env); - assert!(matches!(result, Err(_))); - assert_eq!( - charged(charging_listener), - weight_of_store_key(key_length) as RevertibleWeight - ); - } - - #[test] - #[allow(non_snake_case)] - fn verify__charges_before_reading() { - let (env, charging_listener) = InputCorruptedEnvironment::::new(41); - let result = SnarcosChainExtension::snarcos_verify(env); - assert!(matches!(result, Err(_))); - assert_eq!( - charged(charging_listener), - weight_of_verify(None) as RevertibleWeight - ); - } -} diff --git a/bin/runtime/src/chain_extension/tests/environments.rs b/bin/runtime/src/chain_extension/tests/environments.rs new file mode 100644 index 0000000000..115c0ab273 --- /dev/null +++ b/bin/runtime/src/chain_extension/tests/environments.rs @@ -0,0 +1,67 @@ +use std::{ + marker::PhantomData, + ops::Neg, + sync::mpsc::{channel, Sender}, +}; + +use super::*; + +pub trait Mode {} + +pub enum StoreKeyMode {} +pub enum VerifyMode {} + +impl Mode for StoreKeyMode {} +impl Mode for VerifyMode {} + +/// May signal that there is something to read, but no read can succeed. +pub struct InputCorruptedEnvironment { + in_len: ByteCount, + charging_channel: Sender, + _phantom: PhantomData, +} + +impl InputCorruptedEnvironment { + pub fn new(in_len: ByteCount) -> (Self, Receiver) { + let (sender, receiver) = channel(); + ( + Self { + in_len, + charging_channel: sender, + _phantom: Default::default(), + }, + receiver, + ) + } +} + +impl InputCorruptedEnvironment { + pub fn key_len(&self) -> ByteCount { + self.in_len - (size_of::() as ByteCount) + } +} + +impl Environment for InputCorruptedEnvironment { + type ChargedAmount = Weight; + + fn in_len(&self) -> ByteCount { + self.in_len + } + + fn read(&self, _max_len: u32) -> Result, DispatchError> { + Err(DispatchError::Other("Some error")) + } + + fn charge_weight(&mut self, amount: Weight) -> Result { + self.charging_channel + .send(amount as RevertibleWeight) + .unwrap(); + Ok(amount) + } + + fn adjust_weight(&mut self, charged: Weight, actual_weight: Weight) { + self.charging_channel + .send(((charged - actual_weight) as RevertibleWeight).neg()) + .unwrap(); + } +} diff --git a/bin/runtime/src/chain_extension/tests/mod.rs b/bin/runtime/src/chain_extension/tests/mod.rs new file mode 100644 index 0000000000..131029b848 --- /dev/null +++ b/bin/runtime/src/chain_extension/tests/mod.rs @@ -0,0 +1,55 @@ +use std::sync::mpsc::Receiver; + +use environments::{InputCorruptedEnvironment, StoreKeyMode, VerifyMode}; + +use super::*; + +mod environments; + +type RevertibleWeight = i64; + +fn vk_bytes() -> &'static [u8] { + include_bytes!("resources/xor.vk.bytes") +} + +fn proof_bytes() -> &'static [u8] { + include_bytes!("resources/xor.proof.bytes") +} + +fn input_bytes() -> &'static [u8] { + include_bytes!("resources/xor.public_input.bytes") +} + +fn charged(charging_listener: Receiver) -> RevertibleWeight { + charging_listener.into_iter().sum() +} + +#[test] +fn extension_is_enabled() { + assert!(SnarcosChainExtension::enabled()) +} + +#[test] +#[allow(non_snake_case)] +fn store_key__charges_before_reading() { + let (env, charging_listener) = InputCorruptedEnvironment::::new(41); + let key_length = env.key_len(); + let result = SnarcosChainExtension::snarcos_store_key(env); + assert!(matches!(result, Err(_))); + assert_eq!( + charged(charging_listener), + weight_of_store_key(key_length) as RevertibleWeight + ); +} + +#[test] +#[allow(non_snake_case)] +fn verify__charges_before_reading() { + let (env, charging_listener) = InputCorruptedEnvironment::::new(41); + let result = SnarcosChainExtension::snarcos_verify(env); + assert!(matches!(result, Err(_))); + assert_eq!( + charged(charging_listener), + weight_of_verify(None) as RevertibleWeight + ); +} diff --git a/bin/runtime/src/chain_extension/test_resources/xor.proof.bytes b/bin/runtime/src/chain_extension/tests/resources/xor.proof.bytes similarity index 100% rename from bin/runtime/src/chain_extension/test_resources/xor.proof.bytes rename to bin/runtime/src/chain_extension/tests/resources/xor.proof.bytes diff --git a/bin/runtime/src/chain_extension/test_resources/xor.public_input.bytes b/bin/runtime/src/chain_extension/tests/resources/xor.public_input.bytes similarity index 100% rename from bin/runtime/src/chain_extension/test_resources/xor.public_input.bytes rename to bin/runtime/src/chain_extension/tests/resources/xor.public_input.bytes diff --git a/bin/runtime/src/chain_extension/test_resources/xor.vk.bytes b/bin/runtime/src/chain_extension/tests/resources/xor.vk.bytes similarity index 100% rename from bin/runtime/src/chain_extension/test_resources/xor.vk.bytes rename to bin/runtime/src/chain_extension/tests/resources/xor.vk.bytes From 61a374f4f611f5d1ef2796416ab84491f5f3e4f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 14:11:30 +0100 Subject: [PATCH 25/41] Too long vk --- .../src/chain_extension/tests/environments.rs | 8 +++++++- bin/runtime/src/chain_extension/tests/mod.rs | 19 +++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/bin/runtime/src/chain_extension/tests/environments.rs b/bin/runtime/src/chain_extension/tests/environments.rs index 115c0ab273..ae6c2023f7 100644 --- a/bin/runtime/src/chain_extension/tests/environments.rs +++ b/bin/runtime/src/chain_extension/tests/environments.rs @@ -18,15 +18,20 @@ impl Mode for VerifyMode {} pub struct InputCorruptedEnvironment { in_len: ByteCount, charging_channel: Sender, + on_read: Option>, _phantom: PhantomData, } impl InputCorruptedEnvironment { - pub fn new(in_len: ByteCount) -> (Self, Receiver) { + pub fn new( + in_len: ByteCount, + on_read: Option>, + ) -> (Self, Receiver) { let (sender, receiver) = channel(); ( Self { in_len, + on_read, charging_channel: sender, _phantom: Default::default(), }, @@ -49,6 +54,7 @@ impl Environment for InputCorruptedEnvironment { } fn read(&self, _max_len: u32) -> Result, DispatchError> { + self.on_read.as_ref().map(|action| action()); Err(DispatchError::Other("Some error")) } diff --git a/bin/runtime/src/chain_extension/tests/mod.rs b/bin/runtime/src/chain_extension/tests/mod.rs index 131029b848..2d10c8224e 100644 --- a/bin/runtime/src/chain_extension/tests/mod.rs +++ b/bin/runtime/src/chain_extension/tests/mod.rs @@ -32,7 +32,7 @@ fn extension_is_enabled() { #[test] #[allow(non_snake_case)] fn store_key__charges_before_reading() { - let (env, charging_listener) = InputCorruptedEnvironment::::new(41); + let (env, charging_listener) = InputCorruptedEnvironment::::new(41, None); let key_length = env.key_len(); let result = SnarcosChainExtension::snarcos_store_key(env); assert!(matches!(result, Err(_))); @@ -42,10 +42,25 @@ fn store_key__charges_before_reading() { ); } +#[test] +#[allow(non_snake_case)] +fn store_key__too_long_vk() { + let (env, charging_listener) = InputCorruptedEnvironment::::new( + ByteCount::MAX, + Some(Box::new(|| panic!("Shouldn't read anything at all"))), + ); + let result = SnarcosChainExtension::snarcos_store_key(env); + assert!(matches!( + result, + Ok(RetVal::Converging(SNARCOS_STORE_KEY_TOO_LONG_KEY)) + )); + assert_eq!(charged(charging_listener), 0); +} + #[test] #[allow(non_snake_case)] fn verify__charges_before_reading() { - let (env, charging_listener) = InputCorruptedEnvironment::::new(41); + let (env, charging_listener) = InputCorruptedEnvironment::::new(41, None); let result = SnarcosChainExtension::snarcos_verify(env); assert!(matches!(result, Err(_))); assert_eq!( From fdceb3ef71bd105abc9a2c1485162b2bb50ddf2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 14:30:17 +0100 Subject: [PATCH 26/41] Positive case failing because no externalities environment... --- bin/runtime/src/chain_extension/mod.rs | 4 +- .../src/chain_extension/tests/environments.rs | 56 +++++++++++++++++++ bin/runtime/src/chain_extension/tests/mod.rs | 31 ++++++++++ 3 files changed, 89 insertions(+), 2 deletions(-) diff --git a/bin/runtime/src/chain_extension/mod.rs b/bin/runtime/src/chain_extension/mod.rs index 9ab23dfe2b..e69545050d 100644 --- a/bin/runtime/src/chain_extension/mod.rs +++ b/bin/runtime/src/chain_extension/mod.rs @@ -1,4 +1,4 @@ -use codec::Decode; +use codec::{Decode, Encode}; use frame_support::{log::error, weights::Weight}; use pallet_contracts::{ chain_extension::{ @@ -106,7 +106,7 @@ where /// the order of values is important. /// /// It cannot be `MaxEncodedLen` due to `Vec<_>` and thus `Environment::read_as` cannot be used. -#[derive(Decode)] +#[derive(Decode, Encode)] struct StoreKeyArgs { pub identifier: VerificationKeyIdentifier, pub key: Vec, diff --git a/bin/runtime/src/chain_extension/tests/environments.rs b/bin/runtime/src/chain_extension/tests/environments.rs index ae6c2023f7..f9e980081e 100644 --- a/bin/runtime/src/chain_extension/tests/environments.rs +++ b/bin/runtime/src/chain_extension/tests/environments.rs @@ -71,3 +71,59 @@ impl Environment for InputCorruptedEnvironment { .unwrap(); } } + +/// 'Fully functional' mock. +pub struct MockedEnvironment { + charging_channel: Sender, + content: Vec, + _phantom: PhantomData, +} + +impl MockedEnvironment { + pub fn new(content: Vec) -> (Self, Receiver) { + let (sender, receiver) = channel(); + ( + Self { + content, + charging_channel: sender, + _phantom: Default::default(), + }, + receiver, + ) + } +} + +impl MockedEnvironment { + pub fn key_len(&self) -> ByteCount { + self.in_len() - (size_of::() as ByteCount) + } +} + +impl Environment for MockedEnvironment { + type ChargedAmount = Weight; + + fn in_len(&self) -> ByteCount { + self.content.len() as ByteCount + } + + fn read(&self, max_len: u32) -> Result, DispatchError> { + if max_len > self.in_len() { + Ok(self.content.clone()) + } else { + Ok(self.content[..max_len as usize].to_vec()) + } + } + + fn charge_weight(&mut self, amount: Weight) -> Result { + self.charging_channel + .send(amount as RevertibleWeight) + .unwrap(); + Ok(amount) + } + + fn adjust_weight(&mut self, charged: Weight, actual_weight: Weight) { + self.charging_channel + .send(((charged - actual_weight) as RevertibleWeight).neg()) + .unwrap(); + } +} diff --git a/bin/runtime/src/chain_extension/tests/mod.rs b/bin/runtime/src/chain_extension/tests/mod.rs index 2d10c8224e..6c6bd55664 100644 --- a/bin/runtime/src/chain_extension/tests/mod.rs +++ b/bin/runtime/src/chain_extension/tests/mod.rs @@ -3,11 +3,14 @@ use std::sync::mpsc::Receiver; use environments::{InputCorruptedEnvironment, StoreKeyMode, VerifyMode}; use super::*; +use crate::chain_extension::tests::environments::MockedEnvironment; mod environments; type RevertibleWeight = i64; +const IDENTIFIER: VerificationKeyIdentifier = [1, 7, 2, 9]; + fn vk_bytes() -> &'static [u8] { include_bytes!("resources/xor.vk.bytes") } @@ -34,7 +37,9 @@ fn extension_is_enabled() { fn store_key__charges_before_reading() { let (env, charging_listener) = InputCorruptedEnvironment::::new(41, None); let key_length = env.key_len(); + let result = SnarcosChainExtension::snarcos_store_key(env); + assert!(matches!(result, Err(_))); assert_eq!( charged(charging_listener), @@ -49,7 +54,9 @@ fn store_key__too_long_vk() { ByteCount::MAX, Some(Box::new(|| panic!("Shouldn't read anything at all"))), ); + let result = SnarcosChainExtension::snarcos_store_key(env); + assert!(matches!( result, Ok(RetVal::Converging(SNARCOS_STORE_KEY_TOO_LONG_KEY)) @@ -57,11 +64,35 @@ fn store_key__too_long_vk() { assert_eq!(charged(charging_listener), 0); } +#[test] +#[allow(non_snake_case)] +fn store_key__positive_scenario() { + let content = StoreKeyArgs { + key: vk_bytes().to_vec(), + identifier: IDENTIFIER, + }; + let (env, charging_listener) = MockedEnvironment::::new(content.encode()); + let key_length = env.key_len(); + + let result = SnarcosChainExtension::snarcos_store_key(env); + + assert!(matches!( + result, + Ok(RetVal::Converging(SNARCOS_STORE_KEY_OK)) + )); + assert_eq!( + charged(charging_listener), + weight_of_store_key(key_length) as RevertibleWeight + ); +} + #[test] #[allow(non_snake_case)] fn verify__charges_before_reading() { let (env, charging_listener) = InputCorruptedEnvironment::::new(41, None); + let result = SnarcosChainExtension::snarcos_verify(env); + assert!(matches!(result, Err(_))); assert_eq!( charged(charging_listener), From 3b9c78c6714a94459d85fb7c58ebda38edc2bff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 14:31:18 +0100 Subject: [PATCH 27/41] Remove resources, we will mock pallet --- bin/runtime/src/chain_extension/tests/mod.rs | 14 +------------- .../tests/resources/xor.proof.bytes | 2 -- .../tests/resources/xor.public_input.bytes | Bin 264 -> 0 bytes .../chain_extension/tests/resources/xor.vk.bytes | Bin 776 -> 0 bytes 4 files changed, 1 insertion(+), 15 deletions(-) delete mode 100644 bin/runtime/src/chain_extension/tests/resources/xor.proof.bytes delete mode 100644 bin/runtime/src/chain_extension/tests/resources/xor.public_input.bytes delete mode 100644 bin/runtime/src/chain_extension/tests/resources/xor.vk.bytes diff --git a/bin/runtime/src/chain_extension/tests/mod.rs b/bin/runtime/src/chain_extension/tests/mod.rs index 6c6bd55664..5ca86cceea 100644 --- a/bin/runtime/src/chain_extension/tests/mod.rs +++ b/bin/runtime/src/chain_extension/tests/mod.rs @@ -11,18 +11,6 @@ type RevertibleWeight = i64; const IDENTIFIER: VerificationKeyIdentifier = [1, 7, 2, 9]; -fn vk_bytes() -> &'static [u8] { - include_bytes!("resources/xor.vk.bytes") -} - -fn proof_bytes() -> &'static [u8] { - include_bytes!("resources/xor.proof.bytes") -} - -fn input_bytes() -> &'static [u8] { - include_bytes!("resources/xor.public_input.bytes") -} - fn charged(charging_listener: Receiver) -> RevertibleWeight { charging_listener.into_iter().sum() } @@ -68,7 +56,7 @@ fn store_key__too_long_vk() { #[allow(non_snake_case)] fn store_key__positive_scenario() { let content = StoreKeyArgs { - key: vk_bytes().to_vec(), + key: vec![], identifier: IDENTIFIER, }; let (env, charging_listener) = MockedEnvironment::::new(content.encode()); diff --git a/bin/runtime/src/chain_extension/tests/resources/xor.proof.bytes b/bin/runtime/src/chain_extension/tests/resources/xor.proof.bytes deleted file mode 100644 index 818eb0cca9..0000000000 --- a/bin/runtime/src/chain_extension/tests/resources/xor.proof.bytes +++ /dev/null @@ -1,2 +0,0 @@ -��u��u��st|�\CF -ϕ�Y��9�8�� �H�04����BOo@�������5�H�ܜ��_m+_�h��q�k!�~��}%!]y\�ZU���F�?���B��Ȑ�%�e4����\�C� Wָ��E0����8�^M)KhnTyUHl8@*Qnn1SL$CWH)z5DjmkZ7toQ4eN zyx8`jaJB+_cw4WG5)8wDq77y{fN_BqMwAcJ4sld^oq_oBTQx|PYt%#H98R35#A7KU{K_AZC34^Cxfs&5Gd@KVfe^w#8pyQEG zVy+EYFo?vHIj|LpjyHyc%wl@YToF@GKx84`jYrcHY#9{^000000001<0DkKBW9iq!^&0sv z9mLb}ZXD@XU?uq3mjzPwoggi&t&>K&&nN!-H!Bo{e|{2%_~fJczm9L05}sjdaJ3g8 zv_m6qRYUOj8+xr2W-!(;8HjI?$zK=>58)C{MTP)b{PdNK5;#oHAILtfn&IQV=76_wDLbvF zNi<+t-4^`jIRLV1g4V20>)jQc!}>!U_biUp$-%)YIleF^GQ5 zb~}H7m1tVkm3WF}Uj1gFs4^Hc`*y$hkFCGwdq`_z=a2x^nR!|)#jmbZ+)`0R4X8IW z>8~?7o4Jp>Mt)CWh*|J5O#WM;G2BnSlwTs<&)H1snkzB0CSTcgqj2((S&JW7@SiL1 GeoYkj8h)t& From 47f0ef9f2f1aff95e7ee2575e2bb7031b290a76e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 15:16:49 +0100 Subject: [PATCH 28/41] Remove temporarily failing test --- bin/runtime/src/chain_extension/tests/mod.rs | 42 ++++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/bin/runtime/src/chain_extension/tests/mod.rs b/bin/runtime/src/chain_extension/tests/mod.rs index 5ca86cceea..6b75c07e94 100644 --- a/bin/runtime/src/chain_extension/tests/mod.rs +++ b/bin/runtime/src/chain_extension/tests/mod.rs @@ -52,27 +52,27 @@ fn store_key__too_long_vk() { assert_eq!(charged(charging_listener), 0); } -#[test] -#[allow(non_snake_case)] -fn store_key__positive_scenario() { - let content = StoreKeyArgs { - key: vec![], - identifier: IDENTIFIER, - }; - let (env, charging_listener) = MockedEnvironment::::new(content.encode()); - let key_length = env.key_len(); - - let result = SnarcosChainExtension::snarcos_store_key(env); - - assert!(matches!( - result, - Ok(RetVal::Converging(SNARCOS_STORE_KEY_OK)) - )); - assert_eq!( - charged(charging_listener), - weight_of_store_key(key_length) as RevertibleWeight - ); -} +// #[test] +// #[allow(non_snake_case)] +// fn store_key__positive_scenario() { +// let content = StoreKeyArgs { +// key: vec![], +// identifier: IDENTIFIER, +// }; +// let (env, charging_listener) = MockedEnvironment::::new(content.encode()); +// let key_length = env.key_len(); +// +// let result = SnarcosChainExtension::snarcos_store_key(env); +// +// assert!(matches!( +// result, +// Ok(RetVal::Converging(SNARCOS_STORE_KEY_OK)) +// )); +// assert_eq!( +// charged(charging_listener), +// weight_of_store_key(key_length) as RevertibleWeight +// ); +// } #[test] #[allow(non_snake_case)] From 3b3b40de9c819086a06350b660a07d0e70a18362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 16:06:04 +0100 Subject: [PATCH 29/41] Fat environment refactor --- .../tests/{environments.rs => environment.rs} | 108 +++++++++--------- bin/runtime/src/chain_extension/tests/mod.rs | 11 +- 2 files changed, 56 insertions(+), 63 deletions(-) rename bin/runtime/src/chain_extension/tests/{environments.rs => environment.rs} (53%) diff --git a/bin/runtime/src/chain_extension/tests/environments.rs b/bin/runtime/src/chain_extension/tests/environment.rs similarity index 53% rename from bin/runtime/src/chain_extension/tests/environments.rs rename to bin/runtime/src/chain_extension/tests/environment.rs index f9e980081e..a57e0aeca6 100644 --- a/bin/runtime/src/chain_extension/tests/environments.rs +++ b/bin/runtime/src/chain_extension/tests/environment.rs @@ -6,23 +6,37 @@ use std::{ use super::*; -pub trait Mode {} - +pub trait FunctionMode {} pub enum StoreKeyMode {} pub enum VerifyMode {} +impl FunctionMode for StoreKeyMode {} +impl FunctionMode for VerifyMode {} -impl Mode for StoreKeyMode {} -impl Mode for VerifyMode {} +pub trait ReadingMode {} +pub enum CorruptedMode {} +pub enum StandardMode {} +impl ReadingMode for CorruptedMode {} +impl ReadingMode for StandardMode {} -/// May signal that there is something to read, but no read can succeed. -pub struct InputCorruptedEnvironment { - in_len: ByteCount, +trait _Read { + fn _read(&self, max_len: ByteCount) -> Result, DispatchError>; +} + +pub struct MockedEnvironment { + /// Channel to report all charges. charging_channel: Sender, + + /// `Some(_)` iff `RM = CorruptedMode`. on_read: Option>, - _phantom: PhantomData, + /// `Some(_)` iff `RM = StandardMode`. + content: Option>, + + in_len: ByteCount, + + _phantom: PhantomData<(FM, RM)>, } -impl InputCorruptedEnvironment { +impl MockedEnvironment { pub fn new( in_len: ByteCount, on_read: Option>, @@ -30,62 +44,32 @@ impl InputCorruptedEnvironment { let (sender, receiver) = channel(); ( Self { - in_len, - on_read, charging_channel: sender, + on_read, + content: None, + in_len, _phantom: Default::default(), }, receiver, ) } } - -impl InputCorruptedEnvironment { - pub fn key_len(&self) -> ByteCount { - self.in_len - (size_of::() as ByteCount) - } -} - -impl Environment for InputCorruptedEnvironment { - type ChargedAmount = Weight; - - fn in_len(&self) -> ByteCount { - self.in_len - } - - fn read(&self, _max_len: u32) -> Result, DispatchError> { +impl _Read for MockedEnvironment { + fn _read(&self, _max_len: ByteCount) -> Result, DispatchError> { self.on_read.as_ref().map(|action| action()); Err(DispatchError::Other("Some error")) } - - fn charge_weight(&mut self, amount: Weight) -> Result { - self.charging_channel - .send(amount as RevertibleWeight) - .unwrap(); - Ok(amount) - } - - fn adjust_weight(&mut self, charged: Weight, actual_weight: Weight) { - self.charging_channel - .send(((charged - actual_weight) as RevertibleWeight).neg()) - .unwrap(); - } } -/// 'Fully functional' mock. -pub struct MockedEnvironment { - charging_channel: Sender, - content: Vec, - _phantom: PhantomData, -} - -impl MockedEnvironment { +impl MockedEnvironment { pub fn new(content: Vec) -> (Self, Receiver) { let (sender, receiver) = channel(); ( Self { - content, charging_channel: sender, + on_read: None, + in_len: content.len() as ByteCount, + content: Some(content), _phantom: Default::default(), }, receiver, @@ -93,25 +77,35 @@ impl MockedEnvironment { } } -impl MockedEnvironment { +impl _Read for MockedEnvironment { + fn _read(&self, max_len: ByteCount) -> Result, DispatchError> { + let content = self.content.as_ref().unwrap(); + if max_len > self.in_len { + Ok(content.clone()) + } else { + Ok(content[..max_len as usize].to_vec()) + } + } +} + +impl MockedEnvironment { pub fn key_len(&self) -> ByteCount { - self.in_len() - (size_of::() as ByteCount) + self.in_len - (size_of::() as ByteCount) } } -impl Environment for MockedEnvironment { +impl Environment for MockedEnvironment +where + MockedEnvironment: _Read, +{ type ChargedAmount = Weight; fn in_len(&self) -> ByteCount { - self.content.len() as ByteCount + self.in_len } fn read(&self, max_len: u32) -> Result, DispatchError> { - if max_len > self.in_len() { - Ok(self.content.clone()) - } else { - Ok(self.content[..max_len as usize].to_vec()) - } + self._read(max_len) } fn charge_weight(&mut self, amount: Weight) -> Result { diff --git a/bin/runtime/src/chain_extension/tests/mod.rs b/bin/runtime/src/chain_extension/tests/mod.rs index 6b75c07e94..b2095b1eda 100644 --- a/bin/runtime/src/chain_extension/tests/mod.rs +++ b/bin/runtime/src/chain_extension/tests/mod.rs @@ -1,11 +1,10 @@ use std::sync::mpsc::Receiver; -use environments::{InputCorruptedEnvironment, StoreKeyMode, VerifyMode}; +use environment::{CorruptedMode, MockedEnvironment, StandardMode, StoreKeyMode, VerifyMode}; use super::*; -use crate::chain_extension::tests::environments::MockedEnvironment; -mod environments; +mod environment; type RevertibleWeight = i64; @@ -23,7 +22,7 @@ fn extension_is_enabled() { #[test] #[allow(non_snake_case)] fn store_key__charges_before_reading() { - let (env, charging_listener) = InputCorruptedEnvironment::::new(41, None); + let (env, charging_listener) = MockedEnvironment::::new(41, None); let key_length = env.key_len(); let result = SnarcosChainExtension::snarcos_store_key(env); @@ -38,7 +37,7 @@ fn store_key__charges_before_reading() { #[test] #[allow(non_snake_case)] fn store_key__too_long_vk() { - let (env, charging_listener) = InputCorruptedEnvironment::::new( + let (env, charging_listener) = MockedEnvironment::::new( ByteCount::MAX, Some(Box::new(|| panic!("Shouldn't read anything at all"))), ); @@ -77,7 +76,7 @@ fn store_key__too_long_vk() { #[test] #[allow(non_snake_case)] fn verify__charges_before_reading() { - let (env, charging_listener) = InputCorruptedEnvironment::::new(41, None); + let (env, charging_listener) = MockedEnvironment::::new(41, None); let result = SnarcosChainExtension::snarcos_verify(env); From 7c30f0eeab09170f7b5d6c1035c2c148f0f36eef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 16:12:21 +0100 Subject: [PATCH 30/41] Move environment trait to separate module --- .../src/chain_extension/environment.rs | 48 +++++++++++++++++++ bin/runtime/src/chain_extension/mod.rs | 48 ++----------------- 2 files changed, 52 insertions(+), 44 deletions(-) create mode 100644 bin/runtime/src/chain_extension/environment.rs diff --git a/bin/runtime/src/chain_extension/environment.rs b/bin/runtime/src/chain_extension/environment.rs new file mode 100644 index 0000000000..a89222af3b --- /dev/null +++ b/bin/runtime/src/chain_extension/environment.rs @@ -0,0 +1,48 @@ +use frame_support::weights::Weight; +use pallet_contracts::{ + chain_extension::{BufInBufOutState, Environment as SubstrateEnvironment, Ext, SysConfig}, + ChargedAmount, +}; +use sp_core::crypto::UncheckedFrom; +use sp_runtime::DispatchError; +use sp_std::vec::Vec; + +use crate::chain_extension::ByteCount; + +/// Abstraction around `pallet_contracts::chain_extension::Environment`. Makes testing easier. +/// +/// Gathers all the methods that are used by `SnarcosChainExtension`. For now all operations are +/// performed in `BufInBufOut` mode, so we don't have to take care of other modes. +pub(super) trait Environment: Sized { + type ChargedAmount; + + fn in_len(&self) -> ByteCount; + fn read(&self, max_len: u32) -> Result, DispatchError>; + + fn charge_weight(&mut self, amount: Weight) -> Result; + fn adjust_weight(&mut self, charged: Self::ChargedAmount, actual_weight: Weight); +} + +/// Transparent delegation. +impl Environment for SubstrateEnvironment<'_, '_, E, BufInBufOutState> +where + ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>, +{ + type ChargedAmount = ChargedAmount; + + fn in_len(&self) -> ByteCount { + self.in_len() + } + + fn read(&self, max_len: u32) -> Result, DispatchError> { + self.read(max_len) + } + + fn charge_weight(&mut self, amount: Weight) -> Result { + self.charge_weight(amount) + } + + fn adjust_weight(&mut self, charged: ChargedAmount, actual_weight: Weight) { + self.adjust_weight(charged, actual_weight) + } +} diff --git a/bin/runtime/src/chain_extension/mod.rs b/bin/runtime/src/chain_extension/mod.rs index e69545050d..c2da1c8b2e 100644 --- a/bin/runtime/src/chain_extension/mod.rs +++ b/bin/runtime/src/chain_extension/mod.rs @@ -1,11 +1,8 @@ use codec::{Decode, Encode}; +use environment::Environment; use frame_support::{log::error, weights::Weight}; -use pallet_contracts::{ - chain_extension::{ - BufInBufOutState, ChainExtension, Environment as SubstrateEnvironment, Ext, InitState, - RetVal, SysConfig, - }, - ChargedAmount, +use pallet_contracts::chain_extension::{ + ChainExtension, Environment as SubstrateEnvironment, Ext, InitState, RetVal, SysConfig, }; use pallet_snarcos::{ Config, Error, Pallet as Snarcos, ProvingSystem, VerificationKeyIdentifier, WeightInfo, @@ -17,6 +14,7 @@ use Error::*; use crate::{MaximumVerificationKeyLength, Runtime}; +mod environment; #[cfg(test)] mod tests; @@ -62,44 +60,6 @@ impl ChainExtension for SnarcosChainExtension { pub type ByteCount = u32; -/// Abstraction around `pallet_contracts::chain_extension::Environment`. Makes testing easier. -/// -/// Gathers all the methods that are used by `SnarcosChainExtension`. For now all operations are -/// performed in `BufInBufOut` mode, so we don't have to take care of other modes. -trait Environment: Sized { - type ChargedAmount; - - fn in_len(&self) -> ByteCount; - fn read(&self, max_len: u32) -> Result, DispatchError>; - - fn charge_weight(&mut self, amount: Weight) -> Result; - fn adjust_weight(&mut self, charged: Self::ChargedAmount, actual_weight: Weight); -} - -/// Transparent delegation. -impl Environment for SubstrateEnvironment<'_, '_, E, BufInBufOutState> -where - ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>, -{ - type ChargedAmount = ChargedAmount; - - fn in_len(&self) -> ByteCount { - self.in_len() - } - - fn read(&self, max_len: u32) -> Result, DispatchError> { - self.read(max_len) - } - - fn charge_weight(&mut self, amount: Weight) -> Result { - self.charge_weight(amount) - } - - fn adjust_weight(&mut self, charged: ChargedAmount, actual_weight: Weight) { - self.adjust_weight(charged, actual_weight) - } -} - /// Struct to be decoded from a byte slice passed from the contract. /// /// Notice, that contract can pass these arguments one by one, not necessarily as such struct. Only From 76fd2827adfbd72f1590dc542af65b3f7444626b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 16:45:19 +0100 Subject: [PATCH 31/41] Abstract pallet: executor --- bin/runtime/src/chain_extension/executor.rs | 33 +++++++++++++++++++ bin/runtime/src/chain_extension/mod.rs | 26 ++++++++------- .../src/chain_extension/tests/executor.rs | 20 +++++++++++ bin/runtime/src/chain_extension/tests/mod.rs | 8 +++-- 4 files changed, 73 insertions(+), 14 deletions(-) create mode 100644 bin/runtime/src/chain_extension/executor.rs create mode 100644 bin/runtime/src/chain_extension/tests/executor.rs diff --git a/bin/runtime/src/chain_extension/executor.rs b/bin/runtime/src/chain_extension/executor.rs new file mode 100644 index 0000000000..474ad3e8f3 --- /dev/null +++ b/bin/runtime/src/chain_extension/executor.rs @@ -0,0 +1,33 @@ +use pallet_snarcos::{Error, Pallet as Snarcos, ProvingSystem, VerificationKeyIdentifier}; +use sp_std::vec::Vec; + +use crate::Runtime; + +pub(super) trait Executor: Sized { + fn store_key(identifier: VerificationKeyIdentifier, key: Vec) -> Result<(), Error>; + + fn verify( + verification_key_identifier: VerificationKeyIdentifier, + proof: Vec, + public_input: Vec, + system: ProvingSystem, + ) -> Result<(), Error>; +} + +impl Executor for Runtime { + fn store_key( + identifier: VerificationKeyIdentifier, + key: Vec, + ) -> Result<(), Error> { + Snarcos::::bare_store_key(identifier, key) + } + + fn verify( + verification_key_identifier: VerificationKeyIdentifier, + proof: Vec, + public_input: Vec, + system: ProvingSystem, + ) -> Result<(), Error> { + Snarcos::::bare_verify(verification_key_identifier, proof, public_input, system) + } +} diff --git a/bin/runtime/src/chain_extension/mod.rs b/bin/runtime/src/chain_extension/mod.rs index c2da1c8b2e..051f856735 100644 --- a/bin/runtime/src/chain_extension/mod.rs +++ b/bin/runtime/src/chain_extension/mod.rs @@ -1,20 +1,19 @@ use codec::{Decode, Encode}; use environment::Environment; +use executor::Executor; use frame_support::{log::error, weights::Weight}; use pallet_contracts::chain_extension::{ ChainExtension, Environment as SubstrateEnvironment, Ext, InitState, RetVal, SysConfig, }; -use pallet_snarcos::{ - Config, Error, Pallet as Snarcos, ProvingSystem, VerificationKeyIdentifier, WeightInfo, -}; +use pallet_snarcos::{Config, Error, ProvingSystem, VerificationKeyIdentifier, WeightInfo}; use sp_core::crypto::UncheckedFrom; use sp_runtime::DispatchError; use sp_std::{mem::size_of, vec::Vec}; use Error::*; use crate::{MaximumVerificationKeyLength, Runtime}; - mod environment; +mod executor; #[cfg(test)] mod tests; @@ -48,8 +47,10 @@ impl ChainExtension for SnarcosChainExtension { ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>, { match func_id { - SNARCOS_STORE_KEY_FUNC_ID => Self::snarcos_store_key(env.buf_in_buf_out()), - SNARCOS_VERIFY_FUNC_ID => Self::snarcos_verify(env.buf_in_buf_out()), + SNARCOS_STORE_KEY_FUNC_ID => { + Self::snarcos_store_key::<_, Runtime>(env.buf_in_buf_out()) + } + SNARCOS_VERIFY_FUNC_ID => Self::snarcos_verify::<_, Runtime>(env.buf_in_buf_out()), _ => { error!("Called an unregistered `func_id`: {}", func_id); Err(DispatchError::Other("Unimplemented func_id")) @@ -109,7 +110,9 @@ fn weight_of_verify(system: Option) -> Weight { } impl SnarcosChainExtension { - fn snarcos_store_key(mut env: Env) -> Result { + fn snarcos_store_key( + mut env: Env, + ) -> Result { // Check if it makes sense to read and decode data. let key_length = env .in_len() @@ -133,7 +136,7 @@ impl SnarcosChainExtension { let args = StoreKeyArgs::decode(&mut &*bytes) .map_err(|_| DispatchError::Other("Failed to decode arguments"))?; - let return_status = match Snarcos::::bare_store_key(args.identifier, args.key) { + let return_status = match Exc::store_key(args.identifier, args.key) { Ok(_) => SNARCOS_STORE_KEY_OK, // In case `DispatchResultWithPostInfo` was returned (or some simpler equivalent for // `bare_store_key`), we could adjust weight. However, for the storing key action it @@ -145,7 +148,9 @@ impl SnarcosChainExtension { Ok(RetVal::Converging(return_status)) } - fn snarcos_verify(mut env: Env) -> Result { + fn snarcos_verify( + mut env: Env, + ) -> Result { // We charge optimistically, i.e. assuming that decoding succeeds and the verification // key is present. However, since we don't know the system yet, we have to charge maximal // possible fee. We will adjust it as soon as possible. @@ -165,8 +170,7 @@ impl SnarcosChainExtension { env.adjust_weight(pre_charge, weight_of_verify(Some(args.system))); - let result = - Snarcos::::bare_verify(args.identifier, args.proof, args.input, args.system); + let result = Exc::verify(args.identifier, args.proof, args.input, args.system); let return_status = match result { Ok(_) => SNARCOS_VERIFY_OK, diff --git a/bin/runtime/src/chain_extension/tests/executor.rs b/bin/runtime/src/chain_extension/tests/executor.rs new file mode 100644 index 0000000000..b81f14923e --- /dev/null +++ b/bin/runtime/src/chain_extension/tests/executor.rs @@ -0,0 +1,20 @@ +use pallet_snarcos::{Error, ProvingSystem, VerificationKeyIdentifier}; + +use crate::chain_extension::executor::Executor; + +pub(super) struct MockedExecutor; + +impl Executor for MockedExecutor { + fn store_key(_identifier: VerificationKeyIdentifier, _key: Vec) -> Result<(), Error> { + Err(Error::IdentifierAlreadyInUse) + } + + fn verify( + _verification_key_identifier: VerificationKeyIdentifier, + _proof: Vec, + _public_input: Vec, + _system: ProvingSystem, + ) -> Result<(), Error> { + Err(Error::IncorrectProof) + } +} diff --git a/bin/runtime/src/chain_extension/tests/mod.rs b/bin/runtime/src/chain_extension/tests/mod.rs index b2095b1eda..f4b19ae877 100644 --- a/bin/runtime/src/chain_extension/tests/mod.rs +++ b/bin/runtime/src/chain_extension/tests/mod.rs @@ -1,10 +1,12 @@ use std::sync::mpsc::Receiver; use environment::{CorruptedMode, MockedEnvironment, StandardMode, StoreKeyMode, VerifyMode}; +use executor::MockedExecutor; use super::*; mod environment; +mod executor; type RevertibleWeight = i64; @@ -25,7 +27,7 @@ fn store_key__charges_before_reading() { let (env, charging_listener) = MockedEnvironment::::new(41, None); let key_length = env.key_len(); - let result = SnarcosChainExtension::snarcos_store_key(env); + let result = SnarcosChainExtension::snarcos_store_key::<_, MockedExecutor>(env); assert!(matches!(result, Err(_))); assert_eq!( @@ -42,7 +44,7 @@ fn store_key__too_long_vk() { Some(Box::new(|| panic!("Shouldn't read anything at all"))), ); - let result = SnarcosChainExtension::snarcos_store_key(env); + let result = SnarcosChainExtension::snarcos_store_key::<_, MockedExecutor>(env); assert!(matches!( result, @@ -78,7 +80,7 @@ fn store_key__too_long_vk() { fn verify__charges_before_reading() { let (env, charging_listener) = MockedEnvironment::::new(41, None); - let result = SnarcosChainExtension::snarcos_verify(env); + let result = SnarcosChainExtension::snarcos_verify::<_, MockedExecutor>(env); assert!(matches!(result, Err(_))); assert_eq!( From ee0ce987ec19de5745ace8f59396028ae747b40f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 18:00:20 +0100 Subject: [PATCH 32/41] I am ashamed of what I had to do --- bin/runtime/src/chain_extension/executor.rs | 11 ++- .../src/chain_extension/tests/executor.rs | 23 +++++-- bin/runtime/src/chain_extension/tests/mod.rs | 68 ++++++++++++------- bin/runtime/src/lib.rs | 1 + pallets/snarcos/src/lib.rs | 1 + 5 files changed, 71 insertions(+), 33 deletions(-) diff --git a/bin/runtime/src/chain_extension/executor.rs b/bin/runtime/src/chain_extension/executor.rs index 474ad3e8f3..4db33df04b 100644 --- a/bin/runtime/src/chain_extension/executor.rs +++ b/bin/runtime/src/chain_extension/executor.rs @@ -4,17 +4,24 @@ use sp_std::vec::Vec; use crate::Runtime; pub(super) trait Executor: Sized { - fn store_key(identifier: VerificationKeyIdentifier, key: Vec) -> Result<(), Error>; + type ErrorGenericType; + + fn store_key( + identifier: VerificationKeyIdentifier, + key: Vec, + ) -> Result<(), Error>; fn verify( verification_key_identifier: VerificationKeyIdentifier, proof: Vec, public_input: Vec, system: ProvingSystem, - ) -> Result<(), Error>; + ) -> Result<(), Error>; } impl Executor for Runtime { + type ErrorGenericType = Runtime; + fn store_key( identifier: VerificationKeyIdentifier, key: Vec, diff --git a/bin/runtime/src/chain_extension/tests/executor.rs b/bin/runtime/src/chain_extension/tests/executor.rs index b81f14923e..fd8aa9f5fc 100644 --- a/bin/runtime/src/chain_extension/tests/executor.rs +++ b/bin/runtime/src/chain_extension/tests/executor.rs @@ -1,12 +1,21 @@ -use pallet_snarcos::{Error, ProvingSystem, VerificationKeyIdentifier}; +use std::marker::PhantomData; + +use pallet_snarcos::{Error as SnarcosError, ProvingSystem, VerificationKeyIdentifier}; use crate::chain_extension::executor::Executor; -pub(super) struct MockedExecutor; +type Error = SnarcosError<()>; +type Result = core::result::Result<(), Error>; + +pub(super) struct MockedExecutor; + +impl Executor + for MockedExecutor +{ + type ErrorGenericType = (); -impl Executor for MockedExecutor { - fn store_key(_identifier: VerificationKeyIdentifier, _key: Vec) -> Result<(), Error> { - Err(Error::IdentifierAlreadyInUse) + fn store_key(_identifier: VerificationKeyIdentifier, _key: Vec) -> Result { + StoreKeyResponder } fn verify( @@ -14,7 +23,7 @@ impl Executor for MockedExecutor { _proof: Vec, _public_input: Vec, _system: ProvingSystem, - ) -> Result<(), Error> { - Err(Error::IncorrectProof) + ) -> Result { + VerifyResponder } } diff --git a/bin/runtime/src/chain_extension/tests/mod.rs b/bin/runtime/src/chain_extension/tests/mod.rs index f4b19ae877..8ebf2fd480 100644 --- a/bin/runtime/src/chain_extension/tests/mod.rs +++ b/bin/runtime/src/chain_extension/tests/mod.rs @@ -2,6 +2,7 @@ use std::sync::mpsc::Receiver; use environment::{CorruptedMode, MockedEnvironment, StandardMode, StoreKeyMode, VerifyMode}; use executor::MockedExecutor; +use pallet_snarcos::ProvingSystem::Groth16; use super::*; @@ -11,6 +12,25 @@ mod executor; type RevertibleWeight = i64; const IDENTIFIER: VerificationKeyIdentifier = [1, 7, 2, 9]; +const VK: [u8; 2] = [4, 1]; +const PROOF: [u8; 20] = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 4]; +const INPUT: [u8; 11] = [0, 5, 7, 7, 2, 1, 5, 6, 6, 4, 9]; + +fn store_key_args() -> StoreKeyArgs { + StoreKeyArgs { + identifier: IDENTIFIER, + key: VK.to_vec(), + } +} + +fn verify_args() -> VerifyArgs { + VerifyArgs { + identifier: IDENTIFIER, + proof: PROOF.to_vec(), + input: INPUT.to_vec(), + system: Groth16, + } +} fn charged(charging_listener: Receiver) -> RevertibleWeight { charging_listener.into_iter().sum() @@ -27,7 +47,8 @@ fn store_key__charges_before_reading() { let (env, charging_listener) = MockedEnvironment::::new(41, None); let key_length = env.key_len(); - let result = SnarcosChainExtension::snarcos_store_key::<_, MockedExecutor>(env); + let result = + SnarcosChainExtension::snarcos_store_key::<_, MockedExecutor<{ Ok(()) }, { Ok(()) }>>(env); assert!(matches!(result, Err(_))); assert_eq!( @@ -44,7 +65,8 @@ fn store_key__too_long_vk() { Some(Box::new(|| panic!("Shouldn't read anything at all"))), ); - let result = SnarcosChainExtension::snarcos_store_key::<_, MockedExecutor>(env); + let result = + SnarcosChainExtension::snarcos_store_key::<_, MockedExecutor<{ Ok(()) }, { Ok(()) }>>(env); assert!(matches!( result, @@ -53,34 +75,32 @@ fn store_key__too_long_vk() { assert_eq!(charged(charging_listener), 0); } -// #[test] -// #[allow(non_snake_case)] -// fn store_key__positive_scenario() { -// let content = StoreKeyArgs { -// key: vec![], -// identifier: IDENTIFIER, -// }; -// let (env, charging_listener) = MockedEnvironment::::new(content.encode()); -// let key_length = env.key_len(); -// -// let result = SnarcosChainExtension::snarcos_store_key(env); -// -// assert!(matches!( -// result, -// Ok(RetVal::Converging(SNARCOS_STORE_KEY_OK)) -// )); -// assert_eq!( -// charged(charging_listener), -// weight_of_store_key(key_length) as RevertibleWeight -// ); -// } +#[test] +#[allow(non_snake_case)] +fn store_key__positive_scenario() { + let (env, charging_listener) = + MockedEnvironment::::new(store_key_args().encode()); + + let result = + SnarcosChainExtension::snarcos_store_key::<_, MockedExecutor<{ Ok(()) }, { Ok(()) }>>(env); + + assert!(matches!( + result, + Ok(RetVal::Converging(SNARCOS_STORE_KEY_OK)) + )); + assert_eq!( + charged(charging_listener), + weight_of_store_key(VK.len() as ByteCount) as RevertibleWeight + ); +} #[test] #[allow(non_snake_case)] fn verify__charges_before_reading() { let (env, charging_listener) = MockedEnvironment::::new(41, None); - let result = SnarcosChainExtension::snarcos_verify::<_, MockedExecutor>(env); + let result = + SnarcosChainExtension::snarcos_verify::<_, MockedExecutor<{ Ok(()) }, { Ok(()) }>>(env); assert!(matches!(result, Err(_))); assert_eq!( diff --git a/bin/runtime/src/lib.rs b/bin/runtime/src/lib.rs index 7b6f2a0777..7434188ee5 100644 --- a/bin/runtime/src/lib.rs +++ b/bin/runtime/src/lib.rs @@ -1,6 +1,7 @@ #![cfg_attr(not(feature = "std"), no_std)] // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. #![recursion_limit = "256"] +#![cfg_attr(test, feature(adt_const_params))] // Make the WASM binary available. #[cfg(feature = "std")] diff --git a/pallets/snarcos/src/lib.rs b/pallets/snarcos/src/lib.rs index c60f40b637..d6610f2b7b 100644 --- a/pallets/snarcos/src/lib.rs +++ b/pallets/snarcos/src/lib.rs @@ -36,6 +36,7 @@ pub mod pallet { } #[pallet::error] + #[derive(Clone, Eq, PartialEq)] pub enum Error { /// This verification key identifier is already taken. IdentifierAlreadyInUse, From dfe9288008bf258be7e6b6ef7ca8559845a4fb94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 18:02:43 +0100 Subject: [PATCH 33/41] Ha! Bug found! --- bin/runtime/src/chain_extension/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/runtime/src/chain_extension/mod.rs b/bin/runtime/src/chain_extension/mod.rs index 051f856735..8f639b35d2 100644 --- a/bin/runtime/src/chain_extension/mod.rs +++ b/bin/runtime/src/chain_extension/mod.rs @@ -116,7 +116,10 @@ impl SnarcosChainExtension { // Check if it makes sense to read and decode data. let key_length = env .in_len() - .saturating_sub(size_of::() as ByteCount); + // identifier encoding + .saturating_sub(size_of::() as ByteCount) + // key length encoding + .saturating_sub(size_of::() as ByteCount); if key_length > MaximumVerificationKeyLength::get() { return Ok(RetVal::Converging(SNARCOS_STORE_KEY_TOO_LONG_KEY)); } From 10f6d044f00069b39fcfc5d6bb02d8f93f360858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 18:29:58 +0100 Subject: [PATCH 34/41] Fixed --- bin/runtime/src/chain_extension/mod.rs | 21 ++++++++++++------- .../src/chain_extension/tests/environment.rs | 6 ++++-- .../src/chain_extension/tests/executor.rs | 12 +++++------ bin/runtime/src/chain_extension/tests/mod.rs | 3 ++- bin/runtime/src/lib.rs | 1 + 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/bin/runtime/src/chain_extension/mod.rs b/bin/runtime/src/chain_extension/mod.rs index 8f639b35d2..4a6223a080 100644 --- a/bin/runtime/src/chain_extension/mod.rs +++ b/bin/runtime/src/chain_extension/mod.rs @@ -113,20 +113,19 @@ impl SnarcosChainExtension { fn snarcos_store_key( mut env: Env, ) -> Result { - // Check if it makes sense to read and decode data. - let key_length = env + // Check if it makes sense to read and decode data. This is only an upperbound for the key + // length, because this bytes suffix contain (possibly compressed) info about actual key + // length (needed for decoding). + let approx_key_length = env .in_len() - // identifier encoding - .saturating_sub(size_of::() as ByteCount) - // key length encoding - .saturating_sub(size_of::() as ByteCount); - if key_length > MaximumVerificationKeyLength::get() { + .saturating_sub(size_of::() as ByteCount); + if approx_key_length > MaximumVerificationKeyLength::get() { return Ok(RetVal::Converging(SNARCOS_STORE_KEY_TOO_LONG_KEY)); } // We charge now - even if decoding fails and we shouldn't touch storage, we have to incur // fee for reading memory. - env.charge_weight(weight_of_store_key(key_length))?; + let pre_charged = env.charge_weight(weight_of_store_key(approx_key_length))?; // Parsing will have to be done here. This is due to the fact that methods // `Environment<_,_,_,S: BufIn>::read*` don't move starting pointer and thus we can make @@ -139,6 +138,12 @@ impl SnarcosChainExtension { let args = StoreKeyArgs::decode(&mut &*bytes) .map_err(|_| DispatchError::Other("Failed to decode arguments"))?; + // Now we know the exact key length. + env.adjust_weight( + pre_charged, + weight_of_store_key(args.key.len() as ByteCount), + ); + let return_status = match Exc::store_key(args.identifier, args.key) { Ok(_) => SNARCOS_STORE_KEY_OK, // In case `DispatchResultWithPostInfo` was returned (or some simpler equivalent for diff --git a/bin/runtime/src/chain_extension/tests/environment.rs b/bin/runtime/src/chain_extension/tests/environment.rs index a57e0aeca6..291de89e27 100644 --- a/bin/runtime/src/chain_extension/tests/environment.rs +++ b/bin/runtime/src/chain_extension/tests/environment.rs @@ -89,8 +89,10 @@ impl _Read for MockedEnvironment { } impl MockedEnvironment { - pub fn key_len(&self) -> ByteCount { - self.in_len - (size_of::() as ByteCount) + pub fn approx_key_len(&self) -> ByteCount { + self.in_len + .checked_sub(size_of::() as ByteCount) + .unwrap() } } diff --git a/bin/runtime/src/chain_extension/tests/executor.rs b/bin/runtime/src/chain_extension/tests/executor.rs index fd8aa9f5fc..f9a72879a7 100644 --- a/bin/runtime/src/chain_extension/tests/executor.rs +++ b/bin/runtime/src/chain_extension/tests/executor.rs @@ -1,5 +1,3 @@ -use std::marker::PhantomData; - use pallet_snarcos::{Error as SnarcosError, ProvingSystem, VerificationKeyIdentifier}; use crate::chain_extension::executor::Executor; @@ -7,15 +5,15 @@ use crate::chain_extension::executor::Executor; type Error = SnarcosError<()>; type Result = core::result::Result<(), Error>; -pub(super) struct MockedExecutor; +pub(super) struct MockedExecutor; -impl Executor - for MockedExecutor +impl Executor + for MockedExecutor { type ErrorGenericType = (); fn store_key(_identifier: VerificationKeyIdentifier, _key: Vec) -> Result { - StoreKeyResponder + STORE_KEY_RESPONDER } fn verify( @@ -24,6 +22,6 @@ impl Executor _public_input: Vec, _system: ProvingSystem, ) -> Result { - VerifyResponder + VERIFY_RESPONDER } } diff --git a/bin/runtime/src/chain_extension/tests/mod.rs b/bin/runtime/src/chain_extension/tests/mod.rs index 8ebf2fd480..5c98779a3b 100644 --- a/bin/runtime/src/chain_extension/tests/mod.rs +++ b/bin/runtime/src/chain_extension/tests/mod.rs @@ -45,7 +45,7 @@ fn extension_is_enabled() { #[allow(non_snake_case)] fn store_key__charges_before_reading() { let (env, charging_listener) = MockedEnvironment::::new(41, None); - let key_length = env.key_len(); + let key_length = env.approx_key_len(); let result = SnarcosChainExtension::snarcos_store_key::<_, MockedExecutor<{ Ok(()) }, { Ok(()) }>>(env); @@ -88,6 +88,7 @@ fn store_key__positive_scenario() { result, Ok(RetVal::Converging(SNARCOS_STORE_KEY_OK)) )); + assert_eq!( charged(charging_listener), weight_of_store_key(VK.len() as ByteCount) as RevertibleWeight diff --git a/bin/runtime/src/lib.rs b/bin/runtime/src/lib.rs index 7434188ee5..97dd1b386a 100644 --- a/bin/runtime/src/lib.rs +++ b/bin/runtime/src/lib.rs @@ -1,6 +1,7 @@ #![cfg_attr(not(feature = "std"), no_std)] // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. #![recursion_limit = "256"] +#![allow(incomplete_features)] #![cfg_attr(test, feature(adt_const_params))] // Make the WASM binary available. From d220e843c87f51c065310924e9042eac40171770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 18:46:00 +0100 Subject: [PATCH 35/41] Oh they gonna be hatin --- .../src/chain_extension/tests/executor.rs | 41 +++++++++++++++++-- bin/runtime/src/chain_extension/tests/mod.rs | 14 +++---- bin/runtime/src/lib.rs | 1 + 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/bin/runtime/src/chain_extension/tests/executor.rs b/bin/runtime/src/chain_extension/tests/executor.rs index f9a72879a7..07a0ba7ecd 100644 --- a/bin/runtime/src/chain_extension/tests/executor.rs +++ b/bin/runtime/src/chain_extension/tests/executor.rs @@ -5,15 +5,44 @@ use crate::chain_extension::executor::Executor; type Error = SnarcosError<()>; type Result = core::result::Result<(), Error>; -pub(super) struct MockedExecutor; +#[derive(Clone, Eq, PartialEq)] +pub(super) enum Responder { + Panicker, + Okayer, + Errorer(Error), +} + +/// `struct/enum construction is not supported in generic constants` +pub(super) const fn make_errorer() -> Responder { + Responder::Errorer(ERROR) +} + +pub(super) struct MockedExecutor< + const STORE_KEY_RESPONDER: Responder, + const VERIFY_RESPONDER: Responder, +>; + +pub(super) type Panicker = MockedExecutor<{ Responder::Panicker }, { Responder::Panicker }>; + +pub(super) type StoreKeyOkayer = MockedExecutor<{ Responder::Okayer }, { Responder::Panicker }>; +pub(super) type VerifyOkayer = MockedExecutor<{ Responder::Panicker }, { Responder::Okayer }>; + +pub(super) type StoreKeyErrorer = + MockedExecutor<{ make_errorer::() }, { Responder::Panicker }>; +pub(super) type VerifyErrorer = + MockedExecutor<{ Responder::Panicker }, { make_errorer::() }>; -impl Executor +impl Executor for MockedExecutor { type ErrorGenericType = (); fn store_key(_identifier: VerificationKeyIdentifier, _key: Vec) -> Result { - STORE_KEY_RESPONDER + match STORE_KEY_RESPONDER { + Responder::Panicker => panic!("Function `store_key` shouldn't have been executed"), + Responder::Okayer => Ok(()), + Responder::Errorer(e) => Err(e), + } } fn verify( @@ -22,6 +51,10 @@ impl Executor _public_input: Vec, _system: ProvingSystem, ) -> Result { - VERIFY_RESPONDER + match STORE_KEY_RESPONDER { + Responder::Panicker => panic!("Function `verify` shouldn't have been executed"), + Responder::Okayer => Ok(()), + Responder::Errorer(e) => Err(e), + } } } diff --git a/bin/runtime/src/chain_extension/tests/mod.rs b/bin/runtime/src/chain_extension/tests/mod.rs index 5c98779a3b..85b4082693 100644 --- a/bin/runtime/src/chain_extension/tests/mod.rs +++ b/bin/runtime/src/chain_extension/tests/mod.rs @@ -1,10 +1,10 @@ use std::sync::mpsc::Receiver; use environment::{CorruptedMode, MockedEnvironment, StandardMode, StoreKeyMode, VerifyMode}; -use executor::MockedExecutor; use pallet_snarcos::ProvingSystem::Groth16; use super::*; +use crate::chain_extension::tests::executor::{Panicker, StoreKeyOkayer}; mod environment; mod executor; @@ -47,8 +47,7 @@ fn store_key__charges_before_reading() { let (env, charging_listener) = MockedEnvironment::::new(41, None); let key_length = env.approx_key_len(); - let result = - SnarcosChainExtension::snarcos_store_key::<_, MockedExecutor<{ Ok(()) }, { Ok(()) }>>(env); + let result = SnarcosChainExtension::snarcos_store_key::<_, Panicker>(env); assert!(matches!(result, Err(_))); assert_eq!( @@ -65,8 +64,7 @@ fn store_key__too_long_vk() { Some(Box::new(|| panic!("Shouldn't read anything at all"))), ); - let result = - SnarcosChainExtension::snarcos_store_key::<_, MockedExecutor<{ Ok(()) }, { Ok(()) }>>(env); + let result = SnarcosChainExtension::snarcos_store_key::<_, Panicker>(env); assert!(matches!( result, @@ -81,8 +79,7 @@ fn store_key__positive_scenario() { let (env, charging_listener) = MockedEnvironment::::new(store_key_args().encode()); - let result = - SnarcosChainExtension::snarcos_store_key::<_, MockedExecutor<{ Ok(()) }, { Ok(()) }>>(env); + let result = SnarcosChainExtension::snarcos_store_key::<_, StoreKeyOkayer>(env); assert!(matches!( result, @@ -100,8 +97,7 @@ fn store_key__positive_scenario() { fn verify__charges_before_reading() { let (env, charging_listener) = MockedEnvironment::::new(41, None); - let result = - SnarcosChainExtension::snarcos_verify::<_, MockedExecutor<{ Ok(()) }, { Ok(()) }>>(env); + let result = SnarcosChainExtension::snarcos_verify::<_, Panicker>(env); assert!(matches!(result, Err(_))); assert_eq!( diff --git a/bin/runtime/src/lib.rs b/bin/runtime/src/lib.rs index 97dd1b386a..b1293ab9ea 100644 --- a/bin/runtime/src/lib.rs +++ b/bin/runtime/src/lib.rs @@ -3,6 +3,7 @@ #![recursion_limit = "256"] #![allow(incomplete_features)] #![cfg_attr(test, feature(adt_const_params))] +#![cfg_attr(test, feature(generic_const_exprs))] // Make the WASM binary available. #[cfg(feature = "std")] From d356b90d277cc78a63268e7674f24c7303984d27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 4 Nov 2022 18:50:22 +0100 Subject: [PATCH 36/41] Positive scenario for verify --- bin/runtime/src/chain_extension/mod.rs | 2 +- .../src/chain_extension/tests/executor.rs | 2 +- bin/runtime/src/chain_extension/tests/mod.rs | 30 +++++++++++++++---- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/bin/runtime/src/chain_extension/mod.rs b/bin/runtime/src/chain_extension/mod.rs index 4a6223a080..d6db9c6a9f 100644 --- a/bin/runtime/src/chain_extension/mod.rs +++ b/bin/runtime/src/chain_extension/mod.rs @@ -79,7 +79,7 @@ struct StoreKeyArgs { /// the order of values is important. /// /// It cannot be `MaxEncodedLen` due to `Vec<_>` and thus `Environment::read_as` cannot be used. -#[derive(Decode)] +#[derive(Decode, Encode)] struct VerifyArgs { pub identifier: VerificationKeyIdentifier, pub proof: Vec, diff --git a/bin/runtime/src/chain_extension/tests/executor.rs b/bin/runtime/src/chain_extension/tests/executor.rs index 07a0ba7ecd..17956745ed 100644 --- a/bin/runtime/src/chain_extension/tests/executor.rs +++ b/bin/runtime/src/chain_extension/tests/executor.rs @@ -51,7 +51,7 @@ impl Ex _public_input: Vec, _system: ProvingSystem, ) -> Result { - match STORE_KEY_RESPONDER { + match VERIFY_RESPONDER { Responder::Panicker => panic!("Function `verify` shouldn't have been executed"), Responder::Okayer => Ok(()), Responder::Errorer(e) => Err(e), diff --git a/bin/runtime/src/chain_extension/tests/mod.rs b/bin/runtime/src/chain_extension/tests/mod.rs index 85b4082693..ee4c4a7fe0 100644 --- a/bin/runtime/src/chain_extension/tests/mod.rs +++ b/bin/runtime/src/chain_extension/tests/mod.rs @@ -1,10 +1,9 @@ use std::sync::mpsc::Receiver; use environment::{CorruptedMode, MockedEnvironment, StandardMode, StoreKeyMode, VerifyMode}; -use pallet_snarcos::ProvingSystem::Groth16; use super::*; -use crate::chain_extension::tests::executor::{Panicker, StoreKeyOkayer}; +use crate::chain_extension::tests::executor::{Panicker, StoreKeyOkayer, VerifyOkayer}; mod environment; mod executor; @@ -15,21 +14,24 @@ const IDENTIFIER: VerificationKeyIdentifier = [1, 7, 2, 9]; const VK: [u8; 2] = [4, 1]; const PROOF: [u8; 20] = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 4]; const INPUT: [u8; 11] = [0, 5, 7, 7, 2, 1, 5, 6, 6, 4, 9]; +const SYSTEM: ProvingSystem = ProvingSystem::Groth16; -fn store_key_args() -> StoreKeyArgs { +fn store_key_args() -> Vec { StoreKeyArgs { identifier: IDENTIFIER, key: VK.to_vec(), } + .encode() } -fn verify_args() -> VerifyArgs { +fn verify_args() -> Vec { VerifyArgs { identifier: IDENTIFIER, proof: PROOF.to_vec(), input: INPUT.to_vec(), - system: Groth16, + system: SYSTEM, } + .encode() } fn charged(charging_listener: Receiver) -> RevertibleWeight { @@ -77,7 +79,7 @@ fn store_key__too_long_vk() { #[allow(non_snake_case)] fn store_key__positive_scenario() { let (env, charging_listener) = - MockedEnvironment::::new(store_key_args().encode()); + MockedEnvironment::::new(store_key_args()); let result = SnarcosChainExtension::snarcos_store_key::<_, StoreKeyOkayer>(env); @@ -105,3 +107,19 @@ fn verify__charges_before_reading() { weight_of_verify(None) as RevertibleWeight ); } + +#[test] +#[allow(non_snake_case)] +fn verify__positive_scenario() { + let (env, charging_listener) = + MockedEnvironment::::new(verify_args()); + + let result = SnarcosChainExtension::snarcos_verify::<_, VerifyOkayer>(env); + + assert!(matches!(result, Ok(RetVal::Converging(SNARCOS_VERIFY_OK)))); + + assert_eq!( + charged(charging_listener), + weight_of_verify(Some(SYSTEM)) as RevertibleWeight + ); +} From e5f3b119b0921909fb26e5e72e7ba939f81299c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Mon, 7 Nov 2022 07:09:06 +0100 Subject: [PATCH 37/41] The rest of testcases --- bin/runtime/src/chain_extension/mod.rs | 4 +- .../src/chain_extension/tests/executor.rs | 10 +- bin/runtime/src/chain_extension/tests/mod.rs | 175 +++++++++++++++++- 3 files changed, 180 insertions(+), 9 deletions(-) diff --git a/bin/runtime/src/chain_extension/mod.rs b/bin/runtime/src/chain_extension/mod.rs index d6db9c6a9f..7da32ac4c0 100644 --- a/bin/runtime/src/chain_extension/mod.rs +++ b/bin/runtime/src/chain_extension/mod.rs @@ -23,7 +23,7 @@ pub const SNARCOS_VERIFY_FUNC_ID: u32 = 42; // Return codes for `SNARCOS_STORE_KEY_FUNC_ID`. pub const SNARCOS_STORE_KEY_OK: u32 = 10_000; pub const SNARCOS_STORE_KEY_TOO_LONG_KEY: u32 = 10_001; -pub const SNARCOS_STORE_KEY_IN_USE: u32 = 10_002; +pub const SNARCOS_STORE_IDENTIFIER_IN_USE: u32 = 10_002; pub const SNARCOS_STORE_KEY_ERROR_UNKNOWN: u32 = 10_003; // Return codes for `SNARCOS_VERIFY_FUNC_ID`. @@ -150,7 +150,7 @@ impl SnarcosChainExtension { // `bare_store_key`), we could adjust weight. However, for the storing key action it // doesn't make sense. Err(VerificationKeyTooLong) => SNARCOS_STORE_KEY_TOO_LONG_KEY, - Err(IdentifierAlreadyInUse) => SNARCOS_STORE_KEY_IN_USE, + Err(IdentifierAlreadyInUse) => SNARCOS_STORE_IDENTIFIER_IN_USE, _ => SNARCOS_STORE_KEY_ERROR_UNKNOWN, }; Ok(RetVal::Converging(return_status)) diff --git a/bin/runtime/src/chain_extension/tests/executor.rs b/bin/runtime/src/chain_extension/tests/executor.rs index 17956745ed..1e577e8570 100644 --- a/bin/runtime/src/chain_extension/tests/executor.rs +++ b/bin/runtime/src/chain_extension/tests/executor.rs @@ -12,16 +12,16 @@ pub(super) enum Responder { Errorer(Error), } -/// `struct/enum construction is not supported in generic constants` -pub(super) const fn make_errorer() -> Responder { - Responder::Errorer(ERROR) -} - pub(super) struct MockedExecutor< const STORE_KEY_RESPONDER: Responder, const VERIFY_RESPONDER: Responder, >; +/// `struct/enum construction is not supported in generic constants` +pub(super) const fn make_errorer() -> Responder { + Responder::Errorer(ERROR) +} + pub(super) type Panicker = MockedExecutor<{ Responder::Panicker }, { Responder::Panicker }>; pub(super) type StoreKeyOkayer = MockedExecutor<{ Responder::Okayer }, { Responder::Panicker }>; diff --git a/bin/runtime/src/chain_extension/tests/mod.rs b/bin/runtime/src/chain_extension/tests/mod.rs index ee4c4a7fe0..9c9d2f6269 100644 --- a/bin/runtime/src/chain_extension/tests/mod.rs +++ b/bin/runtime/src/chain_extension/tests/mod.rs @@ -3,7 +3,9 @@ use std::sync::mpsc::Receiver; use environment::{CorruptedMode, MockedEnvironment, StandardMode, StoreKeyMode, VerifyMode}; use super::*; -use crate::chain_extension::tests::executor::{Panicker, StoreKeyOkayer, VerifyOkayer}; +use crate::chain_extension::tests::executor::{ + Panicker, StoreKeyErrorer, StoreKeyOkayer, VerifyErrorer, VerifyOkayer, +}; mod environment; mod executor; @@ -60,7 +62,7 @@ fn store_key__charges_before_reading() { #[test] #[allow(non_snake_case)] -fn store_key__too_long_vk() { +fn store_key__too_much_to_read() { let (env, charging_listener) = MockedEnvironment::::new( ByteCount::MAX, Some(Box::new(|| panic!("Shouldn't read anything at all"))), @@ -75,6 +77,48 @@ fn store_key__too_long_vk() { assert_eq!(charged(charging_listener), 0); } +#[test] +#[allow(non_snake_case)] +fn store_key__pallet_says_too_long_vk() { + let (env, charging_listener) = + MockedEnvironment::::new(store_key_args()); + + let result = SnarcosChainExtension::snarcos_store_key::< + _, + StoreKeyErrorer<{ VerificationKeyTooLong }>, + >(env); + + assert!(matches!( + result, + Ok(RetVal::Converging(SNARCOS_STORE_KEY_TOO_LONG_KEY)) + )); + assert_eq!( + charged(charging_listener), + weight_of_store_key(VK.len() as ByteCount) as RevertibleWeight + ); +} + +#[test] +#[allow(non_snake_case)] +fn store_key__pallet_says_identifier_in_use() { + let (env, charging_listener) = + MockedEnvironment::::new(store_key_args()); + + let result = SnarcosChainExtension::snarcos_store_key::< + _, + StoreKeyErrorer<{ IdentifierAlreadyInUse }>, + >(env); + + assert!(matches!( + result, + Ok(RetVal::Converging(SNARCOS_STORE_IDENTIFIER_IN_USE)) + )); + assert_eq!( + charged(charging_listener), + weight_of_store_key(VK.len() as ByteCount) as RevertibleWeight + ); +} + #[test] #[allow(non_snake_case)] fn store_key__positive_scenario() { @@ -108,6 +152,133 @@ fn verify__charges_before_reading() { ); } +#[test] +#[allow(non_snake_case)] +fn verify__pallet_says_proof_deserialization_failed() { + let (env, charging_listener) = + MockedEnvironment::::new(verify_args()); + + let result = SnarcosChainExtension::snarcos_verify::< + _, + VerifyErrorer<{ DeserializingProofFailed }>, + >(env); + + assert!(matches!( + result, + Ok(RetVal::Converging(SNARCOS_VERIFY_DESERIALIZING_PROOF_FAIL)) + )); + + assert_eq!( + charged(charging_listener), + weight_of_verify(Some(SYSTEM)) as RevertibleWeight + ); +} + +#[test] +#[allow(non_snake_case)] +fn verify__pallet_says_input_deserialization_failed() { + let (env, charging_listener) = + MockedEnvironment::::new(verify_args()); + + let result = SnarcosChainExtension::snarcos_verify::< + _, + VerifyErrorer<{ DeserializingPublicInputFailed }>, + >(env); + + assert!(matches!( + result, + Ok(RetVal::Converging(SNARCOS_VERIFY_DESERIALIZING_INPUT_FAIL)) + )); + + assert_eq!( + charged(charging_listener), + weight_of_verify(Some(SYSTEM)) as RevertibleWeight + ); +} + +#[test] +#[allow(non_snake_case)] +fn verify__pallet_says_no_such_vk() { + let (env, charging_listener) = + MockedEnvironment::::new(verify_args()); + + let result = SnarcosChainExtension::snarcos_verify::< + _, + VerifyErrorer<{ UnknownVerificationKeyIdentifier }>, + >(env); + + assert!(matches!( + result, + Ok(RetVal::Converging(SNARCOS_VERIFY_UNKNOWN_IDENTIFIER)) + )); + + assert_eq!( + charged(charging_listener), + weight_of_verify(Some(SYSTEM)) as RevertibleWeight + ); +} + +#[test] +#[allow(non_snake_case)] +fn verify__pallet_says_vk_deserialization_failed() { + let (env, charging_listener) = + MockedEnvironment::::new(verify_args()); + + let result = SnarcosChainExtension::snarcos_verify::< + _, + VerifyErrorer<{ DeserializingVerificationKeyFailed }>, + >(env); + + assert!(matches!( + result, + Ok(RetVal::Converging(SNARCOS_VERIFY_DESERIALIZING_KEY_FAIL)) + )); + + assert_eq!( + charged(charging_listener), + weight_of_verify(Some(SYSTEM)) as RevertibleWeight + ); +} + +#[test] +#[allow(non_snake_case)] +fn verify__pallet_says_verification_failed() { + let (env, charging_listener) = + MockedEnvironment::::new(verify_args()); + + let result = + SnarcosChainExtension::snarcos_verify::<_, VerifyErrorer<{ VerificationFailed }>>(env); + + assert!(matches!( + result, + Ok(RetVal::Converging(SNARCOS_VERIFY_VERIFICATION_FAIL)) + )); + + assert_eq!( + charged(charging_listener), + weight_of_verify(Some(SYSTEM)) as RevertibleWeight + ); +} + +#[test] +#[allow(non_snake_case)] +fn verify__pallet_says_incorrect_proof() { + let (env, charging_listener) = + MockedEnvironment::::new(verify_args()); + + let result = SnarcosChainExtension::snarcos_verify::<_, VerifyErrorer<{ IncorrectProof }>>(env); + + assert!(matches!( + result, + Ok(RetVal::Converging(SNARCOS_VERIFY_INCORRECT_PROOF)) + )); + + assert_eq!( + charged(charging_listener), + weight_of_verify(Some(SYSTEM)) as RevertibleWeight + ); +} + #[test] #[allow(non_snake_case)] fn verify__positive_scenario() { From 6c311503ff60219544e601b57709630204af75c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Mon, 7 Nov 2022 07:28:40 +0100 Subject: [PATCH 38/41] Refactor testcases --- bin/runtime/src/chain_extension/mod.rs | 4 +- bin/runtime/src/chain_extension/tests/mod.rs | 182 ++++--------------- 2 files changed, 40 insertions(+), 146 deletions(-) diff --git a/bin/runtime/src/chain_extension/mod.rs b/bin/runtime/src/chain_extension/mod.rs index 7da32ac4c0..6057173a5e 100644 --- a/bin/runtime/src/chain_extension/mod.rs +++ b/bin/runtime/src/chain_extension/mod.rs @@ -23,7 +23,7 @@ pub const SNARCOS_VERIFY_FUNC_ID: u32 = 42; // Return codes for `SNARCOS_STORE_KEY_FUNC_ID`. pub const SNARCOS_STORE_KEY_OK: u32 = 10_000; pub const SNARCOS_STORE_KEY_TOO_LONG_KEY: u32 = 10_001; -pub const SNARCOS_STORE_IDENTIFIER_IN_USE: u32 = 10_002; +pub const SNARCOS_STORE_KEY_IDENTIFIER_IN_USE: u32 = 10_002; pub const SNARCOS_STORE_KEY_ERROR_UNKNOWN: u32 = 10_003; // Return codes for `SNARCOS_VERIFY_FUNC_ID`. @@ -150,7 +150,7 @@ impl SnarcosChainExtension { // `bare_store_key`), we could adjust weight. However, for the storing key action it // doesn't make sense. Err(VerificationKeyTooLong) => SNARCOS_STORE_KEY_TOO_LONG_KEY, - Err(IdentifierAlreadyInUse) => SNARCOS_STORE_IDENTIFIER_IN_USE, + Err(IdentifierAlreadyInUse) => SNARCOS_STORE_KEY_IDENTIFIER_IN_USE, _ => SNARCOS_STORE_KEY_ERROR_UNKNOWN, }; Ok(RetVal::Converging(return_status)) diff --git a/bin/runtime/src/chain_extension/tests/mod.rs b/bin/runtime/src/chain_extension/tests/mod.rs index 9c9d2f6269..32f1bb550b 100644 --- a/bin/runtime/src/chain_extension/tests/mod.rs +++ b/bin/runtime/src/chain_extension/tests/mod.rs @@ -77,21 +77,13 @@ fn store_key__too_much_to_read() { assert_eq!(charged(charging_listener), 0); } -#[test] -#[allow(non_snake_case)] -fn store_key__pallet_says_too_long_vk() { +fn simulate_store_key(expected_ret_val: u32) { let (env, charging_listener) = MockedEnvironment::::new(store_key_args()); - let result = SnarcosChainExtension::snarcos_store_key::< - _, - StoreKeyErrorer<{ VerificationKeyTooLong }>, - >(env); + let result = SnarcosChainExtension::snarcos_store_key::<_, Exc>(env); - assert!(matches!( - result, - Ok(RetVal::Converging(SNARCOS_STORE_KEY_TOO_LONG_KEY)) - )); + assert!(matches!(result, Ok(RetVal::Converging(ret_val)) if ret_val == expected_ret_val)); assert_eq!( charged(charging_listener), weight_of_store_key(VK.len() as ByteCount) as RevertibleWeight @@ -100,42 +92,24 @@ fn store_key__pallet_says_too_long_vk() { #[test] #[allow(non_snake_case)] -fn store_key__pallet_says_identifier_in_use() { - let (env, charging_listener) = - MockedEnvironment::::new(store_key_args()); - - let result = SnarcosChainExtension::snarcos_store_key::< - _, - StoreKeyErrorer<{ IdentifierAlreadyInUse }>, - >(env); +fn store_key__pallet_says_too_long_vk() { + simulate_store_key::>( + SNARCOS_STORE_KEY_TOO_LONG_KEY, + ) +} - assert!(matches!( - result, - Ok(RetVal::Converging(SNARCOS_STORE_IDENTIFIER_IN_USE)) - )); - assert_eq!( - charged(charging_listener), - weight_of_store_key(VK.len() as ByteCount) as RevertibleWeight - ); +#[test] +#[allow(non_snake_case)] +fn store_key__pallet_says_identifier_in_use() { + simulate_store_key::>( + SNARCOS_STORE_KEY_IDENTIFIER_IN_USE, + ) } #[test] #[allow(non_snake_case)] fn store_key__positive_scenario() { - let (env, charging_listener) = - MockedEnvironment::::new(store_key_args()); - - let result = SnarcosChainExtension::snarcos_store_key::<_, StoreKeyOkayer>(env); - - assert!(matches!( - result, - Ok(RetVal::Converging(SNARCOS_STORE_KEY_OK)) - )); - - assert_eq!( - charged(charging_listener), - weight_of_store_key(VK.len() as ByteCount) as RevertibleWeight - ); + simulate_store_key::(SNARCOS_STORE_KEY_OK) } #[test] @@ -152,22 +126,13 @@ fn verify__charges_before_reading() { ); } -#[test] -#[allow(non_snake_case)] -fn verify__pallet_says_proof_deserialization_failed() { +fn simulate_verify(expected_ret_val: u32) { let (env, charging_listener) = MockedEnvironment::::new(verify_args()); - let result = SnarcosChainExtension::snarcos_verify::< - _, - VerifyErrorer<{ DeserializingProofFailed }>, - >(env); - - assert!(matches!( - result, - Ok(RetVal::Converging(SNARCOS_VERIFY_DESERIALIZING_PROOF_FAIL)) - )); + let result = SnarcosChainExtension::snarcos_verify::<_, Exc>(env); + assert!(matches!(result, Ok(RetVal::Converging(ret_val)) if ret_val == expected_ret_val)); assert_eq!( charged(charging_listener), weight_of_verify(Some(SYSTEM)) as RevertibleWeight @@ -176,121 +141,50 @@ fn verify__pallet_says_proof_deserialization_failed() { #[test] #[allow(non_snake_case)] -fn verify__pallet_says_input_deserialization_failed() { - let (env, charging_listener) = - MockedEnvironment::::new(verify_args()); - - let result = SnarcosChainExtension::snarcos_verify::< - _, - VerifyErrorer<{ DeserializingPublicInputFailed }>, - >(env); - - assert!(matches!( - result, - Ok(RetVal::Converging(SNARCOS_VERIFY_DESERIALIZING_INPUT_FAIL)) - )); +fn verify__pallet_says_proof_deserialization_failed() { + simulate_verify::>( + SNARCOS_VERIFY_DESERIALIZING_PROOF_FAIL, + ) +} - assert_eq!( - charged(charging_listener), - weight_of_verify(Some(SYSTEM)) as RevertibleWeight - ); +#[test] +#[allow(non_snake_case)] +fn verify__pallet_says_input_deserialization_failed() { + simulate_verify::>( + SNARCOS_VERIFY_DESERIALIZING_INPUT_FAIL, + ) } #[test] #[allow(non_snake_case)] fn verify__pallet_says_no_such_vk() { - let (env, charging_listener) = - MockedEnvironment::::new(verify_args()); - - let result = SnarcosChainExtension::snarcos_verify::< - _, - VerifyErrorer<{ UnknownVerificationKeyIdentifier }>, - >(env); - - assert!(matches!( - result, - Ok(RetVal::Converging(SNARCOS_VERIFY_UNKNOWN_IDENTIFIER)) - )); - - assert_eq!( - charged(charging_listener), - weight_of_verify(Some(SYSTEM)) as RevertibleWeight - ); + simulate_verify::>( + SNARCOS_VERIFY_UNKNOWN_IDENTIFIER, + ) } #[test] #[allow(non_snake_case)] fn verify__pallet_says_vk_deserialization_failed() { - let (env, charging_listener) = - MockedEnvironment::::new(verify_args()); - - let result = SnarcosChainExtension::snarcos_verify::< - _, - VerifyErrorer<{ DeserializingVerificationKeyFailed }>, - >(env); - - assert!(matches!( - result, - Ok(RetVal::Converging(SNARCOS_VERIFY_DESERIALIZING_KEY_FAIL)) - )); - - assert_eq!( - charged(charging_listener), - weight_of_verify(Some(SYSTEM)) as RevertibleWeight - ); + simulate_verify::>( + SNARCOS_VERIFY_DESERIALIZING_KEY_FAIL, + ) } #[test] #[allow(non_snake_case)] fn verify__pallet_says_verification_failed() { - let (env, charging_listener) = - MockedEnvironment::::new(verify_args()); - - let result = - SnarcosChainExtension::snarcos_verify::<_, VerifyErrorer<{ VerificationFailed }>>(env); - - assert!(matches!( - result, - Ok(RetVal::Converging(SNARCOS_VERIFY_VERIFICATION_FAIL)) - )); - - assert_eq!( - charged(charging_listener), - weight_of_verify(Some(SYSTEM)) as RevertibleWeight - ); + simulate_verify::>(SNARCOS_VERIFY_VERIFICATION_FAIL) } #[test] #[allow(non_snake_case)] fn verify__pallet_says_incorrect_proof() { - let (env, charging_listener) = - MockedEnvironment::::new(verify_args()); - - let result = SnarcosChainExtension::snarcos_verify::<_, VerifyErrorer<{ IncorrectProof }>>(env); - - assert!(matches!( - result, - Ok(RetVal::Converging(SNARCOS_VERIFY_INCORRECT_PROOF)) - )); - - assert_eq!( - charged(charging_listener), - weight_of_verify(Some(SYSTEM)) as RevertibleWeight - ); + simulate_verify::>(SNARCOS_VERIFY_INCORRECT_PROOF) } #[test] #[allow(non_snake_case)] fn verify__positive_scenario() { - let (env, charging_listener) = - MockedEnvironment::::new(verify_args()); - - let result = SnarcosChainExtension::snarcos_verify::<_, VerifyOkayer>(env); - - assert!(matches!(result, Ok(RetVal::Converging(SNARCOS_VERIFY_OK)))); - - assert_eq!( - charged(charging_listener), - weight_of_verify(Some(SYSTEM)) as RevertibleWeight - ); + simulate_verify::(SNARCOS_VERIFY_OK) } From 65512a5d79f2d7ffc801470d97de3df7f20f72da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Mon, 7 Nov 2022 07:43:05 +0100 Subject: [PATCH 39/41] Document root modules --- bin/runtime/src/chain_extension/environment.rs | 10 ++++++++-- bin/runtime/src/chain_extension/executor.rs | 9 +++++++++ bin/runtime/src/chain_extension/mod.rs | 9 +++++---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/bin/runtime/src/chain_extension/environment.rs b/bin/runtime/src/chain_extension/environment.rs index a89222af3b..86f2fbae6f 100644 --- a/bin/runtime/src/chain_extension/environment.rs +++ b/bin/runtime/src/chain_extension/environment.rs @@ -11,9 +11,15 @@ use crate::chain_extension::ByteCount; /// Abstraction around `pallet_contracts::chain_extension::Environment`. Makes testing easier. /// -/// Gathers all the methods that are used by `SnarcosChainExtension`. For now all operations are -/// performed in `BufInBufOut` mode, so we don't have to take care of other modes. +/// Gathers all the methods that are used by `SnarcosChainExtension`. For now, all operations are +/// performed in the `BufInBufOut` mode, so we don't have to take care of other modes. +/// +/// Each method is already documented in `pallet_contracts::chain_extension`. pub(super) trait Environment: Sized { + /// A type returned by `charge_weight` and passed to `adjust_weight`. + /// + /// The original type `ChargedAmount` has only a private constructor and thus we have to + /// abstract it as well to make testing it possible. type ChargedAmount; fn in_len(&self) -> ByteCount; diff --git a/bin/runtime/src/chain_extension/executor.rs b/bin/runtime/src/chain_extension/executor.rs index 4db33df04b..a8261a4a1f 100644 --- a/bin/runtime/src/chain_extension/executor.rs +++ b/bin/runtime/src/chain_extension/executor.rs @@ -3,7 +3,15 @@ use sp_std::vec::Vec; use crate::Runtime; +/// Abstraction around `Runtime`. Makes testing easier. +/// +/// Gathers all the methods that are used by `SnarcosChainExtension`. +/// +/// Each method is already documented in `pallet_snarcos`. pub(super) trait Executor: Sized { + /// The error returned from dispatchables is generic. For most purposes however, it doesn't + /// matter what type will be passed there. Normally, `Runtime` will be the generic argument, + /// but in testing it will be sufficient to instantiate it with `()`. type ErrorGenericType; fn store_key( @@ -19,6 +27,7 @@ pub(super) trait Executor: Sized { ) -> Result<(), Error>; } +/// Transparent delegation. impl Executor for Runtime { type ErrorGenericType = Runtime; diff --git a/bin/runtime/src/chain_extension/mod.rs b/bin/runtime/src/chain_extension/mod.rs index 6057173a5e..f90bee1f66 100644 --- a/bin/runtime/src/chain_extension/mod.rs +++ b/bin/runtime/src/chain_extension/mod.rs @@ -114,7 +114,7 @@ impl SnarcosChainExtension { mut env: Env, ) -> Result { // Check if it makes sense to read and decode data. This is only an upperbound for the key - // length, because this bytes suffix contain (possibly compressed) info about actual key + // length, because this bytes suffix contains (possibly compressed) info about actual key // length (needed for decoding). let approx_key_length = env .in_len() @@ -147,8 +147,8 @@ impl SnarcosChainExtension { let return_status = match Exc::store_key(args.identifier, args.key) { Ok(_) => SNARCOS_STORE_KEY_OK, // In case `DispatchResultWithPostInfo` was returned (or some simpler equivalent for - // `bare_store_key`), we could adjust weight. However, for the storing key action it - // doesn't make sense. + // `bare_store_key`), we could have adjusted weight. However, for the storing key action + // it doesn't make much sense. Err(VerificationKeyTooLong) => SNARCOS_STORE_KEY_TOO_LONG_KEY, Err(IdentifierAlreadyInUse) => SNARCOS_STORE_KEY_IDENTIFIER_IN_USE, _ => SNARCOS_STORE_KEY_ERROR_UNKNOWN, @@ -176,6 +176,7 @@ impl SnarcosChainExtension { let args: VerifyArgs = VerifyArgs::decode(&mut &*bytes) .map_err(|_| DispatchError::Other("Failed to decode arguments"))?; + // Now we know the proving system and we can charge appropriate amount of gas. env.adjust_weight(pre_charge, weight_of_verify(Some(args.system))); let result = Exc::verify(args.identifier, args.proof, args.input, args.system); @@ -183,7 +184,7 @@ impl SnarcosChainExtension { let return_status = match result { Ok(_) => SNARCOS_VERIFY_OK, // In case `DispatchResultWithPostInfo` was returned (or some simpler equivalent for - // `bare_store_key`), we could adjust weight. However, we don't support it yet. + // `bare_verify`), we could adjust weight. However, we don't support it yet. Err(DeserializingProofFailed) => SNARCOS_VERIFY_DESERIALIZING_PROOF_FAIL, Err(DeserializingPublicInputFailed) => SNARCOS_VERIFY_DESERIALIZING_INPUT_FAIL, Err(UnknownVerificationKeyIdentifier) => SNARCOS_VERIFY_UNKNOWN_IDENTIFIER, From 475108b0f8041cb6416c501ec41b41aff46cc371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Mon, 7 Nov 2022 08:07:41 +0100 Subject: [PATCH 40/41] Document test modules --- .../src/chain_extension/tests/environment.rs | 41 +++++++++++++++---- .../src/chain_extension/tests/executor.rs | 17 +++++++- bin/runtime/src/chain_extension/tests/mod.rs | 5 +++ 3 files changed, 54 insertions(+), 9 deletions(-) diff --git a/bin/runtime/src/chain_extension/tests/environment.rs b/bin/runtime/src/chain_extension/tests/environment.rs index 291de89e27..9a883b9e52 100644 --- a/bin/runtime/src/chain_extension/tests/environment.rs +++ b/bin/runtime/src/chain_extension/tests/environment.rs @@ -6,36 +6,52 @@ use std::{ use super::*; -pub trait FunctionMode {} -pub enum StoreKeyMode {} -pub enum VerifyMode {} +/// Trait serving as a type-level flag indicating which method we are testing. +pub(super) trait FunctionMode {} +/// We are testing `pallet_snarcos::store_key`. +pub(super) enum StoreKeyMode {} impl FunctionMode for StoreKeyMode {} +/// We are testing `pallet_snarcos::verify`. +pub(super) enum VerifyMode {} impl FunctionMode for VerifyMode {} -pub trait ReadingMode {} -pub enum CorruptedMode {} -pub enum StandardMode {} +/// Trait serving as a type-level flag indicating how reading input from a contract should be done. +pub(super) trait ReadingMode {} +/// Reading fails - we won't be able to read a single byte. +pub(super) enum CorruptedMode {} impl ReadingMode for CorruptedMode {} +/// Reading succeeds - we will read everything. +pub(super) enum StandardMode {} impl ReadingMode for StandardMode {} +/// We will implement reading for every `ReadingMode`. However, there is no other way than such +/// `_Read` trait to tell Rust compiler that in fact, for every `RM` in `MockedEnvironment<_, RM>` +/// there will be such function. trait _Read { fn _read(&self, max_len: ByteCount) -> Result, DispatchError>; } -pub struct MockedEnvironment { +/// Testing counterpart for `pallet_snarcos::chain_extension::Environment`. +pub(super) struct MockedEnvironment { /// Channel to report all charges. + /// + /// We have to save charges outside this object, because it is consumed by the main call. charging_channel: Sender, - /// `Some(_)` iff `RM = CorruptedMode`. + /// `Some(_)` only if `RM = CorruptedMode`. + /// + /// An optional callback to be invoked just before (failing to) read. on_read: Option>, /// `Some(_)` iff `RM = StandardMode`. content: Option>, + /// How many bytes are there waiting to be read. in_len: ByteCount, _phantom: PhantomData<(FM, RM)>, } +/// Creating environment with corrupted reading. impl MockedEnvironment { pub fn new( in_len: ByteCount, @@ -54,6 +70,8 @@ impl MockedEnvironment { ) } } + +/// Corrupted reading with possible additional callback invoked. impl _Read for MockedEnvironment { fn _read(&self, _max_len: ByteCount) -> Result, DispatchError> { self.on_read.as_ref().map(|action| action()); @@ -61,6 +79,7 @@ impl _Read for MockedEnvironment { } } +/// Creating environment with correct reading of `content`. impl MockedEnvironment { pub fn new(content: Vec) -> (Self, Receiver) { let (sender, receiver) = channel(); @@ -77,6 +96,7 @@ impl MockedEnvironment { } } +/// Successful reading. impl _Read for MockedEnvironment { fn _read(&self, max_len: ByteCount) -> Result, DispatchError> { let content = self.content.as_ref().unwrap(); @@ -88,6 +108,11 @@ impl _Read for MockedEnvironment { } } +/// In case we are testing `pallet_snarcos::store_key`, we might want to approximate how long is the +/// verifying key. +/// +/// The returned value will be an upperbound - it will be the sum of the whole key encoding +/// (including its length). impl MockedEnvironment { pub fn approx_key_len(&self) -> ByteCount { self.in_len diff --git a/bin/runtime/src/chain_extension/tests/executor.rs b/bin/runtime/src/chain_extension/tests/executor.rs index 1e577e8570..8725d3c1e4 100644 --- a/bin/runtime/src/chain_extension/tests/executor.rs +++ b/bin/runtime/src/chain_extension/tests/executor.rs @@ -5,30 +5,45 @@ use crate::chain_extension::executor::Executor; type Error = SnarcosError<()>; type Result = core::result::Result<(), Error>; +/// Describes how the `Executor` should behave when one of its methods is called. #[derive(Clone, Eq, PartialEq)] pub(super) enum Responder { + /// Twist and shout. Panicker, + /// Return `Ok(())`. Okayer, + /// Return `Err(Error)`. Errorer(Error), } +/// Testing counterpart for `Runtime`. +/// +/// `STORE_KEY_RESPONDER` instructs how to behave then `store_key` is called. +/// `VERIFY_RESPONDER` instructs how to behave then `verify` is called. pub(super) struct MockedExecutor< const STORE_KEY_RESPONDER: Responder, const VERIFY_RESPONDER: Responder, >; -/// `struct/enum construction is not supported in generic constants` +/// Auxiliary method to construct type argument. +/// +/// Due to "`struct/enum construction is not supported in generic constants`". pub(super) const fn make_errorer() -> Responder { Responder::Errorer(ERROR) } +/// Executor that will scream for every associated method. pub(super) type Panicker = MockedExecutor<{ Responder::Panicker }, { Responder::Panicker }>; +/// Executor that will return `Ok(())` for `store_key` and scream for `verify`. pub(super) type StoreKeyOkayer = MockedExecutor<{ Responder::Okayer }, { Responder::Panicker }>; +/// Executor that will return `Ok(())` for `verify` and scream for `store_key`. pub(super) type VerifyOkayer = MockedExecutor<{ Responder::Panicker }, { Responder::Okayer }>; +/// Executor that will return `Err(ERROR)` for `store_key` and scream for `verify`. pub(super) type StoreKeyErrorer = MockedExecutor<{ make_errorer::() }, { Responder::Panicker }>; +/// Executor that will return `Err(ERROR)` for `verify` and scream for `store_key`. pub(super) type VerifyErrorer = MockedExecutor<{ Responder::Panicker }, { make_errorer::() }>; diff --git a/bin/runtime/src/chain_extension/tests/mod.rs b/bin/runtime/src/chain_extension/tests/mod.rs index 32f1bb550b..2562d7f68c 100644 --- a/bin/runtime/src/chain_extension/tests/mod.rs +++ b/bin/runtime/src/chain_extension/tests/mod.rs @@ -10,6 +10,8 @@ use crate::chain_extension::tests::executor::{ mod environment; mod executor; +/// In order to compute final fee (after all adjustments) sometimes we will have to subtract +/// weights. type RevertibleWeight = i64; const IDENTIFIER: VerificationKeyIdentifier = [1, 7, 2, 9]; @@ -18,6 +20,7 @@ const PROOF: [u8; 20] = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3, 8 const INPUT: [u8; 11] = [0, 5, 7, 7, 2, 1, 5, 6, 6, 4, 9]; const SYSTEM: ProvingSystem = ProvingSystem::Groth16; +/// Returns encoded arguments to `store_key`. fn store_key_args() -> Vec { StoreKeyArgs { identifier: IDENTIFIER, @@ -26,6 +29,7 @@ fn store_key_args() -> Vec { .encode() } +/// Returns encoded arguments to `verify`. fn verify_args() -> Vec { VerifyArgs { identifier: IDENTIFIER, @@ -36,6 +40,7 @@ fn verify_args() -> Vec { .encode() } +/// Fetches all charges and computes the final fee. fn charged(charging_listener: Receiver) -> RevertibleWeight { charging_listener.into_iter().sum() } From f58994e08a99d5f5e5dc6b6844052a0f23909e07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Mon, 7 Nov 2022 08:12:57 +0100 Subject: [PATCH 41/41] Turn off feature warning in tests --- bin/runtime/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/runtime/src/lib.rs b/bin/runtime/src/lib.rs index b1293ab9ea..d06553fb57 100644 --- a/bin/runtime/src/lib.rs +++ b/bin/runtime/src/lib.rs @@ -1,7 +1,8 @@ #![cfg_attr(not(feature = "std"), no_std)] // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. #![recursion_limit = "256"] -#![allow(incomplete_features)] +// For *TESTING PURPOSES ONLY* we use magnificent additional const generics. +#![cfg_attr(test, allow(incomplete_features))] #![cfg_attr(test, feature(adt_const_params))] #![cfg_attr(test, feature(generic_const_exprs))]