Compare commits
No commits in common. "339ea52864ce2963526891ac5dff88d5c61ba178" and "623a66eb28bff69d4fbc7e87dc9ab08814200c21" have entirely different histories.
339ea52864
...
623a66eb28
@ -346,7 +346,7 @@ sha256sum /etc/ghost/casper.json
|
||||
|
||||
You should see:
|
||||
```
|
||||
74f5a6df5e33dac94a8852ddfb73e472283bba0b30e260ca581919eb50c734db /etc/ghost/casper.json
|
||||
4645c7d39a64424d823f659d408070f8c90426117e7af147b0360697b2db7f4f /etc/ghost/casper.json
|
||||
```
|
||||
|
||||
Create running `ghost-node` service that starts on system boot using `--unit-file` flag.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ghost-weaver"
|
||||
version = "0.0.17"
|
||||
version = "0.0.14"
|
||||
description = "Weaving a secure cryptographic tapestry across different external chains."
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
|
||||
@ -616,21 +616,6 @@ pub mod pallet {
|
||||
.propagate(true)
|
||||
.build()
|
||||
}
|
||||
Call::pull_thread {
|
||||
network_id,
|
||||
session,
|
||||
thread_proof,
|
||||
} => {
|
||||
let thread_context =
|
||||
Self::validate_thread(network_id, session, thread_proof)?;
|
||||
|
||||
ValidTransaction::with_tag_prefix("WeaverThread")
|
||||
.priority(T::UnsignedPriority::get())
|
||||
.and_provides(thread_context.to_fixed_bytes())
|
||||
.longevity(LOCK_BLOCK_EXPIRATION)
|
||||
.propagate(true)
|
||||
.build()
|
||||
}
|
||||
_ => InvalidTransaction::Call.into(),
|
||||
}
|
||||
}
|
||||
@ -638,31 +623,6 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
impl<T: Config> Pallet<T> {
|
||||
fn validate_thread(
|
||||
network_id: &NetworkIdOf<T>,
|
||||
session: &WeavingSession,
|
||||
thread_proof: &ThreadProof<BalanceOf<T>>,
|
||||
) -> Result<H256, InvalidTransaction> {
|
||||
let network_data = T::NetworkDataHandler::get(&network_id)
|
||||
.ok_or(InvalidTransaction::BadProof)?;
|
||||
|
||||
let root_hash = LoomStates::<T>::get(&network_id, &session);
|
||||
if root_hash == Default::default() {
|
||||
return Err(InvalidTransaction::BadProof);
|
||||
}
|
||||
|
||||
thread_proof
|
||||
.verify_thread_proof(root_hash, *network_id, &network_data.gatekeeper)
|
||||
.ok_or(InvalidTransaction::BadProof)?;
|
||||
|
||||
let pulled_thread_key = thread_proof.get_unique_key(*session, *network_id);
|
||||
if PulledThreads::<T>::contains_key(&pulled_thread_key) {
|
||||
return Err(InvalidTransaction::Stale);
|
||||
}
|
||||
|
||||
Ok(pulled_thread_key)
|
||||
}
|
||||
|
||||
fn validate_attestation_signature<A>(
|
||||
attestation: &A,
|
||||
signature: &<T::AuthorityId as RuntimeAppPublic>::Signature,
|
||||
|
||||
@ -14,6 +14,7 @@ use ghost_helpers::{
|
||||
merkle_tree::verify_tree_proof,
|
||||
SubstrateBlake2Hasher, SubstrateKeccakHasher, UtxoSha2Hasher,
|
||||
};
|
||||
use ghost_traits::hashing::GhostHasher;
|
||||
|
||||
use crate::{ExternalBlockNumber, ThreadId, WeavingSession};
|
||||
|
||||
@ -349,10 +350,8 @@ where
|
||||
{
|
||||
if EVM_MERKLE_DEPTH as usize != self.proof.len() { return None; }
|
||||
|
||||
let preimage_hash = self.get_preimage_hash(network_id)?;
|
||||
|
||||
let proof_valid = verify_tree_proof::<SubstrateKeccakHasher, _>(
|
||||
&preimage_hash.to_fixed_bytes(),
|
||||
&self.get_preimage_slice(network_id).to_fixed_bytes(),
|
||||
self.proof.as_ref(),
|
||||
root_hash,
|
||||
self.proof_index,
|
||||
@ -363,17 +362,22 @@ where
|
||||
Some((self.receiver.clone(), self.amount))
|
||||
}
|
||||
|
||||
fn get_preimage_hash<NetworkId>(&self, network_id: NetworkId) -> Option<H256>
|
||||
fn get_preimage_slice<NetworkId>(&self, network_id: NetworkId) -> H256
|
||||
where
|
||||
NetworkId: Copy + Clone + Eq + PartialEq + UniqueSaturatedInto<u64>,
|
||||
{
|
||||
let slot_index_usize: usize = self.slot_index.unique_saturated_into();
|
||||
let mut slot_values: Vec<H256> = self.slots.to_vec();
|
||||
|
||||
self.slots.get(slot_index_usize)
|
||||
.filter(|&&provided_hash| {
|
||||
provided_hash == self.compute_arguments_hash(network_id)
|
||||
})
|
||||
.map(|_| cumulative_hash::<SubstrateKeccakHasher, _>(self.slots.iter()))
|
||||
match slot_values.get_mut(slot_index_usize) {
|
||||
Some(slot) => {
|
||||
*slot = self.compute_arguments_hash(network_id);
|
||||
cumulative_hash::<SubstrateKeccakHasher, _>(slot_values)
|
||||
}
|
||||
None => {
|
||||
SubstrateKeccakHasher::empty()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_unique_key<NetworkId>(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user