Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(torii): ensure torii doesn't stop on model processor fail #2093

Merged
merged 5 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies = [

[[package]]
name = "dojo"
version = "0.7.0"
version = "0.7.2"
dependencies = [
"dojo_plugin",
]
Expand Down
21 changes: 15 additions & 6 deletions crates/torii/core/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,12 @@ impl<P: Provider + Sync> Engine<P> {

async fn process_block(&mut self, block_number: u64, block_timestamp: u64) -> Result<()> {
for processor in &self.processors.block {
processor
if let Err(e) = processor
glihm marked this conversation as resolved.
Show resolved Hide resolved
.process(&mut self.db, self.provider.as_ref(), block_number, block_timestamp)
.await?;
.await
{
error!(target: LOG_TARGET, block_number, error = %e, "Processing block.");
}
}
Ok(())
}
Expand All @@ -420,7 +423,7 @@ impl<P: Provider + Sync> Engine<P> {
transaction: &Transaction,
) -> Result<()> {
for processor in &self.processors.transaction {
processor
if let Err(e) = processor
.process(
&mut self.db,
self.provider.as_ref(),
Expand All @@ -430,7 +433,10 @@ impl<P: Provider + Sync> Engine<P> {
transaction_hash,
transaction,
)
.await?
.await
{
error!(target: LOG_TARGET, transaction_hash = %format!("{:#x}", transaction_hash), error = %e, "Processing transaction.");
}
}

Ok(())
Expand All @@ -457,7 +463,7 @@ impl<P: Provider + Sync> Engine<P> {
|| get_selector_from_name(&processor.event_key())? == event.keys[0])
&& processor.validate(event)
{
processor
if let Err(e) = processor
.process(
&self.world,
&mut self.db,
Expand All @@ -467,7 +473,10 @@ impl<P: Provider + Sync> Engine<P> {
event_id,
event,
)
.await?;
.await
{
error!(target: LOG_TARGET, event_name = processor.event_key(), error = %e, "Processing event.");
}
} else {
let unprocessed_event = UnprocessedEvent {
keys: event.keys.iter().map(|k| format!("{:#x}", k)).collect(),
Expand Down
6 changes: 4 additions & 2 deletions crates/torii/core/src/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,10 @@ impl Sql {
}

pub async fn model(&self, model: &str) -> Result<ModelSQLReader> {
let reader = ModelSQLReader::new(model, self.pool.clone()).await?;
Ok(reader)
match ModelSQLReader::new(model, self.pool.clone()).await {
Ok(reader) => Ok(reader),
Err(e) => Err(anyhow::anyhow!("Failed to get model from db for selector {model}: {e}")),
}
}

pub async fn entity(&self, model: String, key: FieldElement) -> Result<Vec<FieldElement>> {
Expand Down
2 changes: 1 addition & 1 deletion examples/spawn-and-move/Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies = [

[[package]]
name = "dojo_examples"
version = "0.7.1"
version = "0.7.2"
dependencies = [
"dojo",
]
Expand Down
Loading