@@ -102,19 +102,34 @@ 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 || length || evm_word || contract_address || chain_id)[0]`
105+ /// `id = H(slot || byte_offset || length || evm_word || contract_address || chain_id || extra )[0]`
106106pub fn identifier_for_value_column (
107107 input : & SlotInput ,
108108 contract_address : & Address ,
109109 chain_id : u64 ,
110110 extra : Vec < u8 > ,
111111) -> u64 {
112+ let extra = contract_address
113+ . 0
114+ . into_iter ( )
115+ . chain ( chain_id. to_be_bytes ( ) )
116+ . chain ( extra)
117+ . collect_vec ( ) ;
118+
119+ identifier_for_value_column_raw ( input, extra)
120+ }
121+
122+ /// Compute identifier for value column in raw mode.
123+ /// The value column could be either simple or mapping slot.
124+ /// `id = H(slot || byte_offset || length || evm_word || extra)[0]`
125+ ///
126+ /// We could custom the `extra` argument, if it's set to `(contract_address || chain_id || extra)`,
127+ /// It's same with `identifier_for_mapping_key_column`.
128+ pub fn identifier_for_value_column_raw ( input : & SlotInput , extra : Vec < u8 > ) -> u64 {
112129 let inputs = once ( input. slot )
113130 . chain ( input. byte_offset . to_be_bytes ( ) )
114131 . chain ( input. length . to_be_bytes ( ) )
115132 . chain ( input. evm_word . to_be_bytes ( ) )
116- . chain ( contract_address. 0 . to_vec ( ) )
117- . chain ( chain_id. to_be_bytes ( ) )
118133 . chain ( extra)
119134 . map ( F :: from_canonical_u8)
120135 . collect_vec ( ) ;
@@ -133,6 +148,15 @@ pub fn identifier_for_mapping_key_column(
133148 compute_id_with_prefix ( KEY_ID_PREFIX , slot, contract_address, chain_id, extra)
134149}
135150
151+ /// Compute key indetifier for mapping variable in raw mode.
152+ /// `key_id = H(KEY || slot || contract_address || chain_id)[0]`
153+ ///
154+ /// We could custom the `extra` argument, if it's set to `(contract_address || chain_id || extra)`,
155+ /// It's same with `identifier_for_mapping_key_column`.
156+ pub fn identifier_for_mapping_key_column_raw ( slot : u8 , extra : Vec < u8 > ) -> u64 {
157+ compute_id_with_prefix_raw ( KEY_ID_PREFIX , slot, extra)
158+ }
159+
136160/// Compute outer key indetifier for mapping of mappings variable.
137161/// `outer_key_id = H(OUT_KEY || slot || contract_address || chain_id)[0]`
138162pub fn identifier_for_outer_mapping_key_column (
@@ -144,6 +168,14 @@ pub fn identifier_for_outer_mapping_key_column(
144168 compute_id_with_prefix ( OUTER_KEY_ID_PREFIX , slot, contract_address, chain_id, extra)
145169}
146170
171+ /// Compute outer key indetifier for mapping of mappings variable in raw mode.
172+ /// `outer_key_id = H(OUT_KEY || slot || contract_address || chain_id)[0]`
173+ ///
174+ /// We could custom the `extra` argument, if it's set to `(contract_address || chain_id || extra)`,
175+ /// It's same with `identifier_for_outer_mapping_key_column`.
176+ pub fn identifier_for_outer_mapping_key_column_raw ( slot : u8 , extra : Vec < u8 > ) -> u64 {
177+ compute_id_with_prefix_raw ( OUTER_KEY_ID_PREFIX , slot, extra)
178+ }
147179/// Compute inner key indetifier for mapping of mappings variable.
148180/// `inner_key_id = H(IN_KEY || slot || contract_address || chain_id)[0]`
149181pub fn identifier_for_inner_mapping_key_column (
@@ -155,6 +187,15 @@ pub fn identifier_for_inner_mapping_key_column(
155187 compute_id_with_prefix ( INNER_KEY_ID_PREFIX , slot, contract_address, chain_id, extra)
156188}
157189
190+ /// Compute inner key indetifier for mapping of mappings variable in raw mode.
191+ /// `inner_key_id = H(IN_KEY || slot || extra)[0]`
192+ ///
193+ /// We could custom the `extra` argument, if it's set to `(contract_address || chain_id || extra)`,
194+ /// It's same with `identifier_for_inner_mapping_key_column`.
195+ pub fn identifier_for_inner_mapping_key_column_raw ( slot : u8 , extra : Vec < u8 > ) -> u64 {
196+ compute_id_with_prefix_raw ( INNER_KEY_ID_PREFIX , slot, extra)
197+ }
198+
158199/// Calculate ID with prefix.
159200fn compute_id_with_prefix (
160201 prefix : & [ u8 ] ,
@@ -163,14 +204,27 @@ fn compute_id_with_prefix(
163204 chain_id : u64 ,
164205 extra : Vec < u8 > ,
165206) -> u64 {
207+ let extra = contract_address
208+ . 0
209+ . into_iter ( )
210+ . chain ( chain_id. to_be_bytes ( ) )
211+ . chain ( extra)
212+ . collect_vec ( ) ;
213+
214+ compute_id_with_prefix_raw ( prefix, slot, extra)
215+ }
216+
217+ /// Calculate ID with prefix in raw mode.
218+ ///
219+ /// We could custom the `extra` argument, if it's set to `(contract_address || chain_id || extra)`,
220+ /// It's same with `compute_id_with_prefix`.
221+ fn compute_id_with_prefix_raw ( prefix : & [ u8 ] , slot : u8 , extra : Vec < u8 > ) -> u64 {
166222 let inputs: Vec < F > = prefix
167223 . iter ( )
168224 . cloned ( )
169225 . chain ( once ( slot) )
170- . chain ( contract_address. 0 )
171- . chain ( chain_id. to_be_bytes ( ) )
172226 . chain ( extra)
173- . collect :: < Vec < u8 > > ( )
227+ . collect_vec ( )
174228 . to_fields ( ) ;
175229
176230 H :: hash_no_pad ( & inputs) . elements [ 0 ] . to_canonical_u64 ( )
0 commit comments