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

refactor: Byte record bounds #32

Merged
merged 1 commit into from
Jun 6, 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
3 changes: 1 addition & 2 deletions core/src/operations/add.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::air::{Word, WordAirBuilder};
use crate::bytes::event::ByteRecord;
use crate::runtime::ExecutionRecord;

use p3_air::AirBuilder;
use p3_field::{AbstractField, Field};
Expand All @@ -20,7 +19,7 @@ pub struct AddOperation<T> {
impl<F: Field> AddOperation<F> {
pub fn populate(
&mut self,
record: &mut ExecutionRecord,
record: &mut impl ByteRecord,
shard: u32,
a_u32: u32,
b_u32: u32,
Expand Down
3 changes: 1 addition & 2 deletions core/src/operations/add4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::air::Word;
use crate::air::WordAirBuilder;
use crate::air::WORD_SIZE;
use crate::bytes::event::ByteRecord;
use crate::runtime::ExecutionRecord;

/// A set of columns needed to compute the add of four words.
#[derive(AlignedBorrow, Default, Debug, Clone, Copy)]
Expand Down Expand Up @@ -34,7 +33,7 @@ pub struct Add4Operation<T> {
impl<F: Field> Add4Operation<F> {
pub fn populate(
&mut self,
record: &mut ExecutionRecord,
record: &mut impl ByteRecord,
shard: u32,
a_u32: u32,
b_u32: u32,
Expand Down
3 changes: 1 addition & 2 deletions core/src/operations/add5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::air::Word;
use crate::air::WordAirBuilder;
use crate::air::WORD_SIZE;
use crate::bytes::event::ByteRecord;
use crate::runtime::ExecutionRecord;

/// A set of columns needed to compute the sum of five words.
#[derive(AlignedBorrow, Default, Debug, Clone, Copy)]
Expand Down Expand Up @@ -38,7 +37,7 @@ impl<F: Field> Add5Operation<F> {
#[allow(clippy::too_many_arguments)]
pub fn populate(
&mut self,
record: &mut ExecutionRecord,
record: &mut impl ByteRecord,
shard: u32,
a_u32: u32,
b_u32: u32,
Expand Down
3 changes: 1 addition & 2 deletions core/src/operations/and.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use crate::bytes::event::ByteRecord;
use crate::bytes::ByteLookupEvent;
use crate::bytes::ByteOpcode;
use crate::disassembler::WORD_SIZE;
use crate::runtime::ExecutionRecord;

/// A set of columns needed to compute the and of two words.
#[derive(AlignedBorrow, Default, Debug, Clone, Copy)]
Expand All @@ -18,7 +17,7 @@ pub struct AndOperation<T> {
}

impl<F: Field> AndOperation<F> {
pub fn populate(&mut self, record: &mut ExecutionRecord, shard: u32, x: u32, y: u32) -> u32 {
pub fn populate(&mut self, record: &mut impl ByteRecord, shard: u32, x: u32, y: u32) -> u32 {
let expected = x & y;
let x_bytes = x.to_le_bytes();
let y_bytes = y.to_le_bytes();
Expand Down
3 changes: 1 addition & 2 deletions core/src/operations/fixed_rotate_right.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::bytes::utils::shr_carry;
use crate::bytes::ByteLookupEvent;
use crate::bytes::ByteOpcode;
use crate::disassembler::WORD_SIZE;
use crate::runtime::ExecutionRecord;

/// A set of columns needed to compute `rotateright` of a word with a fixed offset R.
///
Expand Down Expand Up @@ -42,7 +41,7 @@ impl<F: Field> FixedRotateRightOperation<F> {

pub fn populate(
&mut self,
record: &mut ExecutionRecord,
record: &mut impl ByteRecord,
shard: u32,
input: u32,
rotation: usize,
Expand Down
3 changes: 1 addition & 2 deletions core/src/operations/fixed_shift_right.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::bytes::utils::shr_carry;
use crate::bytes::ByteLookupEvent;
use crate::bytes::ByteOpcode;
use crate::disassembler::WORD_SIZE;
use crate::runtime::ExecutionRecord;

/// A set of columns needed to compute `>>` of a word with a fixed offset R.
///
Expand Down Expand Up @@ -42,7 +41,7 @@ impl<F: Field> FixedShiftRightOperation<F> {

pub fn populate(
&mut self,
record: &mut ExecutionRecord,
record: &mut impl ByteRecord,
shard: u32,
input: u32,
rotation: usize,
Expand Down
3 changes: 1 addition & 2 deletions core/src/operations/not.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use crate::air::Word;
use crate::bytes::event::ByteRecord;
use crate::bytes::ByteOpcode;
use crate::disassembler::WORD_SIZE;
use crate::runtime::ExecutionRecord;

/// A set of columns needed to compute the not of a word.
#[derive(AlignedBorrow, Default, Debug, Clone, Copy)]
Expand All @@ -18,7 +17,7 @@ pub struct NotOperation<T> {
}

impl<F: Field> NotOperation<F> {
pub fn populate(&mut self, record: &mut ExecutionRecord, shard: u32, x: u32) -> u32 {
pub fn populate(&mut self, record: &mut impl ByteRecord, shard: u32, x: u32) -> u32 {
let expected = !x;
let x_bytes = x.to_le_bytes();
for i in 0..WORD_SIZE {
Expand Down
3 changes: 1 addition & 2 deletions core/src/operations/or.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::air::Word;
use crate::bytes::event::ByteRecord;
use crate::bytes::ByteOpcode;
use crate::disassembler::WORD_SIZE;
use crate::runtime::ExecutionRecord;

/// A set of columns needed to compute the or of two words.
///
Expand All @@ -19,7 +18,7 @@ pub struct OrOperation<T> {
}

impl<F: Field> OrOperation<F> {
pub fn populate(&mut self, record: &mut ExecutionRecord, shard: u32, x: u32, y: u32) -> u32 {
pub fn populate(&mut self, record: &mut impl ByteRecord, shard: u32, x: u32, y: u32) -> u32 {
let expected = x | y;
let x_bytes = x.to_le_bytes();
let y_bytes = y.to_le_bytes();
Expand Down
3 changes: 1 addition & 2 deletions core/src/operations/xor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use crate::bytes::event::ByteRecord;
use crate::bytes::ByteLookupEvent;
use crate::bytes::ByteOpcode;
use crate::disassembler::WORD_SIZE;
use crate::runtime::ExecutionRecord;

/// A set of columns needed to compute the xor of two words.
#[derive(AlignedBorrow, Default, Debug, Clone, Copy)]
Expand All @@ -18,7 +17,7 @@ pub struct XorOperation<T> {
}

impl<F: Field> XorOperation<F> {
pub fn populate(&mut self, record: &mut ExecutionRecord, shard: u32, x: u32, y: u32) -> u32 {
pub fn populate(&mut self, record: &mut impl ByteRecord, shard: u32, x: u32, y: u32) -> u32 {
let expected = x ^ y;
let x_bytes = x.to_le_bytes();
let y_bytes = y.to_le_bytes();
Expand Down
4 changes: 2 additions & 2 deletions core/src/syscall/precompiles/blake3/compress/g.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use sphinx_derive::AlignedBorrow;
use super::g_func;
use crate::{
air::{Word, WordAirBuilder, WORD_SIZE},
bytes::event::ByteRecord,
operations::{AddOperation, FixedRotateRightOperation, XorOperation},
runtime::ExecutionRecord,
};
/// A set of columns needed to compute the `g` of the input state.
/// ``` ignore
Expand Down Expand Up @@ -44,7 +44,7 @@ pub struct GOperation<T> {
impl<F: Field> GOperation<F> {
pub fn populate(
&mut self,
record: &mut ExecutionRecord,
record: &mut impl ByteRecord,
shard: u32,
input: [u32; 6],
) -> [u32; 4] {
Expand Down
2 changes: 1 addition & 1 deletion core/src/syscall/precompiles/edwards/ed_decompress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl<F: PrimeField32, P: FieldParameters> EdDecompressCols<F, P> {
pub fn populate<E: EdwardsParameters<BaseField = P>>(
&mut self,
event: &EdDecompressEvent,
record: &mut ExecutionRecord,
record: &mut impl ByteRecord,
) {
let mut new_byte_lookup_events = Vec::new();
self.is_real = F::from_bool(true);
Expand Down