mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 20:21:06 +00:00
Storage chain: Runtime module (#8624)
* Transaction storage runtime module * WIP: Tests * Tests, benchmarks and docs * Made check_proof mandatory * Typo * Renamed a crate * Apply suggestions from code review Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Added weight for on_finalize * Fixed counter mutations * Reorganized tests * Fixed build * Update for the new inherent API * Reworked for the new inherents API * Apply suggestions from code review Co-authored-by: cheme <emericchevalier.pro@gmail.com> Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * Store transactions in a Vec * Added FeeDestination * Get rid of constants * Fixed node runtime build * Fixed benches * Update frame/transaction-storage/src/lib.rs Co-authored-by: cheme <emericchevalier.pro@gmail.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: cheme <emericchevalier.pro@gmail.com> Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
@@ -429,6 +429,24 @@ pub trait Trie {
|
||||
fn keccak_256_ordered_root(input: Vec<Vec<u8>>) -> H256 {
|
||||
Layout::<sp_core::KeccakHasher>::ordered_trie_root(input)
|
||||
}
|
||||
|
||||
/// Verify trie proof
|
||||
fn blake2_256_verify_proof(root: H256, proof: &[Vec<u8>], key: &[u8], value: &[u8]) -> bool {
|
||||
sp_trie::verify_trie_proof::<Layout<sp_core::Blake2Hasher>, _, _, _>(
|
||||
&root,
|
||||
proof,
|
||||
&[(key, Some(value))],
|
||||
).is_ok()
|
||||
}
|
||||
|
||||
/// Verify trie proof
|
||||
fn keccak_256_verify_proof(root: H256, proof: &[Vec<u8>], key: &[u8], value: &[u8]) -> bool {
|
||||
sp_trie::verify_trie_proof::<Layout<sp_core::KeccakHasher>, _, _, _>(
|
||||
&root,
|
||||
proof,
|
||||
&[(key, Some(value))],
|
||||
).is_ok()
|
||||
}
|
||||
}
|
||||
|
||||
/// Interface that provides miscellaneous functions for communicating between the runtime and the node.
|
||||
@@ -824,6 +842,20 @@ pub trait Hashing {
|
||||
}
|
||||
}
|
||||
|
||||
/// Interface that provides transaction indexing API.
|
||||
#[runtime_interface]
|
||||
pub trait TransactionIndex {
|
||||
/// Add transaction index. Returns indexed content hash.
|
||||
fn index(&mut self, extrinsic: u32, size: u32, context_hash: [u8; 32]) {
|
||||
self.storage_index_transaction(extrinsic, &context_hash, size);
|
||||
}
|
||||
|
||||
/// Conduct a 512-bit Keccak hash.
|
||||
fn renew(&mut self, extrinsic: u32, context_hash: [u8; 32]) {
|
||||
self.storage_renew_transaction_index(extrinsic, &context_hash);
|
||||
}
|
||||
}
|
||||
|
||||
/// Interface that provides functions to access the Offchain DB.
|
||||
#[runtime_interface]
|
||||
pub trait OffchainIndex {
|
||||
@@ -1434,6 +1466,7 @@ pub type SubstrateHostFunctions = (
|
||||
crate::trie::HostFunctions,
|
||||
offchain_index::HostFunctions,
|
||||
runtime_tasks::HostFunctions,
|
||||
transaction_index::HostFunctions,
|
||||
);
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user