@@ -926,7 +926,7 @@ pub mod zkapp_command {
926
926
use rand:: { seq:: SliceRandom , Rng } ;
927
927
928
928
use crate :: {
929
- account , dummy, gen_compressed, gen_keypair, hash_noinputs,
929
+ dummy, gen_compressed, gen_keypair, hash_noinputs,
930
930
proofs:: {
931
931
field:: { Boolean , ToBoolean } ,
932
932
to_field_elements:: ToFieldElements ,
@@ -1536,33 +1536,6 @@ pub mod zkapp_command {
1536
1536
}
1537
1537
}
1538
1538
1539
- // TODO: Remove this. It's been replaced by `ZkappCheck`
1540
- pub trait OutSnarkCheck {
1541
- type A ;
1542
- type B ;
1543
-
1544
- /// zkapp check.
1545
- // name is `out_zheck`, to differentiate with `zcheck`. It means out of snark
1546
- fn out_zcheck < F : Fn ( ) -> String > ( & self , label : F , x : & Self :: B ) -> Result < ( ) , String > ;
1547
- }
1548
-
1549
- impl < T > OutSnarkCheck for T
1550
- where
1551
- T : Eq ,
1552
- {
1553
- type A = T ;
1554
- type B = T ;
1555
-
1556
- /// zkapp check
1557
- fn out_zcheck < F : Fn ( ) -> String > ( & self , label : F , rhs : & Self :: B ) -> Result < ( ) , String > {
1558
- if self == rhs {
1559
- Ok ( ( ) )
1560
- } else {
1561
- Err ( format ! ( "Equality check failed: {}" , label( ) ) )
1562
- }
1563
- }
1564
- }
1565
-
1566
1539
// TODO: This could be std::ops::Range ?
1567
1540
/// https://github.com/MinaProtocol/mina/blob/2ee6e004ba8c6a0541056076aab22ea162f7eb3a/src/lib/mina_base/zkapp_precondition.ml#L23
1568
1541
#[ derive( Debug , Clone , PartialEq ) ]
@@ -1619,27 +1592,6 @@ pub mod zkapp_command {
1619
1592
}
1620
1593
}
1621
1594
1622
- impl < T > OutSnarkCheck for ClosedInterval < T >
1623
- where
1624
- T : PartialOrd + std:: fmt:: Debug ,
1625
- {
1626
- type A = ClosedInterval < T > ;
1627
- type B = T ;
1628
-
1629
- /// zkapp check
1630
- fn out_zcheck < F : Fn ( ) -> String > ( & self , label : F , rhs : & Self :: B ) -> Result < ( ) , String > {
1631
- /*println!(
1632
- "bounds check lower {:?} rhs {:?} upper {:?}",
1633
- self.lower, rhs, self.upper
1634
- );*/
1635
- if & self . lower <= rhs && rhs <= & self . upper {
1636
- Ok ( ( ) )
1637
- } else {
1638
- Err ( format ! ( "Bounds check failed: {}" , label( ) ) )
1639
- }
1640
- }
1641
- }
1642
-
1643
1595
impl < T > ClosedInterval < T >
1644
1596
where
1645
1597
T : PartialOrd ,
@@ -1737,20 +1689,6 @@ pub mod zkapp_command {
1737
1689
}
1738
1690
}
1739
1691
1740
- impl < T > OrIgnore < T >
1741
- where
1742
- T : OutSnarkCheck < A = T > ,
1743
- {
1744
- /// zkapp check
1745
- pub fn out_zcheck < F : Fn ( ) -> String > ( & self , label : F , rhs : & T :: B ) -> Result < ( ) , String > {
1746
- // println!("[rust] check {}, {:?}", label, ret);
1747
- match self {
1748
- Self :: Ignore => Ok ( ( ) ) ,
1749
- Self :: Check ( t) => t. out_zcheck ( label, rhs) ,
1750
- }
1751
- }
1752
- }
1753
-
1754
1692
impl < T > OrIgnore < T > {
1755
1693
/// https://github.com/MinaProtocol/mina/blob/d7d4aa4d650eb34b45a42b29276554802683ce15/src/lib/mina_base/zkapp_basic.ml#L239
1756
1694
pub fn gen < F > ( mut fun : F ) -> Self
@@ -1806,17 +1744,6 @@ pub mod zkapp_command {
1806
1744
pub total_currency : Numeric < Amount > ,
1807
1745
}
1808
1746
1809
- impl EpochLedger {
1810
- pub fn epoch_ledger ( & self , t : & protocol_state:: EpochLedger < Fp > ) -> Result < ( ) , String > {
1811
- self . hash
1812
- . out_zcheck ( || "epoch_ledger_hash" . to_string ( ) , & t. hash ) ?;
1813
- self . total_currency . out_zcheck (
1814
- || "epoch_ledger_total_currency" . to_string ( ) ,
1815
- & t. total_currency ,
1816
- )
1817
- }
1818
- }
1819
-
1820
1747
/// https://github.com/MinaProtocol/mina/blob/2ee6e004ba8c6a0541056076aab22ea162f7eb3a/src/lib/mina_base/zkapp_precondition.ml#L797
1821
1748
#[ derive( Debug , Clone , PartialEq ) ]
1822
1749
pub struct EpochData {
@@ -1910,25 +1837,6 @@ pub mod zkapp_command {
1910
1837
}
1911
1838
1912
1839
impl EpochData {
1913
- pub fn epoch_data (
1914
- & self ,
1915
- label : & str ,
1916
- t : & protocol_state:: EpochData < Fp > ,
1917
- ) -> Result < ( ) , String > {
1918
- self . ledger . epoch_ledger ( & t. ledger ) ?;
1919
- // ignore seed
1920
- self . start_checkpoint . out_zcheck (
1921
- || format ! ( "{}_{}" , label, "start_checkpoint" ) ,
1922
- & t. start_checkpoint ,
1923
- ) ?;
1924
- self . lock_checkpoint . out_zcheck (
1925
- || format ! ( "{}_{}" , label, "lock_checkpoint" ) ,
1926
- & t. lock_checkpoint ,
1927
- ) ?;
1928
- self . epoch_length
1929
- . out_zcheck ( || format ! ( "{}_{}" , label, "epoch_length" ) , & t. epoch_length )
1930
- }
1931
-
1932
1840
pub fn gen ( ) -> Self {
1933
1841
let mut rng = rand:: thread_rng ( ) ;
1934
1842
@@ -1958,26 +1866,6 @@ pub mod zkapp_command {
1958
1866
}
1959
1867
1960
1868
impl ZkAppPreconditions {
1961
- /// zkapp check
1962
- pub fn out_zcheck ( & self , s : & ProtocolStateView ) -> Result < ( ) , String > {
1963
- self . snarked_ledger_hash
1964
- . out_zcheck ( || "snarker_ledger_hash" . to_string ( ) , & s. snarked_ledger_hash ) ?;
1965
- self . blockchain_length
1966
- . out_zcheck ( || "blockchain_length" . to_string ( ) , & s. blockchain_length ) ?;
1967
- self . min_window_density
1968
- . out_zcheck ( || "min_window_density" . to_string ( ) , & s. min_window_density ) ?;
1969
- self . total_currency
1970
- . out_zcheck ( || "total_currency" . to_string ( ) , & s. total_currency ) ?;
1971
- self . global_slot_since_genesis . out_zcheck (
1972
- || "global_slot_since_genesis" . to_string ( ) ,
1973
- & s. global_slot_since_genesis ,
1974
- ) ?;
1975
- self . staking_epoch_data
1976
- . epoch_data ( "staking_epoch_data" , & s. staking_epoch_data ) ?;
1977
- self . next_epoch_data
1978
- . epoch_data ( "next_epoch_data" , & s. next_epoch_data )
1979
- }
1980
-
1981
1869
pub fn zcheck < Ops : ZkappCheckOps > (
1982
1870
& self ,
1983
1871
s : & ProtocolStateView ,
@@ -2173,84 +2061,6 @@ pub mod zkapp_command {
2173
2061
}
2174
2062
2175
2063
impl Account {
2176
- /// zkapp check
2177
- pub fn out_zcheck < F > ( & self , new_account : bool , mut check : F , a : & account:: Account )
2178
- where
2179
- F : FnMut ( TransactionFailure , bool ) ,
2180
- {
2181
- self . out_zchecks ( new_account, a)
2182
- . iter ( )
2183
- . for_each ( |( failure, res) | check ( failure. clone ( ) , res. is_ok ( ) ) )
2184
- }
2185
-
2186
- fn out_zchecks (
2187
- & self ,
2188
- new_account : bool ,
2189
- a : & account:: Account ,
2190
- ) -> Vec < ( TransactionFailure , Result < ( ) , String > ) > {
2191
- let zkapp = match a. zkapp . as_ref ( ) {
2192
- Some ( zkapp) => MyCow :: Borrow ( & * * zkapp) ,
2193
- None => MyCow :: Own ( ZkAppAccount :: default ( ) ) ,
2194
- } ;
2195
- let mut ret = vec ! [
2196
- (
2197
- TransactionFailure :: AccountBalancePreconditionUnsatisfied ,
2198
- self . balance
2199
- . out_zcheck( || "balance" . to_string( ) , & a. balance) ,
2200
- ) ,
2201
- (
2202
- TransactionFailure :: AccountNoncePreconditionUnsatisfied ,
2203
- self . nonce. out_zcheck( || "nonce" . to_string( ) , & a. nonce) ,
2204
- ) ,
2205
- (
2206
- TransactionFailure :: AccountReceiptChainHashPreconditionUnsatisfied ,
2207
- self . receipt_chain_hash
2208
- . out_zcheck( || "receipt_chain_hash" . to_string( ) , & a. receipt_chain_hash. 0 ) ,
2209
- ) ,
2210
- (
2211
- TransactionFailure :: AccountDelegatePreconditionUnsatisfied ,
2212
- self . delegate. out_zcheck(
2213
- || "delegate" . to_string( ) ,
2214
- & a. delegate. clone( ) . unwrap_or_else( invalid_public_key) ,
2215
- ) ,
2216
- ) ,
2217
- (
2218
- TransactionFailure :: AccountActionStatePreconditionUnsatisfied ,
2219
- match zkapp. action_state. iter( ) . find( |state| {
2220
- self . action_state
2221
- . out_zcheck( || "" . to_string( ) , & * * state)
2222
- . is_ok( )
2223
- } ) {
2224
- None => Err ( "Action state mismatch" . to_string( ) ) ,
2225
- Some ( _) => Ok ( ( ) ) ,
2226
- } ,
2227
- ) ,
2228
- ] ;
2229
-
2230
- for ( i, ( c, v) ) in self . state . iter ( ) . zip ( zkapp. app_state . iter ( ) ) . enumerate ( ) {
2231
- ret. push ( (
2232
- TransactionFailure :: AccountAppStatePreconditionUnsatisfied ( i as u64 ) ,
2233
- c. out_zcheck ( || format ! ( "state[{}]" , i) , v) ,
2234
- ) ) ;
2235
- }
2236
-
2237
- let mut ret2 = vec ! [
2238
- (
2239
- TransactionFailure :: AccountProvedStatePreconditionUnsatisfied ,
2240
- self . proved_state
2241
- . out_zcheck( || "proved_state" . to_string( ) , & zkapp. proved_state) ,
2242
- ) ,
2243
- (
2244
- TransactionFailure :: AccountIsNewPreconditionUnsatisfied ,
2245
- self . is_new
2246
- . out_zcheck( || "is_new" . to_string( ) , & new_account) ,
2247
- ) ,
2248
- ] ;
2249
-
2250
- ret. append ( & mut ret2) ;
2251
- ret
2252
- }
2253
-
2254
2064
fn zchecks < Ops : ZkappCheckOps > (
2255
2065
& self ,
2256
2066
account : & crate :: Account ,
0 commit comments