Skip to content

Grafting issue #5917

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

Merged
merged 1 commit into from
Apr 2, 2025
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions graph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ serde_derive = { workspace = true }
serde_json = { workspace = true }
serde_regex = { workspace = true }
serde_yaml = { workspace = true }
sha2 = "0.10.8"
slog = { version = "2.7.0", features = [
"release_max_level_trace",
"max_level_trace",
Expand Down
14 changes: 11 additions & 3 deletions graph/src/components/subgraph/proof_of_indexing/online.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::{
prelude::{debug, BlockNumber, DeploymentHash, Logger, ENV_VARS},
util::stable_hash_glue::AsBytes,
};
use sha2::{Digest, Sha256};
use stable_hash::{fast::FastStableHasher, FieldAddress, StableHash, StableHasher};
use stable_hash_legacy::crypto::{Blake3SeqNo, SetHasher};
use stable_hash_legacy::prelude::{
Expand All @@ -31,6 +32,8 @@ enum Hashers {
Legacy(SetHasher),
}

const STABLE_HASH_LEN: usize = 32;

impl Hashers {
fn new(version: ProofOfIndexingVersion) -> Self {
match version {
Expand Down Expand Up @@ -132,9 +135,14 @@ impl BlockEventStream {
}
Hashers::Fast(mut digest) => {
if let Some(prev) = prev {
let prev = prev
.try_into()
.expect("Expected valid fast stable hash representation");
let prev = if prev.len() == STABLE_HASH_LEN {
prev.try_into()
.expect("Expected valid fast stable hash representation")
} else {
let mut hasher = Sha256::new();
hasher.update(prev);
hasher.finalize().into()
};
let prev = FastStableHasher::from_bytes(prev);
digest.mixin(&prev);
}
Expand Down
Loading