Skip to content

Commit

Permalink
fix: main regression (succinctlabs#894)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtguibas authored Jun 7, 2024
2 parents 1049583 + bd8c0a9 commit 8c0f501
Show file tree
Hide file tree
Showing 156 changed files with 2,778 additions and 3,542 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ web-time = "1.1.0"
rayon-scan = "0.1.1"
thiserror = "1.0.60"
num-bigint = { version = "0.4.3", default-features = false }
rand = "0.8.5"

[dev-dependencies]
tiny-keccak = { version = "2.0.2", features = ["keccak"] }
Expand Down
8 changes: 0 additions & 8 deletions core/src/air/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ pub trait AluAirBuilder: BaseAirBuilder {
c: Word<impl Into<Self::Expr>>,
shard: impl Into<Self::Expr>,
channel: impl Into<Self::Expr>,
nonce: impl Into<Self::Expr>,
multiplicity: impl Into<Self::Expr>,
) {
let values = once(opcode.into())
Expand All @@ -317,7 +316,6 @@ pub trait AluAirBuilder: BaseAirBuilder {
.chain(c.0.into_iter().map(Into::into))
.chain(once(shard.into()))
.chain(once(channel.into()))
.chain(once(nonce.into()))
.collect();

self.send(AirInteraction::new(
Expand All @@ -337,7 +335,6 @@ pub trait AluAirBuilder: BaseAirBuilder {
c: Word<impl Into<Self::Expr>>,
shard: impl Into<Self::Expr>,
channel: impl Into<Self::Expr>,
nonce: impl Into<Self::Expr>,
multiplicity: impl Into<Self::Expr>,
) {
let values = once(opcode.into())
Expand All @@ -346,7 +343,6 @@ pub trait AluAirBuilder: BaseAirBuilder {
.chain(c.0.into_iter().map(Into::into))
.chain(once(shard.into()))
.chain(once(channel.into()))
.chain(once(nonce.into()))
.collect();

self.receive(AirInteraction::new(
Expand All @@ -363,7 +359,6 @@ pub trait AluAirBuilder: BaseAirBuilder {
shard: impl Into<Self::Expr> + Clone,
channel: impl Into<Self::Expr> + Clone,
clk: impl Into<Self::Expr> + Clone,
nonce: impl Into<Self::Expr> + Clone,
syscall_id: impl Into<Self::Expr> + Clone,
arg1: impl Into<Self::Expr> + Clone,
arg2: impl Into<Self::Expr> + Clone,
Expand All @@ -374,7 +369,6 @@ pub trait AluAirBuilder: BaseAirBuilder {
shard.clone().into(),
channel.clone().into(),
clk.clone().into(),
nonce.clone().into(),
syscall_id.clone().into(),
arg1.clone().into(),
arg2.clone().into(),
Expand All @@ -391,7 +385,6 @@ pub trait AluAirBuilder: BaseAirBuilder {
shard: impl Into<Self::Expr> + Clone,
channel: impl Into<Self::Expr> + Clone,
clk: impl Into<Self::Expr> + Clone,
nonce: impl Into<Self::Expr> + Clone,
syscall_id: impl Into<Self::Expr> + Clone,
arg1: impl Into<Self::Expr> + Clone,
arg2: impl Into<Self::Expr> + Clone,
Expand All @@ -402,7 +395,6 @@ pub trait AluAirBuilder: BaseAirBuilder {
shard.clone().into(),
channel.clone().into(),
clk.clone().into(),
nonce.clone().into(),
syscall_id.clone().into(),
arg1.clone().into(),
arg2.clone().into(),
Expand Down
23 changes: 1 addition & 22 deletions core/src/alu/add_sub/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use core::borrow::{Borrow, BorrowMut};
use core::mem::size_of;

use p3_air::{Air, AirBuilder, BaseAir};
use p3_field::AbstractField;
use p3_air::{Air, BaseAir};
use p3_field::PrimeField;
use p3_matrix::dense::RowMajorMatrix;
use p3_matrix::Matrix;
Expand Down Expand Up @@ -39,9 +38,6 @@ pub struct AddSubCols<T> {
/// The channel number, used for byte lookup table.
pub channel: T,

/// The nonce of the operation.
pub nonce: T,

/// Instance of `AddOperation` to handle addition logic in `AddSubChip`'s ALU operations.
/// It's result will be `a` for the add operation and `b` for the sub operation.
pub add_operation: AddOperation<T>,
Expand Down Expand Up @@ -133,13 +129,6 @@ impl<F: PrimeField> MachineAir<F> for AddSubChip {
// Pad the trace to a power of two.
pad_to_power_of_two::<NUM_ADD_SUB_COLS, F>(&mut trace.values);

// Write the nonces to the trace.
for i in 0..trace.height() {
let cols: &mut AddSubCols<F> =
trace.values[i * NUM_ADD_SUB_COLS..(i + 1) * NUM_ADD_SUB_COLS].borrow_mut();
cols.nonce = F::from_canonical_usize(i);
}

trace
}

Expand All @@ -162,14 +151,6 @@ where
let main = builder.main();
let local = main.row_slice(0);
let local: &AddSubCols<AB::Var> = (*local).borrow();
let next = main.row_slice(1);
let next: &AddSubCols<AB::Var> = (*next).borrow();

// Constrain the incrementing nonce.
builder.when_first_row().assert_zero(local.nonce);
builder
.when_transition()
.assert_eq(local.nonce + AB::Expr::one(), next.nonce);

// Evaluate the addition operation.
AddOperation::<AB::F>::eval(
Expand All @@ -191,7 +172,6 @@ where
local.operand_2,
local.shard,
local.channel,
local.nonce,
local.is_add,
);

Expand All @@ -203,7 +183,6 @@ where
local.operand_2,
local.shard,
local.channel,
local.nonce,
local.is_sub,
);

Expand Down
20 changes: 0 additions & 20 deletions core/src/alu/bitwise/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use core::borrow::{Borrow, BorrowMut};
use core::mem::size_of;

use p3_air::AirBuilder;
use p3_air::{Air, BaseAir};
use p3_field::AbstractField;
use p3_field::PrimeField;
use p3_matrix::dense::RowMajorMatrix;
use p3_matrix::Matrix;
Expand Down Expand Up @@ -33,9 +31,6 @@ pub struct BitwiseCols<T> {
/// The channel number, used for byte lookup table.
pub channel: T,

/// The nonce of the operation.
pub nonce: T,

/// The output operand.
pub a: Word<T>,

Expand Down Expand Up @@ -116,12 +111,6 @@ impl<F: PrimeField> MachineAir<F> for BitwiseChip {
// Pad the trace to a power of two.
pad_to_power_of_two::<NUM_BITWISE_COLS, F>(&mut trace.values);

for i in 0..trace.height() {
let cols: &mut BitwiseCols<F> =
trace.values[i * NUM_BITWISE_COLS..(i + 1) * NUM_BITWISE_COLS].borrow_mut();
cols.nonce = F::from_canonical_usize(i);
}

trace
}

Expand All @@ -144,14 +133,6 @@ where
let main = builder.main();
let local = main.row_slice(0);
let local: &BitwiseCols<AB::Var> = (*local).borrow();
let next = main.row_slice(1);
let next: &BitwiseCols<AB::Var> = (*next).borrow();

// Constrain the incrementing nonce.
builder.when_first_row().assert_zero(local.nonce);
builder
.when_transition()
.assert_eq(local.nonce + AB::Expr::one(), next.nonce);

// Get the opcode for the operation.
let opcode = local.is_xor * ByteOpcode::XOR.as_field::<AB::F>()
Expand Down Expand Up @@ -185,7 +166,6 @@ where
local.c,
local.shard,
local.channel,
local.nonce,
local.is_xor + local.is_or + local.is_and,
);

Expand Down
Loading

0 comments on commit 8c0f501

Please sign in to comment.