Skip to content

Commit 838282d

Browse files
authored
Merge pull request #836 from openmina/fix/zkapp-precondition-failures-order
fix(ledger): Fix handling of precondition checks ordering
2 parents 77592b9 + 667791e commit 838282d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

ledger/src/scan_state/transaction_logic.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,20 +2107,24 @@ pub mod zkapp_command {
21072107
.iter()
21082108
.zip(&zkapp_account.app_state)
21092109
.enumerate()
2110+
// Reversed to enforce right-to-left order application of `f` like in OCaml
21102111
.rev()
21112112
.map(|(i, (s, account_s))| {
21122113
let b = (s, Fp::zero).zcheck::<Ops>(account_s, w);
21132114
(AccountAppStatePreconditionUnsatisfied(i as u64), b)
21142115
})
21152116
.collect::<Vec<_>>();
2116-
// We need to call rev here, in order to match OCaml order
2117-
bools.into_iter().rev()
2117+
// Not reversed again because we are constructing these results in
2118+
// reverse order to match the OCaml evaluation order.
2119+
bools.into_iter()
21182120
})
21192121
.chain([
21202122
{
21212123
let bools: Vec<_> = zkapp_account
21222124
.action_state
21232125
.iter()
2126+
// Reversed to enforce right-to-left order application of `f` like in OCaml
2127+
.rev()
21242128
.map(|account_s| {
21252129
(action_state, ZkAppAccount::empty_action_state)
21262130
.zcheck::<Ops>(account_s, w)

0 commit comments

Comments
 (0)