Skip to content

Commit

Permalink
mmr id temp fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rkdud007 committed Sep 12, 2024
1 parent b1f5278 commit cb07d56
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 20 deletions.
2 changes: 1 addition & 1 deletion hdp/src/preprocessor/compile/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl Compilable for ModuleVec {

// TODO : need fix
let compiled_result = CompilationResult::new(
1,
11155111,
commit_results_maps,
mmr_header_map,
accounts,
Expand Down
10 changes: 3 additions & 7 deletions hdp/src/primitives/processed_types/mmr.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};

use crate::primitives::{block::header::MMRMetaFromNewIndexer, utils::hex_string_to_uint, ChainId};
use crate::primitives::{block::header::MMRMetaFromNewIndexer, utils::hex_string_to_uint};

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Eq, Hash)]
pub struct MMRMeta {
Expand All @@ -9,29 +9,26 @@ pub struct MMRMeta {
pub size: u64,
// hex encoded
pub peaks: Vec<String>,
pub chain_id: u128,
}

impl MMRMeta {
pub fn new(id: u64, root: String, size: u64, peaks: Vec<String>, chain_id: u128) -> Self {
pub fn new(id: u64, root: String, size: u64, peaks: Vec<String>) -> Self {
MMRMeta {
id,
root,
size,
peaks,
chain_id,
}
}
}

impl MMRMeta {
pub fn from_indexer(val: MMRMetaFromNewIndexer, chain_id: ChainId) -> Self {
pub fn from_indexer(val: MMRMetaFromNewIndexer) -> Self {
MMRMeta {
id: hex_string_to_uint(&val.mmr_id),
root: val.mmr_root,
size: val.mmr_size,
peaks: val.mmr_peaks,
chain_id: chain_id.to_numeric_id(),
}
}
}
Expand Down Expand Up @@ -61,7 +58,6 @@ mod tests {
"0x66c82fce8bfc291095c6c9255b1f7ccf725a1e91e8ae8cd8c43ceb111c21480".to_string(),
"0x2e5274895f9cd556bb8dee5b2551e9cda9aa3caa23532f9824abcc62d5ad273".to_string(),
],
11155111,
);

let processed_string = include_str!("../../../../fixtures/primitives/mmr.json");
Expand Down
4 changes: 2 additions & 2 deletions hdp/src/provider/evm/from_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl EvmProvider {
self._chunk_vec_blocks_for_indexer(block_range)
};

let chain_id = keys.iter().next().unwrap().chain_id;
// let chain_id = keys.iter().next().unwrap().chain_id;
let mut fetched_headers_proofs: HashMap<MMRMeta, HashSet<ProcessedHeader>> = HashMap::new();

let real_target_blocks = keys.iter().map(|x| x.block_number).collect::<HashSet<_>>();
Expand Down Expand Up @@ -111,7 +111,7 @@ impl EvmProvider {
.collect();

let fetched_mmr = indexer_response.mmr_meta;
let mmr_meta = MMRMeta::from_indexer(fetched_mmr, chain_id);
let mmr_meta = MMRMeta::from_indexer(fetched_mmr);
fetched_headers_proofs
.entry(mmr_meta)
.and_modify(|existing_headers| {
Expand Down
2 changes: 1 addition & 1 deletion hdp/src/provider/evm/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl EvmProvider {
.get_headers_proof(start_block, end_block)
.await?;
let fetched_mmr = indexer_response.mmr_meta;
let mmr_meta = MMRMeta::from_indexer(fetched_mmr, self.header_provider.chain_id);
let mmr_meta = MMRMeta::from_indexer(fetched_mmr);

// TODO lets think how not clone the mmr_meta
fetched_headers_proofs_with_blocks_map.extend(
Expand Down
43 changes: 34 additions & 9 deletions input.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"result_root": "0x34b46123c4ab406cec0586364d8ed193353f0e9fb1b32cac0988fc0970dc50a2",
"proofs": [
{
"chain_id": 11155111,
"chain_id": 1,
"mmr_with_headers": [
{
"mmr_meta": {
Expand All @@ -23,8 +23,7 @@
"0x5f3202e8d32391896022ddb916b83f165d2d7486261304f3e029aad6258ba2c",
"0x3a98faad3cc3bdeee0f2a346469fe4e67d364c98f8f5adf03f472000194081c",
"0x48bb57587a1e690409d81b70f3fe2ee625f25f008ec0773e55a0e1293c9e025"
],
"chain_id": 11155111
]
},
"headers": [
{
Expand Down Expand Up @@ -135,12 +134,25 @@
],
"accounts": [
{
"address": ["0x5d89d5862ca7e8af", "0x36b7d426ab6d61d6", "0x2f4722cf"],
"address": [
"0x5d89d5862ca7e8af",
"0x36b7d426ab6d61d6",
"0x2f4722cf"
],
"account_key": "0x7fd6daf0de598ff611452d8eb4ec5f7e99e8ef74d175073be14cdc936830b5d3",
"proofs": [
{
"block_number": 6375109,
"proof_bytes_len": [532, 532, 532, 532, 532, 404, 83, 104],
"proof_bytes_len": [
532,
532,
532,
532,
532,
404,
83,
104
],
"proof": [
[
"0x444e529da01102f9",
Expand Down Expand Up @@ -575,13 +587,26 @@
],
"storages": [
{
"address": ["0x5d89d5862ca7e8af", "0x36b7d426ab6d61d6", "0x2f4722cf"],
"slot": ["0x0", "0x0", "0x0", "0x1000000000000000"],
"address": [
"0x5d89d5862ca7e8af",
"0x36b7d426ab6d61d6",
"0x2f4722cf"
],
"slot": [
"0x0",
"0x0",
"0x0",
"0x1000000000000000"
],
"storage_key": "0x1b6847dc741a1b0cd08d278845f9d819d87b734759afb55fe2de5cb82a9ae672",
"proofs": [
{
"block_number": 6375109,
"proof_bytes_len": [532, 83, 69],
"proof_bytes_len": [
532,
83,
69
],
"proof": [
[
"0xdaaaa563a01102f9",
Expand Down Expand Up @@ -752,4 +777,4 @@
}
}
]
}
}

0 comments on commit cb07d56

Please sign in to comment.