@@ -936,7 +936,7 @@ pub mod zkapp_command {
936
936
currency:: { MinMax , Sgn } ,
937
937
GenesisConstant , GENESIS_CONSTANT ,
938
938
} ,
939
- zkapps:: snark:: zkapp_check:: InSnarkCheck ,
939
+ zkapps:: snark:: { zkapp_check:: InSnarkCheck , ZkappCheckOps } ,
940
940
AuthRequired , MutableFp , MyCow , Permissions , SetVerificationKey , ToInputs , TokenSymbol ,
941
941
VerificationKey , VerificationKeyWire , VotingFor , ZkAppAccount , ZkAppUri ,
942
942
} ;
@@ -1976,7 +1976,11 @@ pub mod zkapp_command {
1976
1976
. epoch_data ( "next_epoch_data" , & s. next_epoch_data )
1977
1977
}
1978
1978
1979
- pub fn checked_zcheck ( & self , s : & ProtocolStateView , w : & mut Witness < Fp > ) -> Boolean {
1979
+ pub fn checked_zcheck < Ops : ZkappCheckOps > (
1980
+ & self ,
1981
+ s : & ProtocolStateView ,
1982
+ w : & mut Witness < Fp > ,
1983
+ ) -> Boolean {
1980
1984
let Self {
1981
1985
snarked_ledger_hash,
1982
1986
blockchain_length,
@@ -2006,12 +2010,13 @@ pub mod zkapp_command {
2006
2010
// Reverse to match OCaml order of the list, while still executing `checked_zcheck`
2007
2011
// in correct order
2008
2012
[
2009
- ( epoch_length, ClosedInterval :: min_max) . checked_zcheck ( & view. epoch_length , w) ,
2010
- ( lock_checkpoint, Fp :: zero) . checked_zcheck ( & view. lock_checkpoint , w) ,
2011
- ( start_checkpoint, Fp :: zero) . checked_zcheck ( & view. start_checkpoint , w) ,
2013
+ ( epoch_length, ClosedInterval :: min_max)
2014
+ . checked_zcheck :: < Ops > ( & view. epoch_length , w) ,
2015
+ ( lock_checkpoint, Fp :: zero) . checked_zcheck :: < Ops > ( & view. lock_checkpoint , w) ,
2016
+ ( start_checkpoint, Fp :: zero) . checked_zcheck :: < Ops > ( & view. start_checkpoint , w) ,
2012
2017
( total_currency, ClosedInterval :: min_max)
2013
- . checked_zcheck ( & view. ledger . total_currency , w) ,
2014
- ( hash, Fp :: zero) . checked_zcheck ( & view. ledger . hash , w) ,
2018
+ . checked_zcheck :: < Ops > ( & view. ledger . total_currency , w) ,
2019
+ ( hash, Fp :: zero) . checked_zcheck :: < Ops > ( & view. ledger . hash , w) ,
2015
2020
]
2016
2021
} ;
2017
2022
@@ -2022,21 +2027,21 @@ pub mod zkapp_command {
2022
2027
// in correct order
2023
2028
let bools = [
2024
2029
( global_slot_since_genesis, ClosedInterval :: min_max)
2025
- . checked_zcheck ( & s. global_slot_since_genesis , w) ,
2026
- ( total_currency, ClosedInterval :: min_max) . checked_zcheck ( & s. total_currency , w) ,
2030
+ . checked_zcheck :: < Ops > ( & s. global_slot_since_genesis , w) ,
2031
+ ( total_currency, ClosedInterval :: min_max)
2032
+ . checked_zcheck :: < Ops > ( & s. total_currency , w) ,
2027
2033
( min_window_density, ClosedInterval :: min_max)
2028
- . checked_zcheck ( & s. min_window_density , w) ,
2034
+ . checked_zcheck :: < Ops > ( & s. min_window_density , w) ,
2029
2035
( blockchain_length, ClosedInterval :: min_max)
2030
- . checked_zcheck ( & s. blockchain_length , w) ,
2031
- ( snarked_ledger_hash, Fp :: zero) . checked_zcheck ( & s. snarked_ledger_hash , w) ,
2036
+ . checked_zcheck :: < Ops > ( & s. blockchain_length , w) ,
2037
+ ( snarked_ledger_hash, Fp :: zero) . checked_zcheck :: < Ops > ( & s. snarked_ledger_hash , w) ,
2032
2038
]
2033
2039
. into_iter ( )
2034
2040
. rev ( )
2035
2041
. chain ( staking_epoch_data. into_iter ( ) . rev ( ) )
2036
- . chain ( next_epoch_data. into_iter ( ) . rev ( ) )
2037
- . collect :: < Vec < _ > > ( ) ;
2042
+ . chain ( next_epoch_data. into_iter ( ) . rev ( ) ) ;
2038
2043
2039
- Boolean :: all ( & bools, w)
2044
+ Ops :: boolean_all ( bools, w)
2040
2045
}
2041
2046
2042
2047
/// https://github.com/MinaProtocol/mina/blob/3753a8593cc1577bcf4da16620daf9946d88e8e5/src/lib/mina_base/zkapp_precondition.ml#L1303
@@ -2245,7 +2250,7 @@ pub mod zkapp_command {
2245
2250
ret
2246
2251
}
2247
2252
2248
- fn checked_zchecks (
2253
+ fn checked_zchecks < Ops : ZkappCheckOps > (
2249
2254
& self ,
2250
2255
account : & crate :: Account ,
2251
2256
new_account : Boolean ,
@@ -2277,12 +2282,12 @@ pub mod zkapp_command {
2277
2282
let mut checks: Vec < ( TransactionFailure , _ ) > = [
2278
2283
(
2279
2284
AccountIsNewPreconditionUnsatisfied ,
2280
- ( & is_new, || Boolean :: False ) . checked_zcheck ( & new_account, w) ,
2285
+ ( & is_new, || Boolean :: False ) . checked_zcheck :: < Ops > ( & new_account, w) ,
2281
2286
) ,
2282
2287
(
2283
2288
AccountProvedStatePreconditionUnsatisfied ,
2284
2289
( & proved_state, || Boolean :: False )
2285
- . checked_zcheck ( & zkapp_account. proved_state . to_boolean ( ) , w) ,
2290
+ . checked_zcheck :: < Ops > ( & zkapp_account. proved_state . to_boolean ( ) , w) ,
2286
2291
) ,
2287
2292
]
2288
2293
. into_iter ( )
@@ -2293,7 +2298,7 @@ pub mod zkapp_command {
2293
2298
. enumerate ( )
2294
2299
. rev ( )
2295
2300
. map ( |( i, ( s, account_s) ) | {
2296
- let b = ( s, Fp :: zero) . checked_zcheck ( account_s, w) ;
2301
+ let b = ( s, Fp :: zero) . checked_zcheck :: < Ops > ( account_s, w) ;
2297
2302
( AccountAppStatePreconditionUnsatisfied ( i as u64 ) , b)
2298
2303
} )
2299
2304
. collect :: < Vec < _ > > ( ) ;
@@ -2307,30 +2312,31 @@ pub mod zkapp_command {
2307
2312
. iter ( )
2308
2313
. map ( |account_s| {
2309
2314
( action_state, ZkAppAccount :: empty_action_state)
2310
- . checked_zcheck ( account_s, w)
2315
+ . checked_zcheck :: < Ops > ( account_s, w)
2311
2316
} )
2312
2317
. collect ( ) ;
2313
2318
(
2314
2319
AccountActionStatePreconditionUnsatisfied ,
2315
- Boolean :: any ( & bools, w) ,
2320
+ Ops :: boolean_any ( bools, w) ,
2316
2321
)
2317
2322
} ,
2318
2323
(
2319
2324
AccountDelegatePreconditionUnsatisfied ,
2320
2325
( delegate, CompressedPubKey :: empty)
2321
- . checked_zcheck ( & * account. delegate_or_empty ( ) , w) ,
2326
+ . checked_zcheck :: < Ops > ( & * account. delegate_or_empty ( ) , w) ,
2322
2327
) ,
2323
2328
(
2324
2329
AccountReceiptChainHashPreconditionUnsatisfied ,
2325
- ( receipt_chain_hash, Fp :: zero) . checked_zcheck ( & account. receipt_chain_hash . 0 , w) ,
2330
+ ( receipt_chain_hash, Fp :: zero)
2331
+ . checked_zcheck :: < Ops > ( & account. receipt_chain_hash . 0 , w) ,
2326
2332
) ,
2327
2333
(
2328
2334
AccountNoncePreconditionUnsatisfied ,
2329
- ( nonce, ClosedInterval :: min_max) . checked_zcheck ( & account. nonce , w) ,
2335
+ ( nonce, ClosedInterval :: min_max) . checked_zcheck :: < Ops > ( & account. nonce , w) ,
2330
2336
) ,
2331
2337
(
2332
2338
AccountBalancePreconditionUnsatisfied ,
2333
- ( balance, ClosedInterval :: min_max) . checked_zcheck ( & account. balance , w) ,
2339
+ ( balance, ClosedInterval :: min_max) . checked_zcheck :: < Ops > ( & account. balance , w) ,
2334
2340
) ,
2335
2341
] )
2336
2342
. collect :: < Vec < _ > > ( ) ;
@@ -2452,17 +2458,18 @@ pub mod zkapp_command {
2452
2458
MyCow :: Borrow ( & self . 0 )
2453
2459
}
2454
2460
2455
- pub fn checked_zcheck < Fun > (
2461
+ pub fn checked_zcheck < Ops , Fun > (
2456
2462
& self ,
2457
2463
new_account : Boolean ,
2458
2464
account : & crate :: Account ,
2459
2465
mut check : Fun ,
2460
2466
w : & mut Witness < Fp > ,
2461
2467
) where
2468
+ Ops : ZkappCheckOps ,
2462
2469
Fun : FnMut ( TransactionFailure , Boolean , & mut Witness < Fp > ) ,
2463
2470
{
2464
2471
let this = self . to_full ( ) ;
2465
- for ( failure, passed) in this. checked_zchecks ( account, new_account, w) {
2472
+ for ( failure, passed) in this. checked_zchecks :: < Ops > ( account, new_account, w) {
2466
2473
check ( failure, passed, w) ;
2467
2474
}
2468
2475
}
0 commit comments