From 3ceda3145269c02c8039d9dbee6fce4e7d4e7186 Mon Sep 17 00:00:00 2001 From: Peter Zhang Date: Fri, 21 Nov 2025 16:29:51 +0800 Subject: [PATCH] add logs --- node/rpc/src/zgs/api.rs | 3 +++ node/rpc/src/zgs/impl.rs | 19 +++++++++++++++++++ node/storage/src/log_store/flow_store.rs | 4 ++-- node/storage/src/log_store/log_manager.rs | 1 + 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/node/rpc/src/zgs/api.rs b/node/rpc/src/zgs/api.rs index abc33ea..a3b0ac1 100644 --- a/node/rpc/src/zgs/api.rs +++ b/node/rpc/src/zgs/api.rs @@ -87,4 +87,7 @@ pub trait Rpc { #[method(name = "getFlowContext")] async fn get_flow_context(&self) -> RpcResult<(H256, u64)>; + + #[method(name = "getChunkByIndex")] + async fn get_chunk_by_index(&self, chunk_index: u64) -> RpcResult>>; } diff --git a/node/rpc/src/zgs/impl.rs b/node/rpc/src/zgs/impl.rs index cffc7fa..60b5eab 100644 --- a/node/rpc/src/zgs/impl.rs +++ b/node/rpc/src/zgs/impl.rs @@ -238,6 +238,25 @@ impl RpcServer for RpcServerImpl { async fn get_flow_context(&self) -> RpcResult<(H256, u64)> { Ok(self.ctx.log_store.get_context().await?) } + + async fn get_chunk_by_index(&self, chunk_index: u64) -> RpcResult>> { + debug!(%chunk_index, "zgs_getChunkByIndex"); + match self + .ctx + .log_store + .get_chunk_by_flow_index(chunk_index, 1) + .await? + { + Some(chunk_array) => { + if chunk_array.data.len() > 0 { + Ok(Some(chunk_array.data)) + } else { + Ok(None) + } + } + None => Ok(None), + } + } } impl RpcServerImpl { diff --git a/node/storage/src/log_store/flow_store.rs b/node/storage/src/log_store/flow_store.rs index 94d7863..cb1b248 100644 --- a/node/storage/src/log_store/flow_store.rs +++ b/node/storage/src/log_store/flow_store.rs @@ -236,7 +236,7 @@ impl FlowWrite for FlowStore { debug!( "Entry batch data at 12288 before insert: {:?}", - batch_data_12288.as_ssz_bytes() + batch_data_12288 ); let mut batch_list = Vec::new(); @@ -293,7 +293,7 @@ impl FlowWrite for FlowStore { debug!( "Entry batch data at 12288 after insert: {:?}", - batch_data_12288.as_ssz_bytes() + batch_data_12288 ); res diff --git a/node/storage/src/log_store/log_manager.rs b/node/storage/src/log_store/log_manager.rs index c3bdc0f..02058b9 100644 --- a/node/storage/src/log_store/log_manager.rs +++ b/node/storage/src/log_store/log_manager.rs @@ -1125,6 +1125,7 @@ impl LogManager { let chunk_roots = self.flow_store.append_entries(flow_entry_array)?; debug!("fill leaf for pora_chunks_merkle"); for (chunk_index, chunk_root) in chunk_roots { + debug!("fill leaf: chunk_index={}, chunk_root={:?}", chunk_index, chunk_root); if chunk_index < merkle.pora_chunks_merkle.leaves() as u64 { merkle .pora_chunks_merkle