Skip to content

Commit 3f60558

Browse files
committed
refactor: Refactor operations to use ByteRecord trait
- Replaced the specific `ExecutionRecord` argument with the more general `impl ByteRecord` across all `populate` functions, promoting better flexibility. - Removed unused `ExecutionRecord` imports in various operation implementation files.
1 parent 8dd4513 commit 3f60558

File tree

11 files changed

+12
-21
lines changed

11 files changed

+12
-21
lines changed

core/src/operations/add.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::air::{Word, WordAirBuilder};
22
use crate::bytes::event::ByteRecord;
3-
use crate::runtime::ExecutionRecord;
43

54
use p3_air::AirBuilder;
65
use p3_field::{AbstractField, Field};
@@ -20,7 +19,7 @@ pub struct AddOperation<T> {
2019
impl<F: Field> AddOperation<F> {
2120
pub fn populate(
2221
&mut self,
23-
record: &mut ExecutionRecord,
22+
record: &mut impl ByteRecord,
2423
shard: u32,
2524
a_u32: u32,
2625
b_u32: u32,

core/src/operations/add4.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use crate::air::Word;
66
use crate::air::WordAirBuilder;
77
use crate::air::WORD_SIZE;
88
use crate::bytes::event::ByteRecord;
9-
use crate::runtime::ExecutionRecord;
109

1110
/// A set of columns needed to compute the add of four words.
1211
#[derive(AlignedBorrow, Default, Debug, Clone, Copy)]
@@ -34,7 +33,7 @@ pub struct Add4Operation<T> {
3433
impl<F: Field> Add4Operation<F> {
3534
pub fn populate(
3635
&mut self,
37-
record: &mut ExecutionRecord,
36+
record: &mut impl ByteRecord,
3837
shard: u32,
3938
a_u32: u32,
4039
b_u32: u32,

core/src/operations/add5.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use crate::air::Word;
66
use crate::air::WordAirBuilder;
77
use crate::air::WORD_SIZE;
88
use crate::bytes::event::ByteRecord;
9-
use crate::runtime::ExecutionRecord;
109

1110
/// A set of columns needed to compute the sum of five words.
1211
#[derive(AlignedBorrow, Default, Debug, Clone, Copy)]
@@ -38,7 +37,7 @@ impl<F: Field> Add5Operation<F> {
3837
#[allow(clippy::too_many_arguments)]
3938
pub fn populate(
4039
&mut self,
41-
record: &mut ExecutionRecord,
40+
record: &mut impl ByteRecord,
4241
shard: u32,
4342
a_u32: u32,
4443
b_u32: u32,

core/src/operations/and.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::bytes::event::ByteRecord;
77
use crate::bytes::ByteLookupEvent;
88
use crate::bytes::ByteOpcode;
99
use crate::disassembler::WORD_SIZE;
10-
use crate::runtime::ExecutionRecord;
1110

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

2019
impl<F: Field> AndOperation<F> {
21-
pub fn populate(&mut self, record: &mut ExecutionRecord, shard: u32, x: u32, y: u32) -> u32 {
20+
pub fn populate(&mut self, record: &mut impl ByteRecord, shard: u32, x: u32, y: u32) -> u32 {
2221
let expected = x & y;
2322
let x_bytes = x.to_le_bytes();
2423
let y_bytes = y.to_le_bytes();

core/src/operations/fixed_rotate_right.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use crate::bytes::utils::shr_carry;
88
use crate::bytes::ByteLookupEvent;
99
use crate::bytes::ByteOpcode;
1010
use crate::disassembler::WORD_SIZE;
11-
use crate::runtime::ExecutionRecord;
1211

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

4342
pub fn populate(
4443
&mut self,
45-
record: &mut ExecutionRecord,
44+
record: &mut impl ByteRecord,
4645
shard: u32,
4746
input: u32,
4847
rotation: usize,

core/src/operations/fixed_shift_right.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use crate::bytes::utils::shr_carry;
88
use crate::bytes::ByteLookupEvent;
99
use crate::bytes::ByteOpcode;
1010
use crate::disassembler::WORD_SIZE;
11-
use crate::runtime::ExecutionRecord;
1211

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

4342
pub fn populate(
4443
&mut self,
45-
record: &mut ExecutionRecord,
44+
record: &mut impl ByteRecord,
4645
shard: u32,
4746
input: u32,
4847
rotation: usize,

core/src/operations/not.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::air::Word;
77
use crate::bytes::event::ByteRecord;
88
use crate::bytes::ByteOpcode;
99
use crate::disassembler::WORD_SIZE;
10-
use crate::runtime::ExecutionRecord;
1110

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

2019
impl<F: Field> NotOperation<F> {
21-
pub fn populate(&mut self, record: &mut ExecutionRecord, shard: u32, x: u32) -> u32 {
20+
pub fn populate(&mut self, record: &mut impl ByteRecord, shard: u32, x: u32) -> u32 {
2221
let expected = !x;
2322
let x_bytes = x.to_le_bytes();
2423
for i in 0..WORD_SIZE {

core/src/operations/or.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use crate::air::Word;
66
use crate::bytes::event::ByteRecord;
77
use crate::bytes::ByteOpcode;
88
use crate::disassembler::WORD_SIZE;
9-
use crate::runtime::ExecutionRecord;
109

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

2120
impl<F: Field> OrOperation<F> {
22-
pub fn populate(&mut self, record: &mut ExecutionRecord, shard: u32, x: u32, y: u32) -> u32 {
21+
pub fn populate(&mut self, record: &mut impl ByteRecord, shard: u32, x: u32, y: u32) -> u32 {
2322
let expected = x | y;
2423
let x_bytes = x.to_le_bytes();
2524
let y_bytes = y.to_le_bytes();

core/src/operations/xor.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::bytes::event::ByteRecord;
77
use crate::bytes::ByteLookupEvent;
88
use crate::bytes::ByteOpcode;
99
use crate::disassembler::WORD_SIZE;
10-
use crate::runtime::ExecutionRecord;
1110

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

2019
impl<F: Field> XorOperation<F> {
21-
pub fn populate(&mut self, record: &mut ExecutionRecord, shard: u32, x: u32, y: u32) -> u32 {
20+
pub fn populate(&mut self, record: &mut impl ByteRecord, shard: u32, x: u32, y: u32) -> u32 {
2221
let expected = x ^ y;
2322
let x_bytes = x.to_le_bytes();
2423
let y_bytes = y.to_le_bytes();

core/src/syscall/precompiles/blake3/compress/g.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use sphinx_derive::AlignedBorrow;
44
use super::g_func;
55
use crate::{
66
air::{Word, WordAirBuilder, WORD_SIZE},
7+
bytes::event::ByteRecord,
78
operations::{AddOperation, FixedRotateRightOperation, XorOperation},
8-
runtime::ExecutionRecord,
99
};
1010
/// A set of columns needed to compute the `g` of the input state.
1111
/// ``` ignore
@@ -44,7 +44,7 @@ pub struct GOperation<T> {
4444
impl<F: Field> GOperation<F> {
4545
pub fn populate(
4646
&mut self,
47-
record: &mut ExecutionRecord,
47+
record: &mut impl ByteRecord,
4848
shard: u32,
4949
input: [u32; 6],
5050
) -> [u32; 4] {

0 commit comments

Comments
 (0)