mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 03:01:07 +00:00
Cumulus changes version 2 (#2313)
* ensure imbalances are properly accounted for (#2183) * ensure imbalances are properly accounted for * bump runtime version * Update node/runtime/src/lib.rs * implement contract events (#2161) * implement contract events * update runtime * renaming * update test code hash * improve complexity details * add deposit event base cost * add test * Revert "add deposit event base cost" This reverts commit 58ec010c0f4f4f0e16935ad41da32aedd17a8c57. * update test * Revert "update test" This reverts commit 6fe61a593ccf0d41f09a0b97472b28ed8751a999. * Revert "Revert "add deposit event base cost"" This reverts commit 145e8a9bac15313a4c380aa66b94fd4d36fa3f6d. * Fix format a bit * Replace Vec<u8> with [u8; 32] for contract storage key (#2184) * Replace Vec<u8> with [u8; 32] for contract storage key * Read storage keys from sandbox memory into fixed size buffer * Increment `impl_version` * Remove redundant Ok(()) and explicitly specify StorageKey buffer type (#2188) * Switch to `derive(Encode, Decode)` for `Call` (#2178) * Add some tests * More tests * Switch to `derive(Encode, Decode)` for `Call` * Update lock files * Simplify the macro cases * Cache changes trie config in db storage (#2170) * cache changes trie config in db storage * Update core/client/db/src/lib.rs Co-Authored-By: svyatonik <svyatonik@gmail.com> * Update core/client/db/src/lib.rs Co-Authored-By: svyatonik <svyatonik@gmail.com> * Fix version check for renamed runtime api methods (#2190) * Add feature to disable including the test-runtime wasm blob * Enable `std` feature for `consensus_authorities` * Implement `skip_initialize_block` and `initialize_block` for runtime api * Add test and fixes bug * Begin to implement support for passing the `ProofRecorder` * Make sure proof generation works as intended * Fixes tests * Make `BlockBuilder` generate proofs on request. * Adds `TestClientBuilder` to simplify creating a test client * Add `include-wasm-blob` to `test-client` as well * Make `test-client` compile without including the wasm file * Disable more stuff in test-client without wasm * Reorganize the re-exports * Use correct bounds * Update docs * Update core/client/src/block_builder/block_builder.rs Co-Authored-By: bkchr <bkchr@users.noreply.github.com> * Extend test to actually generated proof * Switch to enum for `skip_initialize_block` * Some wasm files updates
This commit is contained in:
@@ -16,7 +16,10 @@
|
||||
|
||||
//! Substrate Client
|
||||
|
||||
use std::{marker::PhantomData, collections::{HashSet, BTreeMap, HashMap}, sync::Arc, panic::UnwindSafe, result};
|
||||
use std::{
|
||||
marker::PhantomData, collections::{HashSet, BTreeMap, HashMap}, sync::Arc,
|
||||
panic::UnwindSafe, result, cell::RefCell, rc::Rc,
|
||||
};
|
||||
use crate::error::Error;
|
||||
use futures::sync::mpsc;
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
@@ -26,16 +29,23 @@ use runtime_primitives::{
|
||||
generic::{BlockId, SignedBlock},
|
||||
};
|
||||
use consensus::{
|
||||
Error as ConsensusError, ErrorKind as ConsensusErrorKind, ImportBlock, ImportResult,
|
||||
BlockOrigin, ForkChoiceStrategy, well_known_cache_keys::Id as CacheKeyId,
|
||||
Error as ConsensusError, ErrorKind as ConsensusErrorKind, ImportBlock,
|
||||
ImportResult, BlockOrigin, ForkChoiceStrategy,
|
||||
well_known_cache_keys::Id as CacheKeyId,
|
||||
};
|
||||
use runtime_primitives::traits::{
|
||||
Block as BlockT, Header as HeaderT, Zero, As, NumberFor, CurrentHeight, BlockNumberToHash,
|
||||
ApiRef, ProvideRuntimeApi, Digest, DigestItem
|
||||
Block as BlockT, Header as HeaderT, Zero, As, NumberFor, CurrentHeight,
|
||||
BlockNumberToHash, ApiRef, ProvideRuntimeApi, Digest, DigestItem
|
||||
};
|
||||
use runtime_primitives::BuildStorage;
|
||||
use crate::runtime_api::{CallRuntimeAt, ConstructRuntimeApi};
|
||||
use primitives::{Blake2Hasher, H256, ChangesTrieConfiguration, convert_hash, NeverNativeValue, ExecutionContext};
|
||||
use crate::runtime_api::{
|
||||
CallRuntimeAt, ConstructRuntimeApi, Core as CoreApi, ProofRecorder,
|
||||
InitializeBlock,
|
||||
};
|
||||
use primitives::{
|
||||
Blake2Hasher, H256, ChangesTrieConfiguration, convert_hash,
|
||||
NeverNativeValue, ExecutionContext
|
||||
};
|
||||
use primitives::storage::{StorageKey, StorageData};
|
||||
use primitives::storage::well_known_keys;
|
||||
use parity_codec::{Encode, Decode};
|
||||
@@ -49,8 +59,8 @@ use hash_db::Hasher;
|
||||
|
||||
use crate::backend::{self, BlockImportOperation, PrunableStateChangesTrieStorage};
|
||||
use crate::blockchain::{
|
||||
self, Info as ChainInfo, Backend as ChainBackend, HeaderBackend as ChainHeaderBackend,
|
||||
ProvideCache, Cache,
|
||||
self, Info as ChainInfo, Backend as ChainBackend,
|
||||
HeaderBackend as ChainHeaderBackend, ProvideCache, Cache,
|
||||
};
|
||||
use crate::call_executor::{CallExecutor, LocalCallExecutor};
|
||||
use executor::{RuntimeVersion, RuntimeInfo};
|
||||
@@ -610,7 +620,23 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
Self: ProvideRuntimeApi,
|
||||
<Self as ProvideRuntimeApi>::Api: BlockBuilderAPI<Block>
|
||||
{
|
||||
block_builder::BlockBuilder::at_block(parent, &self)
|
||||
block_builder::BlockBuilder::at_block(parent, &self, false)
|
||||
}
|
||||
|
||||
/// Create a new block, built on top of `parent` with proof recording enabled.
|
||||
///
|
||||
/// While proof recording is enabled, all accessed trie nodes are saved.
|
||||
/// These recorded trie nodes can be used by a third party to proof the
|
||||
/// output of this block builder without having access to the full storage.
|
||||
pub fn new_block_at_with_proof_recording(
|
||||
&self, parent: &BlockId<Block>
|
||||
) -> error::Result<block_builder::BlockBuilder<Block, Self>> where
|
||||
E: Clone + Send + Sync,
|
||||
RA: Send + Sync,
|
||||
Self: ProvideRuntimeApi,
|
||||
<Self as ProvideRuntimeApi>::Api: BlockBuilderAPI<Block>
|
||||
{
|
||||
block_builder::BlockBuilder::at_block(parent, &self, true)
|
||||
}
|
||||
|
||||
/// Lock the import lock, and run operations inside.
|
||||
@@ -1340,27 +1366,36 @@ impl<B, E, Block, RA> ProvideRuntimeApi for Client<B, E, Block, RA> where
|
||||
impl<B, E, Block, RA> CallRuntimeAt<Block> for Client<B, E, Block, RA> where
|
||||
B: backend::Backend<Block, Blake2Hasher>,
|
||||
E: CallExecutor<Block, Blake2Hasher> + Clone + Send + Sync,
|
||||
Block: BlockT<Hash=H256>
|
||||
Block: BlockT<Hash=H256>,
|
||||
{
|
||||
fn call_api_at<
|
||||
'a,
|
||||
R: Encode + Decode + PartialEq,
|
||||
NC: FnOnce() -> result::Result<R, &'static str> + UnwindSafe,
|
||||
C: CoreApi<Block>,
|
||||
>(
|
||||
&self,
|
||||
core_api: &C,
|
||||
at: &BlockId<Block>,
|
||||
function: &'static str,
|
||||
args: Vec<u8>,
|
||||
changes: &mut OverlayedChanges,
|
||||
initialized_block: &mut Option<BlockId<Block>>,
|
||||
changes: &RefCell<OverlayedChanges>,
|
||||
initialize_block: InitializeBlock<'a, Block>,
|
||||
native_call: Option<NC>,
|
||||
context: ExecutionContext,
|
||||
recorder: &Option<Rc<RefCell<ProofRecorder<Block>>>>,
|
||||
) -> error::Result<NativeOrEncoded<R>> {
|
||||
let manager = match context {
|
||||
ExecutionContext::BlockConstruction => self.execution_strategies.block_construction.get_manager(),
|
||||
ExecutionContext::Syncing => self.execution_strategies.syncing.get_manager(),
|
||||
ExecutionContext::Importing => self.execution_strategies.importing.get_manager(),
|
||||
ExecutionContext::OffchainWorker(_) => self.execution_strategies.offchain_worker.get_manager(),
|
||||
ExecutionContext::Other => self.execution_strategies.other.get_manager(),
|
||||
ExecutionContext::BlockConstruction =>
|
||||
self.execution_strategies.block_construction.get_manager(),
|
||||
ExecutionContext::Syncing =>
|
||||
self.execution_strategies.syncing.get_manager(),
|
||||
ExecutionContext::Importing =>
|
||||
self.execution_strategies.importing.get_manager(),
|
||||
ExecutionContext::OffchainWorker(_) =>
|
||||
self.execution_strategies.offchain_worker.get_manager(),
|
||||
ExecutionContext::Other =>
|
||||
self.execution_strategies.other.get_manager(),
|
||||
};
|
||||
|
||||
let mut offchain_extensions = match context {
|
||||
@@ -1369,15 +1404,16 @@ impl<B, E, Block, RA> CallRuntimeAt<Block> for Client<B, E, Block, RA> where
|
||||
};
|
||||
|
||||
self.executor.contextual_call::<_, _, fn(_,_) -> _,_,_>(
|
||||
|| core_api.initialize_block(at, &self.prepare_environment_block(at)?),
|
||||
at,
|
||||
function,
|
||||
&args,
|
||||
changes,
|
||||
initialized_block,
|
||||
|| self.prepare_environment_block(at),
|
||||
initialize_block,
|
||||
manager,
|
||||
native_call,
|
||||
offchain_extensions.as_mut(),
|
||||
recorder,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user