mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 10:01:17 +00:00
Refactor/substrate state machine generic (#553)
* Genric over hasher * WIP start adding NodeCodec * Add codec to TrieBackend * Typechecks * Fix error type * Cleanup * Tests build (and fail) * Fix tests: don't use MemoryDB::default() * Lockfile * Address grumbles * Teach environmental! about generics * Add Finder artifacts * whitespace * Add a toy impl of Hasher and plug it in to Externalities * Use `uint` and `fixed-hash` from `parity-common` Remove unused U512 Add test to ensure H256 impls heapsizeof * lock file updates * Make hashes Encodable/Decodable * lock file updates * Impl FromIterator for TestExternalities so we can collect() and use map! * Use rustc-hex from crates Use rlp from master so dependencies do not mess up the scope * Fix tests in runtime-io * lockfile shenanigans * Add a BlakeHasher impl * Use BlakeHasher in runtime-io * lockfile updates * ws * Add a Blake2/RLP-flavoured NodeCodec * Use Blake-flavoured Hasher and NodeCodec * lockfile * Implement PartialEq and Default for TestExternalities * Add note about limitations of environmental! * Make it compile, but this is probably broken * Derive Debug so tests in executor can work * Make executor use BlakeHasher * ws * WIP make client generic * typechecks * cleanup * client tests pass * Fix client/db * cleanup * Fix network * Fix rpc * Fix service * Make TestExternalities work better au lieu d'un HashMap * Fix tests in council * Fix tests in contract * Fix tests in council * Fix democracy * Add comment about odd-looking reexports in tests * Don't need to load branch * Fix staking * Fix session * Some polkadot fixes and lockfile * Fix executive * fixup lockfile * Fix polkadot/api * Fix polkadot/service * Fix polkadot/runtime tests * Fix tests in test-runtime * Test fixes * Fix missing component in the `std` feature * Use PhantomData and Result from core * Fix paths Use core * load heapsize on wasm * implement `HeapSizeOf` for wasm * Add toy impl of `blake2_256` for no_std * lockfile * Use kvdb* from parity-common and fix errors * rebuilt lockfile * Add dummy impl of `on_advance_round` for rhododendron::Context * Fix build after merge * Add HeapSizeOf bound where needed * Sort out dependencies for no_std * Add HeapSizeOf bound where needed * use temp branch pending PR merges * Remove unneeded tests * Lock file and wasm artifacts * lockfile * Use magic commit for libp2p * Cleanup * Implement blake2_256 for no_std * Back on parity-common master * missing type params * Update Cargo.lock * whitespace * Rename concrete Rlp node codec "RlpCodec" and use everywhere Implement a Keccak-flavoured Rlp NodeCodec and use everywhere Add a KeccakHasher * Switch to use KeccakHasher * Lock file and runtimes * fixup lockfile * Fix outstanding issue using concrete types (thanks @gnunicorn) * Cleanup * More cleanup * Comment out Blake2 Hasher * implement ext_keccak256 * Address todo: FetchChecker is generic * all tests passing
This commit is contained in:
committed by
Robert Habermeier
parent
8db30afe53
commit
c5e68a7b9b
@@ -30,6 +30,7 @@ use primitives::{
|
||||
SessionKey, Timestamp, UncheckedExtrinsic,
|
||||
};
|
||||
use primitives::parachain::{DutyRoster, Id as ParaId};
|
||||
use substrate_primitives::{KeccakHasher, RlpCodec};
|
||||
|
||||
use {BlockBuilder, PolkadotApi, LocalPolkadotApi, ErrorKind, Error, Result};
|
||||
|
||||
@@ -60,7 +61,7 @@ macro_rules! with_runtime {
|
||||
}}
|
||||
}
|
||||
|
||||
impl<B: LocalBackend<Block>> BlockBuilder for ClientBlockBuilder<B, LocalCallExecutor<B, NativeExecutor<LocalDispatch>>, Block> {
|
||||
impl<B: LocalBackend<Block, KeccakHasher, RlpCodec>> BlockBuilder for ClientBlockBuilder<B, LocalCallExecutor<B, NativeExecutor<LocalDispatch>>, Block, KeccakHasher, RlpCodec> {
|
||||
fn push_extrinsic(&mut self, extrinsic: UncheckedExtrinsic) -> Result<()> {
|
||||
self.push(extrinsic).map_err(Into::into)
|
||||
}
|
||||
@@ -71,8 +72,8 @@ impl<B: LocalBackend<Block>> BlockBuilder for ClientBlockBuilder<B, LocalCallExe
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: LocalBackend<Block>> PolkadotApi for Client<B, LocalCallExecutor<B, NativeExecutor<LocalDispatch>>, Block> {
|
||||
type BlockBuilder = ClientBlockBuilder<B, LocalCallExecutor<B, NativeExecutor<LocalDispatch>>, Block>;
|
||||
impl<B: LocalBackend<Block, KeccakHasher, RlpCodec>> PolkadotApi for Client<B, LocalCallExecutor<B, NativeExecutor<LocalDispatch>>, Block> {
|
||||
type BlockBuilder = ClientBlockBuilder<B, LocalCallExecutor<B, NativeExecutor<LocalDispatch>>, Block, KeccakHasher, RlpCodec>;
|
||||
|
||||
fn session_keys(&self, at: &BlockId) -> Result<Vec<SessionKey>> {
|
||||
with_runtime!(self, at, ::runtime::Consensus::authorities)
|
||||
@@ -158,7 +159,7 @@ impl<B: LocalBackend<Block>> PolkadotApi for Client<B, LocalCallExecutor<B, Nati
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: LocalBackend<Block>> LocalPolkadotApi for Client<B, LocalCallExecutor<B, NativeExecutor<LocalDispatch>>, Block>
|
||||
impl<B: LocalBackend<Block, KeccakHasher, RlpCodec>> LocalPolkadotApi for Client<B, LocalCallExecutor<B, NativeExecutor<LocalDispatch>>, Block>
|
||||
{}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -184,7 +185,7 @@ mod tests {
|
||||
]
|
||||
}
|
||||
|
||||
fn client() -> Client<InMemory<Block>, LocalCallExecutor<InMemory<Block>, NativeExecutor<LocalDispatch>>, Block> {
|
||||
fn client() -> Client<InMemory<Block, KeccakHasher, RlpCodec>, LocalCallExecutor<InMemory<Block, KeccakHasher, RlpCodec>, NativeExecutor<LocalDispatch>>, Block> {
|
||||
let genesis_config = GenesisConfig {
|
||||
consensus: Some(ConsensusConfig {
|
||||
code: LocalDispatch::native_equivalent().to_vec(),
|
||||
|
||||
@@ -27,6 +27,7 @@ use primitives::{
|
||||
use runtime::Address;
|
||||
use primitives::parachain::{DutyRoster, Id as ParaId};
|
||||
use {PolkadotApi, BlockBuilder, RemotePolkadotApi, Result, ErrorKind};
|
||||
use substrate_primitives::{KeccakHasher, RlpCodec};
|
||||
|
||||
/// Light block builder. TODO: make this work (efficiently)
|
||||
#[derive(Clone, Copy)]
|
||||
@@ -43,9 +44,9 @@ impl BlockBuilder for LightBlockBuilder {
|
||||
}
|
||||
|
||||
/// Remote polkadot API implementation.
|
||||
pub struct RemotePolkadotApiWrapper<B: Backend<Block>, E: CallExecutor<Block>>(pub Arc<Client<B, E, Block>>);
|
||||
pub struct RemotePolkadotApiWrapper<B: Backend<Block, KeccakHasher, RlpCodec>, E: CallExecutor<Block, KeccakHasher, RlpCodec>>(pub Arc<Client<B, E, Block>>);
|
||||
|
||||
impl<B: Backend<Block>, E: CallExecutor<Block>> PolkadotApi for RemotePolkadotApiWrapper<B, E> {
|
||||
impl<B: Backend<Block, KeccakHasher, RlpCodec>, E: CallExecutor<Block, KeccakHasher, RlpCodec>> PolkadotApi for RemotePolkadotApiWrapper<B, E> {
|
||||
type BlockBuilder = LightBlockBuilder;
|
||||
|
||||
fn session_keys(&self, at: &BlockId) -> Result<Vec<SessionKey>> {
|
||||
@@ -104,4 +105,4 @@ impl<B: Backend<Block>, E: CallExecutor<Block>> PolkadotApi for RemotePolkadotAp
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: RemoteBackend<Block>, E: CallExecutor<Block>> RemotePolkadotApi for RemotePolkadotApiWrapper<B, E> {}
|
||||
impl<B: RemoteBackend<Block, KeccakHasher, RlpCodec>, E: CallExecutor<Block, KeccakHasher, RlpCodec>> RemotePolkadotApi for RemotePolkadotApiWrapper<B, E> {}
|
||||
|
||||
Reference in New Issue
Block a user