Skip to content
Merged
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
34 changes: 34 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,40 @@ jobs:
cd ledger
cargo test --release -- -Z unstable-options --report-time

ledger-32x9-tests:
runs-on: ubuntu-20.04
steps:
- name: Git checkout
uses: actions/checkout@v4
- name: Setup build dependencies
run: |
sudo apt update
sudo apt install -y protobuf-compiler
- name: Setup Rust
run: |
# Nightly to be able to use `--report-time` below
rustup install nightly
rustup override set nightly
- name: Download circuits files
run: |
git clone --depth 1 https://github.com/openmina/circuit-blobs.git
ln -s -b $PWD/circuit-blobs/* ledger/
- name: Enable 32x9 fields implementation
run: |
cargo install sd
sd '^mina-curves.*$' '' ./Cargo.toml
sd '^ark-ff = \{ version .*$' '' ./Cargo.toml
sd -F '# UNCOMMENTED_IN_CI ' '' ./Cargo.toml
cat ./Cargo.toml
- name: Build ledger tests
run: |
cd ledger
cargo build --release --tests
- name: Run ledger tests
run: |
cd ledger
cargo test --release -- -Z unstable-options --report-time

tx-fuzzer-check:
runs-on: ubuntu-20.04
steps:
Expand Down
34 changes: 17 additions & 17 deletions Cargo.lock

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

28 changes: 17 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,16 @@ indexing_slicing = "warn"
mina-p2p-messages = { path = "mina-p2p-messages" }
poseidon = { path = "poseidon" }
ledger = { path = "ledger", package = "mina-tree" }
mina-hasher = { git = "https://github.com/openmina/proof-systems", rev = "d0cd63b" }
mina-signer = { git = "https://github.com/openmina/proof-systems", rev = "d0cd63b" }
mina-curves = { git = "https://github.com/openmina/proof-systems", rev = "d0cd63b" }
o1-utils = { git = "https://github.com/openmina/proof-systems", rev = "d0cd63b" }
kimchi = { git = "https://github.com/openmina/proof-systems", rev = "d0cd63b" }
mina-poseidon = {git = "https://github.com/openmina/proof-systems", rev = "d0cd63b"}
poly-commitment = {git = "https://github.com/openmina/proof-systems", rev = "d0cd63b"}

mina-hasher = { git = "https://github.com/openmina/proof-systems", rev = "c478b19" }
mina-signer = { git = "https://github.com/openmina/proof-systems", rev = "c478b19" }
mina-curves = { git = "https://github.com/openmina/proof-systems", rev = "c478b19" }
# UNCOMMENTED_IN_CI mina-curves = { git = "https://github.com/openmina/proof-systems", rev = "c478b19", features = [ "32x9" ] }
o1-utils = { git = "https://github.com/openmina/proof-systems", rev = "c478b19" }
kimchi = { git = "https://github.com/openmina/proof-systems", rev = "c478b19" }
mina-poseidon = {git = "https://github.com/openmina/proof-systems", rev = "c478b19" }
poly-commitment = {git = "https://github.com/openmina/proof-systems", rev = "c478b19" }

libp2p = { git = "https://github.com/openmina/rust-libp2p", rev = "5c44c7d9", default-features = false }
vrf = { path = "vrf" }
openmina-node-account = { path = "node/account" }
Expand All @@ -63,6 +66,9 @@ linkme = "0.3.22"
static_assertions = "1.1.0"
juniper = { version = "0.16" }

ark-ff = { version = "0.3.0", features = [ "parallel", "asm", "std" ] }
# UNCOMMENTED_IN_CI ark-ff = { version = "0.3.0", features = [ "parallel", "asm", "std", "32x9" ] }


[profile.fuzz]
inherits = "release"
Expand All @@ -76,10 +82,10 @@ incremental = false
codegen-units = 1

[patch.crates-io]
ark-ff = { git = "https://github.com/openmina/algebra", rev = "33a1de2" } # branch: fix-openmina
ark-ec = { git = "https://github.com/openmina/algebra", rev = "33a1de2" } # branch: fix-openmina
ark-poly = { git = "https://github.com/openmina/algebra", rev = "33a1de2" } # branch: fix-openmina
ark-serialize = { git = "https://github.com/openmina/algebra", rev = "33a1de2" } # branch: fix-openmina
ark-ff = { git = "https://github.com/openmina/algebra", rev = "f42a8ec" } # branch: fix-openmina-webnode
ark-ec = { git = "https://github.com/openmina/algebra", rev = "f42a8ec" } # branch: fix-openmina-webnode
ark-poly = { git = "https://github.com/openmina/algebra", rev = "f42a8ec" } # branch: fix-openmina-webnode
ark-serialize = { git = "https://github.com/openmina/algebra", rev = "f42a8ec" } # branch: fix-openmina-webnode

[profile.test.package."*"]
opt-level = 3
Expand Down
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mina-hasher = { workspace = true }
mina-p2p-messages = { workspace = true }
poseidon = { workspace = true }
hex = "0.4.3"
ark-ff = { version = "0.3.0", features = [ "parallel", "asm", "std" ] }
ark-ff = { workspace = true }

[target.'cfg(not(target_family = "wasm"))'.dependencies]
redux = { workspace = true, features=["serializable_callbacks"] }
Expand Down
2 changes: 1 addition & 1 deletion ledger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ libc = "0.2"

itertools = "0.10"

ark-ff = { version = "0.3.0", features = [ "parallel", "asm", "std" ] }
ark-ff = { workspace = true }
ark-ec = { version = "0.3.0", features = [ "std" ] }
ark-serialize = { version = "0.3.0", features = [ "std" ] }
ark-poly = { version = "0.3.0", features = [ "std" ] }
Expand Down
8 changes: 7 additions & 1 deletion ledger/src/account/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1760,14 +1760,20 @@ mod tests {

#[test]
fn test_size_account() {
const SIZE_WITH_9LIMBS: usize = 296;

#[cfg(not(target_family = "wasm"))]
const SIZE: usize = 280;

// FIXME: was 2496bytes before zkapp got boxed, what should be the size now?
#[cfg(target_family = "wasm")]
const SIZE: usize = 280;

assert_eq!(std::mem::size_of::<Account>(), SIZE);
if std::mem::size_of::<BigInteger256>() == 9 * 4 {
assert_eq!(std::mem::size_of::<Account>(), SIZE_WITH_9LIMBS);
} else {
assert_eq!(std::mem::size_of::<Account>(), SIZE);
}
}

#[test]
Expand Down
7 changes: 4 additions & 3 deletions ledger/src/port_ocaml/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,15 @@ fn hash_field(f: &Fp) -> u32 {
let mut acc = 0;

let bigint: BigInteger256 = (*f).into();
let nignore: usize = bigint.0.iter().rev().take_while(|&b| *b == 0).count();
let bigint = bigint.to_64x4();
let nignore: usize = bigint.iter().rev().take_while(|&b| *b == 0).count();

for bigint in bigint.0.iter().take(BigInteger256::NUM_LIMBS - nignore) {
for bigint in bigint.iter().take(BigInteger256::NUM_LIMBS - nignore) {
acc = mix(acc, (bigint & 0xFFFF_FFFF) as u32);
acc = mix(acc, (bigint >> 32) as u32);
}

if bigint.0.last().unwrap() & 0x8000_0000_0000_0000 != 0 {
if bigint.last().unwrap() & 0x8000_0000_0000_0000 != 0 {
// TODO: Not sure if that condition is correct
acc += 1;
}
Expand Down
22 changes: 11 additions & 11 deletions ledger/src/proofs/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,17 +316,17 @@ mod floating_point {
}

const COEFFICIENTS: [(Sgn, BigInteger256); 11] = [
(Sgn::Pos, BigInteger256::new([405058, 0, 0, 0])),
(Sgn::Neg, BigInteger256::new([1007582, 0, 0, 0])),
(Sgn::Pos, BigInteger256::new([465602, 0, 0, 0])),
(Sgn::Neg, BigInteger256::new([161365, 0, 0, 0])),
(Sgn::Pos, BigInteger256::new([44739, 0, 0, 0])),
(Sgn::Neg, BigInteger256::new([10337, 0, 0, 0])),
(Sgn::Pos, BigInteger256::new([2047, 0, 0, 0])),
(Sgn::Neg, BigInteger256::new([354, 0, 0, 0])),
(Sgn::Pos, BigInteger256::new([54, 0, 0, 0])),
(Sgn::Neg, BigInteger256::new([7, 0, 0, 0])),
(Sgn::Pos, BigInteger256::new([0, 0, 0, 0])),
(Sgn::Pos, BigInteger256::from_64x4([405058, 0, 0, 0])),
(Sgn::Neg, BigInteger256::from_64x4([1007582, 0, 0, 0])),
(Sgn::Pos, BigInteger256::from_64x4([465602, 0, 0, 0])),
(Sgn::Neg, BigInteger256::from_64x4([161365, 0, 0, 0])),
(Sgn::Pos, BigInteger256::from_64x4([44739, 0, 0, 0])),
(Sgn::Neg, BigInteger256::from_64x4([10337, 0, 0, 0])),
(Sgn::Pos, BigInteger256::from_64x4([2047, 0, 0, 0])),
(Sgn::Neg, BigInteger256::from_64x4([354, 0, 0, 0])),
(Sgn::Pos, BigInteger256::from_64x4([54, 0, 0, 0])),
(Sgn::Neg, BigInteger256::from_64x4([7, 0, 0, 0])),
(Sgn::Pos, BigInteger256::from_64x4([0, 0, 0, 0])),
];

pub struct Params {
Expand Down
5 changes: 4 additions & 1 deletion ledger/src/proofs/group_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ fn sqrt_exn<F: FieldWitness>(x: F, w: &mut Witness<F>) -> F {
}

fn is_square<F: FieldWitness>(x: F) -> bool {
let s = x.pow(F::Params::MODULUS_MINUS_ONE_DIV_TWO);
use ark_ff::BigInteger;

let modulus_minus_one_div_two = F::Params::MODULUS_MINUS_ONE_DIV_TWO.to_64x4();
let s = x.pow(modulus_minus_one_div_two);
s.is_zero() || s.is_one()
}

Expand Down
1 change: 1 addition & 0 deletions ledger/src/proofs/numbers/currency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use crate::ToInputs;

use super::common::{range_check, ForZkappCheck};

#[derive(Debug)]
pub enum RangeCheckFlaggedKind {
Add,
Sub,
Expand Down
8 changes: 4 additions & 4 deletions ledger/src/proofs/public_input/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ impl MessagesForNextWrapProof {
let field: Fq = hash_fields(&fields);

let bigint: BigInteger256 = field.into_repr();
bigint.0
bigint.to_64x4()
}

pub fn hash_checked(&self, w: &mut Witness<Fq>) -> [u64; 4] {
let fields: Vec<Fq> = self.to_fields();
let field: Fq = checked_hash2(&fields, w);

let bigint: BigInteger256 = field.into_repr();
bigint.0
bigint.to_64x4()
}

// TODO: De-duplicate with above
Expand All @@ -75,7 +75,7 @@ impl MessagesForNextWrapProof {
let field: Fq = crate::proofs::transaction::checked_hash3(&fields, w);

let bigint: BigInteger256 = field.into_repr();
bigint.0
bigint.to_64x4()
}

/// Implementation of `to_field_elements`
Expand Down Expand Up @@ -152,7 +152,7 @@ where
let field: Fp = hash_fields(&fields);

let bigint: BigInteger256 = field.into_repr();
bigint.0
bigint.to_64x4()
}

/// Implementation of `to_field_elements`
Expand Down
3 changes: 2 additions & 1 deletion ledger/src/proofs/public_input/scalar_challenge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ pub struct ScalarChallenge {
impl<F: FieldWitness> From<F> for ScalarChallenge {
fn from(value: F) -> Self {
let bigint: BigInteger256 = value.into();
Self::new(bigint.0[0], bigint.0[1])
let bigint = bigint.to_64x4();
Self::new(bigint[0], bigint[1])
}
}

Expand Down
Loading
Loading