Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: get rid of all assignment ops in airs #1699

Merged
merged 8 commits into from
Oct 29, 2024
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
2 changes: 0 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ jobs:
env:
RUSTFLAGS: -Copt-level=3 -Cdebug-assertions -Coverflow-checks=y -Cdebuginfo=0 -C target-cpu=native
RUST_BACKTRACE: 1
# FRI_QUERIES: 1
SP1_DEV: 1

test-arm:
Expand Down Expand Up @@ -89,7 +88,6 @@ jobs:
env:
RUSTFLAGS: -Copt-level=3 -Cdebug-assertions -Coverflow-checks=y -Cdebuginfo=0 -C target-cpu=native
RUST_BACKTRACE: 1
# FRI_QUERIES: 1
SP1_DEV: 1

lint:
Expand Down
96 changes: 38 additions & 58 deletions Cargo.lock

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

77 changes: 40 additions & 37 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,46 +68,49 @@ sp1-lib = { path = "crates/zkvm/lib", version = "3.0.0", default-features = fals
sp1-zkvm = { path = "crates/zkvm/entrypoint", version = "3.0.1", default-features = false }

# p3
p3-air = "0.1.4-succinct"
p3-field = "0.1.4-succinct"
p3-commit = "0.1.4-succinct"
p3-matrix = "0.1.4-succinct"
p3-baby-bear = { version = "0.1.4-succinct", features = ["nightly-features"] }
p3-util = "0.1.4-succinct"
p3-challenger = "0.1.4-succinct"
p3-dft = "0.1.4-succinct"
p3-fri = "0.1.4-succinct"
p3-keccak-air = "0.1.4-succinct"
p3-blake3 = "0.1.4-succinct"
p3-merkle-tree = "0.1.4-succinct"
p3-poseidon2 = "0.1.4-succinct"
p3-symmetric = "0.1.4-succinct"
p3-uni-stark = "0.1.4-succinct"
p3-maybe-rayon = "0.1.4-succinct"
p3-bn254-fr = "0.1.4-succinct"
# p3-air = "0.1.4-succinct"
# p3-field = "0.1.4-succinct"
# p3-commit = "0.1.4-succinct"
# p3-matrix = "0.1.4-succinct"
# p3-baby-bear = { version = "0.1.4-succinct", features = ["nightly-features"] }
# p3-util = "0.1.4-succinct"
# p3-challenger = "0.1.4-succinct"
# p3-dft = "0.1.4-succinct"
# p3-fri = "0.1.4-succinct"
# p3-goldilocks = "0.1.4-succinct"
# p3-keccak = "0.1.4-succinct"
# p3-keccak-air = "0.1.4-succinct"
# p3-blake3 = "0.1.4-succinct"
# p3-mds = "0.1.4-succinct"
# p3-merkle-tree = "0.1.4-succinct"
# p3-poseidon2 = "0.1.4-succinct"
# p3-symmetric = "0.1.4-succinct"
# p3-uni-stark = "0.1.4-succinct"
# p3-maybe-rayon = "0.1.4-succinct"
# p3-bn254-fr = "0.1.4-succinct"

# For local development.

# p3-air = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v3" }
# p3-field = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v3" }
# p3-commit = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v3" }
# p3-matrix = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v3" }
# p3-baby-bear = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v3" }
# p3-util = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v3" }
# p3-challenger = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v3" }
# p3-dft = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v3" }
# p3-fri = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v3" }
# p3-goldilocks = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v3" }
# p3-keccak = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v3" }
# p3-keccak-air = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v3" }
# p3-blake3 = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v3" }
# p3-mds = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v3" }
# p3-merkle-tree = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v3" }
# p3-poseidon2 = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v3" }
# p3-symmetric = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v3" }
# p3-uni-stark = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v3" }
# p3-maybe-rayon = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v3" }
# p3-bn254-fr = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v3" }
p3-air = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v4" }
p3-field = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v4" }
p3-commit = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v4" }
p3-matrix = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v4" }
p3-baby-bear = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v4" }
p3-util = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v4" }
p3-challenger = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v4" }
p3-dft = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v4" }
p3-fri = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v4" }
p3-goldilocks = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v4" }
p3-keccak = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v4" }
p3-keccak-air = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v4" }
p3-blake3 = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v4" }
p3-mds = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v4" }
p3-merkle-tree = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v4" }
p3-poseidon2 = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v4" }
p3-symmetric = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v4" }
p3-uni-stark = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v4" }
p3-maybe-rayon = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v4" }
p3-bn254-fr = { git = "https://github.com/Plonky3/Plonky3", branch = "sp1-v4" }

# p3-air = { path = "../Plonky3/air" }
# p3-field = { path = "../Plonky3/field" }
Expand Down
16 changes: 10 additions & 6 deletions crates/core/machine/src/alu/divrem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,16 +572,20 @@ where

// Add remainder.
if i < WORD_SIZE {
c_times_quotient_plus_remainder[i] += local.remainder[i].into();
c_times_quotient_plus_remainder[i] =
c_times_quotient_plus_remainder[i].clone() + local.remainder[i].into();
} else {
// If rem is negative, add 0xff to the upper 4 bytes.
c_times_quotient_plus_remainder[i] += sign_extension.clone();
c_times_quotient_plus_remainder[i] =
c_times_quotient_plus_remainder[i].clone() + sign_extension.clone();
}

// Propagate carry.
c_times_quotient_plus_remainder[i] -= local.carry[i] * base;
c_times_quotient_plus_remainder[i] =
c_times_quotient_plus_remainder[i].clone() - local.carry[i] * base;
if i > 0 {
c_times_quotient_plus_remainder[i] += local.carry[i - 1].into();
c_times_quotient_plus_remainder[i] =
c_times_quotient_plus_remainder[i].clone() + local.carry[i - 1].into();
}
}

Expand Down Expand Up @@ -628,8 +632,8 @@ where
let mut rem_byte_sum = zero.clone();
let mut b_byte_sum = zero.clone();
for i in 0..WORD_SIZE {
rem_byte_sum += local.remainder[i].into();
b_byte_sum += local.b[i].into();
rem_byte_sum = rem_byte_sum.clone() + local.remainder[i].into();
b_byte_sum = b_byte_sum + local.b[i].into();
}

// 1. If remainder < 0, then b < 0.
Expand Down
6 changes: 3 additions & 3 deletions crates/core/machine/src/alu/lt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,10 @@ where
{
// Once the byte flag was set to one, we turn off the quality check flag.
// We can do this by calculating the sum of the flags since only `1` is set to `1`.
is_inequality_visited += flag.into();
is_inequality_visited = is_inequality_visited.clone() + flag.into();

b_comparison_byte += b_byte.clone() * flag;
c_comparison_byte += c_byte.clone() * flag;
b_comparison_byte = b_comparison_byte.clone() + b_byte.clone() * flag;
c_comparison_byte = c_comparison_byte.clone() + c_byte.clone() * flag;

// If inequality is not visited, assert that the bytes are equal.
builder
Expand Down
2 changes: 1 addition & 1 deletion crates/core/machine/src/alu/mul/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ where
for i in 0..PRODUCT_SIZE {
for j in 0..PRODUCT_SIZE {
if i + j < PRODUCT_SIZE {
m[i + j] += b[i].clone() * c[j].clone();
m[i + j] = m[i + j].clone() + b[i].clone() * c[j].clone();
}
}
}
Expand Down
Loading
Loading