Skip to content

Commit b9b021a

Browse files
committed
wip
1 parent 340ae91 commit b9b021a

File tree

3 files changed

+25
-26
lines changed

3 files changed

+25
-26
lines changed

crates/node/src/full/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl Node {
109109
let block_downloader = BatchBlockDownloader::new_gateway(gateway_client.clone(), 3);
110110
pipeline.add_stage(Blocks::new(provider.clone(), block_downloader));
111111
pipeline.add_stage(Classes::new(provider.clone(), gateway_client.clone(), 3));
112-
pipeline.add_stage(StateTrie::new(provider.clone()));
112+
// pipeline.add_stage(StateTrie::new(provider.clone()));
113113

114114
// --- build rpc server
115115

@@ -190,8 +190,6 @@ impl Node {
190190
}
191191

192192
pub async fn launch(self) -> Result<LaunchedNode> {
193-
println!("Launching node");
194-
195193
if let Some(ref cfg) = self.config.metrics {
196194
let reports: Vec<Box<dyn Report>> = vec![Box::new(self.db.clone()) as Box<dyn Report>];
197195
let exporter = PrometheusRecorder::current().expect("qed; should exist at this point");

crates/sync/pipeline/src/lib.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ use katana_provider_api::stage::StageCheckpointProvider;
7373
use katana_provider_api::ProviderError;
7474
use katana_stage::{Stage, StageExecutionInput, StageExecutionOutput};
7575
use tokio::sync::watch;
76-
use tracing::{debug, error, info, info_span, trace, Instrument};
76+
use tracing::{debug, error, info, info_span, trace, Instrument, Span};
7777

7878
/// The result of a pipeline execution.
7979
pub type PipelineResult<T> = Result<T, Error>;
@@ -254,13 +254,6 @@ impl<P: StageCheckpointProvider> Pipeline<P> {
254254
continue;
255255
}
256256
}
257-
258-
debug!(target: "pipeline", "Waiting for new command.");
259-
260-
// Wait for the next command
261-
if self.command_rx.changed().await.is_err() {
262-
break;
263-
}
264257
}
265258

266259
info!(target: "pipeline", "Pipeline finished.");
@@ -317,27 +310,29 @@ impl<P: StageCheckpointProvider> Pipeline<P> {
317310
let from = if checkpoint == 0 {
318311
checkpoint
319312
} else {
320-
// plus 1 because the checkpoint is inclusive
313+
// plus 1 because the checkpoint is the last block processed, so we need to start from the next block
321314
checkpoint + 1
322315
};
323316

324317
let input = StageExecutionInput::new(from, to);
325-
let span = info_span!(target: "pipeline", "execute", stage = %id, %from, %to);
318+
let span = info_span!(target: "pipeline", "stage.execute", stage = %id, %from, %to);
319+
let _guard = span.enter();
326320

327-
info!(target: "pipeline", %id, %from, %to, "Executing stage.");
321+
info!(target: "pipeline", stage = %id, %from, %to, "[{}/{}] Executing stage.", i + 1, last_stage_idx + 1);
328322

329323
let StageExecutionOutput { last_block_processed } =
330324
stage
331325
.execute(&input)
332-
.instrument(span)
326+
.instrument(Span::current())
333327
.await
334328
.map_err(|error| Error::StageExecution { id, error })?;
335329

330+
info!(target: "pipeline", stage = %id, %from, %to, "Stage execution completed.");
331+
336332

337333
self.provider.set_checkpoint(id, last_block_processed)?;
338334
last_block_processed_list.push(last_block_processed);
339-
340-
info!(target: "pipeline", %id, %from, %to, "Stage execution completed.");
335+
info!(target: "pipeline", stage = %id, checkpoint = %to, "New checkpoint set.");
341336
}
342337

343338
Ok(last_block_processed_list.into_iter().min().unwrap_or(to))

crates/sync/stage/src/blocks/mod.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use katana_primitives::Felt;
1414
use katana_provider::api::block::BlockWriter;
1515
use num_traits::ToPrimitive;
1616
use starknet::core::types::ResourcePrice;
17-
use tracing::debug;
17+
use tracing::{debug, error, trace};
1818

1919
use crate::{Stage, StageExecutionInput, StageExecutionOutput, StageResult};
2020

@@ -51,21 +51,27 @@ where
5151
.downloader
5252
.download_blocks(input.from(), input.to())
5353
.await
54-
.map_err(Error::Gateway)?;
54+
.map_err(Error::Gateway)
55+
.inspect_err(|e| error!(error = %e , "Error downloading blocks."))?;
5556

5657
if !blocks.is_empty() {
5758
debug!(target: "stage", id = %self.id(), total = %blocks.len(), "Storing blocks to storage.");
5859

5960
// Store blocks to storage
6061
for block in blocks {
6162
let (block, receipts, state_updates) = extract_block_data(block)?;
62-
63-
self.provider.insert_block_with_states_and_receipts(
64-
block,
65-
state_updates,
66-
receipts,
67-
Vec::new(),
68-
)?;
63+
let block_number = block.block.header.number;
64+
65+
self.provider
66+
.insert_block_with_states_and_receipts(
67+
block,
68+
state_updates,
69+
receipts,
70+
Vec::new(),
71+
)
72+
.inspect_err(
73+
|e| error!(error = %e, block = %block_number, "Error storing block."),
74+
)?;
6975
}
7076
}
7177

0 commit comments

Comments
 (0)