Skip to content

Commit

Permalink
Revert "fix: Check if head exists before trying to unfail" (#5433)
Browse files Browse the repository at this point in the history
This reverts commit 2649a4e.
  • Loading branch information
mangas committed May 23, 2024
1 parent 1209443 commit 87bcd52
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
44 changes: 21 additions & 23 deletions core/src/subgraph/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,29 +175,27 @@ where
// revert the deployment head. It should lead to the same result since the error was
// deterministic.
if let Some(current_ptr) = self.inputs.store.block_ptr() {
let adapter = &self.inputs.triggers_adapter;
let is_on_main_chain = adapter.is_on_main_chain(current_ptr.cheap_clone()).await?;

// If the subgraph is not on the main chain, the first thing the block stream will do is
// revert the deployment head, and with it any errors.
if is_on_main_chain {
if let Some(parent_ptr) = adapter.parent_ptr(&current_ptr).await? {
// This reverts the deployment head to the parent_ptr if
// deterministic errors happened.
//
// There's no point in calling it if we have no current or parent block
// pointers, because there would be: no block to revert to or to search
// errors from (first execution).
//
// We attempt to unfail deterministic errors to mitigate deterministic
// errors caused by wrong data being consumed from the providers. It has
// been a frequent case in the past so this helps recover on a larger scale.
let _outcome = self
.inputs
.store
.unfail_deterministic_error(&current_ptr, &parent_ptr)
.await?;
}
if let Some(parent_ptr) = self
.inputs
.triggers_adapter
.parent_ptr(&current_ptr)
.await?
{
// This reverts the deployment head to the parent_ptr if
// deterministic errors happened.
//
// There's no point in calling it if we have no current or parent block
// pointers, because there would be: no block to revert to or to search
// errors from (first execution).
//
// We attempt to unfail deterministic errors to mitigate deterministic
// errors caused by wrong data being consumed from the providers. It has
// been a frequent case in the past so this helps recover on a larger scale.
let _outcome = self
.inputs
.store
.unfail_deterministic_error(&current_ptr, &parent_ptr)
.await?;
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/src/fixture/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ impl<C: Blockchain> TriggersAdapter<C> for MockTriggersAdapter<C> {
}

async fn is_on_main_chain(&self, _ptr: BlockPtr) -> Result<bool, Error> {
Ok(true)
todo!()
}

async fn parent_ptr(&self, block: &BlockPtr) -> Result<Option<BlockPtr>, Error> {
Expand Down

0 comments on commit 87bcd52

Please sign in to comment.