Skip to content
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
35 changes: 22 additions & 13 deletions Cargo.lock

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

13 changes: 6 additions & 7 deletions src/chain/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use crate::{error::QuantusError, log_verbose};
use jsonrpsee::ws_client::{WsClient, WsClientBuilder};
use qp_dilithium_crypto::types::DilithiumSignatureScheme;
use qp_poseidon::PoseidonHasher;
use sp_core::{crypto::AccountId32, ByteArray};
use sp_runtime::{traits::IdentifyAccount, MultiAddress};
use std::{sync::Arc, time::Duration};
Expand All @@ -18,17 +17,17 @@ use subxt::{
use subxt_metadata::Metadata as SubxtMetadata;

#[derive(Debug, Clone, Copy)]
pub struct SubxtPoseidonHasher;
pub struct SubxtBlake2bHasher;

impl subxt::config::Hasher for SubxtPoseidonHasher {
impl subxt::config::Hasher for SubxtBlake2bHasher {
type Output = sp_core::H256;

fn new(_metadata: &SubxtMetadata) -> Self {
SubxtPoseidonHasher
SubxtBlake2bHasher
}

fn hash(&self, bytes: &[u8]) -> Self::Output {
<PoseidonHasher as sp_runtime::traits::Hash>::hash(bytes)
<sp_runtime::traits::BlakeTwo256 as sp_runtime::traits::Hash>::hash(bytes)
}
}

Expand All @@ -38,8 +37,8 @@ impl Config for ChainConfig {
type AccountId = AccountId32;
type Address = MultiAddress<Self::AccountId, ()>;
type Signature = DilithiumSignatureScheme;
type Hasher = SubxtPoseidonHasher;
type Header = SubstrateHeader<u32, SubxtPoseidonHasher>;
type Hasher = SubxtBlake2bHasher;
type Header = SubstrateHeader<u32, SubxtBlake2bHasher>;
type AssetId = u32;
type ExtrinsicParams = DefaultExtrinsicParams<Self>;
}
Expand Down
6 changes: 3 additions & 3 deletions src/cli/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use crate::{
};
use clap::Subcommand;
use colored::Colorize;
use qp_poseidon::PoseidonHasher;
use sp_core::crypto::Ss58Codec;
use sp_runtime::traits::Hash;
use std::str::FromStr;
use subxt::events::EventDetails;

Expand Down Expand Up @@ -706,8 +706,8 @@ fn summarize_extrinsic(ext_hex: &str) -> (usize, String, String) {
(ext_str.as_bytes().to_vec(), ext_str.len())
};

// Compute extrinsic hash using Poseidon (chain hasher)
let h = <PoseidonHasher as sp_runtime::traits::Hash>::hash(&bytes);
// Compute extrinsic hash using Blake2b (chain hasher)
let h = sp_runtime::traits::BlakeTwo256::hash(&bytes);
let hash_hex = format!("{h:#x}");

let preview = if ext_str.len() > 20 { ext_str[..20].to_string() } else { ext_str.to_string() };
Expand Down
Loading