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

syn: Remove bpf target support in hash feature #3078

Conversation

acheroncrypto
Copy link
Collaborator

Problem

anchor-syn is used for code parsing and generation, but we also have hash feature that has bpf target related code:

anchor/lang/syn/src/hash.rs

Lines 101 to 116 in 0a1d458

// Call via a system call to perform the calculation
#[cfg(target_arch = "bpf")]
{
extern "C" {
fn sol_sha256(vals: *const u8, val_len: u64, hash_result: *mut u8) -> u64;
}
let mut hash_result = [0; HASH_BYTES];
unsafe {
sol_sha256(
vals as *const _ as *const u8,
vals.len() as u64,
&mut hash_result as *mut _ as *mut u8,
);
}
Hash::new_from_array(hash_result)
}

This whole module was copied from solana_program::hash, which is likely why bpf related code wasn't removed. On-chain hashing should be done using solana_program::hash, which has the exact same functionality.

Also, bpf target arch has been deprecated as mentioned in #3062 (comment).

Summary of changes

Remove bpf target arch related code.

Copy link

vercel bot commented Jul 10, 2024

@acheroncrypto is attempting to deploy a commit to the coral-xyz Team on Vercel.

A member of the Team first needs to authorize it.

@acheroncrypto acheroncrypto merged commit fd6174a into coral-xyz:master Jul 11, 2024
48 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant