srml-contract: Fix Gas type to u64 (#2944)

* srml-contract: Move gas costs from Config to Schedule.

* srml-contract: Define Gas units fixed as u64.

This removes Gas as a configurable type on the contracts Trait.

* Bump node runtime spec/impl versions.
This commit is contained in:
Jim Posen
2019-06-26 14:17:45 +02:00
committed by Gavin Wood
parent 554a790eaa
commit 4c52aec260
13 changed files with 151 additions and 145 deletions
+12 -12
View File
@@ -63,17 +63,17 @@ pub struct WasmExecutable {
}
/// Loader which fetches `WasmExecutable` from the code cache.
pub struct WasmLoader<'a, T: Trait> {
schedule: &'a Schedule<T::Gas>,
pub struct WasmLoader<'a> {
schedule: &'a Schedule,
}
impl<'a, T: Trait> WasmLoader<'a, T> {
pub fn new(schedule: &'a Schedule<T::Gas>) -> Self {
impl<'a> WasmLoader<'a> {
pub fn new(schedule: &'a Schedule) -> Self {
WasmLoader { schedule }
}
}
impl<'a, T: Trait> crate::exec::Loader<T> for WasmLoader<'a, T> {
impl<'a, T: Trait> crate::exec::Loader<T> for WasmLoader<'a> {
type Executable = WasmExecutable;
fn load_init(&self, code_hash: &CodeHash<T>) -> Result<WasmExecutable, &'static str> {
@@ -93,17 +93,17 @@ impl<'a, T: Trait> crate::exec::Loader<T> for WasmLoader<'a, T> {
}
/// Implementation of `Vm` that takes `WasmExecutable` and executes it.
pub struct WasmVm<'a, T: Trait> {
schedule: &'a Schedule<T::Gas>,
pub struct WasmVm<'a> {
schedule: &'a Schedule,
}
impl<'a, T: Trait> WasmVm<'a, T> {
pub fn new(schedule: &'a Schedule<T::Gas>) -> Self {
impl<'a> WasmVm<'a> {
pub fn new(schedule: &'a Schedule) -> Self {
WasmVm { schedule }
}
}
impl<'a, T: Trait> crate::exec::Vm<T> for WasmVm<'a, T> {
impl<'a, T: Trait> crate::exec::Vm<T> for WasmVm<'a> {
type Executable = WasmExecutable;
fn execute<E: Ext<T = T>>(
@@ -303,9 +303,9 @@ mod tests {
use crate::exec::Vm;
let wasm = wabt::wat2wasm(wat).unwrap();
let schedule = crate::Schedule::<u64>::default();
let schedule = crate::Schedule::default();
let prefab_module =
prepare_contract::<Test, super::runtime::Env>(&wasm, &schedule).unwrap();
prepare_contract::<super::runtime::Env>(&wasm, &schedule).unwrap();
let exec = WasmExecutable {
// Use a "call" convention.