Description
Hi everyone,
I'm working on a custom Substrate-based blockchain where we've changed the default hashing algorithm from Blake2-256
to SHA3-256
. On the chain side, everything compiles, runs, and syncs correctly. However, we're facing issues when integrating with Polkadot JS API and the Polkadot JS Web UI (apps front-end).
Runtime Change
In the runtime/src/lib.rs
, we've done the following change:
/// A hash of some data used by the chain.
pub type Hash = H256;
/// The hashing algorithm used by the chain.
pub type Hashing = sha3_substrate_hashing::Sha3Hashing;
This ensures that all hashing in the runtime now uses SHA3-256 instead of the default Blake2.
The custom hasher (sha3_substrate_hashing::Sha3Hashing
) implements sp_core::Hasher
correctly.
Problem on Polkadot JS Frontend
When we connect to our custom chain using the Polkadot JS Apps frontend, we get this error on the block explorer page:
"Unable to retrieve the specified block details. Unable to retrieve header and parent from supplied hash"
This issue seems to stem from a mismatch between the expected hashing algorithm (Blake2) in Polkadot JS API and what our chain actually uses (SHA3).
Investigated So Far
- Chain metadata seems to fetch correctly.
- system_chain(), system_name(), and system_version() RPCs work fine.
- But when using api.rpc.chain.getHeader(hash) or viewing any block on the UI, it fails.
- We suspect the issue is with the way the API or UI hashes block numbers to get hashes, still expecting Blake2.
Related Info
- Chain spec includes correct Hashing = Sha3Hashing.
- Hash length (H256) remains standard.
- No exotic encoding, just different hashing.
Questions
- Is there a way to configure Polkadot JS API or Apps frontend to use SHA3-256 as the hashing algorithm?
- If not directly configurable, where in the Polkadot JS API repo should I look to patch this manually for now?
- Is there any support or prior work for using non-default hashers (e.g., SHA3) with the Polkadot JS ecosystem?
Any guidance or pointers would be really appreciated. Thanks in advance!