mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-29 23:07:26 +00:00
Final tweaks for PoC-2 runtime upgrade (#348)
* Final tweaks for PoC-2 runtime upgrade * Address grumble * Avoid slow wasm * New poc-2-era bootnodes * Fix warning * Typo * Fix for allocation in wasm * Fix & runtimes. * PoC-1 should be default. * Name testnet Krumme Lanke, update README * YML update * Use the right port
This commit is contained in:
@@ -20,7 +20,7 @@ use std::cmp::Ordering;
|
||||
use parking_lot::Mutex;
|
||||
use std::collections::HashMap;
|
||||
use wasmi::{
|
||||
Module, ModuleInstance, MemoryInstance, MemoryRef, TableRef, ImportsBuilder,
|
||||
Module, ModuleInstance, MemoryInstance, MemoryRef, TableRef, ImportsBuilder, self
|
||||
};
|
||||
use wasmi::RuntimeValue::{I32, I64};
|
||||
use wasmi::memory_units::{Pages, Bytes};
|
||||
@@ -28,7 +28,7 @@ use state_machine::{Externalities, CodeExecutor};
|
||||
use error::{Error, ErrorKind, Result};
|
||||
use wasm_utils::UserError;
|
||||
use primitives::{blake2_256, twox_128, twox_256};
|
||||
use primitives::hexdisplay::{HexDisplay, ascii_format};
|
||||
use primitives::hexdisplay::HexDisplay;
|
||||
use primitives::sandbox as sandbox_primitives;
|
||||
use triehash::ordered_trie_root;
|
||||
use sandbox;
|
||||
@@ -200,9 +200,9 @@ impl_function_executor!(this: FunctionExecutor<'e, E>,
|
||||
let key = this.memory.get(key_data, key_len as usize).map_err(|_| UserError("Invalid attempt to determine key in ext_set_storage"))?;
|
||||
let value = this.memory.get(value_data, value_len as usize).map_err(|_| UserError("Invalid attempt to determine value in ext_set_storage"))?;
|
||||
if let Some(_preimage) = this.hash_lookup.get(&key) {
|
||||
debug_trace!(target: "wasm-trace", "*** Setting storage: %{} -> {} [k={}]", ascii_format(&_preimage), HexDisplay::from(&value), HexDisplay::from(&key));
|
||||
debug_trace!(target: "wasm-trace", "*** Setting storage: %{} -> {} [k={}]", ::primitives::hexdisplay::ascii_format(&_preimage), HexDisplay::from(&value), HexDisplay::from(&key));
|
||||
} else {
|
||||
debug_trace!(target: "wasm-trace", "*** Setting storage: {} -> {} [k={}]", ascii_format(&key), HexDisplay::from(&value), HexDisplay::from(&key));
|
||||
debug_trace!(target: "wasm-trace", "*** Setting storage: {} -> {} [k={}]", ::primitives::hexdisplay::ascii_format(&key), HexDisplay::from(&value), HexDisplay::from(&key));
|
||||
}
|
||||
this.ext.set_storage(key, value);
|
||||
Ok(())
|
||||
@@ -211,9 +211,9 @@ impl_function_executor!(this: FunctionExecutor<'e, E>,
|
||||
let key = this.memory.get(key_data, key_len as usize).map_err(|_| UserError("Invalid attempt to determine key in ext_clear_storage"))?;
|
||||
debug_trace!(target: "wasm-trace", "*** Clearing storage: {} [k={}]",
|
||||
if let Some(_preimage) = this.hash_lookup.get(&key) {
|
||||
format!("%{}", ascii_format(&_preimage))
|
||||
format!("%{}", ::primitives::hexdisplay::ascii_format(&_preimage))
|
||||
} else {
|
||||
format!(" {}", ascii_format(&key))
|
||||
format!(" {}", ::primitives::hexdisplay::ascii_format(&key))
|
||||
}, HexDisplay::from(&key));
|
||||
this.ext.clear_storage(&key);
|
||||
Ok(())
|
||||
@@ -234,9 +234,9 @@ impl_function_executor!(this: FunctionExecutor<'e, E>,
|
||||
|
||||
debug_trace!(target: "wasm-trace", "*** Getting storage: {} == {} [k={}]",
|
||||
if let Some(_preimage) = this.hash_lookup.get(&key) {
|
||||
format!("%{}", ascii_format(&_preimage))
|
||||
format!("%{}", ::primitives::hexdisplay::ascii_format(&_preimage))
|
||||
} else {
|
||||
format!(" {}", ascii_format(&key))
|
||||
format!(" {}", ::primitives::hexdisplay::ascii_format(&key))
|
||||
},
|
||||
if let Some(ref b) = maybe_value {
|
||||
format!("{}", HexDisplay::from(b))
|
||||
@@ -264,9 +264,9 @@ impl_function_executor!(this: FunctionExecutor<'e, E>,
|
||||
let maybe_value = this.ext.storage(&key);
|
||||
debug_trace!(target: "wasm-trace", "*** Getting storage: {} == {} [k={}]",
|
||||
if let Some(_preimage) = this.hash_lookup.get(&key) {
|
||||
format!("%{}", ascii_format(&_preimage))
|
||||
format!("%{}", ::primitives::hexdisplay::ascii_format(&_preimage))
|
||||
} else {
|
||||
format!(" {}", ascii_format(&key))
|
||||
format!(" {}", ::primitives::hexdisplay::ascii_format(&key))
|
||||
},
|
||||
if let Some(ref b) = maybe_value {
|
||||
format!("{}", HexDisplay::from(b))
|
||||
@@ -557,7 +557,7 @@ impl WasmExecutor {
|
||||
|
||||
let size = data.len() as u32;
|
||||
let offset = fec.heap.allocate(size);
|
||||
memory.set(offset, &data).expect("heap always gives a sensible offset to write");
|
||||
memory.set(offset, &data).map_err(|_: wasmi::Error| Error::from(ErrorKind::PleaseRetry))?;
|
||||
|
||||
let result = instance.invoke_export(
|
||||
method,
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -68,11 +68,11 @@ pub fn clear_storage(key: &[u8]) {
|
||||
);
|
||||
}
|
||||
|
||||
/// Clear the storage of some particular key.
|
||||
pub fn exists_storage(key: &[u8]) {
|
||||
/// Check whether a given `key` exists in storage.
|
||||
pub fn exists_storage(key: &[u8]) -> bool {
|
||||
ext::with(|ext|
|
||||
ext.exists_storage(key)
|
||||
);
|
||||
).unwrap_or(false)
|
||||
}
|
||||
|
||||
/// Clear the storage entries key of which starts with the given prefix.
|
||||
|
||||
@@ -101,12 +101,12 @@ pub fn clear_storage(key: &[u8]) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Clear the storage of some particular key.
|
||||
pub fn exists_storage(key: &[u8]) {
|
||||
/// Determine whether a particular key exists in storage.
|
||||
pub fn exists_storage(key: &[u8]) -> bool {
|
||||
unsafe {
|
||||
ext_exists_storage(
|
||||
key.as_ptr(), key.len() as u32
|
||||
) != 0;
|
||||
) != 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,22 @@ impl<'a> Input for IncrementalInput<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: only introduce this wrapper for types where it makes sense, ideally have it within the module declaration.
|
||||
|
||||
struct AppendZeroes<'a, I: Input + 'a> {
|
||||
input: &'a mut I,
|
||||
}
|
||||
|
||||
impl<'a, I: Input + 'a> Input for AppendZeroes<'a, I> {
|
||||
fn read(&mut self, into: &mut [u8]) -> usize {
|
||||
let r = self.input.read(into);
|
||||
for z in &mut into[r..] {
|
||||
*z = 0;
|
||||
};
|
||||
into.len()
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the value of the item in storage under `key`, or `None` if there is no explicit entry.
|
||||
pub fn get<T: Codec + Sized>(key: &[u8]) -> Option<T> {
|
||||
let key = twox_128(key);
|
||||
@@ -47,7 +63,7 @@ pub fn get<T: Codec + Sized>(key: &[u8]) -> Option<T> {
|
||||
key: &key[..],
|
||||
pos: 0,
|
||||
};
|
||||
Decode::decode(&mut input).expect("storage is not null, therefore must be a valid type")
|
||||
Decode::decode(&mut AppendZeroes { input: &mut input } ).expect("storage is not null, therefore must be a valid type")
|
||||
})
|
||||
}
|
||||
|
||||
@@ -103,8 +119,7 @@ pub fn take_or_else<T: Codec + Sized, F: FnOnce() -> T>(key: &[u8], default_valu
|
||||
|
||||
/// Check to see if `key` has an explicit entry in storage.
|
||||
pub fn exists(key: &[u8]) -> bool {
|
||||
let mut x = [0u8; 0];
|
||||
runtime_io::read_storage(&twox_128(key)[..], &mut x[..], 0).is_some()
|
||||
runtime_io::exists_storage(&twox_128(key)[..])
|
||||
}
|
||||
|
||||
/// Ensure `key` has no explicit entry in storage.
|
||||
|
||||
@@ -71,7 +71,7 @@ impl<G: Serialize + DeserializeOwned + BuildStorage> Configuration<G> {
|
||||
pruning: PruningMode::ArchiveAll,
|
||||
execution_strategy: ExecutionStrategy::Both,
|
||||
min_heap_pages: 8,
|
||||
max_heap_pages: 512,
|
||||
max_heap_pages: 1024,
|
||||
};
|
||||
configuration.network.boot_nodes = configuration.chain_spec.boot_nodes().to_vec();
|
||||
configuration
|
||||
|
||||
@@ -700,6 +700,7 @@ name = "substrate-runtime-primitives"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"integer-sqrt 0.1.0 (git+https://github.com/paritytech/integer-sqrt-rs.git)",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.64 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.64 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
Reference in New Issue
Block a user