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

graph: Disallow grafts within the reorg threshold #5135

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Changes from all 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
13 changes: 13 additions & 0 deletions graph/src/data/subgraph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,19 @@ impl Graft {
"failed to graft onto `{}` at block {} since it has only processed block {}",
self.base, self.block, ptr.number
))),
// The graft point must be at least `reorg_threshold` blocks
// behind the subgraph head so that a reorg can not affect the
// data that we copy for grafting
//
// This is pretty nasty: we have tests in the subgraph runner
// tests that graft onto the subgraph head directly. We
// therefore skip this check in debug builds and only turn it on
// in release builds
#[cfg(not(debug_assertions))]
(Some(ptr), true) if self.block + ENV_VARS.reorg_threshold >= ptr.number => Err(GraftBaseInvalid(format!(
"failed to graft onto `{}` at block {} since it's only at block {} which is within the reorg threshold of {} blocks",
self.base, self.block, ptr.number, ENV_VARS.reorg_threshold
))),
// If the base deployment is failed *and* the `graft.block` is not
// less than the `base.block`, the graft shouldn't be permitted.
//
Expand Down
Loading