Skip to content

Commit c1818a8

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 434aec7 commit c1818a8

File tree

11 files changed

+12
-35
lines changed

11 files changed

+12
-35
lines changed

core/src/operations/add.rs

Lines changed: 1 addition & 4 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};
@@ -19,9 +18,7 @@ pub struct AddOperation<T> {
1918

2019
impl<F: Field> AddOperation<F> {
2120
pub fn populate(
22-
&mut self,
23-
record: &mut ExecutionRecord,
24-
shard: u32,
21+
&mut self, record: &mut impl ByteRecord, shard: u32,
2522
a_u32: u32,
2623
b_u32: u32,
2724
) -> u32 {

core/src/operations/add4.rs

Lines changed: 1 addition & 4 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)]
@@ -33,9 +32,7 @@ pub struct Add4Operation<T> {
3332

3433
impl<F: Field> Add4Operation<F> {
3534
pub fn populate(
36-
&mut self,
37-
record: &mut ExecutionRecord,
38-
shard: u32,
35+
&mut self, record: &mut impl ByteRecord, shard: u32,
3936
a_u32: u32,
4037
b_u32: u32,
4138
c_u32: u32,

core/src/operations/add5.rs

Lines changed: 1 addition & 4 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)]
@@ -37,9 +36,7 @@ pub struct Add5Operation<T> {
3736
impl<F: Field> Add5Operation<F> {
3837
#[allow(clippy::too_many_arguments)]
3938
pub fn populate(
40-
&mut self,
41-
record: &mut ExecutionRecord,
42-
shard: u32,
39+
&mut self, record: &mut impl ByteRecord, shard: u32,
4340
a_u32: u32,
4441
b_u32: u32,
4542
c_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 & 4 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
///
@@ -41,9 +40,7 @@ impl<F: Field> FixedRotateRightOperation<F> {
4140
}
4241

4342
pub fn populate(
44-
&mut self,
45-
record: &mut ExecutionRecord,
46-
shard: u32,
43+
&mut self, record: &mut impl ByteRecord, shard: u32,
4744
input: u32,
4845
rotation: usize,
4946
) -> u32 {

core/src/operations/fixed_shift_right.rs

Lines changed: 1 addition & 4 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
///
@@ -41,9 +40,7 @@ impl<F: Field> FixedShiftRightOperation<F> {
4140
}
4241

4342
pub fn populate(
44-
&mut self,
45-
record: &mut ExecutionRecord,
46-
shard: u32,
43+
&mut self, record: &mut impl ByteRecord, shard: u32,
4744
input: u32,
4845
rotation: usize,
4946
) -> u32 {

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 & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ use sphinx_derive::AlignedBorrow;
33

44
use super::g_func;
55
use crate::{
6-
air::{Word, WordAirBuilder, WORD_SIZE},
7-
operations::{AddOperation, FixedRotateRightOperation, XorOperation},
8-
runtime::ExecutionRecord,
6+
air::{Word, WordAirBuilder, WORD_SIZE}, bytes::event::ByteRecord, operations::{AddOperation, FixedRotateRightOperation, XorOperation}
97
};
108
/// A set of columns needed to compute the `g` of the input state.
119
/// ``` ignore
@@ -43,9 +41,7 @@ pub struct GOperation<T> {
4341

4442
impl<F: Field> GOperation<F> {
4543
pub fn populate(
46-
&mut self,
47-
record: &mut ExecutionRecord,
48-
shard: u32,
44+
&mut self, record: &mut impl ByteRecord, shard: u32,
4945
input: [u32; 6],
5046
) -> [u32; 4] {
5147
let mut a = input[0];

0 commit comments

Comments
 (0)