Extensible transactions (and tips) (#3102)

* Make extrinsics extensible.

Also Remove old extrinsic types.

* Rest of mockup. Add tips.

* Fix some build issues

* Runtiem builds :)

* Substrate builds.

* Fix a doc test

* Compact encoding

* Extract out the era logic into an extension

* Weight Check signed extension. (#3115)

* Weight signed extension.

* Revert a bit + test for check era.

* Update Cargo.toml

* Update node/cli/src/factory_impl.rs

* Update node/executor/src/lib.rs

* Update node/executor/src/lib.rs

* Don't use len for weight - use data.

* Operational Transaction; second attempt (#3138)

* working poc added.

* some fixes.

* Update doc.

* Fix all tests + final logic.

* more refactoring.

* nits.

* System block limit in bytes.

* Silent the storage macro warnings.

* More logic more tests.

* Fix import.

* Refactor names.

* Fix build.

* Update srml/balances/src/lib.rs

* Final refactor.

* Bump transaction version

* Fix weight mult test.

* Fix more tests and improve doc.

* Bump.

* Make some tests work again.

* Fix subkey.

* Remove todos + bump.

* Ignore expensive test.

* Bump.
This commit is contained in:
Gavin Wood
2019-07-23 01:06:49 +08:00
committed by Kian Peymani
parent 4f5654b67d
commit 78bc5edc14
55 changed files with 1965 additions and 1646 deletions
+16 -13
View File
@@ -255,7 +255,7 @@
use srml_support::{StorageValue, dispatch::Result, decl_module, decl_storage, decl_event};
use system::{ensure_signed, ensure_root};
use sr_primitives::weights::TransactionWeight;
use sr_primitives::weights::SimpleDispatchInfo;
/// Our module's configuration trait. All our types and consts go in here. If the
/// module is dependent on specific other modules, then their configuration traits
@@ -396,19 +396,18 @@ decl_module! {
//
// If you don't respect these rules, it is likely that your chain will be attackable.
//
// Each transaction can optionally indicate a weight. The weight is passed in as a
// custom attribute and the value can be anything that implements the `Weighable`
// trait. Most often using substrate's default `TransactionWeight` is enough for you.
// Each transaction can define an optional `#[weight]` attribute to convey a set of static
// information about its dispatch. The `system` and `executive` module then use this
// information to properly execute the transaction, whilst keeping the total load of the
// chain in a moderate rate.
//
// A basic weight is a tuple of `(base_weight, byte_weight)`. Upon including each transaction
// in a block, the final weight is calculated as `base_weight + byte_weight * tx_size`.
// If this value, added to the weight of all included transactions, exceeds `MAX_TRANSACTION_WEIGHT`,
// the transaction is not included. If no weight attribute is provided, the `::default()`
// implementation of `TransactionWeight` is used.
//
// The example below showcases a transaction which is relatively costly, but less dependent on
// the input, hence `byte_weight` is configured smaller.
#[weight = TransactionWeight::Basic(100_000, 10)]
// The _right-hand-side_ value of the `#[weight]` attribute can be any type that implements
// a set of traits, namely [`WeighData`] and [`ClassifyDispatch`]. The former conveys the
// weight (a numeric representation of pure execution time and difficulty) of the
// transaction and the latter demonstrates the `DispatchClass` of the call. A higher weight
// means a larger transaction (less of which can be placed in a single block). See the
// `CheckWeight` signed extension struct in the `system` module for more information.
#[weight = SimpleDispatchInfo::FixedNormal(10_000)]
fn accumulate_dummy(origin, increase_by: T::Balance) -> Result {
// This is a public call, so we ensure that the origin is some signed account.
let _sender = ensure_signed(origin)?;
@@ -525,6 +524,8 @@ mod tests {
pub struct Test;
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const MaximumBlockWeight: u32 = 1024;
pub const MaximumBlockLength: u32 = 2 * 1024;
}
impl system::Trait for Test {
type Origin = Origin;
@@ -538,6 +539,8 @@ mod tests {
type WeightMultiplierUpdate = ();
type Event = ();
type BlockHashCount = BlockHashCount;
type MaximumBlockWeight = MaximumBlockWeight;
type MaximumBlockLength = MaximumBlockLength;
}
parameter_types! {
pub const ExistentialDeposit: u64 = 0;