Skip to content

Commit a2c4cfc

Browse files
committed
Remove bit_offset in API.
1 parent 93c80de commit a2c4cfc

File tree

5 files changed

+15
-34
lines changed

5 files changed

+15
-34
lines changed

mp2-v1/src/api.rs

+5-23
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,6 @@ pub struct SlotInput {
216216
pub(crate) slot: u8,
217217
/// The offset in bytes where to extract this column in a given EVM word
218218
pub(crate) byte_offset: usize,
219-
/// The starting offset in `byte_offset` of the bits to be extracted for this column.
220-
/// The column bits will start at `byte_offset * 8 + bit_offset`.
221-
pub(crate) bit_offset: usize,
222219
/// The length (in bits) of the field to extract in the EVM word
223220
pub(crate) length: usize,
224221
/// At which EVM word is this column extracted from. For simple variables,
@@ -230,30 +227,19 @@ pub struct SlotInput {
230227
impl From<&ColumnInfo> for SlotInput {
231228
fn from(column_info: &ColumnInfo) -> Self {
232229
let slot = u8::try_from(column_info.slot.to_canonical_u64()).unwrap();
233-
let [byte_offset, bit_offset, length] = [
234-
column_info.byte_offset,
235-
column_info.bit_offset,
236-
column_info.length,
237-
]
238-
.map(|f| usize::try_from(f.to_canonical_u64()).unwrap());
230+
let [byte_offset, length] = [column_info.byte_offset, column_info.length]
231+
.map(|f| usize::try_from(f.to_canonical_u64()).unwrap());
239232
let evm_word = u32::try_from(column_info.evm_word.to_canonical_u64()).unwrap();
240233

241-
SlotInput::new(slot, byte_offset, bit_offset, length, evm_word)
234+
SlotInput::new(slot, byte_offset, length, evm_word)
242235
}
243236
}
244237

245238
impl SlotInput {
246-
pub fn new(
247-
slot: u8,
248-
byte_offset: usize,
249-
bit_offset: usize,
250-
length: usize,
251-
evm_word: u32,
252-
) -> Self {
239+
pub fn new(slot: u8, byte_offset: usize, length: usize, evm_word: u32) -> Self {
253240
Self {
254241
slot,
255242
byte_offset,
256-
bit_offset,
257243
length,
258244
evm_word,
259245
}
@@ -267,10 +253,6 @@ impl SlotInput {
267253
self.byte_offset
268254
}
269255

270-
pub fn bit_offset(&self) -> usize {
271-
self.bit_offset
272-
}
273-
274256
pub fn length(&self) -> usize {
275257
self.length
276258
}
@@ -354,7 +336,7 @@ pub fn compute_table_info(
354336
input.slot,
355337
id,
356338
input.byte_offset,
357-
input.bit_offset,
339+
0, // bit_offset
358340
input.length,
359341
input.evm_word,
360342
)

mp2-v1/src/values_extraction/gadgets/column_info.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl ColumnInfo {
6969
slot_input.slot,
7070
identifier,
7171
slot_input.byte_offset,
72-
slot_input.bit_offset,
72+
0, // bit_offset
7373
slot_input.length,
7474
slot_input.evm_word,
7575
)

mp2-v1/src/values_extraction/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub fn identifier_block_column() -> u64 {
102102
/// Compute identifier for value column.
103103
///
104104
/// The value column could be either simple or mapping slot.
105-
/// `id = H(slot || byte_offset || bit_offset || length || evm_word || contract_address || chain_id)[0]`
105+
/// `id = H(slot || byte_offset || length || evm_word || contract_address || chain_id)[0]`
106106
pub fn identifier_for_value_column(
107107
input: &SlotInput,
108108
contract_address: &Address,
@@ -111,7 +111,6 @@ pub fn identifier_for_value_column(
111111
) -> u64 {
112112
let inputs = once(input.slot)
113113
.chain(input.byte_offset.to_be_bytes())
114-
.chain(input.bit_offset.to_be_bytes())
115114
.chain(input.length.to_be_bytes())
116115
.chain(input.evm_word.to_be_bytes())
117116
.chain(contract_address.0.to_vec())

mp2-v1/tests/common/cases/indexing.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -994,10 +994,10 @@ impl LargeStruct {
994994

995995
pub fn slot_inputs(slot: u8) -> Vec<SlotInput> {
996996
vec![
997-
SlotInput::new(slot, 0, 0, 256, 0),
997+
SlotInput::new(slot, 0, 256, 0),
998998
// Big-endian layout
999-
SlotInput::new(slot, 16, 0, 128, 1),
1000-
SlotInput::new(slot, 0, 0, 128, 1),
999+
SlotInput::new(slot, 16, 128, 1),
1000+
SlotInput::new(slot, 0, 128, 1),
10011001
]
10021002
}
10031003

mp2-v1/tests/common/cases/table_source.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -416,13 +416,13 @@ impl SingleValuesExtractionArgs {
416416
pub fn slot_inputs() -> Vec<SlotInput> {
417417
vec![
418418
// bool
419-
SlotInput::new(SINGLE_SLOTS[0], 0, 0, 256, 0),
419+
SlotInput::new(SINGLE_SLOTS[0], 0, 256, 0),
420420
// uint256
421-
SlotInput::new(SINGLE_SLOTS[1], 0, 0, 256, 0),
421+
SlotInput::new(SINGLE_SLOTS[1], 0, 256, 0),
422422
// string
423-
SlotInput::new(SINGLE_SLOTS[2], 0, 0, 256, 0),
423+
SlotInput::new(SINGLE_SLOTS[2], 0, 256, 0),
424424
// address
425-
SlotInput::new(SINGLE_SLOTS[3], 0, 0, 256, 0),
425+
SlotInput::new(SINGLE_SLOTS[3], 0, 256, 0),
426426
]
427427
}
428428
pub fn table_info(contract: &Contract) -> Vec<ColumnInfo> {
@@ -656,7 +656,7 @@ impl MappingValuesExtractionArgs {
656656
}
657657
}
658658
pub fn slot_input() -> SlotInput {
659-
SlotInput::new(MAPPING_SLOT, 0, 0, 256, 0)
659+
SlotInput::new(MAPPING_SLOT, 0, 256, 0)
660660
}
661661
pub async fn init_contract_data(
662662
&mut self,

0 commit comments

Comments
 (0)