Skip to content

Commit ddb1ac8

Browse files
committed
Call our new non_snark::{start,step} to apply zkapps
1 parent e431ec4 commit ddb1ac8

File tree

10 files changed

+1136
-1127
lines changed

10 files changed

+1136
-1127
lines changed

ledger/src/proofs/zkapp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,8 +745,8 @@ pub fn zkapp_command_witnesses_exn(
745745
data: call_stack,
746746
hash: Fp::zero(), // TODO
747747
},
748-
transaction_commitment: TransactionCommitment(transaction_commitment.0),
749-
full_transaction_commitment: TransactionCommitment(full_transaction_commitment.0),
748+
transaction_commitment: TransactionCommitment(transaction_commitment),
749+
full_transaction_commitment: TransactionCommitment(full_transaction_commitment),
750750
excess,
751751
supply_increase,
752752
ledger,

ledger/src/scan_state/scan_state.rs

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ use crate::{
3232
transaction_partially_applied::{
3333
TransactionPartiallyApplied, ZkappCommandPartiallyApplied,
3434
},
35+
zkapp_command::AccountUpdate,
3536
TransactionStatus,
3637
},
3738
},
38-
sparse_ledger::{LedgerIntf, SparseLedger},
39+
sparse_ledger::SparseLedger,
3940
staged_ledger::hash::AuxHash,
4041
verifier::Verifier,
42+
zkapps::intefaces::LedgerInterface,
43+
Account,
4144
};
4245

4346
use self::transaction_snark::{InitStack, LedgerProof, OneOrTwo, Registers};
@@ -1434,7 +1437,7 @@ impl ScanState {
14341437
apply_first_pass_sparse_ledger: ApplyFirstSparse,
14351438
) -> Result<Pass, String>
14361439
where
1437-
L: LedgerIntf + Clone,
1440+
L: LedgerInterface<W = (), Bool = bool, Account = Account, AccountUpdate = AccountUpdate>,
14381441
F: Fn(Fp) -> Result<MinaStateProtocolStateValueStableV2, String>,
14391442
ApplyFirst: Fn(
14401443
Slot,
@@ -1455,7 +1458,9 @@ impl ScanState {
14551458
let stop_at_first_pass = stop_at_first_pass.unwrap_or(false);
14561459

14571460
#[derive(Clone)]
1458-
enum PreviousIncompleteTxns<L: LedgerIntf + Clone> {
1461+
enum PreviousIncompleteTxns<
1462+
L: LedgerInterface<W = (), Bool = bool, Account = Account, AccountUpdate = AccountUpdate>,
1463+
> {
14591464
Unapplied(Vec<Arc<TransactionWithWitness>>),
14601465
PartiallyApplied(Vec<(TransactionStatus, TransactionPartiallyApplied<L>)>),
14611466
}
@@ -1469,7 +1474,12 @@ impl ScanState {
14691474
get_protocol_state: F,
14701475
) -> Result<TransactionPartiallyApplied<L>, String>
14711476
where
1472-
L: LedgerIntf + Clone,
1477+
L: LedgerInterface<
1478+
W = (),
1479+
Bool = bool,
1480+
Account = Account,
1481+
AccountUpdate = AccountUpdate,
1482+
>,
14731483
F: Fn(Fp) -> Result<MinaStateProtocolStateValueStableV2, String>,
14741484
Apply: Fn(
14751485
Slot,
@@ -1536,7 +1546,12 @@ impl ScanState {
15361546
apply_second_pass: ApplySecond,
15371547
) -> Result<(), String>
15381548
where
1539-
L: LedgerIntf + Clone,
1549+
L: LedgerInterface<
1550+
W = (),
1551+
Bool = bool,
1552+
Account = Account,
1553+
AccountUpdate = AccountUpdate,
1554+
>,
15401555
ApplySecond:
15411556
Fn(&mut L, TransactionPartiallyApplied<L>) -> Result<TransactionApplied, String>,
15421557
{
@@ -1568,7 +1583,12 @@ impl ScanState {
15681583
apply_txns_second_pass: ApplySecondPass,
15691584
) -> Result<R, String>
15701585
where
1571-
L: LedgerIntf + Clone,
1586+
L: LedgerInterface<
1587+
W = (),
1588+
Bool = bool,
1589+
Account = Account,
1590+
AccountUpdate = AccountUpdate,
1591+
>,
15721592
F: Fn(Fp) -> Result<MinaStateProtocolStateValueStableV2, String>,
15731593
ApplySecondPass: Fn(Acc<L>) -> Result<R, String>,
15741594
ApplyFirstSparse: Fn(
@@ -1622,7 +1642,7 @@ impl ScanState {
16221642
block_global_slot: zkapp.global_state.block_global_slot,
16231643
};
16241644

1625-
let local_state = LocalStateEnv {
1645+
let local_state = LocalStateEnv::<L> {
16261646
stack_frame: zkapp.local_state.stack_frame,
16271647
call_stack: zkapp.local_state.call_stack,
16281648
transaction_commitment: zkapp.local_state.transaction_commitment,
@@ -1711,7 +1731,12 @@ impl ScanState {
17111731
apply_txns_second_pass: &'a impl Fn(Acc<L>) -> Result<(), String>,
17121732
) -> Result<Pass, String>
17131733
where
1714-
L: LedgerIntf + Clone + 'a,
1734+
L: LedgerInterface<
1735+
W = (),
1736+
Bool = bool,
1737+
Account = Account,
1738+
AccountUpdate = AccountUpdate,
1739+
>,
17151740
{
17161741
use PreviousIncompleteTxns::{PartiallyApplied, Unapplied};
17171742

@@ -1862,7 +1887,7 @@ impl ScanState {
18621887
apply_first_pass_sparse_ledger: ApplyFirstSparse,
18631888
) -> Result<Pass, String>
18641889
where
1865-
L: LedgerIntf + Clone,
1890+
L: LedgerInterface<W = (), Bool = bool, Account = Account, AccountUpdate = AccountUpdate>,
18661891
F: Fn(Fp) -> Result<MinaStateProtocolStateValueStableV2, String>,
18671892
ApplyFirst: Fn(
18681893
Slot,
@@ -1899,7 +1924,7 @@ impl ScanState {
18991924
apply_first_pass_sparse_ledger: ApplyFirstSparse,
19001925
) -> Result<Pass, String>
19011926
where
1902-
L: LedgerIntf + Clone,
1927+
L: LedgerInterface<W = (), Bool = bool, Account = Account, AccountUpdate = AccountUpdate>,
19031928
F: Fn(Fp) -> Result<MinaStateProtocolStateValueStableV2, String>,
19041929
ApplyFirst: Fn(
19051930
Slot,
@@ -1939,7 +1964,7 @@ impl ScanState {
19391964
apply_first_pass_sparse_ledger: ApplyFirstSparse,
19401965
) -> Result<Pass, String>
19411966
where
1942-
L: LedgerIntf + Clone,
1967+
L: LedgerInterface<W = (), Bool = bool, Account = Account, AccountUpdate = AccountUpdate>,
19431968
F: Fn(Fp) -> Result<MinaStateProtocolStateValueStableV2, String>,
19441969
ApplyFirst: Fn(
19451970
Slot,

0 commit comments

Comments
 (0)