Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ jobs:
--exclude mina-archive-breadcrumb-compare \
--exclude webrtc-sniffer
# --exclude mina-tree
# --exclude mina-tx-type
# --exclude vrf

account-tests:
Expand Down
17 changes: 17 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"ledger",
"macros",
"mina-p2p-messages",
"mina-tx-type",
"node",
"node/account",
"node/common",
Expand Down Expand Up @@ -147,6 +148,7 @@ mina-p2p-messages = { path = "mina-p2p-messages" }
mina-poseidon = { git = "https://github.com/o1-labs/proof-systems", tag = "0.2.0" }
mina-signer = { git = "https://github.com/o1-labs/proof-systems", tag = "0.2.0" }
mina-transport = { path = "tools/transport" }
mina-tx-type = { path = "mina-tx-type" }
mio = { version = "1.0.4", features = ["os-poll", "net"] }
multiaddr = "0.18.1"
multihash = { version = "0.18.1", features = ["blake2b"] }
Expand Down
1 change: 1 addition & 0 deletions ledger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ mina-macros = { workspace = true }
mina-p2p-messages = { workspace = true }
mina-poseidon = { workspace = true }
mina-signer = { workspace = true }
mina-tx-type = { workspace = true }
num-bigint = { workspace = true }
o1-utils = { workspace = true }
once_cell = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions ledger/src/account/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::{
numbers::{
currency::{CheckedAmount, CheckedBalance},
nat::{CheckedSlot, CheckedSlotSpan},
ToCheckedExt,
},
to_field_elements::ToFieldElements,
},
Expand Down
5 changes: 3 additions & 2 deletions ledger/src/proofs/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use crate::{
numbers::{
currency::CheckedSigned,
nat::{CheckedNat, CheckedSlot},
SignedToCheckedExt, ToCheckedExt,
},
step::extract_recursion_challenges,
to_field_elements::ToFieldElementsDebug,
Expand Down Expand Up @@ -621,7 +622,7 @@ mod vrf {
scale_non_constant, InnerCurve,
},
},
scan_state::currency::{Amount, Balance},
scan_state::currency::{Amount, AmountFeeFieldExt, Balance},
sparse_ledger::SparseLedger,
AccountIndex, Address, AppendToInputs,
};
Expand Down Expand Up @@ -752,7 +753,7 @@ mod vrf {
use floating_point::*;

let top = SnarkyInteger::create(my_stake.to_field::<Fp>(), balance_upper_bound());
let bottom = SnarkyInteger::create(total_stake.to_field::<Fp>(), amount_upper_bound());
let bottom = SnarkyInteger::create(total_stake.to_field(), amount_upper_bound());
let precision = PARAMS.per_term_precision;

let point = floating_point::of_quotient(precision, top, bottom, w);
Expand Down
28 changes: 27 additions & 1 deletion ledger/src/proofs/field.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
//! Field-related traits and types for proof circuits.
//!
//! # Refactoring Notes (mina-tx-type extraction)
//!
//! The following types in this module have been duplicated in `mina-tx-type`:
//! - `FieldWitness` trait
//! - `GroupAffine<F>` type alias
//! - `Boolean` enum
//! - `CircuitVar<T>` enum
//! - `ShiftedValue<F>` struct (via `ShiftingValue` trait)
//! - `Shift<F>`, `ShiftFq` types
//! - `FromFpFq`, `IntoGeneric`, `ToBoolean`, `Params<F>` types
//!
//! To complete the migration to `mina-tx-type`:
//! 1. Replace these local type definitions with imports from `mina_tx_type`
//! 2. Update all usages throughout the ledger crate
//! 3. This will then allow replacing `ToFieldElements` trait with import
//!
//! See: mina-tx-type/src/proofs/field.rs for the equivalent types

use ark_ec::{short_weierstrass::Projective, AffineRepr, CurveGroup};
use ark_ff::{BigInteger256, FftField, Field, PrimeField};
use kimchi::curve::KimchiCurve;
Expand All @@ -19,9 +39,15 @@ use super::{
BACKEND_TICK_ROUNDS_N, BACKEND_TOCK_ROUNDS_N,
};

/// Type alias for affine curve points parameterized by field witness.
///
/// **Note:** This type is duplicated in `mina_tx_type::GroupAffine`.
pub type GroupAffine<F> = ark_ec::short_weierstrass::Affine<<F as FieldWitness>::Parameters>;

/// All the generics we need during witness generation
/// All the generics we need during witness generation.
///
/// **Note:** This trait is duplicated in `mina_tx_type::FieldWitness`.
/// See module-level docs for the migration plan.
pub trait FieldWitness
where
Self: Field
Expand Down
14 changes: 8 additions & 6 deletions ledger/src/proofs/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ use mina_curves::pasta::{Fp, Fq};
use mina_p2p_messages::{bigint::InvalidBigInt, v2};

use crate::{
proofs::transaction::transaction_snark::assert_equal_local_state,
proofs::{
numbers::SignedToCheckedExt, transaction::transaction_snark::assert_equal_local_state,
},
scan_state::{
fee_excess::FeeExcess,
pending_coinbase,
Expand Down Expand Up @@ -61,8 +63,8 @@ fn merge_main(
);

let _supply_increase = {
let s1 = s1.supply_increase.to_checked::<Fp>();
let s2 = s2.supply_increase.to_checked::<Fp>();
let s1 = s1.supply_increase.to_checked();
let s2 = s2.supply_increase.to_checked();
s1.add(&s2, w)
};

Expand All @@ -82,12 +84,12 @@ fn merge_main(
fee_excess_r,
..
} = statement.fee_excess;
fee_excess_l.to_checked::<Fp>().value(w);
fee_excess_r.to_checked::<Fp>().value(w);
fee_excess_l.to_checked().value(w);
fee_excess_r.to_checked().value(w);

// Only `Statement.supply_increase`, not `supply_increase`
let supply_increase = statement.supply_increase;
supply_increase.to_checked::<Fp>().value(w);
supply_increase.to_checked().value(w);
}

Ok((s1, s2))
Expand Down
3 changes: 2 additions & 1 deletion ledger/src/proofs/numbers/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ use crate::{
pub trait ForZkappCheck<F: FieldWitness>: Magnitude {
type CheckedType;

fn zkapp_to_field(&self) -> F;
fn to_checked(&self) -> Self::CheckedType {
Self::checked_from_field(self.to_field::<F>())
Self::checked_from_field(self.zkapp_to_field())
}
fn checked_from_field(field: F) -> Self::CheckedType;
fn lte(this: &Self::CheckedType, other: &Self::CheckedType, w: &mut Witness<F>) -> Boolean;
Expand Down
Loading
Loading