Skip to content

Commit 677103e

Browse files
committed
Fix block proof generation with zero supply increase
1 parent 63d6e53 commit 677103e

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

ledger/src/proofs/block.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,7 +1375,6 @@ pub mod consensus {
13751375

13761376
let (new_total_currency, _overflow) = {
13771377
let total_currency: Amount = previous_state.total_currency;
1378-
w.exists(supply_increase.force_value());
13791378
total_currency
13801379
.to_checked()
13811380
.add_signed_flagged(supply_increase, w)
@@ -1639,7 +1638,7 @@ fn block_main<'a>(
16391638
};
16401639

16411640
let supply_increase = w.exists_no_check(match txn_stmt_ledger_hashes_didn_t_change {
1642-
Boolean::True => CheckedSigned::zero(),
1641+
Boolean::True => CheckedSigned::const_zero(),
16431642
Boolean::False => txn_snark.supply_increase.to_checked(),
16441643
});
16451644

ledger/src/proofs/numbers/currency.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ where
8686
Self::of_unsigned(T::zero())
8787
}
8888

89+
pub fn const_zero() -> Self {
90+
Self {
91+
magnitude: T::zero(),
92+
sgn: Sgn::Pos,
93+
value: Cell::new(None),
94+
}
95+
}
96+
8997
pub fn negate(self) -> Self {
9098
Self {
9199
magnitude: self.magnitude,
@@ -215,15 +223,14 @@ where
215223
}
216224

217225
pub fn equal(&self, other: &Self, w: &mut Witness<F>) -> Boolean {
218-
// We decompose this way because of OCaml evaluation order
219-
let t2 = other.value(w);
220226
let t1 = self.value(w);
227+
let t2 = other.value(w);
221228
field::equal(t1, t2, w)
222229
}
223230

224231
pub fn const_equal(&self, other: &Self, w: &mut Witness<F>) -> Boolean {
225-
let t2 = other.value(w);
226232
let t1 = self.value(w);
233+
let t2 = other.value(w);
227234
field::equal(t1, t2, w)
228235
}
229236
}

0 commit comments

Comments
 (0)