From deaf224d0f5bd6023aed3423fc7c1bdb67b9a39d Mon Sep 17 00:00:00 2001 From: Peilun Li Date: Fri, 6 Sep 2024 17:53:21 +0800 Subject: [PATCH] nit. --- node/storage/src/log_store/load_chunk/mod.rs | 30 ++++++-------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/node/storage/src/log_store/load_chunk/mod.rs b/node/storage/src/log_store/load_chunk/mod.rs index 30af81a..f62fe7c 100644 --- a/node/storage/src/log_store/load_chunk/mod.rs +++ b/node/storage/src/log_store/load_chunk/mod.rs @@ -6,13 +6,13 @@ mod serde; use ::serde::{Deserialize, Serialize}; use std::cmp::min; -use anyhow::{bail, Result}; +use anyhow::Result; use ethereum_types::H256; use ssz_derive::{Decode, Encode}; use crate::log_store::log_manager::data_to_merkle_leaves; use crate::try_option; -use append_merkle::MerkleTreeRead; +use append_merkle::{Algorithm, MerkleTreeRead, Sha3Algorithm}; use shared_types::{ChunkArray, DataRoot, Merkle}; use tracing::trace; use zgs_spec::{ @@ -244,15 +244,6 @@ impl EntryBatch { for subtree in self.data.get_subtree_list() { trace!(?subtree, "get subtree, leaves={}", merkle.leaves()); if subtree.start_sector != merkle.leaves() { - println!( - "start_sector={} leaves={}", - subtree.start_sector, - merkle.leaves() - ); - let subtree_size = 1 << (subtree.subtree_height - 1); - if subtree.start_sector % subtree_size != 0 { - bail!("error"); - } let leaf_data = try_option!( self.get_unsealed_data(merkle.leaves(), subtree.start_sector - merkle.leaves()) ); @@ -267,13 +258,13 @@ impl EntryBatch { merkle.append_list(data_to_merkle_leaves(&leaf_data).expect("aligned")); } // TODO(zz): Optimize. - // for index in 0..merkle.leaves() { - // if merkle.leaf_at(index)?.is_none() { - // if let Some(leaf_data) = self.get_unsealed_data(index, 1) { - // merkle.fill_leaf(index, Sha3Algorithm::leaf(&leaf_data)); - // } - // } - // } + for index in 0..merkle.leaves() { + if merkle.leaf_at(index)?.is_none() { + if let Some(leaf_data) = self.get_unsealed_data(index, 1) { + merkle.fill_leaf(index, Sha3Algorithm::leaf(&leaf_data)); + } + } + } Ok(Some(merkle)) } } @@ -281,9 +272,6 @@ impl EntryBatch { #[cfg(test)] mod tests { use super::{EntryBatch, SealAnswer}; - use crate::log_store::load_chunk::chunk_data::EntryBatchData::Incomplete; - use crate::log_store::load_chunk::chunk_data::{IncompleteData, PartialBatch, Subtree}; - use append_merkle::MerkleTreeRead; use ethereum_types::H256; use zgs_spec::{ BYTES_PER_SEAL, BYTES_PER_SECTOR, SEALS_PER_LOAD, SECTORS_PER_LOAD, SECTORS_PER_SEAL,