-
Notifications
You must be signed in to change notification settings - Fork 1
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
fix: add single and mapping struct to integration test for generic extraction (Part 4) #397
base: generic-extraction-row-id-update
Are you sure you want to change the base?
Changes from 12 commits
93c80de
a2c4cfc
d7607cf
51768ea
b33cd73
911aadb
6b8d4bc
e2b717c
302b17e
6155a66
051bf96
c21fe13
29fd77b
2d1aa8a
38d6d30
be3db69
973325d
c423611
50a58d9
f53f0ee
45deacf
8e1fb40
a22e6d7
47a5784
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ use crate::{ | |
use alloy::primitives::Address; | ||
use anyhow::Result; | ||
use itertools::Itertools; | ||
use log::debug; | ||
use mp2_common::{ | ||
digest::Digest, | ||
group_hashing::map_to_curve_point, | ||
|
@@ -209,15 +210,12 @@ pub enum SlotInputs { | |
MappingWithLength(Vec<SlotInput>, u8), | ||
} | ||
|
||
#[derive(Debug)] | ||
#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)] | ||
pub struct SlotInput { | ||
/// Slot information of the variable | ||
pub(crate) slot: u8, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is redundant information, can we extract it and put it separately ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, but I make this |
||
/// The offset in bytes where to extract this column in a given EVM word | ||
pub(crate) byte_offset: usize, | ||
/// The starting offset in `byte_offset` of the bits to be extracted for this column. | ||
/// The column bits will start at `byte_offset * 8 + bit_offset`. | ||
pub(crate) bit_offset: usize, | ||
/// The length (in bits) of the field to extract in the EVM word | ||
pub(crate) length: usize, | ||
/// At which EVM word is this column extracted from. For simple variables, | ||
|
@@ -229,30 +227,19 @@ pub struct SlotInput { | |
impl From<&ColumnInfo> for SlotInput { | ||
fn from(column_info: &ColumnInfo) -> Self { | ||
let slot = u8::try_from(column_info.slot.to_canonical_u64()).unwrap(); | ||
let [byte_offset, bit_offset, length] = [ | ||
column_info.byte_offset, | ||
column_info.bit_offset, | ||
column_info.length, | ||
] | ||
.map(|f| usize::try_from(f.to_canonical_u64()).unwrap()); | ||
let [byte_offset, length] = [column_info.byte_offset, column_info.length] | ||
.map(|f| usize::try_from(f.to_canonical_u64()).unwrap()); | ||
let evm_word = u32::try_from(column_info.evm_word.to_canonical_u64()).unwrap(); | ||
|
||
SlotInput::new(slot, byte_offset, bit_offset, length, evm_word) | ||
SlotInput::new(slot, byte_offset, length, evm_word) | ||
} | ||
} | ||
|
||
impl SlotInput { | ||
pub fn new( | ||
slot: u8, | ||
byte_offset: usize, | ||
bit_offset: usize, | ||
length: usize, | ||
evm_word: u32, | ||
) -> Self { | ||
pub fn new(slot: u8, byte_offset: usize, length: usize, evm_word: u32) -> Self { | ||
Self { | ||
slot, | ||
byte_offset, | ||
bit_offset, | ||
length, | ||
evm_word, | ||
} | ||
|
@@ -266,10 +253,6 @@ impl SlotInput { | |
self.byte_offset | ||
} | ||
|
||
pub fn bit_offset(&self) -> usize { | ||
self.bit_offset | ||
} | ||
|
||
pub fn length(&self) -> usize { | ||
self.length | ||
} | ||
|
@@ -338,7 +321,7 @@ fn value_metadata<const MAX_COLUMNS: usize, const MAX_FIELD_PER_EVM: usize>( | |
} | ||
|
||
/// Compute the table information for the value columns. | ||
fn compute_table_info( | ||
pub fn compute_table_info( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we are doing big changes, let's take a shot at having a better unified API. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, in commit c21fe13 I added the similar functions ( |
||
inputs: Vec<SlotInput>, | ||
address: &Address, | ||
chain_id: u64, | ||
|
@@ -353,7 +336,7 @@ fn compute_table_info( | |
input.slot, | ||
id, | ||
input.byte_offset, | ||
input.bit_offset, | ||
0, // bit_offset | ||
input.length, | ||
input.evm_word, | ||
) | ||
|
@@ -438,8 +421,16 @@ pub fn metadata_hash<const MAX_COLUMNS: usize, const MAX_FIELD_PER_EVM: usize>( | |
chain_id, | ||
extra, | ||
); | ||
// Correspond to the computation of final extraction base circuit. | ||
let value_digest = map_to_curve_point(&value_digest.to_fields()); | ||
nicholas-mainardi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// add contract digest | ||
let contract_digest = contract_metadata_digest(contract_address); | ||
debug!( | ||
"METADATA_HASH ->\n\tvalues_ext_md = {:?}\n\tcontract_md = {:?}\n\tfinal_ex_md(contract + values_ex) = {:?}", | ||
value_digest.to_weierstrass(), | ||
contract_digest.to_weierstrass(), | ||
(contract_digest + value_digest).to_weierstrass(), | ||
); | ||
// compute final hash | ||
combine_digest_and_block(contract_digest + value_digest) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SlotInput::new()
<-- now that we now there is no bitpacking level, then we can get rid of thebit_offset
argument and just set it to 0 for the moment, until we refactor the circuit to be simpler.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
bit_offset
in theSlotInput
and thenew
function in commit a2c4cfc.