Merklize PoH TX mixin hash (#4644)
This commit is contained in:
parent
c5e6ebb496
commit
f20ba423ca
|
@ -2201,6 +2201,7 @@ dependencies = [
|
||||||
"solana-exchange-program 0.17.0",
|
"solana-exchange-program 0.17.0",
|
||||||
"solana-kvstore 0.17.0",
|
"solana-kvstore 0.17.0",
|
||||||
"solana-logger 0.17.0",
|
"solana-logger 0.17.0",
|
||||||
|
"solana-merkle-tree 0.17.0",
|
||||||
"solana-metrics 0.17.0",
|
"solana-metrics 0.17.0",
|
||||||
"solana-netutil 0.17.0",
|
"solana-netutil 0.17.0",
|
||||||
"solana-runtime 0.17.0",
|
"solana-runtime 0.17.0",
|
||||||
|
|
|
@ -55,6 +55,7 @@ solana-ed25519-dalek = "0.2.0"
|
||||||
solana-exchange-program = { path = "../programs/exchange_program", version = "0.17.0" }
|
solana-exchange-program = { path = "../programs/exchange_program", version = "0.17.0" }
|
||||||
solana-kvstore = { path = "../kvstore", version = "0.17.0", optional = true }
|
solana-kvstore = { path = "../kvstore", version = "0.17.0", optional = true }
|
||||||
solana-logger = { path = "../logger", version = "0.17.0" }
|
solana-logger = { path = "../logger", version = "0.17.0" }
|
||||||
|
solana-merkle-tree = { path = "../merkle-tree", version = "0.17.0" }
|
||||||
solana-metrics = { path = "../metrics", version = "0.17.0" }
|
solana-metrics = { path = "../metrics", version = "0.17.0" }
|
||||||
solana-netutil = { path = "../netutil", version = "0.17.0" }
|
solana-netutil = { path = "../netutil", version = "0.17.0" }
|
||||||
solana-runtime = { path = "../runtime", version = "0.17.0" }
|
solana-runtime = { path = "../runtime", version = "0.17.0" }
|
||||||
|
|
|
@ -10,8 +10,9 @@ use chrono::prelude::Utc;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use rayon::ThreadPool;
|
use rayon::ThreadPool;
|
||||||
use solana_budget_api::budget_instruction;
|
use solana_budget_api::budget_instruction;
|
||||||
|
use solana_merkle_tree::MerkleTree;
|
||||||
use solana_metrics::inc_new_counter_warn;
|
use solana_metrics::inc_new_counter_warn;
|
||||||
use solana_sdk::hash::{Hash, Hasher};
|
use solana_sdk::hash::Hash;
|
||||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||||
use solana_sdk::transaction::Transaction;
|
use solana_sdk::transaction::Transaction;
|
||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
|
@ -172,13 +173,16 @@ impl Entry {
|
||||||
|
|
||||||
pub fn hash_transactions(transactions: &[Transaction]) -> Hash {
|
pub fn hash_transactions(transactions: &[Transaction]) -> Hash {
|
||||||
// a hash of a slice of transactions only needs to hash the signatures
|
// a hash of a slice of transactions only needs to hash the signatures
|
||||||
let mut hasher = Hasher::default();
|
let signatures: Vec<_> = transactions
|
||||||
transactions.iter().for_each(|tx| {
|
.iter()
|
||||||
if !tx.signatures.is_empty() {
|
.flat_map(|tx| tx.signatures.iter().map(|sig| sig.as_ref()))
|
||||||
hasher.hash(&tx.signatures[0].as_ref());
|
.collect();
|
||||||
|
let merkle_tree = MerkleTree::new(&signatures);
|
||||||
|
if let Some(root_hash) = merkle_tree.get_root() {
|
||||||
|
*root_hash
|
||||||
|
} else {
|
||||||
|
Hash::default()
|
||||||
}
|
}
|
||||||
});
|
|
||||||
hasher.result()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates the hash `num_hashes` after `start_hash`. If the transaction contains
|
/// Creates the hash `num_hashes` after `start_hash`. If the transaction contains
|
||||||
|
|
Loading…
Reference in New Issue