Transaction Fee Module (#1648)

* wip

* Split bytes fee charging and charging by amount into different traits.

* Move to edition 2018.

* Implemented charge fee traits for fees module.

* Implemented 'on_finalise' for fee module.

* Updated fees finalize impl.

* Renaming and documentation update.

* Added overflow & underflow check for fee calculation.

* Added mock and unit tests for fee module.

* More unit tests for fees module.

* Fixed srml-executive unit tests.

* Remove transaction base/bytes fee from balances module, fix unit tests.

* fix compile error

* Fixed unit test.

* Minor fixes.

* Bump spec version.

* Bump spec version.

* Updated fees module and runtime wasm.

* Fees module code style improvement; updated runtime wasm.

* Bump spec and impl version.
This commit is contained in:
Xiliang Chen
2019-02-15 23:21:38 +13:00
committed by Bastian Köcher
parent 6a6c3155a6
commit fafffdb771
31 changed files with 672 additions and 90 deletions
+7 -3
View File
@@ -27,6 +27,7 @@ use runtime_io;
use srml_support::{StorageMap, StorageDoubleMap, assert_ok, impl_outer_event, impl_outer_dispatch, impl_outer_origin};
use substrate_primitives::{Blake2Hasher};
use system::{self, Phase, EventRecord};
use fees;
use {wabt, balances, consensus};
use hex_literal::*;
use assert_matches::assert_matches;
@@ -44,7 +45,7 @@ mod contract {
}
impl_outer_event! {
pub enum MetaEvent for Test {
balances<T>, contract<T>,
balances<T>, contract<T>, fees<T>,
}
}
impl_outer_origin! {
@@ -88,6 +89,11 @@ impl consensus::Trait for Test {
type SessionKey = UintAuthorityId;
type InherentOfflineReport = ();
}
impl fees::Trait for Test {
type Event = MetaEvent;
type Amount = u64;
type TransferAsset = Balances;
}
impl Trait for Test {
type Call = Call;
type Gas = u64;
@@ -165,8 +171,6 @@ impl ExtBuilder {
t.extend(
balances::GenesisConfig::<Test> {
balances: vec![],
transaction_base_fee: 0,
transaction_byte_fee: 0,
existential_deposit: self.existential_deposit,
transfer_fee: self.transfer_fee,
creation_fee: self.creation_fee,