fix: debug updates on node-sequencer synchronization

This commit is contained in:
Oleksandr Pravdyvyi
2024-12-29 14:11:47 +02:00
parent 1ce6141cc1
commit 90da8b45f4
19 changed files with 158 additions and 30 deletions
+2
View File
@@ -12,4 +12,6 @@ pub struct NodeConfig {
pub sequencer_addr: String,
///Sequencer polling duration for new blocks in seconds
pub seq_poll_timeout_secs: u64,
///Port to listen
pub port: u16,
}
+4
View File
@@ -72,6 +72,8 @@ impl NodeCore {
let client = Arc::new(SequencerClient::new(config.clone())?);
let genesis_id = client.get_genesis_id().await?;
info!("Gesesis id is {genesis_id:?}");
let genesis_block = client.get_block(genesis_id.genesis_id).await?.block;
let mut storage = NodeChainStore::new_with_genesis(&config.home, genesis_block);
@@ -84,6 +86,7 @@ impl NodeCore {
if let Ok(block) = client.get_block(next_block).await {
storage.dissect_insert_block(block.block)?;
info!("Preprocessed block with id {next_block:?}");
} else {
break;
}
@@ -107,6 +110,7 @@ impl NodeCore {
let mut storage_guard = wrapped_storage_thread.write().await;
storage_guard.dissect_insert_block(block.block)?;
info!("Processed block with id {next_block:?}");
}
wrapped_chain_height_thread.store(next_block, Ordering::Relaxed);
+8
View File
@@ -67,3 +67,11 @@ impl SequencerRpcRequest {
}
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct SequencerRpcResponse {
pub jsonrpc: String,
pub result: serde_json::Value,
pub id: u64,
}
+6 -6
View File
@@ -3,7 +3,7 @@ use anyhow::Result;
use json::{
GetBlockDataRequest, GetBlockDataResponse, GetGenesisIdRequest, GetGenesisIdResponse,
RegisterAccountRequest, RegisterAccountResponse, SendTxRequest, SendTxResponse,
SequencerRpcRequest,
SequencerRpcRequest, SequencerRpcResponse,
};
use k256::elliptic_curve::group::GroupEncoding;
use reqwest::Client;
@@ -62,9 +62,9 @@ impl SequencerClient {
let call_res = call_builder.json(&request).send().await?;
let response = call_res.json::<Value>().await?;
let response = call_res.json::<SequencerRpcResponse>().await?;
Ok(response)
Ok(response.result)
}
pub async fn get_block(
@@ -121,11 +121,11 @@ impl SequencerClient {
pub async fn get_genesis_id(&self) -> Result<GetGenesisIdResponse, SequencerClientError> {
let genesis_req = GetGenesisIdRequest {};
let req = serde_json::to_value(genesis_req)?;
let req = serde_json::to_value(genesis_req).unwrap();
let resp = self.call_method_with_payload("get_genesis", req).await?;
let resp = self.call_method_with_payload("get_genesis", req).await.unwrap();
let resp_deser = serde_json::from_value(resp)?;
let resp_deser = serde_json::from_value(resp).unwrap();
Ok(resp_deser)
}