Skip to content

sha256-hasher: Deprecate extend_and_hash#250

Merged
joncinque merged 1 commit intoanza-xyz:masterfrom
joncinque:dep-extend-and-hash
Jul 25, 2025
Merged

sha256-hasher: Deprecate extend_and_hash#250
joncinque merged 1 commit intoanza-xyz:masterfrom
joncinque:dep-extend-and-hash

Conversation

@joncinque
Copy link
Copy Markdown
Collaborator

Problem

As noted in anza-xyz/agave#7028, the extend_and_hash function is unnecessary and creates another allocation, so we inlined it in Agave.

Summary of changes

Deprecate it formally in the crate. This PR will be backported to v2.x and published, so we can remove the function in a follow-up PR.

#### Problem

As noted in anza-xyz/agave#7028, the
`extend_and_hash` function is unnecessary and creates another
allocation, so we inlined it in Agave.

#### Summary of changes

Deprecate it formally in the crate. This PR will be backported to v2.x
and published, so we can remove the function in a follow-up PR.
@joncinque joncinque requested a review from febo July 25, 2025 10:30
Comment thread sha256-hasher/src/lib.rs

/// Return the hash of the given hash extended with the given value.
#[deprecated(since = "2.3.0", note = "Use `hashv(&[hash.as_ref(), val])` directly")]
pub fn extend_and_hash(id: &Hash, val: &[u8]) -> Hash {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to replace the implementation with hashv(&[id.as_ref(), &val]) given that it is what people should be doing directly?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. If there were more users of this function, we probably should. But in this case, I'm happier to limit the API surface 😅

Copy link
Copy Markdown
Contributor

@febo febo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just left a comment that might not be applicable.

@joncinque joncinque added the backport maintenance/v2.x Automatically creates a backport PR to `maintenance/v2.x` once the PR is closed label Jul 25, 2025
@joncinque joncinque merged commit 75f6556 into anza-xyz:master Jul 25, 2025
26 checks passed
@joncinque joncinque deleted the dep-extend-and-hash branch July 25, 2025 10:52
@github-actions
Copy link
Copy Markdown
Contributor

The backport to maintenance/v2.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-maintenance/v2.x maintenance/v2.x
# Navigate to the new working tree
cd .worktrees/backport-maintenance/v2.x
# Create a new branch
git switch --create backport-250-to-maintenance/v2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 75f6556dfdaad065e3077c4bd2f29390d0764aed
# Push it to GitHub
git push --set-upstream origin backport-250-to-maintenance/v2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-maintenance/v2.x

Then, create a pull request where the base branch is maintenance/v2.x and the compare/head branch is backport-250-to-maintenance/v2.x.

@joncinque
Copy link
Copy Markdown
Collaborator Author

Eh, I'll just do the backport manually then.

febo pushed a commit to febo/solana-sdk that referenced this pull request Sep 21, 2025
#### Problem

As noted in anza-xyz/agave#7028, the
`extend_and_hash` function is unnecessary and creates another
allocation, so we inlined it in Agave.

#### Summary of changes

Deprecate it formally in the crate. This PR will be backported to v2.x
and published, so we can remove the function in a follow-up PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport maintenance/v2.x Automatically creates a backport PR to `maintenance/v2.x` once the PR is closed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants