Pass transaction source to validate_transaction (#5366)

* WiP

* Support source in the runtime API.

* Finish implementation in txpool.

* Fix warning.

* Fix tests.

* Apply suggestions from code review

Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-Authored-By: Nikolay Volf <nikvolf@gmail.com>

* Extra changes.

* Fix test and benches.

* fix test

* Fix test & benches again.

* Fix tests.

* Update bumpalo

* Fix doc test.

* Fix doctest.

* Fix doctest.

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
This commit is contained in:
Tomasz Drwięga
2020-03-25 14:09:23 +01:00
committed by GitHub
parent 601ac11e52
commit 04ccb179e9
37 changed files with 414 additions and 163 deletions
@@ -21,7 +21,7 @@ use crate::traits::{
self, Member, MaybeDisplay, SignedExtension, Dispatchable,
};
use crate::traits::ValidateUnsigned;
use crate::transaction_validity::TransactionValidity;
use crate::transaction_validity::{TransactionValidity, TransactionSource};
/// Definition of something that the external world might want to say; its
/// existence implies that it has been checked and is good, particularly with
@@ -50,6 +50,9 @@ where
fn validate<U: ValidateUnsigned<Call = Self::Call>>(
&self,
// TODO [#5006;ToDr] should source be passed to `SignedExtension`s?
// Perhaps a change for 2.0 to avoid breaking too much APIs?
source: TransactionSource,
info: Self::DispatchInfo,
len: usize,
) -> TransactionValidity {
@@ -57,7 +60,7 @@ where
Extra::validate(extra, id, &self.function, info.clone(), len)
} else {
let valid = Extra::validate_unsigned(&self.function, info, len)?;
let unsigned_validation = U::validate_unsigned(&self.function)?;
let unsigned_validation = U::validate_unsigned(source, &self.function)?;
Ok(valid.combine_with(unsigned_validation))
}
}