Companion for #3007 (Track teleported assets) (#436)

* Companion for #3007: Track teleported assets

* Bump

* Try fix the breakage

Co-authored-by: Sergei Shulepov <sergei@parity.io>
This commit is contained in:
Gavin Wood
2021-05-12 22:51:28 +02:00
committed by GitHub
parent 3194febb1f
commit 23d04ceb3c
5 changed files with 282 additions and 239 deletions
+264 -224
View File
File diff suppressed because it is too large Load Diff
@@ -47,6 +47,7 @@ sc-client-api = { git = "https://github.com/paritytech/substrate", default-featu
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-executor-common = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
cumulus-test-client = { path = "../../test/client" } cumulus-test-client = { path = "../../test/client" }
env_logger = "0.7.1" env_logger = "0.7.1"
@@ -184,17 +184,13 @@ fn new_test_ext() -> sp_io::TestExternalities {
.into() .into()
} }
struct CallInWasm(Vec<u8>); struct ReadRuntimeVersion(Vec<u8>);
impl sp_core::traits::CallInWasm for CallInWasm { impl sp_core::traits::ReadRuntimeVersion for ReadRuntimeVersion {
fn call_in_wasm( fn read_runtime_version(
&self, &self,
_wasm_code: &[u8], _wasm_code: &[u8],
_code_hash: Option<Vec<u8>>,
_method: &str,
_call_data: &[u8],
_ext: &mut dyn sp_externalities::Externalities, _ext: &mut dyn sp_externalities::Externalities,
_missing_host_functions: sp_core::traits::MissingHostFunctions,
) -> Result<Vec<u8>, String> { ) -> Result<Vec<u8>, String> {
Ok(self.0.clone()) Ok(self.0.clone())
} }
@@ -207,10 +203,11 @@ fn wasm_ext() -> sp_io::TestExternalities {
impl_version: 1, impl_version: 1,
..Default::default() ..Default::default()
}; };
let call_in_wasm = CallInWasm(version.encode());
let mut ext = new_test_ext(); let mut ext = new_test_ext();
ext.register_extension(sp_core::traits::CallInWasmExt::new(call_in_wasm)); ext.register_extension(sp_core::traits::ReadRuntimeVersionExt::new(
ReadRuntimeVersion(version.encode()),
));
ext ext
} }
@@ -27,7 +27,6 @@ use sc_executor::{
}; };
use sp_blockchain::HeaderBackend; use sp_blockchain::HeaderBackend;
use sp_consensus::SelectChain; use sp_consensus::SelectChain;
use sp_core::traits::CallInWasm;
use sp_io::TestExternalities; use sp_io::TestExternalities;
use sp_keyring::AccountKeyring::*; use sp_keyring::AccountKeyring::*;
use sp_runtime::{ use sp_runtime::{
@@ -42,6 +41,8 @@ fn call_validate_block(
block_data: ParachainBlockData<Block>, block_data: ParachainBlockData<Block>,
relay_parent_storage_root: Hash, relay_parent_storage_root: Hash,
) -> Result<Header> { ) -> Result<Header> {
use sc_executor_common::runtime_blob::RuntimeBlob;
let mut ext = TestExternalities::default(); let mut ext = TestExternalities::default();
let mut ext_ext = ext.ext(); let mut ext_ext = ext.ext();
let params = ValidationParams { let params = ValidationParams {
@@ -61,13 +62,15 @@ fn call_validate_block(
); );
executor executor
.call_in_wasm( .uncached_call(
&WASM_BINARY.expect("You need to build the WASM binaries to run the tests!"), RuntimeBlob::uncompress_if_needed(
None, &WASM_BINARY.expect("You need to build the WASM binaries to run the tests!"),
)
.expect("RuntimeBlob uncompress & parse"),
&mut ext_ext,
false,
"validate_block", "validate_block",
&params, &params,
&mut ext_ext,
sp_core::traits::MissingHostFunctions::Disallow,
) )
.map(|v| ValidationResult::decode(&mut &v[..]).expect("Decode `ValidationResult`.")) .map(|v| ValidationResult::decode(&mut &v[..]).expect("Decode `ValidationResult`."))
.map(|v| Header::decode(&mut &v.head_data.0[..]).expect("Decode `Header`.")) .map(|v| Header::decode(&mut &v.head_data.0[..]).expect("Decode `Header`."))
@@ -280,6 +280,8 @@ pub type LocalAssetTransactor = CurrencyAdapter<
LocationToAccountId, LocationToAccountId,
// Our chain's account ID type (we can't get away without mentioning it explicitly): // Our chain's account ID type (we can't get away without mentioning it explicitly):
AccountId, AccountId,
// We don't track any teleports.
(),
>; >;
/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance, /// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,